Skip to content

Commit

Permalink
Merge pull request #404 from dyashuni/windows_tester
Browse files Browse the repository at this point in the history
Port git_tester.py on Windows
  • Loading branch information
dyashuni authored Sep 2, 2022
2 parents e97b37c + bdd0220 commit 6fa8cd0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
60 changes: 33 additions & 27 deletions examples/git_tester.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
import os
import shutil

from sys import platform
from pydriller import Repository
import os
import datetime
os.system("cp examples/speedtest.py examples/speedtest2.py") # the file has to be outside of git
for idx, commit in enumerate(Repository('.', from_tag="v0.6.0").traverse_commits()):
name=commit.msg.replace('\n', ' ').replace('\r', ' ')
print(idx, commit.hash, name)


speedtest_src_path = os.path.join("examples", "speedtest.py")
speedtest_copy_path = os.path.join("examples", "speedtest2.py")
shutil.copyfile(speedtest_src_path, speedtest_copy_path) # the file has to be outside of git

commits = list(Repository('.', from_tag="v0.6.0").traverse_commits())
print("Found commits:")
for idx, commit in enumerate(commits):
name = commit.msg.replace('\n', ' ').replace('\r', ' ')
print(idx, commit.hash, name)

for commit in Repository('.', from_tag="v0.6.0").traverse_commits():

name=commit.msg.replace('\n', ' ').replace('\r', ' ')
print(commit.hash, name)

os.system(f"git checkout {commit.hash}; rm -rf build; ")
for commit in commits:
name = commit.msg.replace('\n', ' ').replace('\r', ' ')
print("\nProcessing", commit.hash, name)

if os.path.exists("build"):
shutil.rmtree("build")
os.system(f"git checkout {commit.hash}")
print("\n\n--------------------\n\n")
ret=os.system("python -m pip install .")
print(ret)

if ret != 0:
print ("build failed!!!!")
print ("build failed!!!!")
print ("build failed!!!!")
print ("build failed!!!!")
continue

os.system(f'python examples/speedtest2.py -n "{name}" -d 4 -t 1')
os.system(f'python examples/speedtest2.py -n "{name}" -d 64 -t 1')
os.system(f'python examples/speedtest2.py -n "{name}" -d 128 -t 1')
os.system(f'python examples/speedtest2.py -n "{name}" -d 4 -t 24')
os.system(f'python examples/speedtest2.py -n "{name}" -d 128 -t 24')
ret = os.system("python -m pip install .")
print("Install result:", ret)

if ret != 0:
print("build failed!!!!")
print("build failed!!!!")
print("build failed!!!!")
print("build failed!!!!")
continue

os.system(f'python {speedtest_copy_path} -n "{name}" -d 4 -t 1')
os.system(f'python {speedtest_copy_path} -n "{name}" -d 64 -t 1')
os.system(f'python {speedtest_copy_path} -n "{name}" -d 128 -t 1')
os.system(f'python {speedtest_copy_path} -n "{name}" -d 4 -t 24')
os.system(f'python {speedtest_copy_path} -n "{name}" -d 128 -t 24')
4 changes: 2 additions & 2 deletions python_bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Index {

void loadIndex(const std::string &path_to_index, size_t max_elements) {
if (appr_alg) {
std::cerr<<"Warning: Calling load_index for an already inited index. Old index is being deallocated.";
std::cerr << "Warning: Calling load_index for an already inited index. Old index is being deallocated." << std::endl;
delete appr_alg;
}
appr_alg = new hnswlib::HierarchicalNSW<dist_t>(l2space, path_to_index, false, max_elements);
Expand Down Expand Up @@ -768,7 +768,7 @@ class BFIndex {

void loadIndex(const std::string &path_to_index, size_t max_elements) {
if (alg) {
std::cerr<<"Warning: Calling load_index for an already inited index. Old index is being deallocated.";
std::cerr << "Warning: Calling load_index for an already inited index. Old index is being deallocated." << std::endl;
delete alg;
}
alg = new hnswlib::BruteforceSearch<dist_t>(space, path_to_index);
Expand Down

0 comments on commit 6fa8cd0

Please sign in to comment.