-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into ibl_exporter
- Loading branch information
Showing
609 changed files
with
51,017 additions
and
26,108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
#!/bin/bash | ||
|
||
MARKER=$1 | ||
NOVIRTUALENV=$2 | ||
|
||
# Check if the second argument is provided and if it is equal to --no-virtual-env | ||
if [ -z "$NOVIRTUALENV" ] || [ "$NOVIRTUALENV" != "--no-virtual-env" ]; then | ||
source $GITHUB_WORKSPACE/test_env/bin/activate | ||
fi | ||
|
||
source $GITHUB_WORKSPACE/test_env/bin/activate | ||
pytest -m "$MARKER" -vv -ra --durations=0 --durations-min=0.001 | tee report.txt; test ${PIPESTATUS[0]} -eq 0 || exit 1 | ||
echo "# Timing profile of ${MARKER}" >> $GITHUB_STEP_SUMMARY | ||
python $GITHUB_WORKSPACE/.github/build_job_summary.py report.txt >> $GITHUB_STEP_SUMMARY | ||
python $GITHUB_WORKSPACE/.github/scripts/build_job_summary.py report.txt >> $GITHUB_STEP_SUMMARY | ||
rm report.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This folder contains test scripts for running in the CI, that are not run as part of the usual | ||
CI because they are too long / heavy. These are run on cron-jobs once per week. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import os | ||
import re | ||
from pathlib import Path | ||
import requests | ||
import json | ||
from packaging.version import parse | ||
import spikeinterface | ||
|
||
def get_pypi_versions(package_name): | ||
""" | ||
Make an API call to pypi to retrieve all | ||
available versions of the kilosort package. | ||
""" | ||
url = f"https://pypi.org/pypi/{package_name}/json" | ||
response = requests.get(url) | ||
response.raise_for_status() | ||
data = response.json() | ||
versions = list(sorted(data["releases"].keys())) | ||
# Filter out versions that are less than 4.0.16 | ||
versions = [ver for ver in versions if parse(ver) >= parse("4.0.16")] | ||
return versions | ||
|
||
|
||
if __name__ == "__main__": | ||
# Get all KS4 versions from pipi and write to file. | ||
package_name = "kilosort" | ||
versions = get_pypi_versions(package_name) | ||
with open(Path(os.path.realpath(__file__)).parent / "kilosort4-latest-version.json", "w") as f: | ||
print(versions) | ||
json.dump(versions, f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
from pathlib import Path | ||
import argparse | ||
import os | ||
|
||
|
||
# We get the list of files change as an input | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("changed_files_in_the_pull_request", nargs="*", help="List of changed files") | ||
args = parser.parse_args() | ||
|
||
changed_files_in_the_pull_request = args.changed_files_in_the_pull_request | ||
changed_files_in_the_pull_request_paths = [Path(file) for file in changed_files_in_the_pull_request] | ||
|
||
# We assume nothing has been changed | ||
|
||
core_changed = False | ||
pyproject_toml_changed = False | ||
neobaseextractor_changed = False | ||
extractors_changed = False | ||
plexon2_changed = False | ||
preprocessing_changed = False | ||
postprocessing_changed = False | ||
qualitymetrics_changed = False | ||
sorters_changed = False | ||
sorters_external_changed = False | ||
sorters_internal_changed = False | ||
comparison_changed = False | ||
curation_changed = False | ||
widgets_changed = False | ||
exporters_changed = False | ||
sortingcomponents_changed = False | ||
generation_changed = False | ||
stream_extractors_changed = False | ||
github_actions_changed = False | ||
|
||
|
||
for changed_file in changed_files_in_the_pull_request_paths: | ||
|
||
file_is_in_src = changed_file.parts[0] == "src" | ||
|
||
if changed_file.name == "pyproject.toml": | ||
pyproject_toml_changed = True | ||
elif changed_file.name == "neobaseextractor.py": | ||
neobaseextractor_changed = True | ||
extractors_changed = True | ||
elif changed_file.name == "plexon2.py": | ||
plexon2_changed = True | ||
elif changed_file.name == "nwbextractors.py": | ||
extractors_changed = True # There are NWB tests that are not streaming | ||
stream_extractors_changed = True | ||
elif changed_file.name == "iblextractors.py": | ||
stream_extractors_changed = True | ||
elif "core" in changed_file.parts: | ||
core_changed = True | ||
elif "extractors" in changed_file.parts: | ||
extractors_changed = True | ||
elif "preprocessing" in changed_file.parts: | ||
preprocessing_changed = True | ||
elif "postprocessing" in changed_file.parts: | ||
postprocessing_changed = True | ||
elif "qualitymetrics" in changed_file.parts: | ||
qualitymetrics_changed = True | ||
elif "comparison" in changed_file.parts: | ||
comparison_changed = True | ||
elif "curation" in changed_file.parts: | ||
curation_changed = True | ||
elif "widgets" in changed_file.parts: | ||
widgets_changed = True | ||
elif "exporters" in changed_file.parts: | ||
exporters_changed = True | ||
elif "sortingcomponents" in changed_file.parts: | ||
sortingcomponents_changed = True | ||
elif "generation" in changed_file.parts: | ||
generation_changed = True | ||
elif "sorters" in changed_file.parts: | ||
if "external" in changed_file.parts: | ||
sorters_external_changed = True | ||
elif "internal" in changed_file.parts: | ||
sorters_internal_changed = True | ||
else: | ||
sorters_changed = True | ||
elif ".github" in changed_file.parts: | ||
if "workflows" in changed_file.parts: | ||
github_actions_changed = True | ||
|
||
|
||
run_everything = core_changed or pyproject_toml_changed or neobaseextractor_changed or github_actions_changed | ||
run_generation_tests = run_everything or generation_changed | ||
run_extractor_tests = run_everything or extractors_changed or plexon2_changed | ||
run_preprocessing_tests = run_everything or preprocessing_changed | ||
run_postprocessing_tests = run_everything or postprocessing_changed | ||
run_qualitymetrics_tests = run_everything or qualitymetrics_changed | ||
run_curation_tests = run_everything or curation_changed | ||
run_sortingcomponents_tests = run_everything or sortingcomponents_changed | ||
|
||
run_comparison_test = run_everything or run_generation_tests or comparison_changed | ||
run_widgets_test = run_everything or run_qualitymetrics_tests or run_preprocessing_tests or widgets_changed | ||
run_exporters_test = run_everything or run_widgets_test or exporters_changed | ||
|
||
run_sorters_test = run_everything or sorters_changed | ||
run_internal_sorters_test = run_everything or run_sortingcomponents_tests or sorters_internal_changed | ||
|
||
run_streaming_extractors_test = stream_extractors_changed or github_actions_changed | ||
|
||
install_plexon_dependencies = plexon2_changed | ||
|
||
|
||
environment_varaiables_to_add = { | ||
"RUN_EXTRACTORS_TESTS": run_extractor_tests, | ||
"RUN_PREPROCESSING_TESTS": run_preprocessing_tests, | ||
"RUN_POSTPROCESSING_TESTS": run_postprocessing_tests, | ||
"RUN_QUALITYMETRICS_TESTS": run_qualitymetrics_tests, | ||
"RUN_CURATION_TESTS": run_curation_tests, | ||
"RUN_SORTINGCOMPONENTS_TESTS": run_sortingcomponents_tests, | ||
"RUN_GENERATION_TESTS": run_generation_tests, | ||
"RUN_COMPARISON_TESTS": run_comparison_test, | ||
"RUN_WIDGETS_TESTS": run_widgets_test, | ||
"RUN_EXPORTERS_TESTS": run_exporters_test, | ||
"RUN_SORTERS_TESTS": run_sorters_test, | ||
"RUN_INTERNAL_SORTERS_TESTS": run_internal_sorters_test, | ||
"INSTALL_PLEXON_DEPENDENCIES": install_plexon_dependencies, | ||
"RUN_STREAMING_EXTRACTORS_TESTS": run_streaming_extractors_test, | ||
} | ||
|
||
# Write the conditions to the GITHUB_ENV file | ||
env_file = os.getenv("GITHUB_ENV") | ||
with open(env_file, "a") as f: | ||
for key, value in environment_varaiables_to_add.items(): | ||
f.write(f"{key}={value}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import subprocess | ||
import math | ||
|
||
import_statement_list = [ | ||
"import spikeinterface", | ||
"import spikeinterface.core", | ||
"import spikeinterface.extractors", | ||
"import spikeinterface.qualitymetrics", | ||
"import spikeinterface.preprocessing", | ||
"import spikeinterface.comparison", | ||
"import spikeinterface.postprocessing", | ||
"import spikeinterface.sortingcomponents", | ||
"import spikeinterface.curation", | ||
"import spikeinterface.exporters", | ||
"import spikeinterface.widgets", | ||
"import spikeinterface.full", | ||
] | ||
|
||
n_samples = 10 | ||
# Note that the symbols at the end are for centering the table | ||
markdown_output = f"## \n\n| Imported Module ({n_samples=}) | Importing Time (seconds) | Standard Deviation (seconds) | Times List (seconds) |\n| :--: | :--------------: | :------------------: | :-------------: |\n" | ||
|
||
exceptions = [] | ||
|
||
for import_statement in import_statement_list: | ||
time_taken_list = [] | ||
for _ in range(n_samples): | ||
script_to_execute = ( | ||
f"import timeit \n" | ||
f"import_statement = '{import_statement}' \n" | ||
f"time_taken = timeit.timeit(import_statement, number=1) \n" | ||
f"print(time_taken) \n" | ||
) | ||
|
||
result = subprocess.run(["python", "-c", script_to_execute], capture_output=True, text=True) | ||
|
||
if result.returncode != 0: | ||
error_message = ( | ||
f"Error when running {import_statement} \n" f"Error in subprocess: {result.stderr.strip()}\n" | ||
) | ||
exceptions.append(error_message) | ||
break | ||
|
||
time_taken = float(result.stdout.strip()) | ||
time_taken_list.append(time_taken) | ||
|
||
for time in time_taken_list: | ||
import_time_threshold = 3.0 # Most of the times is sub-second but there outliers | ||
if time >= import_time_threshold: | ||
exceptions.append( | ||
f"Importing {import_statement} took: {time:.2f} s. Should be <: {import_time_threshold} s." | ||
) | ||
break | ||
|
||
|
||
if time_taken_list: | ||
avg_time = sum(time_taken_list) / len(time_taken_list) | ||
std_time = math.sqrt(sum((x - avg_time) ** 2 for x in time_taken_list) / len(time_taken_list)) | ||
times_list_str = ", ".join(f"{time:.2f}" for time in time_taken_list) | ||
markdown_output += f"| `{import_statement}` | {avg_time:.2f} | {std_time:.2f} | {times_list_str} |\n" | ||
|
||
import_time_threshold = 2.0 | ||
if avg_time > import_time_threshold: | ||
exceptions.append( | ||
f"Importing {import_statement} took: {avg_time:.2f} s in average. Should be <: {import_time_threshold} s." | ||
) | ||
|
||
if exceptions: | ||
raise Exception("\n".join(exceptions)) | ||
|
||
# This is displayed to GITHUB_STEP_SUMMARY | ||
print(markdown_output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["4.0.10", "4.0.11", "4.0.12", "4.0.5", "4.0.6", "4.0.7", "4.0.8", "4.0.9"] |
Oops, something went wrong.