fix: disable execute after print compilation#3041
fix: disable execute after print compilation#3041johanneskoester merged 7 commits intosnakemake:mainfrom
Conversation
with flag `print-compilation`, it is not intend to execute the code, which can be incomplete, and running it will waste time and print errors to the screen. Also, I add some asserts to some properties as they are typing as Optional.
WalkthroughThe changes involve multiple modifications across several files in the Snakemake codebase. A new decorator function Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- snakemake/api.py (2 hunks)
- snakemake/parser.py (2 hunks)
- snakemake/persistence.py (1 hunks)
- snakemake/workflow.py (33 hunks)
Additional context used
Path-based instructions (4)
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/api.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/parser.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/workflow.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/parser.py
1311-1311: Ambiguous variable name:
l(E741)
snakemake/workflow.py
20-20:
typing.Dictimported but unusedRemove unused import:
typing.Dict(F401)
Additional comments not posted (38)
snakemake/persistence.py (1)
44-44: Type annotation update is appropriate.The change from
Path = NonetoPath | None = Noneenhances type clarity and aligns with modern Python type hinting practices.snakemake/api.py (2)
290-295: Introduction of_no_dagdecorator is well-structured.The
_no_dagdecorator is defined outside of thedagfunction, enhancing code organization and reusability. It setscoresto 1, aligning with the PR objective.
297-297: Application of_no_dagdecorator tolintmethod is appropriate.The
lintmethod now inherits the behavior of settingcoresto 1, which is consistent with the intended functionality.snakemake/parser.py (2)
73-74: Type annotation added forlinenofunction.The addition of type annotation for the
tokenparameter enhances clarity and type safety.
1299-1305: Type annotations and reformatting added toparsefunction.The type annotations for
workflowandlinemapenhance clarity and type safety. The reformatting improves readability.snakemake/workflow.py (33)
151-151: LGTM!The change from
Mapping[str, str]todict[str, str]is appropriate for specifying the type more precisely.
152-152: LGTM!The change to allow
overwrite_workdirto be of typestrorPathenhances flexibility in handling file paths.
253-253: LGTM!The assertion ensures that
storage_settingsis notNone, which helps prevent potential runtime errors.
274-274: LGTM!The assertion ensures that
storage_settingsis notNone, which helps prevent potential runtime errors.
386-389: LGTM!The condition ensures that
execution_settingsis notNonebefore accessinguse_threads, which is a good practice.
473-473: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
478-478: LGTM!The assertion ensures that
deployment_settingsis notNone, which helps prevent potential runtime errors.
666-669: LGTM!The condition ensures that
storage_settingsanddefault_storage_providerare notNonebefore proceeding, which is a good practice.
679-680: LGTM!The change to allow
shadow_prefixto be of typestr,Path, orNoneenhances flexibility.
698-698: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
799-799: LGTM!The assertion ensures that
deployment_settingsis notNone, which helps prevent potential runtime errors.
818-818: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
837-837: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
857-857: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
912-912: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
928-928: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
938-938: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
948-948: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
958-958: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
971-971: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
987-987: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
1006-1006: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
1017-1017: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
1040-1040: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
1048-1048: LGTM!The assertion ensures that
deployment_settingsis notNone, which helps prevent potential runtime errors.
1054-1054: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
1064-1064: LGTM!The assertion ensures that
dag_settingsis notNone, which helps prevent potential runtime errors.
1086-1091: LGTM!The assertions ensure that critical settings are not
None, which helps prevent potential runtime errors.
1360-1361: LGTM!The assertion ensures that the frame is not
None, which helps prevent potential runtime errors.
1388-1389: LGTM!The assertion ensures that the frame is not
None, which helps prevent potential runtime errors.
1435-1435: LGTM!Adding a type hint for
linemapimproves code clarity and type safety.
1447-1447: LGTM!The return statement aligns with the PR objective to disable execution after print compilation.
1969-1969: LGTM!The assertion ensures that
deployment_settingsis notNone, which helps prevent potential runtime errors.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
johanneskoester
left a comment
There was a problem hiding this comment.
Thank you so much! I have just a few questions about the changes.
snakemake/workflow.py
Outdated
| deploy.append("conda") | ||
| if DeploymentMethod.APPTAINER in self.deployment_settings.deployment_method: | ||
| deploy.append("singularity") | ||
| if self.deployment_settings is not None: |
There was a problem hiding this comment.
why would this be none here?
There was a problem hiding this comment.
These following checks of None are added as these params are setted as None when it was created. mypy warned me that. Probably an assert is proper here, or I will ignore these type of warnings? Thanks for your advice!
snakemake/workflow.py
Outdated
| assert self.dag_settings is not None | ||
| self._prepare_dag( | ||
| forceall=self.dag_settings.forceall, | ||
| forceall=self.dag_settings.forceall, # True? |
There was a problem hiding this comment.
Sorry for the trailing comment added here, I've deleted it
snakemake/workflow.py
Outdated
| path = str(path) | ||
| if self.storage_settings.default_storage_provider is not None: | ||
| if ( | ||
| self.storage_settings is not None |
There was a problem hiding this comment.
Why would this be None here?
snakemake/workflow.py
Outdated
| return ( | ||
| self.execution_settings.use_threads | ||
| ( | ||
| self.execution_settings is not None |
There was a problem hiding this comment.
Why would this be None here?
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- snakemake/parser.py (2 hunks)
- snakemake/workflow.py (33 hunks)
Files skipped from review as they are similar to previous changes (2)
- snakemake/parser.py
- snakemake/workflow.py
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- snakemake/workflow.py (36 hunks)
Files skipped from review as they are similar to previous changes (1)
- snakemake/workflow.py
snakemake/parser.py
Outdated
| def parse( | ||
| path, | ||
| workflow: "workflow.Workflow", | ||
| linemap: dict[int, int], |
There was a problem hiding this comment.
| linemap: dict[int, int], | |
| linemap: Dict[int, int], |
I rather used typing.Dict so far for backwards compatibility. Can you change the rest?
There was a problem hiding this comment.
Ah wait, I will do that quickly.
There was a problem hiding this comment.
Sorry for my miss, and I'm grateful for your help!
|
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- snakemake/common/init.py (1 hunks)
- snakemake/io.py (2 hunks)
- snakemake/parser.py (2 hunks)
- snakemake/workflow.py (36 hunks)
Files skipped from review due to trivial changes (2)
- snakemake/common/init.py
- snakemake/io.py
Files skipped from review as they are similar to previous changes (2)
- snakemake/parser.py
- snakemake/workflow.py
🤖 I have created a release *beep* *boop* --- ## [8.19.0](v8.18.2...v8.19.0) (2024-08-29) ### Features * check consistency of output file mtimes (must be newer than input files) ([#3050](#3050)) ([666cf62](666cf62)) * print host name when executing workflow ([#3048](#3048)) ([b0ff787](b0ff787)) ### Bug Fixes * `mem` and `disk` inference fixes ([#3040](#3040)) ([7530794](7530794)) * avoid error accessing superclass in ioutils ([#3056](#3056)) ([a66a5f5](a66a5f5)) * disable execute after print compilation ([#3041](#3041)) ([86ed3cd](86ed3cd)) * download report assets upon package build such that reports become possible offline (cont. of [#2904](#2904)) ([#3026](#3026)) ([e8dad4b](e8dad4b)) ### Documentation * Add 'Editor integrations' section to Installation page ([#3045](#3045)) ([9a4006d](9a4006d)) * Fix typo (seesee to see) ([#3037](#3037)) ([de201fb](de201fb)) * various documentation fixes ([#3052](#3052)) ([b11460c](b11460c)) --- 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>
with flag `print-compilation`, it is not intend to execute the code, which can be incomplete, and running it will waste time and print errors to the screen. Also, I add some asserts to some properties as they are typing as Optional. <!--Add a description of your PR here--> ### QC <!-- Make sure that you can tick the boxes below. --> * [ ] The PR contains a test case for the changes or the changes are already covered by an existing test case. * [ ] The documentation (`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). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a reusable decorator that standardizes resource settings in the Workflow API. - **Enhancements** - Improved type annotations for better clarity and type safety across multiple classes. - Added assertions in critical methods to ensure necessary settings are initialized before use. - **Refactor** - Streamlined several function signatures and internal logic for enhanced readability and maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Johannes Köster <johannes.koester@uni-due.de> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [8.19.0](snakemake/snakemake@v8.18.2...v8.19.0) (2024-08-29) ### Features * check consistency of output file mtimes (must be newer than input files) ([snakemake#3050](snakemake#3050)) ([666cf62](snakemake@666cf62)) * print host name when executing workflow ([snakemake#3048](snakemake#3048)) ([b0ff787](snakemake@b0ff787)) ### Bug Fixes * `mem` and `disk` inference fixes ([snakemake#3040](snakemake#3040)) ([7530794](snakemake@7530794)) * avoid error accessing superclass in ioutils ([snakemake#3056](snakemake#3056)) ([a66a5f5](snakemake@a66a5f5)) * disable execute after print compilation ([snakemake#3041](snakemake#3041)) ([86ed3cd](snakemake@86ed3cd)) * download report assets upon package build such that reports become possible offline (cont. of [snakemake#2904](snakemake#2904)) ([snakemake#3026](snakemake#3026)) ([e8dad4b](snakemake@e8dad4b)) ### Documentation * Add 'Editor integrations' section to Installation page ([snakemake#3045](snakemake#3045)) ([9a4006d](snakemake@9a4006d)) * Fix typo (seesee to see) ([snakemake#3037](snakemake#3037)) ([de201fb](snakemake@de201fb)) * various documentation fixes ([snakemake#3052](snakemake#3052)) ([b11460c](snakemake@b11460c)) --- 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>



with flag
print-compilation, it is not intend to execute the code, which can be incomplete, and running it will waste time and print errors to the screen.Also, I add some asserts to some properties as they are typing as Optional.
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
Enhancements
Refactor