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

feat: support for post deploy scripts #1325

Merged
merged 18 commits into from Jan 14, 2022
23 changes: 23 additions & 0 deletions snakemake/deployment/conda.py
Expand Up @@ -4,6 +4,7 @@
__license__ = "MIT"

import os
from pathlib import Path
import re
from snakemake.sourcecache import LocalGitFile, LocalSourceFile, infer_source_file
import subprocess
Expand Down Expand Up @@ -365,6 +366,28 @@ def create(self, dryrun=False):
cmd, stderr=subprocess.STDOUT, universal_newlines=True
)

# TODO run post-deploy.sh if present
post_deploy_script = Path(env_file).with_suffix(".post-deploy.sh")
if post_deploy_script.exists():
if ON_WINDOWS:
raise WorkflowError(
"Post deploy script {} provided for conda env {} but unsupported on windows.".format(
post_deploy_script, env_file
)
)
# run the script relative to current workdir
logger.info(
"Running post-deploy script {}...".format(
post_deploy_script.relative_to(os.getcwd())
)
)
shell.check_output(
conda.shellcmd(
env_path, "sh {}".format(post_deploy_script)
),
stderr=subprocess.STDOUT,
)

FelixMoelder marked this conversation as resolved.
Show resolved Hide resolved
# cleanup if requested
if self._cleanup is CondaCleanupMode.tarballs:
logger.info("Cleaning up conda package tarballs.")
Expand Down