-
Notifications
You must be signed in to change notification settings - Fork 207
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
fix: prevent unwanted subprocess termination #1079
base: main
Are you sure you want to change the base?
fix: prevent unwanted subprocess termination #1079
Conversation
Hello @ollie-bell :D I see this is an attempt to basically disable the cutout check. |
Hey no worries! So it doesn't quite disable the cutout check. It only disables the check if snakemake is being run as a subprocess (i.e. snakemake calling itself). The behaviour it avoids is something like this (although it's been a while since I thought about it now!):
If instead you just want to remove the cutout check functional call entirely and replace it with a config param then that's also a solution for sure, and this PR will not be necessary. I just proposed this change which didn't change the overall behaviour or introduce any new configuration. |
Ah now I see. However, your question raises the problem whether we want this check to be performed always, which is a good point. |
So I think what you mean is if you modify these lines Lines 348 to 349 in f660a3a
to something like: if config["enable"].get("build_cutout", False):
if not config["run"].get("allow_cutout_overwrite", False):
terminate_if_cutout_exists(config) I think the problem my PR addresses will still exist if this is the case. You might not want to allow cutout overwrite if one already exists, so you'd set |
Mmm so in plain terms, what do you want to achieve is that the first execution creates the cutout and the following do not right? It appears to me that the behavior is no different than calling the scenarios by simply disabling the check on the cutout, no? |
Ah yes if you remove the check entirely (as in, delete the |
Just to further follow up, I was wondering if you were interested in such feature |
Hi @davide-f. I've added a test snakefile which is a minimal reproduction of the issue. You can run it like so: snakemake --snakefile test/test_cutout_termination.smk -c1 --config subprocess_check=0 I have included detailed output below which shows that the run fails after the If you have another way you'd like to address the issue then absolutely no problem! Without fix:Building DAG of jobs...
Using shell: /opt/homebrew/bin/bash
Provided cores: 1 (use --cores to define parallelism)
Rules claiming more threads will be scaled down.
Job stats:
job count
------------- -------
build_cutout 1
remove_cutout 1
total 2
Select jobs to execute...
[Sun Sep 29 15:55:48 2024]
rule build_cutout:
output: cutout.txt
jobid: 1
reason: Missing output files: cutout.txt
resources: tmpdir=/var/folders/gs/wmf0yh194f77d4k9694p85p00000gp/T
[Sun Sep 29 15:55:48 2024]
Finished job 1.
1 of 2 steps (50%) done
Select jobs to execute...
[Sun Sep 29 15:55:48 2024]
rule remove_cutout:
input: cutout.txt
jobid: 0
reason: Rules with a run or shell declaration but no output are always executed.
resources: tmpdir=/var/folders/gs/wmf0yh194f77d4k9694p85p00000gp/T
Exception in file /Users/ollieb/Documents/pypsa-earth/test/test_cutout_termination, line 25:
A cutout file cutout.txt exists and risks to be overwritten. If this is an intended behavior, please move or delete this file and re-run the rule.
File "/Users/ollieb/Documents/pypsa-earth/test/test_cutout_termination", line 31, in <module>
File "/Users/ollieb/Documents/pypsa-earth/test/test_cutout_termination", line 25, in terminate_if_cutout_exists
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
Complete log: .snakemake/log/2024-09-29T155548.095661.snakemake.log With fix:Building DAG of jobs...
Using shell: /opt/homebrew/bin/bash
Provided cores: 1 (use --cores to define parallelism)
Rules claiming more threads will be scaled down.
Job stats:
job count
------------- -------
build_cutout 1
remove_cutout 1
total 2
Select jobs to execute...
[Sun Sep 29 16:03:06 2024]
rule build_cutout:
output: cutout.txt
jobid: 1
reason: Missing output files: cutout.txt
resources: tmpdir=/var/folders/gs/wmf0yh194f77d4k9694p85p00000gp/T
[Sun Sep 29 16:03:06 2024]
Finished job 1.
1 of 2 steps (50%) done
Select jobs to execute...
[Sun Sep 29 16:03:06 2024]
rule remove_cutout:
input: cutout.txt
jobid: 0
reason: Rules with a run or shell declaration but no output are always executed.
resources: tmpdir=/var/folders/gs/wmf0yh194f77d4k9694p85p00000gp/T
Building DAG of jobs...
Using shell: /opt/homebrew/bin/bash
Provided cores: 1 (use --cores to define parallelism)
Rules claiming more threads will be scaled down.
Select jobs to execute...
[Sun Sep 29 16:03:06 2024]
Finished job 0.
2 of 2 steps (100%) done
Complete log: .snakemake/log/2024-09-29T160306.064004.snakemake.log |
…ll/pypsa-earth into fix-cutout-terminate-subprocess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ollie-bell ! :D
Alternative approaches are possible and solves your issue. We are happy to welcome it :)
We have two minor comments and happy to merge this afterwards :D
@@ -36,6 +36,7 @@ PyPSA-Earth 0.4.1 | |||
* Fixed problematic float parsing (`_parse_float`) in `clean_osm_data.py` to make sure all OSM lines are correctly accounted for `PR #1089 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1089>`__ | |||
* Fix minor bug for advanced csp implementation `PR #1076 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1076>`__ | |||
* Fix minor bug in `build_powerplants.py` where the gas technology assignment incorrectly introduced NaN values for all powerplant technologies. `PR #1102 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1102>`__ | |||
* Fix unwanted termination due to existing cutout during snakemake subprocess calls `PR #1079 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/1079>`__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind moving this up? :)
@@ -0,0 +1,50 @@ | |||
# SPDX-FileCopyrightText: PyPSA-Earth and PyPSA-Eur Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for the test example! :)
Do you think it shall be included or can we remove it? [less material to maintain]
Closes # (if applicable).
#839 (comment)
Changes proposed in this Pull Request
See comment #839 (comment)
Checklist
envs/environment.yaml
anddoc/requirements.txt
.config.default.yaml
andconfig.tutorial.yaml
.test/
(note tests are changing the config.tutorial.yaml)doc/configtables/*.csv
and line references are adjusted indoc/configuration.rst
anddoc/tutorial.rst
.doc/release_notes.rst
is amended in the format of previous release notes, including reference to the requested PR.