Skip to content

Commit

Permalink
improve import time display
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Jun 1, 2024
1 parent 000e0ba commit c70fedb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 8 additions & 2 deletions .github/import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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) |\n| :--: | :--------------: | :------------------: |\n"
markdown_output = f"## \n\n| Imported Module ({n_samples=}) | Importing Time (seconds) | Standard Deviation (seconds) | Times List (seconds) |\n| :--: | :--------------: | :------------------: | :-------------: |\n"

exceptions = []

Expand All @@ -45,10 +45,16 @@
time_taken = float(result.stdout.strip())
time_taken_list.append(time_taken)

for time in time_taken_list:
if time > 2.5:
exceptions.append(f"Importing {import_statement} took too long: {time:.2f} seconds")
break

if time_taken_list:
avg_time_taken = sum(time_taken_list) / len(time_taken_list)
std_dev_time_taken = math.sqrt(sum((x - avg_time_taken) ** 2 for x in time_taken_list) / len(time_taken_list))
markdown_output += f"| `{import_statement}` | {avg_time_taken:.2f} | {std_dev_time_taken:.2f} |\n"
times_list_str = ", ".join(f"{time:.2f}" for time in time_taken_list)
markdown_output += f"| `{import_statement}` | {avg_time_taken:.2f} | {std_dev_time_taken:.2f} | {times_list_str} |\n"

if exceptions:
raise Exception("\n".join(exceptions))
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/test_imports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Install Spikeinterface with only core dependencies
run: |
git config --global user.email "[email protected]"
git config --global user.name "CI Almighty"
python -m pip install -U pip # Official recommended way
pip install -e . # This should install core only
pip install . # This should install core only
- name: Profile Imports
run: |
echo "## OS: ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY
Expand All @@ -38,8 +38,7 @@ jobs:
shell: bash # Necessary for pipeline to work on windows
- name: Install in full mode
run: |
python -m pip install -U pip # Official recommended way
pip install -e .[full]
pip install .[full]
- name: Profile Imports with full
run: |
# Add a header to separate the two profiles
Expand Down

0 comments on commit c70fedb

Please sign in to comment.