Permalink
Browse files

Allow PLANEMO_CONDA_PREFIX to be set a default for ``--conda_prefix``.

A few other options too that might be useful - along with a framework enhancement for options to make this easy and regular.
  • Loading branch information...
jmchilton committed Aug 31, 2016
1 parent ca19910 commit 24008abe9ed9927e62203bc7b23fad334ad68f75
Showing with 16 additions and 1 deletion.
  1. +11 −1 planemo/config.py
  2. +5 −0 planemo/options.py
@@ -72,6 +72,7 @@ def planemo_option(*args, **kwargs):
"""
option_type = kwargs.get("type", None)
use_global_config = kwargs.pop("use_global_config", False)
use_env_var = kwargs.pop("use_env_var", False)

if "default" in kwargs:
default = kwargs.pop("default")
@@ -93,7 +94,16 @@ def callback(ctx, param, value):
kwargs["callback"] = callback
kwargs["default"] = None

return click.option(*args, **kwargs)
if use_env_var:
name = None
for arg in args:
if arg.startswith("--"):
name = arg[len("--"):]
assert name
kwargs["envvar"] = "PLANEMO_%s" % name.upper()

option = click.option(*args, **kwargs)
return option


def global_config_path(config_path=None):
@@ -49,6 +49,7 @@ def serve_engine_option():
type=click.Choice(["galaxy", "docker_galaxy"]),
default="galaxy",
use_global_config=True,
use_env_var=True,
help=("Select an engine to serve aritfacts such as tools "
"and workflows. Defaults to a local Galaxy, but running Galaxy within "
"a Docker container.")
@@ -102,6 +103,7 @@ def galaxy_email_option():
type=str,
default="planemo@galaxyproject.org",
use_global_config=True,
use_env_var=True,
help="E-mail address to use when launching single-user Galaxy server.",
)

@@ -119,6 +121,7 @@ def galaxy_database_seed_option():
"--galaxy_database_seed",
default=None,
use_global_config=True,
use_env_var=True,
type=click.Path(exists=True, file_okay=True, resolve_path=True),
help="Preseeded Galaxy sqlite database to target.",
)
@@ -403,6 +406,7 @@ def conda_prefix_option():
return planemo_option(
"--conda_prefix",
use_global_config=True,
use_env_var=True,
type=click.Path(file_okay=False, dir_okay=True),
help="Conda prefix to use for conda dependency commands."
)
@@ -430,6 +434,7 @@ def conda_ensure_channels_option():
"--conda_ensure_channels",
type=str,
use_global_config=True,
use_env_var=True,
help=("Ensure conda is configured with specified comma separated "
"list of channels."),
default="r,bioconda,iuc",

0 comments on commit 24008ab

Please sign in to comment.