cli.conda_env#

showyourwork.cli.conda_env.run_in_env(command, **kwargs)#

Run a command in the isolated showyourwork conda environment.

This function creates and activates an isolated conda environment and executes command in it, with optional kwargs passed to subprocess.run. The conda environment is specified in showyourwork/workflow/envs/environment.yml and consists primarily of the dependencies needed to execute Snakemake, including mamba. To this environment we add the specific version of showyourwork requested in the article repository’s showyourwork.yml file.

Note that this ensures that the article is built with the version of showyourwork specified by the workflow, and not the version the user currently has installed.

To speed things up on future runs, we cache the environment in the temporary folder ~/.showyourwork/env.

Parameters
  • command (str) – The command to run.

  • kwargs – Keyword arguments to pass to subprocess.run.

Returns

The result of the command.

Return type

subprocess.CompletedProcess

Raises
  • exceptions.CondaNotFoundError – If conda is not found.

  • exceptions.ShowyourworkException – If the cwd is not the top level of a showyourwork project.

  • exceptions.ShowyourworkNotFoundError – If the requested version of showyourwork in the config file cannot be found.