-
Notifications
You must be signed in to change notification settings - Fork 3
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
Establish snakemake workflow by importing pypsa-earth
rules as module
#4
Establish snakemake workflow by importing pypsa-earth
rules as module
#4
Conversation
pypsa-earth
rules as module
Inclusion of I have added |
Hi, @GbotemiB. Could you please test the PR. Try solving the network from |
Hi @yerbol-akhmetov, I tested it on a fresh repo. I got this error Config file submodules/pypsa-earth/config.default.yaml is extended by additional config specified via the command line.
Config file submodules/pypsa-earth/configs/bundle_config.yaml is extended by additional config specified via the command line.
Config file configs/config.main.yaml is extended by additional config specified via the command line.
FileNotFoundError in file /Volumes/MBP Ext Disk/Yerbol/efuels-supply-potentials/submodules/pypsa-earth/Snakefile, line 36:
[Errno 2] No such file or directory: 'config.default.yaml'
File "/Volumes/MBP Ext Disk/Yerbol/efuels-supply-potentials/Snakefile", line 47, in <module>
File "/Volumes/MBP Ext Disk/Yerbol/efuels-supply-potentials/submodules/pypsa-earth/Snakefile", line 36, in <module>
File "/Volumes/MBP Ext Disk/Yerbol/efuels-supply-potentials/submodules/pypsa-earth/scripts/_helpers.py", line 59, in check_config_version Looks like it was not able to find the config.default.yaml file. By the way, I ran the code in the main working directory. |
@GbotemiB. Yes it will not work with main. Please make the following changes to the files. I have created a PR to upstream already. But for now try locally: |
@yerbol-akhmetov, I have tested the code and it works fine. Although I had to comment so other rules since it was taking time. |
Which rules were tested? In my case, I run everything except |
I only test the add electricity rule. Other files were present which was why i skipped it, but if you want testing with just removing |
Can you please fully solve it? Skip |
@GbotemiB, if everything works, then we can merge it I think. For now, we do not have custom scripts that will use into pypsa-earth workflow except |
@yerbol-akhmetov I ran the model again, and got this error. /Users/gbotemi/miniconda3/envs/pypsa-earth/lib/python3.10/site-packages/pypsa/networkclustering.py:16: UserWarning:
The namespace `pypsa.networkclustering` is deprecated and will be removed in PyPSA v0.24. Please use `pypsa.clustering.spatial instead`.
Can't find the repo path.
ERROR:_helpers:An error happened in module '/Users/gbotemi/miniconda3/envs/pypsa-earth/lib/python3.10/logging/__init__.py', function '_open': [Errno 2] No such file or directory: '/submodules/pypsa-earth/logs/US_2021/simplify_network/elec_s.log'
Traceback (most recent call last):
File "/Users/gbotemi/Documents/code/PYPSA/US/efuels-supply-potentials/.snakemake/scripts/tmps2t3jmow.simplify_network.py", line 972, in <module>
configure_logging(snakemake)
File "/Users/gbotemi/Documents/code/PYPSA/US/efuels-supply-potentials/submodules/pypsa-earth/scripts/_helpers.py", line 222, in configure_logging
logging.FileHandler(logfile),
File "/Users/gbotemi/miniconda3/envs/pypsa-earth/lib/python3.10/logging/__init__.py", line 1169, in __init__
StreamHandler.__init__(self, self._open())
File "/Users/gbotemi/miniconda3/envs/pypsa-earth/lib/python3.10/logging/__init__.py", line 1201, in _open
return open_func(self.baseFilename, self.mode,
FileNotFoundError: [Errno 2] No such file or directory: '/submodules/pypsa-earth/logs/US_2021/simplify_network/elec_s.log' Is this similar to the error you encountered? |
Yes, I used to encounter such error. But now I don't, I do not quite know the reason. It needs to be investigated. I run base thought pypsa-earth repo. Then, I run through outside snakemake. Maybe path the log storing location was missing. Can you also try to find the reason? I do not encounter such error now, but I will try to replicate somehow. |
Alright, I will try to investigate the issue. |
Good day. This draft PR is focused on importing the
pypsa-earth
rules into local snakemake. It is still a draft PR, it is still not finished.The current implementation enables to execute
snakemake --cores 1 retrieve_databundle_light --configfile configs/calibration/config.usa_PE.yaml
inefuels-supply-potentials
directory. However, it requires few changes inpypsa-earth/scripts/_helpers.py
. In particular, the path forconfig.default.yaml
incheck_config_version
function needs to be absolute. This was the change: https://github.com/yerbol-akhmetov/pypsa-earth/blob/1ccce2e128dc72b0ebb6344b7758cce8dbee369d/scripts/_helpers.py#L42-L48I have pushed this change as
snakemake_import
branch: https://github.com/yerbol-akhmetov/pypsa-earth/tree/snakemake_importCurrently, if we execute retrieve databundle command, the command will execute, but files will be stored in main drive folder (C://). It is because the path for output files in
pypsa-earth
Snakefile refer to relative path. This is given as example. The outputs are generally: "results/", "resources/.." and etc.I have tried a step further by adding absolute path to outputs and inputs in Snakefile of pypsa-earth and it seemed to work.
@FabianHofmann, @davide-f, @martacki, I would be very glad to get a hint if such approach is right. Currently, the problem is when outer Snakemake rules are executed, they treat inner
pypsa-earth
rules being executed as in outside (in efuels-supply-potential directory). Appending sys.path.append('submodules/pypsa-earth') did not helped though. The only option I currently see is to make pypsa-earth rules use absolute paths, something like this: