Skip to content

Commit 3ef246e

Browse files
committed
allow env var forwarding
1 parent 1e78aeb commit 3ef246e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/goldfinch/utils/click2cwl_cli.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def convert(
5151
return super().convert(value, param, ctx)
5252

5353

54-
class MetadataParam(click.types.StringParamType):
54+
class FieldValueParam(click.types.StringParamType):
5555
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> str:
5656
args = value.split("=", 1)
5757
if len(args) != 2 or not args[0].strip() or not args[1].strip():
5858
raise click.BadParameter(
59-
"Metadata must be specified as '<field>=<value>'",
59+
"Option must be specified as '<field>=<value>'",
6060
param=param,
6161
ctx=ctx,
6262
)
@@ -146,13 +146,22 @@ def resolve_cli_command(
146146
"General metadata for the CWL document defined as '<field>=<value>' for each entry. "
147147
f"Can be repeated for multiple metadata field properties {CWL_METADATA_FIELDS}."
148148
),
149-
type=MetadataParam(),
149+
type=FieldValueParam(),
150150
multiple=True,
151151
)
152152
@click.option(
153153
"--docker",
154154
help="Specific docker image to use for the CWL command line tool.",
155155
)
156+
@click.option(
157+
"-e", "--env",
158+
help=(
159+
"Specific environment variables and values required by the CWL command line tool. "
160+
"Can be repeated for multiple '<variable>=<value>' combinations."
161+
),
162+
type=FieldValueParam(),
163+
multiple=True,
164+
)
156165
@click.option(
157166
"--coresMin", "coresMin",
158167
help="Minimum CPU cores resource requirement the CWL command line tool.",
@@ -249,7 +258,7 @@ def main(ctx: click.Context, **kwargs: str) -> None:
249258
output_cwl = kwargs["output"]
250259

251260
# add additional parameters to the CWL context
252-
for req in ["docker", "wall-time", "coresMin", "coresMax", "ramMin", "ramMax", "metadata", "cwl-version"]:
261+
for req in ["docker", "env", "wall-time", "coresMin", "coresMax", "ramMin", "ramMax", "metadata", "cwl-version"]:
253262
val = kwargs.get(req) or kwargs.get(req.replace("-", "_"))
254263
if val:
255264
val = [val] if isinstance(val, str) else val

0 commit comments

Comments
 (0)