eoap_cwlwrap.types

Type utilities and validators used by the workflow wrapper.

Compatibility helpers inspect CWL type names, unions, and array item types. Conversion helpers replace matching types with the EOAP URI type identified by URL_TYPE, preserving union members and array structure.

Stage-in validators require exactly one URI-compatible input and exactly one output compatible with the requested Directory or File type. Stage-out validators require exactly one compatible Directory or File input and exactly one URI-compatible output. Invalid staging contracts raise transpiler_mate.api.PluginFailureError.

Inspect, convert, and validate CWL parameter types for staging.

Directory_or_File = Directory | File module-attribute

A Directory Workflow or a File union type.

URL_SCHEMA = 'https://raw.githubusercontent.com/eoap/schemas/main/string_format.yaml' module-attribute

The URL of the string-format schema

URL_TYPE = f'{URL_SCHEMA}#URI' module-attribute

The fully qualified name URI CWL type

is_nullable(typ)

Detects if the input type can be nullable.

Parameters:
  • typ (Any) –

    Any CWL type.

Returns:
  • bool –

    True if the input type can be nullable, False otherwise.

is_type_assignable_to(actual, expected)

Detects if the actual type can be assignable to the expected type.

Parameters:
  • actual (Any) –

    Any CWL type.

  • expected (Any) –

    Any CWL type.

Returns:
  • bool –

    True if the actual type can be assigned to the expected type, False otherwise.

get_assignable_type(actual, expected)

is_directory_compatible_type(typ)

Detects if the actual type can be assignable to Directory type.

Parameters:
  • typ (Any) –

    Any CWL type.

Returns:
  • bool –

    True if the input type can be assigned to Directory, False otherwise.

is_file_compatible_type(typ)

Detects if the actual type can be assignable to File type.

Parameters:
  • typ (Any) –

    Any CWL type.

Returns:
  • bool –

    True if the input type can be assigned to File, False otherwise.

is_directory_or_file_compatible_type(typ)

Detects if the actual type can be assignable to Directory or File types.

Parameters:
  • typ (Any) –

    Any CWL type.

Returns:
  • bool –

    True if the input type can be assigned to Directory or File, False otherwise.

is_uri_compatible_type(typ)

Detects if the actual type can be assignable to https://raw.githubusercontent.com/eoap/schemas/refs/heads/main/string_format.yaml#URI type.

Parameters:
  • typ (Any) –

    Any CWL type.

Returns:
  • bool –

    True if the input type can be assigned to the EOAP URI type, False otherwise.

is_array_type(typ)

Detects if the actual type can be assignable to array type.

Parameters:
  • typ (Any) –

    Any CWL type.

Returns:
  • bool –

    True if the input type can be assigned to an array type, False otherwise.

replace_type_with_url(source, to_be_replaced)

Replace matching CWL types recursively with the EOAP URI type.

Parameters:
  • source (Any) –

    Any CWL type.

  • to_be_replaced (Any) –

    The CWL type that has to be replaced.

Returns:
  • Any –

    The new type.

replace_directory_with_url(typ)

Deep replaces the Directory type in the source type with the https://raw.githubusercontent.com/eoap/schemas/refs/heads/main/string_format.yaml#URI type.

Parameters:
  • typ (Any) –

    Any CWL type.

Returns:
  • Any –

    The new type.

type_to_string(typ)

Serializes a CWL type to a human-readable string.

Parameters:
  • typ (Any) –

    Any CWL type.

Returns:
  • str –

    The human-readable string representing the input CWL type.

validate_directory_stage_in(directory_stage_in)

Checks if a CWL stage-in document is a URI-compatible input and Directory-compatible output Process.

Parameters:
  • directory_stage_in (Process) –

    Any CWL Process.

Returns:
  • None –

    None.

validate_file_stage_in(file_stage_in)

Checks if a CWL stage-in document is a URI-compatible input and File-compatible output Process.

Parameters:
  • file_stage_in (Process) –

    Any CWL Process.

Returns:
  • None –

    None.

validate_directory_stage_out(directory_stage_out)

Checks if a CWL stage-out document is a Directory-compatible input and URI-compatible output Process.

Parameters:
  • directory_stage_out (Process) –

    Any CWL Process.

Returns:
  • None –

    None.

validate_file_stage_out(file_stage_out)

Checks if a CWL stage-out document is a File-compatible input and URI-compatible output Process.

Parameters:
  • file_stage_out (Process) –

    Any CWL Process.

Returns:
  • None –

    None.