You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrapped a tool in a bash script mytool.bash . If I just set the PATH to add this tool, it is not found by cwl-runner
$ export PATH=${PWD}:${PATH}
$ ls -la mytool.bash
-rwxrwxr-x 1 lindenb lindenb 1079 Aug 3 16:08 mytoolbash
$ which graph2cwl.bash
/home/lindenb/tmp/mytool.bash
$ cwl-runner test.cwl
cwl-runner 1.0.20150728161219
Must provide input in the form of a json file or command line parameters.
[job 166667916] exec mytool.bash 1
'mytool' not found
[job 166667916] completed permanentFail
setting a full path in the tool section is OK. However, gcc is called in mytool.bash, and then I get:
gcc: error trying to exec 'cc1': execvp: No such file or directory
Exception while running job
I don't know why mytool.bash is being executed as mytool. Can you post your CWL file that demonstrates the bug?
The 2nd behavior is expected according to the spec:
When executing the tool, the child process must not inherit environment variables from the parent process. The tool must execute in a new, empty environment, containing only environment variables defined by EnvVarRequirement, the default environment of the Docker container specified in DockerRequirement (if applicable), and TMPDIR.
The rationale is that you want to declare the runtime environment as explicitly as possible. So the best approach would be to add a job input parameter with the desired value for $CC and set it with EnvVarRequirement:
inputs:
- id: "#cc"type: Filelabel: Path to the C compiler to use.requirements:
- class: EnvVarRequirementenvDef:
- envName: CCenvValue:
engine: "cwl:JsonPointer"script: job/cc/path
I'm running into a similar issue, trying to provide the PATH for tools when not using Docker.
When I build tool-specific containers with Docker, I make sure the baseCommand is available in the container's PATH, and leave the value of baseCommand to a single file name. This seems to be the typical use case, and the one in the examples.
But, If I want to run this without Docker (e.g. --no-container on a host where Docker isn't available), I need to declare an EnvVarRequirement and explicitly the PATH (as above). The problem is now that I can't use the same workflow or tool definition with and without Docker (without some really ugly workarounds). I prefer to leave the DockerRequirement to a hint, specifically for this reason.
What about something like a LocalEnvVarRequirement? This could set env variables (such as PATH) only when the tool is not running in a container. I do like the explicit nature of providing PATH and other env variables, but Docker certainly bucks the trend.
You're right that setting PATH causes a conflict between Docker and the local path. Perhaps what is really needed is a concept of runtime configuration sets? Then the platform would select a given configuration set for the runtime environment.
#37 was our original thinking on this, but I suspect it needs to be more explicit by actually listing out runtime environments that the requirements apply to. One thing that concerns me is how to assign names to runtimes, either we have to enumerate all possible runtime environments (eg debian, red hat, docker, python, java...) or leave it up to tool authors (which will result in inconsistent naming, but be more flexible). Then one of the inputs to the tool would be to select the desired runtime.
The issue that keeps coming up is usability related to the environment (specifically PATH here and in #85), so as a user I'm selfishly interested in that aspect. Electing a configuration set based on the runtime sounds like it would be flexible enough, but adds complexity and still doesn't explicitly govern environment in a Docker container (not that you could or would want to).
I think what I'm stuck on is that Docker images provide a default environment that lets me write shorter CWL scripts, while the non-container execution has no default environment nor a way to provide one at runtime.
As a test I added the --preserve-environment switch to the reference implementation. 447c2fa. It saved me a lot of noise in my tool and workflow definitions trying to defer to a default PATH (for docker) with the flexibility of injecting one. I use it with --no-container. And leave it off when I run my workflow with Docker, so the containers still use their default PATHs. This let me use the same workflow on OS X + Docker as a Linux SLURM cluster (without Docker).
But to provide more explicit environment, maybe a --default_environment [k1=v1,k2=v2 | environment.json] option?. I'm not sure how this would be defined in the spec, but it would apply to runtimes without a default environment (so not docker). Conflicting values in EnvVarRequirements could override the defaults or raise a warning/error.
@dleehr yes, you've put your finger on it. So far we've focused on Docker as the solution for providing the runtime environment, so other mechanisms for defining the runtime environment still need to be designed. I agree from a short-term usability perspective, it's helpful to have an option to preserve the local runtime environment. However, for the long term goal of CWL is to support portability, what we really need are designs for how to describe and specify the supported runtime environments of a tool.
That's going to take awhile, so in the mean time, I'm open to merging some version of --preserve-environment if you want to make a pull request. See my comment on 447c2fa.
Activity
tetron commentedon Aug 8, 2015
There's two different things going on here.
I don't know why
mytool.bashis being executed asmytool. Can you post your CWL file that demonstrates the bug?The 2nd behavior is expected according to the spec:
The rationale is that you want to declare the runtime environment as explicitly as possible. So the best approach would be to add a job input parameter with the desired value for $CC and set it with
EnvVarRequirement:In your job:
{ "cc": { "class": "File", "path": "/usr/bin/gcc" } }Of course, if setting environment variables for each program is not practical, you can also set $PATH using
EnvVarRequirementas well.dleehr commentedon Sep 10, 2015
I'm running into a similar issue, trying to provide the PATH for tools when not using Docker.
When I build tool-specific containers with Docker, I make sure the
baseCommandis available in the container's PATH, and leave the value ofbaseCommandto a single file name. This seems to be the typical use case, and the one in the examples.But, If I want to run this without Docker (e.g.
--no-containeron a host where Docker isn't available), I need to declare an EnvVarRequirement and explicitly the PATH (as above). The problem is now that I can't use the same workflow or tool definition with and without Docker (without some really ugly workarounds). I prefer to leave the DockerRequirement to a hint, specifically for this reason.What about something like a
LocalEnvVarRequirement? This could set env variables (such as PATH) only when the tool is not running in a container. I do like the explicit nature of providing PATH and other env variables, but Docker certainly bucks the trend.dleehr commentedon Sep 10, 2015
I see this was referenced in #85, and like @ntijanic's proposal of adding a
--preserve-environmentswitch.tetron commentedon Sep 10, 2015
You're right that setting PATH causes a conflict between Docker and the local path. Perhaps what is really needed is a concept of runtime configuration sets? Then the platform would select a given configuration set for the runtime environment.
tetron commentedon Sep 10, 2015
#37 was our original thinking on this, but I suspect it needs to be more explicit by actually listing out runtime environments that the requirements apply to. One thing that concerns me is how to assign names to runtimes, either we have to enumerate all possible runtime environments (eg debian, red hat, docker, python, java...) or leave it up to tool authors (which will result in inconsistent naming, but be more flexible). Then one of the inputs to the tool would be to select the desired runtime.
What do you think?
dleehr commentedon Sep 11, 2015
The issue that keeps coming up is usability related to the environment (specifically
PATHhere and in #85), so as a user I'm selfishly interested in that aspect. Electing a configuration set based on the runtime sounds like it would be flexible enough, but adds complexity and still doesn't explicitly govern environment in a Docker container (not that you could or would want to).I think what I'm stuck on is that Docker images provide a default environment that lets me write shorter CWL scripts, while the non-container execution has no default environment nor a way to provide one at runtime.
As a test I added the
--preserve-environmentswitch to the reference implementation. 447c2fa. It saved me a lot of noise in my tool and workflow definitions trying to defer to a default PATH (for docker) with the flexibility of injecting one. I use it with--no-container. And leave it off when I run my workflow with Docker, so the containers still use their default PATHs. This let me use the same workflow on OS X + Docker as a Linux SLURM cluster (without Docker).But to provide more explicit environment, maybe a
--default_environment [k1=v1,k2=v2 | environment.json]option?. I'm not sure how this would be defined in the spec, but it would apply to runtimes without a default environment (so not docker). Conflicting values inEnvVarRequirements could override the defaults or raise a warning/error.mr-c commentedon Sep 11, 2015
Perhaps
--no-containershould imply--preserve-environment?tetron commentedon Sep 13, 2015
@dleehr yes, you've put your finger on it. So far we've focused on Docker as the solution for providing the runtime environment, so other mechanisms for defining the runtime environment still need to be designed. I agree from a short-term usability perspective, it's helpful to have an option to preserve the local runtime environment. However, for the long term goal of CWL is to support portability, what we really need are designs for how to describe and specify the supported runtime environments of a tool.
That's going to take awhile, so in the mean time, I'm open to merging some version of --preserve-environment if you want to make a pull request. See my comment on 447c2fa.
dleehr commentedon Sep 14, 2015
OK. I think that's a good solution for now. Will follow up with a PR.