I/O Schemas
The WES components understand the GA4GH IO Schema Profile (opens in a new tab) (docs (opens in a new tab)): JSON Schema 2020-12 with x-ga4gh-* keywords that describe the inputs and outputs of a workflow, for example to render input forms and to show outputs.
Profile version
The package supports version 0.3.0 of the profile, pinned at commit 2c3dc49 (opens in a new tab). Its meta-schema and vocabularies are bundled with the package; scripts/sync-io-schema.mjs in the package copies them, the conformance suite, the test vectors and the example schemas from a checkout of the profile's repository at the pinned commit.
Checks
Before ecc-client-ga4gh-wes-io-form uses an IO schema, it checks it offline, as the profile asks:
$schemamust name the profile's meta-schema.- The schema must pass the meta-schema, with formats asserted.
- Every
$refininputs,outputsand the top-level$defsmust resolve within the schema. Nothing is fetched over the network: a schema that refers to a remote schema is rejected. Embedded resources may not reuse the$idof a schema in use (such as the profile's meta-schema).
Input values are then validated against the schema's inputs with the semantics of JSON Schema 2020-12. Failures are reported with the JSON Pointer of the value, the keyword that failed and a message.
The checks pass the profile's conformance suite (every valid case is accepted, every invalid one rejected) and accept the profile's example schemas.
Validator and Content Security Policy
The checks use @hyperjump/json-schema (opens in a new tab), which doesn't compile schemas into code, so pages that embed the components need no 'unsafe-eval' in their Content Security Policy.
hyperjump's settings are global to the page: the package turns off its retrieval of schemas over HTTP(S) and turns on format assertion. Pages that use hyperjump themselves get these settings, too.
The validator sits behind a small interface (IoSchemaValidator), so that another library could replace it without changing the components. Apps can use the checks themselves and replace the validator through @elixir-cloud/wes/utils:
import { checkIoSchema, setIoSchemaValidator } from '@elixir-cloud/wes/utils';
const result = await checkIoSchema(schema);
if (result.valid) {
const { valid, errors } = result.validateInputs(values);
}Checks run one after the other, because hyperjump's registry of schemas is global.
File references
JSON Schema can't check the values of file references (x-ga4gh-file), so the components check them by the profile's rules (see Values (opens in a new tab)) before a value is used:
- A URI must have a scheme on the deployment's allow-list (
allowedSchemesof the components, defaultdrs https), narrowed by the file reference's ownschemes, which never extend it.javascript,data,fileand other schemes that run code or refer to local data are always refused. - Inputs may also be relative paths (files attached to the run request), but only where the file reference has no
schemes: no..segments (also not percent-encoded), no leading~,//or\\, and no absolute paths. - Control characters and leading or trailing whitespace are refused, as they could hide a scheme.
Outputs must be absolute URIs. The checks pass the profile's test vectors for file reference values (tests/vectors/file-values).
Run requests
@elixir-cloud/wes/utils builds WES run requests from input values by the profile's engine bindings (opens in a new tab), which ecc-client-ga4gh-wes-run-create uses in schema mode:
import {
buildRunRequest,
findPrimaryDescriptorPath,
trsDescriptorUrl,
} from '@elixir-cloud/wes/utils';
const request = await buildRunRequest(schema, values, {
workflowUrl: trsDescriptorUrl(trsUrl, toolId, versionId, 'NFL', findPrimaryDescriptorPath(files)),
binding: { descriptorTypeVersion: 'DSL2' }, // only if the schema has none
});toWorkflowParams()checks the schema, validates the values againstinputs, checks every file reference value, and translates the values for the descriptor type: unqualified names forNFLandSMK, names qualified with the entry point forWDL,FileandDirectoryobjects for CWL file values. Inputs are renamed byx-ga4gh-parameter; defaults of the schema are never inserted. Values that Nextflow or the CWL loader would change (${, keys with-for Nextflow;Fileobjects, keys with$or:for CWL) are refused. Errors areTranslationErrors with the JSON Pointer of the value.buildRunRequest()addsworkflow_type,workflow_type_versionandworkflow_url(for CWL, with the entry point as its fragment). Tags and engine parameters are left to the caller and to engine profiles.trsDescriptorUrl(),findPrimaryDescriptorPath()andfindSchemaFile()give the workflow URL of a TRS tool version and find its IO schema among its files.unsupportedBy()says whether a WES service runs a binding's type and version, by itsservice-info.
The translation passes the profile's test vectors (tests/vectors/wes-params, workflow-urls and trs-files). It needs a validator that can check subschemas (validateAt of the check result), and refuses schemas that it can't follow: references that don't resolve within the document, references and branches inside embedded $id resources, and $dynamicRef. GALAXY workflows have no binding in profile 0.3.0.
Run outputs
normaliseOutputs() from @elixir-cloud/wes/utils builds the normalised outputs object (opens in a new tab) of a WES run from what the server reports, keyed by the outputs of an IO schema, which ecc-client-ga4gh-wes-run shows:
import { normaliseOutputs } from '@elixir-cloud/wes/utils';
const result = await normaliseOutputs(schema, runLog, {
outputDir: 's3://bucket/runs/7', // where the server keeps the run's files
localDir: '/data/runs/7/out', // the same directory as the engine sees it
});
// result.conformance: 'conformant' | 'non-conformant' | 'partial'
// result.outputs: { report: 's3://bucket/runs/7/report/report.html', ... }- Outputs are found by name (the property name, or
nameofx-ga4gh-parameter, qualified with the entry point for WDL), else byx-ga4gh-output-globamong the files that the server lists: Sapporo's list of files, WESkit'sfilesystem, orfilesof the options. CWLFileandDirectoryobjects give theirlocation; paths underlocalDir, and relative paths, become URIs underoutputDir(each segment percent-encoded); other paths are reported asunconverted. - Listed entries are checked before globs are matched: absolute paths,
.,..and empty segments, backslashes, control characters, a colon in the first segment, URIs outsideoutputDir, with a query or fragment, or with an encoded/are skipped and reported (skippedFiles, without user information, query and fragment, which may carry credentials). WESkit's presigned URLs (S3) are dropped. - The object is validated against
outputsfor a run that completed (non-conformantoutputs are kept as they are, witherrors); for a run that ended otherwise, output by output, and invalid outputs are left out (removed). File references must be absolute URIs with one of theirschemes. - Outputs that the schema doesn't declare (
undeclared), files that no output found (unmatchedFiles) and globs of one file with several matches (ambiguous) are reported, never dropped silently. - A run that hasn't ended, a run log of an unsupported shape and inconsistent options raise a
NormalisationError(withschemaErrorsfor a schema that doesn't conform to the profile).
The normaliser never fetches anything, and it doesn't check output URIs against the deployment's allow-list: ecc-client-ga4gh-wes-run-output does that before it shows or fetches a file. It passes the profile's test vectors (tests/vectors/wes-outputs) and needs a validator that validates outputs (validateOutputs of the check result). Unlike the reference implementation, it checks the schemes of file references only in the shapes that values are converted by (files, lists, records, files keyed by name, a single branch besides null, allOf), not inside other unions. It doesn't follow references into embedded $id resources (the value is then kept as reported, for validation to report), and refuses values nested more than 64 levels deep (unconverted).
Descriptions
Titles, descriptions and enum values of IO schemas are always shown as text, never as markup.
Descriptions with "x-ga4gh-description-format": "markdown" are shown as plain text, which the profile allows. The package also has a renderer for the profile's Markdown subset (raw HTML shown as escaped text, images as their alt text, links only with a scheme from allowedSchemes, which open in a new window; of GFM only tables, strikethrough and autolinks), built on markdown-it (opens in a new tab). It is switched off until the maintainers decide whether the components render Markdown; an app can switch it on for all components with setDescriptionFormat('markdown') from @elixir-cloud/wes/utils. markdown-it is part of the package's bundle either way.
