transformations create
Interact with workflow transformations
Synopsis
Create Workflow Transformation
omics alpha workbench transformations create [TRANSFORMATION_SCRIPT]
[--namespace=NAMESPACE]
[--workflow=WORKFLOW_ID]
[--version=VERSION_ID]
[--id=ID]
[--next-transformation=NEXT_TRANSFORMATION_ID]
[--label=LABEL]
Description
This command enables the creation of a new transformation for a specified workflow version. A transformation is a script used to modify data before submitting a workflow to the execution engine. The script can be written in JavaScript. Transformations can be linked together to form a sequence that processes the data before workflow execution.
Examples
Create transformation for a given workflow and version, with a generated ID. The transformation returns the provided context without any modifications:
omics alpha workbench transformations create --workflow my-workflow-id --version v1 "(context) => { return context }"
Create transformation for a given workflow and version, with a specific ID. The transformation returns the provided context without any modifications:
omics alpha workbench transformations create --workflow my-workflow-id --version v1 --id my-transformation "(context) => { return context }"
Create transformation for a given workflow and version, with labels. The transformation returns the provided context without any modifications:
omics alpha workbench transformations create --workflow my-workflow-id --version v1 --label 'foo' --label 'bar' "(context) => { return context }"
Create transformation for a given workflow and version, with a chained transformation. The transformation returns the provided context without any modifications:
omics alpha workbench transformations create --workflow my-workflow-id --version v1 --next-transformation my-transformation "(context) => { return context }"
Create transformation for a given workflow and version, with script loaded from a JavaScript file:
// transformation.js
const transformation = (context) => {
const generateCohortId = () => {
const prefix = 'cohort';
const timestamp = new Date().toISOString();
return `${prefix}_${timestamp}`;
};
if (!context.workflow_params['my_workflow.cohort']?.foo) {
throw new Error('Missing required parameter');
}
return {
workflow_params: {
'my_workflow.cohort': {
cohort_id: context.workflow_params['my_workflow.cohort']?.cohort_id ?? generateCohortId(),
sample_id: context.workflow_params['my_workflow.some_input'].foo
}
}
};
}
omics alpha workbench transformations create --workflow my-workflow-id --version v1 @transformation.js
Positional Arguments
TRANSFORMATION_SCRIPT
TRANSFORMATION_SCRIPT
The transformation script to execute. This positional argument is required. The script can be provided as a string or a path to a JavaScript file (needs to be prefixed with @). The script should be a function that takes a single argument, context, and returns a modified context object. You do not need to return the entire context object, only the parts that you want to modify. Results of transformations are merged into the final context object. The context object is a JSON object that contains the workflow parameters and other metadata.
Flags:
--namespace
=STRING
--namespace
=STRING
An optional flag to define the namespace to connect to. By default, the namespace is extracted from the user's credentials.
--workflow
=STRING
--workflow
=STRING
The ID of the workflow to which the transformation will be added.
--version
=STRING
--version
=STRING
The ID of the workflow version to which the transformation will be added.
--id
=STRING
--id
=STRING
The ID for the workflow transformation. If not provided, the ID will be auto-generated.
--next-transformation
=STRING
--next-transformation
=STRING
The ID of the next transformation in the sequence. If provided, the transformation will be chained to the specified transformation.
--label
=STRING
--label
=STRING
A label to add to the transformation. This flag can be used multiple times to add multiple labels.
Last updated
Was this helpful?