Skip to content

Commit f66a3b2

Browse files
authored
Merge branch 'main' into add-tests-for-qm-structure
2 parents 6529bd3 + 6dbf7c6 commit f66a3b2

File tree

264 files changed

+9909
-3092
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

264 files changed

+9909
-3092
lines changed

.github/actions/show-test-environment/action.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
from pathlib import Path
2+
import argparse
3+
import os
4+
5+
6+
# We get the list of files change as an input
7+
parser = argparse.ArgumentParser()
8+
parser.add_argument("changed_files_in_the_pull_request", nargs="*", help="List of changed files")
9+
args = parser.parse_args()
10+
11+
changed_files_in_the_pull_request = args.changed_files_in_the_pull_request
12+
changed_files_in_the_pull_request_paths = [Path(file) for file in changed_files_in_the_pull_request]
13+
14+
# We assume nothing has been changed
15+
16+
core_changed = False
17+
pyproject_toml_changed = False
18+
neobaseextractor_changed = False
19+
extractors_changed = False
20+
plexon2_changed = False
21+
preprocessing_changed = False
22+
postprocessing_changed = False
23+
qualitymetrics_changed = False
24+
sorters_changed = False
25+
sorters_external_changed = False
26+
sorters_internal_changed = False
27+
comparison_changed = False
28+
curation_changed = False
29+
widgets_changed = False
30+
exporters_changed = False
31+
sortingcomponents_changed = False
32+
generation_changed = False
33+
34+
35+
for changed_file in changed_files_in_the_pull_request_paths:
36+
37+
file_is_in_src = changed_file.parts[0] == "src"
38+
39+
if not file_is_in_src:
40+
41+
if changed_file.name == "pyproject.toml":
42+
pyproject_toml_changed = True
43+
44+
else:
45+
if changed_file.name == "neobaseextractor.py":
46+
neobaseextractor_changed = True
47+
elif changed_file.name == "plexon2.py":
48+
extractors_changed = True
49+
elif "core" in changed_file.parts:
50+
conditions_changed = True
51+
elif "extractors" in changed_file.parts:
52+
extractors_changed = True
53+
elif "preprocessing" in changed_file.parts:
54+
preprocessing_changed = True
55+
elif "postprocessing" in changed_file.parts:
56+
postprocessing_changed = True
57+
elif "qualitymetrics" in changed_file.parts:
58+
qualitymetrics_changed = True
59+
elif "comparison" in changed_file.parts:
60+
comparison_changed = True
61+
elif "curation" in changed_file.parts:
62+
curation_changed = True
63+
elif "widgets" in changed_file.parts:
64+
widgets_changed = True
65+
elif "exporters" in changed_file.parts:
66+
exporters_changed = True
67+
elif "sortingcomponents" in changed_file.parts:
68+
sortingcomponents_changed = True
69+
elif "generation" in changed_file.parts:
70+
generation_changed = True
71+
elif "sorters" in changed_file.parts:
72+
if "external" in changed_file.parts:
73+
sorters_external_changed = True
74+
elif "internal" in changed_file.parts:
75+
sorters_internal_changed = True
76+
else:
77+
sorters_changed = True
78+
79+
80+
run_everything = core_changed or pyproject_toml_changed or neobaseextractor_changed
81+
run_generation_tests = run_everything or generation_changed
82+
run_extractor_tests = run_everything or extractors_changed
83+
run_preprocessing_tests = run_everything or preprocessing_changed
84+
run_postprocessing_tests = run_everything or postprocessing_changed
85+
run_qualitymetrics_tests = run_everything or qualitymetrics_changed
86+
run_curation_tests = run_everything or curation_changed
87+
run_sortingcomponents_tests = run_everything or sortingcomponents_changed
88+
89+
run_comparison_test = run_everything or run_generation_tests or comparison_changed
90+
run_widgets_test = run_everything or run_qualitymetrics_tests or run_preprocessing_tests or widgets_changed
91+
run_exporters_test = run_everything or run_widgets_test or exporters_changed
92+
93+
run_sorters_test = run_everything or sorters_changed
94+
run_internal_sorters_test = run_everything or run_sortingcomponents_tests or sorters_internal_changed
95+
96+
install_plexon_dependencies = plexon2_changed
97+
98+
environment_varaiables_to_add = {
99+
"RUN_EXTRACTORS_TESTS": run_extractor_tests,
100+
"RUN_PREPROCESSING_TESTS": run_preprocessing_tests,
101+
"RUN_POSTPROCESSING_TESTS": run_postprocessing_tests,
102+
"RUN_QUALITYMETRICS_TESTS": run_qualitymetrics_tests,
103+
"RUN_CURATION_TESTS": run_curation_tests,
104+
"RUN_SORTINGCOMPONENTS_TESTS": run_sortingcomponents_tests,
105+
"RUN_GENERATION_TESTS": run_generation_tests,
106+
"RUN_COMPARISON_TESTS": run_comparison_test,
107+
"RUN_WIDGETS_TESTS": run_widgets_test,
108+
"RUN_EXPORTERS_TESTS": run_exporters_test,
109+
"RUN_SORTERS_TESTS": run_sorters_test,
110+
"RUN_INTERNAL_SORTERS_TESTS": run_internal_sorters_test,
111+
"INSTALL_PLEXON_DEPENDENCIES": install_plexon_dependencies,
112+
}
113+
114+
# Write the conditions to the GITHUB_ENV file
115+
env_file = os.getenv("GITHUB_ENV")
116+
with open(env_file, "a") as f:
117+
for key, value in environment_varaiables_to_add.items():
118+
f.write(f"{key}={value}\n")

.github/import_test.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,52 @@
1818

1919
n_samples = 10
2020
# Note that the symbols at the end are for centering the table
21-
markdown_output = f"## \n\n| Imported Module ({n_samples=}) | Importing Time (seconds) | Standard Deviation (seconds) |\n| :--: | :--------------: | :------------------: |\n"
21+
markdown_output = f"## \n\n| Imported Module ({n_samples=}) | Importing Time (seconds) | Standard Deviation (seconds) | Times List (seconds) |\n| :--: | :--------------: | :------------------: | :-------------: |\n"
2222

2323
exceptions = []
2424

2525
for import_statement in import_statement_list:
2626
time_taken_list = []
2727
for _ in range(n_samples):
2828
script_to_execute = (
29-
f"import timeit \n"
30-
f"import_statement = '{import_statement}' \n"
31-
f"time_taken = timeit.timeit(import_statement, number=1) \n"
32-
f"print(time_taken) \n"
33-
)
29+
f"import timeit \n"
30+
f"import_statement = '{import_statement}' \n"
31+
f"time_taken = timeit.timeit(import_statement, number=1) \n"
32+
f"print(time_taken) \n"
33+
)
3434

3535
result = subprocess.run(["python", "-c", script_to_execute], capture_output=True, text=True)
3636

3737
if result.returncode != 0:
38-
error_message = (
39-
f"Error when running {import_statement} \n"
40-
f"Error in subprocess: {result.stderr.strip()}\n"
38+
error_message = (
39+
f"Error when running {import_statement} \n" f"Error in subprocess: {result.stderr.strip()}\n"
4140
)
4241
exceptions.append(error_message)
4342
break
4443

4544
time_taken = float(result.stdout.strip())
4645
time_taken_list.append(time_taken)
4746

47+
for time in time_taken_list:
48+
import_time_threshold = 2.0 # Most of the times is sub-second but there outliers
49+
if time >= import_time_threshold:
50+
exceptions.append(
51+
f"Importing {import_statement} took: {time:.2f} s. Should be <: {import_time_threshold} s."
52+
)
53+
break
54+
55+
4856
if time_taken_list:
49-
avg_time_taken = sum(time_taken_list) / len(time_taken_list)
50-
std_dev_time_taken = math.sqrt(sum((x - avg_time_taken) ** 2 for x in time_taken_list) / len(time_taken_list))
51-
markdown_output += f"| `{import_statement}` | {avg_time_taken:.2f} | {std_dev_time_taken:.2f} |\n"
57+
avg_time = sum(time_taken_list) / len(time_taken_list)
58+
std_time = math.sqrt(sum((x - avg_time) ** 2 for x in time_taken_list) / len(time_taken_list))
59+
times_list_str = ", ".join(f"{time:.2f}" for time in time_taken_list)
60+
markdown_output += f"| `{import_statement}` | {avg_time:.2f} | {std_time:.2f} | {times_list_str} |\n"
61+
62+
import_time_threshold = 1.0
63+
if avg_time > import_time_threshold:
64+
exceptions.append(
65+
f"Importing {import_statement} took: {avg_time:.2f} s in average. Should be <: {import_time_threshold} s."
66+
)
5267

5368
if exceptions:
5469
raise Exception("\n".join(exceptions))

.github/run_tests.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/bin/bash
22

33
MARKER=$1
4+
NOVIRTUALENV=$2
5+
6+
# Check if the second argument is provided and if it is equal to --no-virtual-env
7+
if [ -z "$NOVIRTUALENV" ] || [ "$NOVIRTUALENV" != "--no-virtual-env" ]; then
8+
source $GITHUB_WORKSPACE/test_env/bin/activate
9+
fi
410

5-
source $GITHUB_WORKSPACE/test_env/bin/activate
611
pytest -m "$MARKER" -vv -ra --durations=0 --durations-min=0.001 | tee report.txt; test ${PIPESTATUS[0]} -eq 0 || exit 1
712
echo "# Timing profile of ${MARKER}" >> $GITHUB_STEP_SUMMARY
813
python $GITHUB_WORKSPACE/.github/build_job_summary.py report.txt >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)