Skip to content
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

Snakemake --generate-unit-tests system breaks relative paths #18

Open
G-kodes opened this issue Nov 18, 2021 · 0 comments
Open

Snakemake --generate-unit-tests system breaks relative paths #18

G-kodes opened this issue Nov 18, 2021 · 0 comments

Comments

@G-kodes
Copy link

G-kodes commented Nov 18, 2021

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'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant