fix: fixed check for remote conda env pinning and post-deploy files; fixed conda env cleanup#3103
Conversation
…fixed conda env cleanup
WalkthroughThe changes modify the Changes
Possibly related PRs
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- snakemake/deployment/conda.py (3 hunks)
- snakemake/persistence.py (1 hunks)
- snakemake/sourcecache.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
snakemake/deployment/conda.py (1)
Pattern
**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.snakemake/persistence.py (1)
Pattern
**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.snakemake/sourcecache.py (1)
Pattern
**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
🔇 Additional comments not posted (15)
snakemake/persistence.py (1)
Line range hint
1-1023: Overall assessment of changes to conda environment cleanupThe modifications to the
conda_cleanup_envsmethod represent a positive step towards more efficient management of conda environments in Snakemake. The focus on cleaning up non-named environments and their associated YAML files is a good approach.However, as noted in the previous comment, there's room for improvement in terms of error handling, logging specificity, and potentially adding a dry-run option. These enhancements would make the cleanup process more robust and informative for users.
The changes align well with the PR objectives of fixing the conda environment cleanup process. They should contribute to better management of conda environments within the Snakemake framework.
snakemake/sourcecache.py (8)
28-28: Importingloggerfor logging retry attemptsThe addition of
from snakemake.logging import loggeris necessary for logging retry attempts, which enhances debugging and monitoring capabilities.
374-374: Settingretries=1inexistsmethodBy setting
retries=1when calling_cachein theexistsmethod, the code ensures that the existence check is quick and avoids unnecessary delays from multiple retries. This seems appropriate for a rapid existence check.
395-395: Addingretriesparameter to_cachemethodIntroducing the
retriesparameter with a default value of 3 in the_cachemethod allows for flexibility in controlling the number of retry attempts during caching operations, enhancing robustness against transient errors.
398-398: Propagatingretriesto_do_cachemethodPassing the
retriesparameter to_do_cacheensures consistent retry behavior throughout the caching process, maintaining alignment with the specified number of retries.
401-401: Includingretriesin_do_cachemethod signatureAdding the
retriesparameter to the_do_cachemethod allows it to control the retry logic when opening the source file, which enhances error handling during caching.
403-403: Passingretriesto_open_local_or_remoteBy passing
retriesto_open_local_or_remote, the code ensures that the retry logic is applied when opening the source file, which is critical for handling transient I/O errors.
428-430: Modifying_open_local_or_remoteto acceptretriesIncluding the
retriesparameter in the_open_local_or_remotemethod signature provides control over the number of retry attempts when opening files, enhancing the method's flexibility and robustness.
437-442: Utilizingretry_callwith logging for retriesUsing
retry_callwith theloggerparameter enables logging of retry attempts, which aids in debugging and monitoring. The specifiedtries,delay, andbackoffparameters provide a balanced retry strategy.snakemake/deployment/conda.py (6)
98-105: Implemented_path_or_uri_prefixmethod to extract file prefixThe new method
_path_or_uri_prefixcorrectly extracts the prefix from the conda environment file path, handling files that end with.yamlor.yml. It returns the prefix without the extension orNoneif the file has a different extension. This enhances code modularity and reusability.
108-112: Refactoredpin_fileproperty to use_get_aux_fileThe
pin_fileproperty now utilizes the_get_aux_filemethod, centralizing the logic for locating auxiliary files related to the conda environment. This refactoring improves maintainability by reducing code duplication.
117-122: Refactoredpost_deploy_fileproperty to use_get_aux_fileSimilarly, the
post_deploy_fileproperty has been refactored to use_get_aux_file. This change further centralizes auxiliary file retrieval, enhancing code consistency and reusability.
124-140: Added_get_aux_filemethod to centralize auxiliary file retrievalThe new
_get_aux_filemethod encapsulates the logic for retrieving auxiliary files based on a given suffix and a custom omission message. It checks if the environment file exists, extracts the prefix, and constructs the auxiliary file path. It also logs a warning if the environment file does not have the expected.yamlor.ymlextension. This addition improves code modularity and simplifies future maintenance.
Line range hint
602-606: Ensured execution of post-deploy script after environment creationThe code now executes the post-deployment script if it is present after the conda environment is created. This change ensures that any necessary post-deployment steps are performed, enhancing the functionality of the deployment process.
628-629: Added cleanup of temporary pin filesTemporary pin files are now properly removed after the environment creation process. This cleanup prevents leftover temporary files, reducing potential clutter and conflicts in the environment directory.
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- snakemake/persistence.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
snakemake/persistence.py (1)
Pattern
**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of theselfargument of methods.
Do not suggest type annotation of theclsargument of classmethods.
Do not suggest return type annotation if a function or method does not contain areturnstatement.
Ruff
snakemake/persistence.py
266-266: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
273-275: Within an
exceptclause, raise exceptions withraise ... from errorraise ... from Noneto distinguish them from errors in exception handling(B904)
🤖 I have created a release *beep* *boop* --- ## [8.20.5](v8.20.4...v8.20.5) (2024-09-25) ### Bug Fixes * fixed check for remote conda env pinning and post-deploy files; fixed conda env cleanup ([#3103](#3103)) ([4d0a7e9](4d0a7e9)) * omit storage downloads during dryrun in workflows with checkpoints ([#3100](#3100)) ([151216a](151216a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>



QC
docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).Summary by CodeRabbit
New Features
Bug Fixes
Documentation