Skip to content

Commit 6fa8cd0

Browse files
authored
Merge pull request #404 from dyashuni/windows_tester
Port git_tester.py on Windows
2 parents e97b37c + bdd0220 commit 6fa8cd0

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

examples/git_tester.py

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,40 @@
1+
import os
2+
import shutil
3+
4+
from sys import platform
15
from pydriller import Repository
2-
import os
3-
import datetime
4-
os.system("cp examples/speedtest.py examples/speedtest2.py") # the file has to be outside of git
5-
for idx, commit in enumerate(Repository('.', from_tag="v0.6.0").traverse_commits()):
6-
name=commit.msg.replace('\n', ' ').replace('\r', ' ')
7-
print(idx, commit.hash, name)
86

97

8+
speedtest_src_path = os.path.join("examples", "speedtest.py")
9+
speedtest_copy_path = os.path.join("examples", "speedtest2.py")
10+
shutil.copyfile(speedtest_src_path, speedtest_copy_path) # the file has to be outside of git
11+
12+
commits = list(Repository('.', from_tag="v0.6.0").traverse_commits())
13+
print("Found commits:")
14+
for idx, commit in enumerate(commits):
15+
name = commit.msg.replace('\n', ' ').replace('\r', ' ')
16+
print(idx, commit.hash, name)
1017

11-
for commit in Repository('.', from_tag="v0.6.0").traverse_commits():
12-
13-
name=commit.msg.replace('\n', ' ').replace('\r', ' ')
14-
print(commit.hash, name)
15-
16-
os.system(f"git checkout {commit.hash}; rm -rf build; ")
18+
for commit in commits:
19+
name = commit.msg.replace('\n', ' ').replace('\r', ' ')
20+
print("\nProcessing", commit.hash, name)
21+
22+
if os.path.exists("build"):
23+
shutil.rmtree("build")
24+
os.system(f"git checkout {commit.hash}")
1725
print("\n\n--------------------\n\n")
18-
ret=os.system("python -m pip install .")
19-
print(ret)
20-
21-
if ret != 0:
22-
print ("build failed!!!!")
23-
print ("build failed!!!!")
24-
print ("build failed!!!!")
25-
print ("build failed!!!!")
26-
continue
27-
28-
os.system(f'python examples/speedtest2.py -n "{name}" -d 4 -t 1')
29-
os.system(f'python examples/speedtest2.py -n "{name}" -d 64 -t 1')
30-
os.system(f'python examples/speedtest2.py -n "{name}" -d 128 -t 1')
31-
os.system(f'python examples/speedtest2.py -n "{name}" -d 4 -t 24')
32-
os.system(f'python examples/speedtest2.py -n "{name}" -d 128 -t 24')
26+
ret = os.system("python -m pip install .")
27+
print("Install result:", ret)
3328

29+
if ret != 0:
30+
print("build failed!!!!")
31+
print("build failed!!!!")
32+
print("build failed!!!!")
33+
print("build failed!!!!")
34+
continue
3435

36+
os.system(f'python {speedtest_copy_path} -n "{name}" -d 4 -t 1')
37+
os.system(f'python {speedtest_copy_path} -n "{name}" -d 64 -t 1')
38+
os.system(f'python {speedtest_copy_path} -n "{name}" -d 128 -t 1')
39+
os.system(f'python {speedtest_copy_path} -n "{name}" -d 4 -t 24')
40+
os.system(f'python {speedtest_copy_path} -n "{name}" -d 128 -t 24')

python_bindings/bindings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class Index {
155155

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

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

0 commit comments

Comments
 (0)