-
Notifications
You must be signed in to change notification settings - Fork 206
Parallelize pytest runs and speed up coverage step #3635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
12e4a25
try to use xdist one more time
mashehu a09161a
[automated] Update CHANGELOG.md
nf-core-bot 269b2f5
Merge branch 'dev' into try-xdist-again
mashehu 9fdd7c6
speed up coverage step
mashehu 2404287
upload textual snapshot only for failing textual tests
mashehu b0cb831
[automated] Update Textual snapshots
nf-core-bot 9acff9b
fix snapshots
mashehu b4a59f2
use also xdist for snapshot generation
mashehu ffed18f
fix snapshot with xdist
mashehu d2193ad
Merge branch 'try-xdist-again' of github.com:mashehu/tools into try-x…
mashehu 62b4f6c
add a delay to fix the snapshot
mashehu a12f4ac
try different delay
mashehu 744d749
[automated] Update CHANGELOG.md
nf-core-bot 9b8a134
move import to beginning of the file
mashehu 7c969c5
Merge branch 'try-xdist-again' of github.com:mashehu/tools into try-x…
mashehu aff0986
Merge branch 'dev' into try-xdist-again
mashehu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,53 @@ | ||
"""Global pytest configuration for nf-core tests setting up worker-specific cache directories to avoid git lock issues.""" | ||
|
||
import os | ||
import shutil | ||
import tempfile | ||
|
||
|
||
def pytest_configure(config): | ||
"""Configure pytest before any tests run - set up worker-specific cache directories.""" | ||
# Get worker ID for pytest-xdist, or 'main' if not using xdist | ||
worker_id = getattr(config, "workerinput", {}).get("workerid", "main") | ||
|
||
# Create temporary directories for this worker | ||
cache_base = tempfile.mkdtemp(prefix=f"nfcore_cache_{worker_id}_") | ||
config_base = tempfile.mkdtemp(prefix=f"nfcore_config_{worker_id}_") | ||
|
||
# Store original values for later restoration | ||
config._original_xdg_cache = os.environ.get("XDG_CACHE_HOME") | ||
config._original_xdg_config = os.environ.get("XDG_CONFIG_HOME") | ||
config._temp_cache_dir = cache_base | ||
config._temp_config_dir = config_base | ||
|
||
# Set environment variables to use worker-specific directories | ||
os.environ["XDG_CACHE_HOME"] = cache_base | ||
os.environ["XDG_CONFIG_HOME"] = config_base | ||
|
||
|
||
def pytest_unconfigure(config): | ||
"""Clean up after all tests are done.""" | ||
# Restore original environment variables | ||
if hasattr(config, "_original_xdg_cache"): | ||
if config._original_xdg_cache is not None: | ||
os.environ["XDG_CACHE_HOME"] = config._original_xdg_cache | ||
else: | ||
os.environ.pop("XDG_CACHE_HOME", None) | ||
|
||
if hasattr(config, "_original_xdg_config"): | ||
if config._original_xdg_config is not None: | ||
os.environ["XDG_CONFIG_HOME"] = config._original_xdg_config | ||
else: | ||
os.environ.pop("XDG_CONFIG_HOME", None) | ||
|
||
# Clean up temporary directories | ||
if hasattr(config, "_temp_cache_dir"): | ||
try: | ||
shutil.rmtree(config._temp_cache_dir) | ||
except (OSError, FileNotFoundError): | ||
pass | ||
if hasattr(config, "_temp_config_dir"): | ||
try: | ||
shutil.rmtree(config._temp_config_dir) | ||
except (OSError, FileNotFoundError): | ||
pass |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.