-
-
Notifications
You must be signed in to change notification settings - Fork 67
write up how to reference a local script #158
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
Comments
Hello @dshepelev15 I recommend one of the following:
class: CommandLineTool
inputs:
my_script:
type: File
inputBinding:
position: 0
# other inputs go here
baseCommand: sh
outputs: [] |
No, I can't use scripts because I run programmatically from some folder and that cwl script don't find related scripts. |
In CWL we have to be explicit about everything, so either the script needs to be
or
or
|
I'm asking for the way for setting up execution shell script without absolute path by them in cwl script |
The |
For instance, I have the following scripts:
json file for input parameters:
And also I have a python script which executes that:
And then I get the following logs after running
|
@dshepelev15 A couple comments Paths to input files must always be of so here is a revised {
"message": "Something",
"input_file": {
"class": "File",
"path": "README.md",
} We'll also need to add #!/bin/bash
echo $1: `cat $2 | wc -l` Since we will be dynamically adding the directory where our CWL description is located to the #!/usr/bin/env cwl-runner
cwlVersion: v1.0
class: CommandLineTool
baseCommand: line_counter.sh
stdout: result.txt
inputs:
message:
type: string
inputBinding:
position: 1
input_file:
type: File
label: file
inputBinding:
position: 2
outputs:
result:
type: stdout Finally, here is the updated import os
from cwltool.main import main
def run_script():
cwl_script_path = '/home/michael/cwltool/runner.cwl'
inputs_path = '/home/michael/cwltool/inputs.json'
original_environ = os.environ.copy()
os.environ["PATH"] = "{}:{}".format(
os.path.dirname(cwl_script_path),
os.environ["PATH"])
res = main([
cwl_script_path,
inputs_path
]
)
os.environ = original_environ # not needed here, but better to be safe
if __name__ == '__main__':
run_script() Here is what I get when I run this: $ chmod a+x line_counter.sh
$ python execution_script.py
INFO execution_script.py 1.0.20190808141559
INFO Resolved '/home/michael/cwltool/runner.cwl' to 'file:///home/michael/cwltool/runner.cwl'
INFO [job runner.cwl] /tmp/2tfzlx_n$ line_counter.sh \
Something \
/tmp/tmpesjv4vno/stg231b1e17-2004-4191-bd65-4f6e8cd8e571/README.rst > /tmp/2tfzlx_n/result.txt
INFO [job runner.cwl] completed success
{
"result": {
"location": "file:///home/michael/cwltool/result.txt",
"basename": "result.txt",
"class": "File",
"checksum": "sha1$ba78fc87000f5fc33b412762514d64cc81c56a5a",
"size": 15,
"path": "/home/michael/cwltool/result.txt"
}
}
INFO Final process status is success
$ cat result.txt
Something: 725 |
Okay, thank you so much, it works! For instance, I have multiple processes and they change my PATH variable and they execute 2 cwl scripts with same bash scripts" name PATH variable will have their 2 directories. And so, the first cwl script may execute second bash script and vice versa. Is it right? If so, how can I solve that problem? |
I found an explanation about that - |
Can you explain to me what do I need to write in input json file for input with array type? For instance, an array of files. |
@dshepelev15 Glad to hear that it worked! For your last question, does https://www.commonwl.org/user_guide/09-array-inputs/index.html help? |
can I reference a python file the same way in tool description and specify this in bashcommand: ["python","filename.py"] |
Can this be done to run a python script: !/usr/bin/env cwl-runner cwlVersion: v1.0 |
for instance, I am defining a CWL tool to refer to a python script to add two numbers given as inputs as follows: cwlVersion: v1.0 inputs: stdout: cwl.output.json outputs: and my python script is as follows: @click.command() if name == 'main': |
Can someone explain to me how to use
InitialWorkDir
requirements without any input parameters.For instance, I need to put my shell scripts near with
cwl script
and run them from thatcwl script
. Is there some way don't use absolute path to scripts? I tried to use EnvVariable like that:But it is not working.
Then I found to use InitialWorkDir requirement. I wrote that via that I can put my scripts inside the cwl script and use relative path to shell scripts, but i didn't find any examples how use that without input_parameters.
Anybody ideas?
The text was updated successfully, but these errors were encountered: