# CWL

ICA supports running pipelines defined using [Common Workflow Language (CWL)](https://www.commonwl.org/).

## Compute Type

To specify a compute type for a CWL CommandLineTool, either define the **ram and number of cores** **or** use the **resource type and size**. The ICA Compute Type will automatically be determined based on [CWL ResourceRequirement](https://www.commonwl.org/v1.0/CommandLineTool.html#ResourceRequirement) coresMin/coresMax (CPU) and ramMin/ramMax (Memory) values using a "best fit" strategy to meet the minimum specified requirements (See the [Compute Types](/connected-analytics/project/p-flow/f-pipelines.md#compute-types) table to see to what the resources are mapped).

For example, take the following `ResourceRequirements`:

```yaml
requirements:
    ResourceRequirement:
      ramMin: 10240
      coresMin: 6
```

This will result in a best fit of `standard-large` ICA Compute Type request for the task.

{% hint style="info" %}
If the specified requirements can not be met by any of the presets, the task will be rejected and failed.
{% endhint %}

See the example below to use the `ResourceRequirement` in the cwl workflow with the Predefined [Compute Types](/connected-analytics/project/p-flow/f-pipelines.md#compute-types)

```yaml
requirements:
    ResourceRequirement:
        https://platform.illumina.com/rdf/ica/resources:type: fpga2
        https://platform.illumina.com/rdf/ica/resources:size: medium 
        https://platform.illumina.com/rdf/ica/resources:tier: standard
```

{% hint style="info" %}

* FPGA requirements can not be set by means of CWL ResourceRequirements.
* The Machine Profile Resource in the graphical editor will override whatever is set for requirements in the ResourceRequirement.
  {% endhint %}

### Standard vs Economy

For each compute type, you can choose between the

* Standard - [**AWS on-demand**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-on-demand-instances.html) (Default) or
* Economy - [**AWS spot instance**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html) tiers.

You can set economy mode with the "tier" parameter

```yaml
requirements:
    ResourceRequirement:
        https://platform.illumina.com/rdf/ica/resources:type: himem
        https://platform.illumina.com/rdf/ica/resources:size: small 
        https://platform.illumina.com/rdf/ica/resources:tier: economy
```

## Considerations

> If no Docker image is specified, Ubuntu will be used as default. Both : and / can be used as separator.

## CWL Overrides

ICA supports overriding workflow requirements at load time using Command Line Interface (CLI) with JSON input. Please refer to [CWL documentation](https://github.com/common-workflow-language/cwltool/tree/3.0.20201203173111#overriding-workflow-requirements-at-load-time) for more details on the CWL overrides feature.

In ICA you can provide the "override" recipes as a part of the input JSON. The following example uses CWL overrides to change the environment variable requirement at load time.

```bash
icav2 projectpipelines start cwl cli-tutorial --data-id fil.a725a68301ee4e6ad28908da12510c25 --input-json '{
  "ipFQ": {
    "class": "File",
    "path": "test.fastq"
  },
  "cwltool:overrides": {
  "tool-fqTOfa.cwl": {
    "requirements": {
      "EnvVarRequirement": {
        "envDef": {
          "MESSAGE": "override_value"
          }
        }                                       
       }
      }
    }
}' --type-input JSON --user-reference overrides-example
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.connected.illumina.com/connected-analytics/project/p-flow/f-pipelines/pi-cwl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
