API reference

CWL to OGC API - Records Transpiler-Mate Plugin.

Plugin registration

CWL to OGC API - Records Transpiler-Mate Plugin.

Source code in src/cwl2ogcrecords/plugin.py
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
@transpiler_plugin(
    name="cwl2ogcrecords",
    description="CWL to OGC API - Records Transpiler-Mate Plugin.",
    options_model=CWL2OGCAPIRecordsOptions,
)
def cwl2ogcrecords(context: TranspilerContext, options: CWL2OGCAPIRecordsOptions) -> None:
    """CWL to OGC API - Records Transpiler-Mate Plugin."""
    logger.info("Converting input CWL to OGC API - Records...")

    record: OGCRecord = OGCRecord(
        id=context.process_id if context.process_id else f"urn:uuid:{uuid.uuid4()}",
    )
    record.created = _to_datetime(context.metadata.date_created)
    record.updated = _to_datetime(datetime.now(timezone.utc))
    record.title = context.metadata.name
    record.description = context.metadata.description if context.metadata.description else None
    record.language = __DEFAULT_LANGUAGE__
    record.resource_languages = [__DEFAULT_LANGUAGE__]

    record.license = ": ".join(
        [
            (str(license.identifier) if isinstance(license, CreativeWork) else str(license))
            for license in (
                context.metadata.license
                if isinstance(context.metadata.license, list)
                else [context.metadata.license]
            )
        ]
    )

    record.contacts = _to_contacts(context.metadata)

    _add_application_metadata(context, options, record)
    _add_kw_themes(context.metadata, record)
    _add_help_links(context.metadata, record)
    _add_workflow_extensions(context, options, record)
    _add_scientific_metadata(context.metadata, options, record)
    _add_vcs_metadata(options, record)

    logger.success("Input CWL successfully converted to OGC API - Records!")

    try:
        options.output.parent.mkdir(parents=True, exist_ok=True)
        logger.info(f"Serializing OGC API - Records metadata to {options.output.absolute()}")

        with options.output.open("w") as output_stream:
            json.dump(
                record.to_dict(include_self_link=False),
                output_stream,
                indent=2,
            )

        logger.success(
            f"OGC API - Records metadata successfully serialized to {options.output.absolute()}"
        )
    except Exception as e:
        raise PluginExecutionError(
            f"An error occurred when serializing to {options.output.absolute()}, see nested exception"
        ) from e

Options

Bases: BaseModel

Options accepted by the CWL to OGC API - Records plugin.

Source code in src/cwl2ogcrecords/plugin.py
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
class CWL2OGCAPIRecordsOptions(BaseModel):
    """Options accepted by the CWL to OGC API - Records plugin."""

    model_config = ConfigDict(extra="forbid")

    output: Path = Field(default=Path("ogc-record.json"), description="The output file path")

    application_url: AnyHttpUrl | None = Field(
        default=None, description="HTTP(S) URL to execute the CWL application via JSON"
    )
    repository_url: Annotated[str, AfterValidator(_validate_repository_url)] | None = Field(
        default=None,
        description="Public repository URL or Git remote, optionally identifying a ref",
    )
    manifest_url: AnyHttpUrl | None = Field(
        default=None, description="CodeMeta or dependency manifest URL"
    )
    application_input_url: AnyHttpUrl | None = Field(
        default=None, description="Example input parameters URL"
    )
    version_history_url: AnyHttpUrl | None = Field(
        default=None, description="Release history or changelog URL"
    )
    workflow_citation: NonEmptyText | None = Field(
        default=None, description="Recommended citation for the workflow itself"
    )
    publication_dois: list[DOI] = Field(
        default_factory=list, description="DOIs of papers describing the workflow"
    )

See the plugin reference for option semantics and the features available since 0.2.0.