Accessing Parameters (arguments)
Any parameters that are defined for your workflow either as part of the workflow definition or by the user at the time of analysis kickoff are injected into the execution environment as environment variables.
Parameters for Nextflow workflows
If your workflow is configured as a Nextflow workflow, we also inject a parameters file containing the complete set of arguments for that instance of the workflow that you can pass to Nextflow via the
--params-file
flag in the workflow script.
To access the argument in your script, we will prepend ARGS_
to the name, and we will capitalize the name. For instance, if you named your argument your_argument_1
, you can access this in the script as $ARGS_YOUR_ARGUMENT_1
. Any such parameters will be visible on the workflow creation page to the right of your script, and you will see a clipboard icon beside the argument name, allowing you to copy the name for use throughout your script.
Accessing Arguments at Workflow Launch
Setting Required Arguments
Any parameters that are marked as required must be passed when launching the workflow. If required arguments have default values, these default values will automatically be populated in the web app, but they are not assumed when launching via the API, and must be provided, even if default values are being used.
To override the default parameters for a workflow run, or to set values for parameters that do not have defaults, you can:
- Pass the values in the confirmation screen when launching via the web app
- If launching the workflow via API, you can provide the arguments directly in the command, or store them in a .json file. For instance, if you saved the below as
my_workflow_arguments.json
:
{
"sample":"the UUID of the sample you want to run the analysis on",
"job_args": {
"your_argument_1": "arg_1_value",
"your_argument_2": "arg_2_value",
}
}
- You can run the workflow, with the above arguments on the sample provided in the JSON, with the below command
curl -u $ONE_CODEX_API_KEY: -H "Content-Type: application/json" -d @my_workflow_arguments.json -X POST https://app.onecodex.com/api/v1/jobs/[workflow_UUID]/run
- where
$ONE_CODEX_API_KEY
is your API key, workflow_UUID
is the unique identifier for the workflow that you want to run on the sample
- Alternatively, you can pass the arguments directly to the cURL command, such as:
curl -u $ONE_CODEX_API_KEY: -H "Content-Type: application/json" -d {"sample":"[sample_UUID]", "job_args":{"your_argument_1": "arg_1_value","your_argument_2": "arg_2_value",}} -X POST https://app.onecodex.com/api/v1/jobs/[workflow_UUID]/run
Updated 24 days ago
Need to make some files available to multiple workflows? Use our Assets feature!