When using the unit tests generated by Snakemake, I am unable to actually RUN the tests as the testing system does not re-set the default working directory to the project root.
Using the provided example config:
- name: Testing
uses: snakemake/snakemake-github-action@v1
with:
directory: '.test'
snakefile: 'workflow/Snakefile'
args: '--cores 1 --use-conda --conda-cleanup-pkgs cache'
stagein: '' # additional preliminary commands to run (can be multiline)
the working directory is now effectively .test instead of project root (.). This is an issue if you are using relative paths to things like, say, resources or config files which is also an issue raised due to Snakemakes recent directive to encourage a new project folder structure.
A good example of this is how one references config files in your Snakefile:
from os.path import join
configfile: join("config", "config.json")
would essentially result in the following error on GitHub Actions:
Traceback (most recent call last):
File "/opt/conda/envs/snakemake/lib/python3.9/site-packages/snakemake/__init__.py", line 593, in snakemake
workflow.include(
File "/opt/conda/envs/snakemake/lib/python3.9/site-packages/snakemake/workflow.py", line 1182, in include
exec(compile(code, snakefile.get_path_or_uri(), "exec"), self.globals)
File "/github/workspace/workflow/Snakefile", line 26, in <module>
configfile: join("config", "config.json")
File "/opt/conda/envs/snakemake/lib/python3.9/site-packages/snakemake/workflow.py", line 1239, in configfile
c = snakemake.io.load_configfile(fp)
File "/opt/conda/envs/snakemake/lib/python3.9/site-packages/snakemake/io.py", line 1618, in load_configfile
config = _load_configfile(configpath)
File "/opt/conda/envs/snakemake/lib/python3.9/site-packages/snakemake/io.py", line 1583, in _load_configfile
obj = open(configpath_or_obj, encoding="utf-8")
FileNotFoundError: [Errno 2] No such file or directory: 'config/config.json'
When using the unit tests generated by Snakemake, I am unable to actually RUN the tests as the testing system does not re-set the default working directory to the project root.
Using the provided example config:
the working directory is now effectively
.test
instead of project root (.
). This is an issue if you are using relative paths to things like, say, resources or config files which is also an issue raised due to Snakemakes recent directive to encourage a new project folder structure.A good example of this is how one references config files in your
Snakefile
:would essentially result in the following error on GitHub Actions: