snakemake / snakemake-github-action

A Github action for running a Snakemake workflow
MIT License
51 stars 12 forks source link

Bug: conda is not properly installed with v8.0.1 (stable) docker build #37

Closed ezherman closed 8 months ago

ezherman commented 9 months ago

It appears that with the stable docker build, conda is not properly installed.

I am getting the following output at the testing stage, from the main branch of this example repo:

Run snakemake/snakemake-github-action@v1.24.0
/usr/bin/docker run --name c90687c166a41fbecb4ede947e588046a9f7bf_9980a9 --label c90687 --workdir /github/workspace --rm -e "INPUT_DIRECTORY" -e "INPUT_SNAKEFILE" -e "INPUT_ARGS" -e "INPUT_STAGEIN" -e "INPUT_TASK" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/example-workflow/example-workflow":"/github/workspace" c90687:c166a41fbecb4ede947e588046a9f7bf  ".test" "workflow/Snakefile" "--use-conda --show-failed-logs --cores 3 --conda-cleanup-pkgs cache --all-temp" "" "run"
Creating specified working directory .test.
Building DAG of jobs...
/usr/bin/bash: line 1: conda: command not found
Traceback (most recent call last):
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/cli.py", line 1970, in args_to_api
    dag_api.execute_workflow(
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/api.py", line 564, in execute_workflow
    workflow.execute(
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/workflow.py", line 1093, in execute
    self.dag.create_conda_envs()
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/dag.py", line 405, in create_conda_envs
    env.create(self.workflow.dryrun)
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/deployment/conda.py", line 393, in create
    pin_file = self.pin_file
               ^^^^^^^^^^^^^
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake_interface_common/utils.py", line 30, in __get__
    value = self.method(instance)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/deployment/conda.py", line 103, in pin_file
    f".{self.conda.platform}.pin.txt"
        ^^^^^^^^^^
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake_interface_common/utils.py", line 30, in __get__
    value = self.method(instance)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/deployment/conda.py", line 96, in conda
    return Conda(
           ^^^^^^
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/deployment/conda.py", line 653, in __init__
    shell.check_output(self._get_cmd("conda info --json"), text=True)
  File "/opt/conda/envs/snakemake/lib/python3.12/site-packages/snakemake/shell.py", line 61, in check_output
    return sp.check_output(cmd, shell=True, executable=executable, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/snakemake/lib/python3.12/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/envs/snakemake/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'conda info --json' returned non-zero exit status 127.

With Snakemake set to v7.32.0 through a modified fork of this repository (see this branch), things run fine:

Run ezherman/snakemake-github-action@5027c0e706ada924ab91e0501bd92185fc98de3c
/usr/bin/docker run --name b197aa9e098a0e4c24830b6af7d8b5b0b515a_1d91e1 --label 3b197a --workdir /github/workspace --rm -e "INPUT_DIRECTORY" -e "INPUT_SNAKEFILE" -e "INPUT_ARGS" -e "INPUT_STAGEIN" -e "INPUT_TASK" -e "INPUT_SHOW-DISK-USAGE-ON-ERROR" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/example-workflow/example-workflow":"/github/workspace" 3b197a:a9e098a0e4c24830b6af7d8b5b0b515a  ".test" "workflow/Snakefile" "--use-conda --show-failed-logs --cores 1 --conda-cleanup-pkgs cache --all-temp" "" "run" "false"
Creating specified working directory .test.
Building DAG of jobs...
Creating conda environment ../workflow/envs/empty.yaml...
Downloading and installing remote packages.
Cleaning up conda package tarballs and package cache.
Environment for /github/workspace/workflow/envs/empty.yaml created (location: .snakemake/conda/aaa81a56a695b55ee8592f26b4d5c73d_)
Using shell: /bin/bash
Provided cores: 1 (use --cores to define parallelism)
Rules claiming more threads will be scaled down.
Job stats:
job      count
-----  -------
touch        1
total        1

Select jobs to execute...

[Thu Dec 21 17:23:19 2023]
rule touch:
    output: file.txt
    log: logs/touch.log
    jobid: 0
    reason: Missing output files: file.txt
    resources: tmpdir=/tmp

Activating conda environment: .snakemake/conda/aaa81a56a695b55ee8592f26b4d5c73d_
[Thu Dec 21 17:23:19 2023]
Finished job 0.
1 of 1 steps (100%) done
Removing temporary output file.txt.
Complete log: .snakemake/log/2023-12-21T172304.173887.snakemake.log

The relevant actions can be found here:

sanjaynagi commented 9 months ago

I am having the same issue. Using your fork for now @ezherman, this solves it.

DavideBrex commented 9 months ago

same issue here, last week it was working now not anymore.

Could be possible to do not pull the latest version? Since my workflow has not been locally tested with snakemake v8

percyfal commented 8 months ago

From snakemake v8 the docker parent image is mambaorg/micromamba, which does not include conda/mamba. I could verify by adding a stagein section:

    - name: Test workflow
      uses: snakemake/snakemake-github-action@v1.25.1
      with:
        directory: .test
        snakefile: workflow/Snakefile
        stagein: micromamba config append channels conda-forge; micromamba install -n snakemake -y rsync conda mamba

in one of my workflows.

johanneskoester commented 8 months ago

Indeed, sorry for the issue, my mistake. I have added mamba to the container here: https://github.com/snakemake/snakemake/commit/eb0c88495b506300fdf7c1afc4c02d6b91c6a582 The next release will fix the issue.

johanneskoester commented 8 months ago

Fixed with Snakemake 8.1 that has just been released.

johanneskoester commented 8 months ago

Apart from that, it would be great to allow selecting a specific Snakemake version via the action arguments. I think this can be achieved in one pass with migrating this into a composite action that simply installs Snakemake and mamba via the micromamba action instead of using a container.