diff --git a/gxformat2/normalized/_conversion.py b/gxformat2/normalized/_conversion.py index 8d796a21..a72f01e4 100644 --- a/gxformat2/normalized/_conversion.py +++ b/gxformat2/normalized/_conversion.py @@ -58,9 +58,9 @@ WorkflowStepOutput, WorkflowStepType, ) +from ..schema.native import CreatorOrganization as NativeCreatorOrganization +from ..schema.native import CreatorPerson as NativeCreatorPerson from ..schema.native import ( - NativeCreatorOrganization, - NativeCreatorPerson, NativeGalaxyWorkflow, NativeInputConnection, NativePostJobAction, diff --git a/gxformat2/normalized/_native.py b/gxformat2/normalized/_native.py index 104e7072..0cf61e01 100644 --- a/gxformat2/normalized/_native.py +++ b/gxformat2/normalized/_native.py @@ -19,8 +19,8 @@ from gxformat2.schema.native import ( _discriminate_comments, _discriminate_creator, - NativeCreatorOrganization, - NativeCreatorPerson, + CreatorOrganization, + CreatorPerson, NativeFrameComment, NativeFreehandComment, NativeGalaxyWorkflow, @@ -53,8 +53,8 @@ NativeCreator: TypeAlias = Annotated[ Union[ - Annotated[NativeCreatorPerson, Tag("NativeCreatorPerson")], - Annotated[NativeCreatorOrganization, Tag("NativeCreatorOrganization")], + Annotated[CreatorPerson, Tag("CreatorPerson")], + Annotated[CreatorOrganization, Tag("CreatorOrganization")], ], Discriminator(_discriminate_creator), ] diff --git a/gxformat2/schema/gxformat2.py b/gxformat2/schema/gxformat2.py index 2ad0e57c..925ad04e 100644 --- a/gxformat2/schema/gxformat2.py +++ b/gxformat2/schema/gxformat2.py @@ -186,6 +186,43 @@ class ToolShedRepository(BaseModel): owner: str = Field(description="The owner of the tool shed repository this tool can be found in.") tool_shed: str = Field(description="The URI of the tool shed containing the repository this tool can be found in - typically this should be toolshed.g2.bx.psu.edu.") +class BaseCreator(BaseModel): + """Base fields shared by all creator types, corresponding to schema.org +Thing properties common to both Person and Organization.""" + + model_config = ConfigDict(populate_by_name=True, extra="allow") + + name: None | str = Field(default=None, description="Full name of the person or organization.") + identifier: None | str = Field(default=None, description="Persistent identifier, typically an ORCID URL (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID.") + url: None | str = Field(default=None, description="Website or profile URL.") + email: None | str = Field(default=None, description="Email address. May include a ``mailto:`` prefix.") + image: None | str = Field(default=None, description="URL to an image or avatar.") + address: None | str = Field(default=None, description="Physical or mailing address.") + alternateName: None | str = Field(default=None, description="An alternate name or alias.") + telephone: None | str = Field(default=None, description="Telephone number.") + faxNumber: None | str = Field(default=None, description="Fax number.") + +class CreatorPerson(BaseCreator): + """A person who created or contributed to the workflow. +Corresponds to a `schema.org Person `_.""" + + model_config = ConfigDict(populate_by_name=True, extra="allow") + + class_: Literal["Person"] = Field(default="Person", alias="class", description="Creator type discriminator (``Person``).") + givenName: None | str = Field(default=None, description="Given (first) name.") + familyName: None | str = Field(default=None, description="Family (last) name.") + honorificPrefix: None | str = Field(default=None, description="Honorific prefix (e.g. ``Dr``, ``Prof``).") + honorificSuffix: None | str = Field(default=None, description="Honorific suffix (e.g. ``M.D.``, ``PhD``).") + jobTitle: None | str = Field(default=None, description="Job title or role.") + +class CreatorOrganization(BaseCreator): + """An organization that created or contributed to the workflow. +Corresponds to a `schema.org Organization `_.""" + + model_config = ConfigDict(populate_by_name=True, extra="allow") + + class_: Literal["Organization"] = Field(default="Organization", alias="class", description="Creator type discriminator (``Organization``).") + class WorkflowInputParameter(InputParameter, HasStepPosition): model_config = ConfigDict(populate_by_name=True, extra="allow") @@ -327,43 +364,6 @@ class FreehandComment(BaseComment): thickness: None | float | int = Field(default=None, description="Line thickness.") line: list[list[float]] | None = Field(default=None, description="Array of ``[x, y]`` coordinate pairs defining the freehand line path.") -class BaseCreator(BaseModel): - """Base fields shared by all creator types, corresponding to schema.org -Thing properties common to both Person and Organization.""" - - model_config = ConfigDict(populate_by_name=True, extra="allow") - - name: None | str = Field(default=None, description="Full name of the person or organization.") - identifier: None | str = Field(default=None, description="Persistent identifier, typically an ORCID URL (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID.") - url: None | str = Field(default=None, description="Website or profile URL.") - email: None | str = Field(default=None, description="Email address. May include a ``mailto:`` prefix.") - image: None | str = Field(default=None, description="URL to an image or avatar.") - address: None | str = Field(default=None, description="Physical or mailing address.") - alternateName: None | str = Field(default=None, description="An alternate name or alias.") - telephone: None | str = Field(default=None, description="Telephone number.") - faxNumber: None | str = Field(default=None, description="Fax number.") - -class CreatorPerson(BaseCreator): - """A person who created or contributed to the workflow. -Corresponds to a `schema.org Person `_.""" - - model_config = ConfigDict(populate_by_name=True, extra="allow") - - class_: Literal["Person"] = Field(default="Person", alias="class", description="Creator type discriminator (``Person``).") - givenName: None | str = Field(default=None, description="Given (first) name.") - familyName: None | str = Field(default=None, description="Family (last) name.") - honorificPrefix: None | str = Field(default=None, description="Honorific prefix (e.g. ``Dr``, ``Prof``).") - honorificSuffix: None | str = Field(default=None, description="Honorific suffix (e.g. ``M.D.``, ``PhD``).") - jobTitle: None | str = Field(default=None, description="Job title or role.") - -class CreatorOrganization(BaseCreator): - """An organization that created or contributed to the workflow. -Corresponds to a `schema.org Organization `_.""" - - model_config = ConfigDict(populate_by_name=True, extra="allow") - - class_: Literal["Organization"] = Field(default="Organization", alias="class", description="Creator type discriminator (``Organization``).") - class GalaxyWorkflow(Process, HasUUID): """A Galaxy workflow description. This record corresponds to the description of a workflow that should be executable on a Galaxy server that includes the contained tool definitions. @@ -410,6 +410,9 @@ class GalaxyWorkflow(Process, HasUUID): StepPosition.model_rebuild() ReferencesTool.model_rebuild() ToolShedRepository.model_rebuild() +BaseCreator.model_rebuild() +CreatorPerson.model_rebuild() +CreatorOrganization.model_rebuild() WorkflowInputParameter.model_rebuild() WorkflowOutputParameter.model_rebuild() WorkflowStep.model_rebuild() @@ -422,9 +425,6 @@ class GalaxyWorkflow(Process, HasUUID): MarkdownComment.model_rebuild() FrameComment.model_rebuild() FreehandComment.model_rebuild() -BaseCreator.model_rebuild() -CreatorPerson.model_rebuild() -CreatorOrganization.model_rebuild() GalaxyWorkflow.model_rebuild() diff --git a/gxformat2/schema/gxformat2_strict.py b/gxformat2/schema/gxformat2_strict.py index ab3c0fa9..429ebd64 100644 --- a/gxformat2/schema/gxformat2_strict.py +++ b/gxformat2/schema/gxformat2_strict.py @@ -186,6 +186,43 @@ class ToolShedRepository(BaseModel): owner: str = Field(description="The owner of the tool shed repository this tool can be found in.") tool_shed: str = Field(description="The URI of the tool shed containing the repository this tool can be found in - typically this should be toolshed.g2.bx.psu.edu.") +class BaseCreator(BaseModel): + """Base fields shared by all creator types, corresponding to schema.org +Thing properties common to both Person and Organization.""" + + model_config = ConfigDict(populate_by_name=True, extra="forbid") + + name: None | str = Field(default=None, description="Full name of the person or organization.") + identifier: None | str = Field(default=None, description="Persistent identifier, typically an ORCID URL (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID.") + url: None | str = Field(default=None, description="Website or profile URL.") + email: None | str = Field(default=None, description="Email address. May include a ``mailto:`` prefix.") + image: None | str = Field(default=None, description="URL to an image or avatar.") + address: None | str = Field(default=None, description="Physical or mailing address.") + alternateName: None | str = Field(default=None, description="An alternate name or alias.") + telephone: None | str = Field(default=None, description="Telephone number.") + faxNumber: None | str = Field(default=None, description="Fax number.") + +class CreatorPerson(BaseCreator): + """A person who created or contributed to the workflow. +Corresponds to a `schema.org Person `_.""" + + model_config = ConfigDict(populate_by_name=True, extra="forbid") + + class_: Literal["Person"] = Field(default="Person", alias="class", description="Creator type discriminator (``Person``).") + givenName: None | str = Field(default=None, description="Given (first) name.") + familyName: None | str = Field(default=None, description="Family (last) name.") + honorificPrefix: None | str = Field(default=None, description="Honorific prefix (e.g. ``Dr``, ``Prof``).") + honorificSuffix: None | str = Field(default=None, description="Honorific suffix (e.g. ``M.D.``, ``PhD``).") + jobTitle: None | str = Field(default=None, description="Job title or role.") + +class CreatorOrganization(BaseCreator): + """An organization that created or contributed to the workflow. +Corresponds to a `schema.org Organization `_.""" + + model_config = ConfigDict(populate_by_name=True, extra="forbid") + + class_: Literal["Organization"] = Field(default="Organization", alias="class", description="Creator type discriminator (``Organization``).") + class WorkflowInputParameter(InputParameter, HasStepPosition): model_config = ConfigDict(populate_by_name=True, extra="forbid") @@ -327,43 +364,6 @@ class FreehandComment(BaseComment): thickness: None | float | int = Field(default=None, description="Line thickness.") line: list[list[float]] | None = Field(default=None, description="Array of ``[x, y]`` coordinate pairs defining the freehand line path.") -class BaseCreator(BaseModel): - """Base fields shared by all creator types, corresponding to schema.org -Thing properties common to both Person and Organization.""" - - model_config = ConfigDict(populate_by_name=True, extra="forbid") - - name: None | str = Field(default=None, description="Full name of the person or organization.") - identifier: None | str = Field(default=None, description="Persistent identifier, typically an ORCID URL (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID.") - url: None | str = Field(default=None, description="Website or profile URL.") - email: None | str = Field(default=None, description="Email address. May include a ``mailto:`` prefix.") - image: None | str = Field(default=None, description="URL to an image or avatar.") - address: None | str = Field(default=None, description="Physical or mailing address.") - alternateName: None | str = Field(default=None, description="An alternate name or alias.") - telephone: None | str = Field(default=None, description="Telephone number.") - faxNumber: None | str = Field(default=None, description="Fax number.") - -class CreatorPerson(BaseCreator): - """A person who created or contributed to the workflow. -Corresponds to a `schema.org Person `_.""" - - model_config = ConfigDict(populate_by_name=True, extra="forbid") - - class_: Literal["Person"] = Field(default="Person", alias="class", description="Creator type discriminator (``Person``).") - givenName: None | str = Field(default=None, description="Given (first) name.") - familyName: None | str = Field(default=None, description="Family (last) name.") - honorificPrefix: None | str = Field(default=None, description="Honorific prefix (e.g. ``Dr``, ``Prof``).") - honorificSuffix: None | str = Field(default=None, description="Honorific suffix (e.g. ``M.D.``, ``PhD``).") - jobTitle: None | str = Field(default=None, description="Job title or role.") - -class CreatorOrganization(BaseCreator): - """An organization that created or contributed to the workflow. -Corresponds to a `schema.org Organization `_.""" - - model_config = ConfigDict(populate_by_name=True, extra="forbid") - - class_: Literal["Organization"] = Field(default="Organization", alias="class", description="Creator type discriminator (``Organization``).") - class GalaxyWorkflow(Process, HasUUID): """A Galaxy workflow description. This record corresponds to the description of a workflow that should be executable on a Galaxy server that includes the contained tool definitions. @@ -410,6 +410,9 @@ class GalaxyWorkflow(Process, HasUUID): StepPosition.model_rebuild() ReferencesTool.model_rebuild() ToolShedRepository.model_rebuild() +BaseCreator.model_rebuild() +CreatorPerson.model_rebuild() +CreatorOrganization.model_rebuild() WorkflowInputParameter.model_rebuild() WorkflowOutputParameter.model_rebuild() WorkflowStep.model_rebuild() @@ -422,9 +425,6 @@ class GalaxyWorkflow(Process, HasUUID): MarkdownComment.model_rebuild() FrameComment.model_rebuild() FreehandComment.model_rebuild() -BaseCreator.model_rebuild() -CreatorPerson.model_rebuild() -CreatorOrganization.model_rebuild() GalaxyWorkflow.model_rebuild() diff --git a/gxformat2/schema/native.py b/gxformat2/schema/native.py index 14f7656c..611462cd 100644 --- a/gxformat2/schema/native.py +++ b/gxformat2/schema/native.py @@ -57,7 +57,7 @@ class NativeStepType(str, Enum): def _discriminate_creator(v: Any) -> str: - disc_map: dict[str, str] = {"Person": "NativeCreatorPerson", "Organization": "NativeCreatorOrganization"} + disc_map: dict[str, str] = {"Person": "CreatorPerson", "Organization": "CreatorOrganization"} if isinstance(v, dict): disc_val: str = str(v.get("class", "")) else: @@ -145,6 +145,43 @@ class ToolShedRepository(BaseModel): owner: str = Field(description="The owner of the tool shed repository this tool can be found in.") tool_shed: str = Field(description="The URI of the tool shed containing the repository this tool can be found in - typically this should be toolshed.g2.bx.psu.edu.") +class BaseCreator(BaseModel): + """Base fields shared by all creator types, corresponding to schema.org +Thing properties common to both Person and Organization.""" + + model_config = ConfigDict(populate_by_name=True, extra="allow") + + name: None | str = Field(default=None, description="Full name of the person or organization.") + identifier: None | str = Field(default=None, description="Persistent identifier, typically an ORCID URL (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID.") + url: None | str = Field(default=None, description="Website or profile URL.") + email: None | str = Field(default=None, description="Email address. May include a ``mailto:`` prefix.") + image: None | str = Field(default=None, description="URL to an image or avatar.") + address: None | str = Field(default=None, description="Physical or mailing address.") + alternateName: None | str = Field(default=None, description="An alternate name or alias.") + telephone: None | str = Field(default=None, description="Telephone number.") + faxNumber: None | str = Field(default=None, description="Fax number.") + +class CreatorPerson(BaseCreator): + """A person who created or contributed to the workflow. +Corresponds to a `schema.org Person `_.""" + + model_config = ConfigDict(populate_by_name=True, extra="allow") + + class_: Literal["Person"] = Field(default="Person", alias="class", description="Creator type discriminator (``Person``).") + givenName: None | str = Field(default=None, description="Given (first) name.") + familyName: None | str = Field(default=None, description="Family (last) name.") + honorificPrefix: None | str = Field(default=None, description="Honorific prefix (e.g. ``Dr``, ``Prof``).") + honorificSuffix: None | str = Field(default=None, description="Honorific suffix (e.g. ``M.D.``, ``PhD``).") + jobTitle: None | str = Field(default=None, description="Job title or role.") + +class CreatorOrganization(BaseCreator): + """An organization that created or contributed to the workflow. +Corresponds to a `schema.org Organization `_.""" + + model_config = ConfigDict(populate_by_name=True, extra="allow") + + class_: Literal["Organization"] = Field(default="Organization", alias="class", description="Creator type discriminator (``Organization``).") + class NativeStepInput(BaseModel): """Describes an input parameter on a step. This is metadata about the input, not the connection wiring (which is in ``input_connections``).""" @@ -322,43 +359,6 @@ class NativeReport(BaseModel): markdown: str = Field(description="Galaxy-flavored Markdown content for the invocation report. Supports template directives like ``history_dataset_as_image(output=\"...\")``.") -class BaseNativeCreator(BaseModel): - """Base fields shared by all creator types, corresponding to schema.org -Thing properties common to both Person and Organization.""" - - model_config = ConfigDict(populate_by_name=True, extra="allow") - - name: None | str = Field(default=None, description="Full name of the person or organization.") - identifier: None | str = Field(default=None, description="Persistent identifier, typically an ORCID URL (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID.") - url: None | str = Field(default=None, description="Website or profile URL.") - email: None | str = Field(default=None, description="Email address. May include a ``mailto:`` prefix.") - image: None | str = Field(default=None, description="URL to an image or avatar.") - address: None | str = Field(default=None, description="Physical or mailing address.") - alternateName: None | str = Field(default=None, description="An alternate name or alias.") - telephone: None | str = Field(default=None, description="Telephone number.") - faxNumber: None | str = Field(default=None, description="Fax number.") - -class NativeCreatorPerson(BaseNativeCreator): - """A person who created or contributed to the workflow. -Corresponds to a `schema.org Person `_.""" - - model_config = ConfigDict(populate_by_name=True, extra="allow") - - class_: Literal["Person"] = Field(default="Person", alias="class", description="Creator type discriminator (``Person``).") - givenName: None | str = Field(default=None, description="Given (first) name.") - familyName: None | str = Field(default=None, description="Family (last) name.") - honorificPrefix: None | str = Field(default=None, description="Honorific prefix (e.g. ``Dr``, ``Prof``).") - honorificSuffix: None | str = Field(default=None, description="Honorific suffix (e.g. ``M.D.``, ``PhD``).") - jobTitle: None | str = Field(default=None, description="Job title or role.") - -class NativeCreatorOrganization(BaseNativeCreator): - """An organization that created or contributed to the workflow. -Corresponds to a `schema.org Organization `_.""" - - model_config = ConfigDict(populate_by_name=True, extra="allow") - - class_: Literal["Organization"] = Field(default="Organization", alias="class", description="Creator type discriminator (``Organization``).") - class NativeSourceMetadata(BaseModel): """Provenance tracking for workflows imported from external sources. Contains either a direct URL or TRS (Tool Registry Service) metadata, @@ -399,7 +399,7 @@ class NativeGalaxyWorkflow(HasUUID): license: None | str = Field(default=None, description="SPDX license identifier (e.g. ``\"MIT\"``, ``\"CC-BY-4.0\"``).") release: None | str = Field(default=None, description="Semantic version for published workflows.") # Discriminated union on 'class' - creator: list[Annotated[Annotated[NativeCreatorPerson, Tag("NativeCreatorPerson")] | Annotated[NativeCreatorOrganization, Tag("NativeCreatorOrganization")], Discriminator(_discriminate_creator)]] | None = None + creator: list[Annotated[Annotated[CreatorPerson, Tag("CreatorPerson")] | Annotated[CreatorOrganization, Tag("CreatorOrganization")], Discriminator(_discriminate_creator)]] | None = None report: None | NativeReport = Field(default=None, description="Workflow invocation report template.") readme: None | str = Field(default=None, description="Detailed workflow description in Markdown.") help: None | str = Field(default=None, description="Help text in Markdown.") @@ -423,6 +423,9 @@ class NativeGalaxyWorkflow(HasUUID): StepPosition.model_rebuild() ReferencesTool.model_rebuild() ToolShedRepository.model_rebuild() +BaseCreator.model_rebuild() +CreatorPerson.model_rebuild() +CreatorOrganization.model_rebuild() NativeStepInput.model_rebuild() NativeStepOutput.model_rebuild() NativeWorkflowOutput.model_rebuild() @@ -439,9 +442,6 @@ class NativeGalaxyWorkflow(HasUUID): NativeFreehandComment.model_rebuild() NativeStep.model_rebuild() NativeReport.model_rebuild() -BaseNativeCreator.model_rebuild() -NativeCreatorPerson.model_rebuild() -NativeCreatorOrganization.model_rebuild() NativeSourceMetadata.model_rebuild() NativeGalaxyWorkflow.model_rebuild() diff --git a/gxformat2/schema/native_strict.py b/gxformat2/schema/native_strict.py index 727c0e9b..2738ac2c 100644 --- a/gxformat2/schema/native_strict.py +++ b/gxformat2/schema/native_strict.py @@ -57,7 +57,7 @@ class NativeStepType(str, Enum): def _discriminate_creator(v: Any) -> str: - disc_map: dict[str, str] = {"Person": "NativeCreatorPerson", "Organization": "NativeCreatorOrganization"} + disc_map: dict[str, str] = {"Person": "CreatorPerson", "Organization": "CreatorOrganization"} if isinstance(v, dict): disc_val: str = str(v.get("class", "")) else: @@ -145,6 +145,43 @@ class ToolShedRepository(BaseModel): owner: str = Field(description="The owner of the tool shed repository this tool can be found in.") tool_shed: str = Field(description="The URI of the tool shed containing the repository this tool can be found in - typically this should be toolshed.g2.bx.psu.edu.") +class BaseCreator(BaseModel): + """Base fields shared by all creator types, corresponding to schema.org +Thing properties common to both Person and Organization.""" + + model_config = ConfigDict(populate_by_name=True, extra="forbid") + + name: None | str = Field(default=None, description="Full name of the person or organization.") + identifier: None | str = Field(default=None, description="Persistent identifier, typically an ORCID URL (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID.") + url: None | str = Field(default=None, description="Website or profile URL.") + email: None | str = Field(default=None, description="Email address. May include a ``mailto:`` prefix.") + image: None | str = Field(default=None, description="URL to an image or avatar.") + address: None | str = Field(default=None, description="Physical or mailing address.") + alternateName: None | str = Field(default=None, description="An alternate name or alias.") + telephone: None | str = Field(default=None, description="Telephone number.") + faxNumber: None | str = Field(default=None, description="Fax number.") + +class CreatorPerson(BaseCreator): + """A person who created or contributed to the workflow. +Corresponds to a `schema.org Person `_.""" + + model_config = ConfigDict(populate_by_name=True, extra="forbid") + + class_: Literal["Person"] = Field(default="Person", alias="class", description="Creator type discriminator (``Person``).") + givenName: None | str = Field(default=None, description="Given (first) name.") + familyName: None | str = Field(default=None, description="Family (last) name.") + honorificPrefix: None | str = Field(default=None, description="Honorific prefix (e.g. ``Dr``, ``Prof``).") + honorificSuffix: None | str = Field(default=None, description="Honorific suffix (e.g. ``M.D.``, ``PhD``).") + jobTitle: None | str = Field(default=None, description="Job title or role.") + +class CreatorOrganization(BaseCreator): + """An organization that created or contributed to the workflow. +Corresponds to a `schema.org Organization `_.""" + + model_config = ConfigDict(populate_by_name=True, extra="forbid") + + class_: Literal["Organization"] = Field(default="Organization", alias="class", description="Creator type discriminator (``Organization``).") + class NativeStepInput(BaseModel): """Describes an input parameter on a step. This is metadata about the input, not the connection wiring (which is in ``input_connections``).""" @@ -322,43 +359,6 @@ class NativeReport(BaseModel): markdown: str = Field(description="Galaxy-flavored Markdown content for the invocation report. Supports template directives like ``history_dataset_as_image(output=\"...\")``.") -class BaseNativeCreator(BaseModel): - """Base fields shared by all creator types, corresponding to schema.org -Thing properties common to both Person and Organization.""" - - model_config = ConfigDict(populate_by_name=True, extra="forbid") - - name: None | str = Field(default=None, description="Full name of the person or organization.") - identifier: None | str = Field(default=None, description="Persistent identifier, typically an ORCID URL (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID.") - url: None | str = Field(default=None, description="Website or profile URL.") - email: None | str = Field(default=None, description="Email address. May include a ``mailto:`` prefix.") - image: None | str = Field(default=None, description="URL to an image or avatar.") - address: None | str = Field(default=None, description="Physical or mailing address.") - alternateName: None | str = Field(default=None, description="An alternate name or alias.") - telephone: None | str = Field(default=None, description="Telephone number.") - faxNumber: None | str = Field(default=None, description="Fax number.") - -class NativeCreatorPerson(BaseNativeCreator): - """A person who created or contributed to the workflow. -Corresponds to a `schema.org Person `_.""" - - model_config = ConfigDict(populate_by_name=True, extra="forbid") - - class_: Literal["Person"] = Field(default="Person", alias="class", description="Creator type discriminator (``Person``).") - givenName: None | str = Field(default=None, description="Given (first) name.") - familyName: None | str = Field(default=None, description="Family (last) name.") - honorificPrefix: None | str = Field(default=None, description="Honorific prefix (e.g. ``Dr``, ``Prof``).") - honorificSuffix: None | str = Field(default=None, description="Honorific suffix (e.g. ``M.D.``, ``PhD``).") - jobTitle: None | str = Field(default=None, description="Job title or role.") - -class NativeCreatorOrganization(BaseNativeCreator): - """An organization that created or contributed to the workflow. -Corresponds to a `schema.org Organization `_.""" - - model_config = ConfigDict(populate_by_name=True, extra="forbid") - - class_: Literal["Organization"] = Field(default="Organization", alias="class", description="Creator type discriminator (``Organization``).") - class NativeSourceMetadata(BaseModel): """Provenance tracking for workflows imported from external sources. Contains either a direct URL or TRS (Tool Registry Service) metadata, @@ -399,7 +399,7 @@ class NativeGalaxyWorkflow(HasUUID): license: None | str = Field(default=None, description="SPDX license identifier (e.g. ``\"MIT\"``, ``\"CC-BY-4.0\"``).") release: None | str = Field(default=None, description="Semantic version for published workflows.") # Discriminated union on 'class' - creator: list[Annotated[Annotated[NativeCreatorPerson, Tag("NativeCreatorPerson")] | Annotated[NativeCreatorOrganization, Tag("NativeCreatorOrganization")], Discriminator(_discriminate_creator)]] | None = None + creator: list[Annotated[Annotated[CreatorPerson, Tag("CreatorPerson")] | Annotated[CreatorOrganization, Tag("CreatorOrganization")], Discriminator(_discriminate_creator)]] | None = None report: None | NativeReport = Field(default=None, description="Workflow invocation report template.") readme: None | str = Field(default=None, description="Detailed workflow description in Markdown.") help: None | str = Field(default=None, description="Help text in Markdown.") @@ -423,6 +423,9 @@ class NativeGalaxyWorkflow(HasUUID): StepPosition.model_rebuild() ReferencesTool.model_rebuild() ToolShedRepository.model_rebuild() +BaseCreator.model_rebuild() +CreatorPerson.model_rebuild() +CreatorOrganization.model_rebuild() NativeStepInput.model_rebuild() NativeStepOutput.model_rebuild() NativeWorkflowOutput.model_rebuild() @@ -439,9 +442,6 @@ class NativeGalaxyWorkflow(HasUUID): NativeFreehandComment.model_rebuild() NativeStep.model_rebuild() NativeReport.model_rebuild() -BaseNativeCreator.model_rebuild() -NativeCreatorPerson.model_rebuild() -NativeCreatorOrganization.model_rebuild() NativeSourceMetadata.model_rebuild() NativeGalaxyWorkflow.model_rebuild() diff --git a/gxformat2/schema/native_v0_1.py b/gxformat2/schema/native_v0_1.py index 1f7dd606..8635ed69 100644 --- a/gxformat2/schema/native_v0_1.py +++ b/gxformat2/schema/native_v0_1.py @@ -2597,10 +2597,20 @@ def save( attrs = frozenset(["changeset_revision", "name", "owner", "tool_shed"]) -class NativeStepInput(Saveable): +class BaseCreator(Saveable): """ - Describes an input parameter on a step. This is metadata about the input, - not the connection wiring (which is in ``input_connections``). + Base fields shared by all creator types, corresponding to schema.org + Thing properties common to both Person and Organization. + + """ + + pass + + +class CreatorPerson(BaseCreator): + """ + A person who created or contributed to the workflow. + Corresponds to a `schema.org Person `_. """ @@ -2608,8 +2618,20 @@ class NativeStepInput(Saveable): def __init__( self, - name: Any, - description: Optional[Any] = None, + name: Optional[Any] = None, + identifier: Optional[Any] = None, + url: Optional[Any] = None, + email: Optional[Any] = None, + image: Optional[Any] = None, + address: Optional[Any] = None, + alternateName: Optional[Any] = None, + telephone: Optional[Any] = None, + faxNumber: Optional[Any] = None, + givenName: Optional[Any] = None, + familyName: Optional[Any] = None, + honorificPrefix: Optional[Any] = None, + honorificSuffix: Optional[Any] = None, + jobTitle: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -2622,17 +2644,62 @@ def __init__( else: self.loadingOptions = LoadingOptions() self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.description = description + self.identifier = identifier + self.url = url + self.email = email + self.image = image + self.address = address + self.alternateName = alternateName + self.telephone = telephone + self.faxNumber = faxNumber + self.class_ = "CreatorPerson" + self.givenName = givenName + self.familyName = familyName + self.honorificPrefix = honorificPrefix + self.honorificSuffix = honorificSuffix + self.jobTitle = jobTitle def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeStepInput): + if isinstance(other, CreatorPerson): return bool( - self.name == other.name and self.description == other.description + self.name == other.name + and self.identifier == other.identifier + and self.url == other.url + and self.email == other.email + and self.image == other.image + and self.address == other.address + and self.alternateName == other.alternateName + and self.telephone == other.telephone + and self.faxNumber == other.faxNumber + and self.class_ == other.class_ + and self.givenName == other.givenName + and self.familyName == other.familyName + and self.honorificPrefix == other.honorificPrefix + and self.honorificSuffix == other.honorificSuffix + and self.jobTitle == other.jobTitle ) return False def __hash__(self) -> int: - return hash((self.name, self.description)) + return hash( + ( + self.name, + self.identifier, + self.url, + self.email, + self.image, + self.address, + self.alternateName, + self.telephone, + self.faxNumber, + self.class_, + self.givenName, + self.familyName, + self.honorificPrefix, + self.honorificSuffix, + self.jobTitle, + ) + ) @classmethod def fromDoc( @@ -2641,7 +2708,7 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "NativeStepInput": + ) -> "CreatorPerson": _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -2653,7 +2720,7 @@ def fromDoc( try: name = load_field( _doc.get("name"), - uri_strtype_True_False_None_None, + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, lc=_doc.get("name") @@ -2701,24 +2768,40 @@ def fromDoc( if docRoot is not None: name = docRoot else: - _errors__.append(ValidationException("missing name")) + name = "_:" + str(_uuid__.uuid4()) if not __original_name_is_none: baseuri = cast(str, name) - description = None - if "description" in _doc: + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = load_field( + _doc.get("class"), + uri_CreatorPersonTypeLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + identifier = None + if "identifier" in _doc: try: - description = load_field( - _doc.get("description"), + identifier = load_field( + _doc.get("identifier"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("description") + lc=_doc.get("identifier") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `description`": + if str(e) == "missing required field `identifier`": _errors__.append( ValidationException( str(e), @@ -2726,13 +2809,13 @@ def fromDoc( ) ) else: - val = _doc.get("description") + val = _doc.get("identifier") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `description` field is not valid because:", - SourceLine(_doc, "description", str), + "the `identifier` field is not valid because:", + SourceLine(_doc, "identifier", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2744,142 +2827,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `description` field is not valid because:", - SourceLine(_doc, "description", str), + "the `identifier` field is not valid because:", + SourceLine(_doc, "identifier", str), [e], - detailed_message=f"the `description` field with value `{val}` " + detailed_message=f"the `identifier` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `name`, `description`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - description=description, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.description is not None: - r["description"] = save( - self.description, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "description"]) - - -class NativeStepOutput(Saveable): - """ - Declares an output produced by a step, with its name and datatype. - - """ - - name: str - - def __init__( - self, - name: Any, - type_: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeStepOutput): - return bool(self.name == other.name and self.type_ == other.type_) - return False - - def __hash__(self) -> int: - return hash((self.name, self.type_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeStepOutput": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - name = None - if "name" in _doc: + url = None + if "url" in _doc: try: - name = load_field( - _doc.get("name"), - uri_strtype_True_False_None_None, + url = load_field( + _doc.get("url"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("url") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `url`": _errors__.append( ValidationException( str(e), @@ -2887,13 +2856,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("url") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `url` field is not valid because:", + SourceLine(_doc, "url", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2905,37 +2874,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `url` field is not valid because:", + SourceLine(_doc, "url", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `url` field with value `{val}` " "is not valid because:", ) ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - _errors__.append(ValidationException("missing name")) - if not __original_name_is_none: - baseuri = cast(str, name) - type_ = None - if "type" in _doc: + email = None + if "email" in _doc: try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_None_type_or_strtype_2, + email = load_field( + _doc.get("email"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("email") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `email`": _errors__.append( ValidationException( str(e), @@ -2943,13 +2903,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("email") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `email` field is not valid because:", + SourceLine(_doc, "email", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2961,144 +2921,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `email` field is not valid because:", + SourceLine(_doc, "email", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `email` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `name`, `type`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - type_=type_, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["name", "type"]) - - -class NativeWorkflowOutput(Saveable): - """ - Designates a step output as a workflow-level output. These appear in the - ``workflow_outputs`` array on each step. - - """ - - def __init__( - self, - output_name: Any, - label: Optional[Any] = None, - uuid: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.label = label - self.output_name = output_name - self.uuid = uuid - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeWorkflowOutput): - return bool( - self.label == other.label - and self.output_name == other.output_name - and self.uuid == other.uuid - ) - return False - - def __hash__(self) -> int: - return hash((self.label, self.output_name, self.uuid)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeWorkflowOutput": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - label = None - if "label" in _doc: + image = None + if "image" in _doc: try: - label = load_field( - _doc.get("label"), + image = load_field( + _doc.get("image"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("image") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `image`": _errors__.append( ValidationException( str(e), @@ -3106,13 +2950,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("image") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `image` field is not valid because:", + SourceLine(_doc, "image", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3124,76 +2968,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `image` field is not valid because:", + SourceLine(_doc, "image", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `image` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("output_name") is None: - raise ValidationException("missing required field `output_name`", None, []) - - output_name = load_field( - _doc.get("output_name"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("output_name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `output_name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("output_name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `output_name` field is not valid because:", - SourceLine(_doc, "output_name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `output_name` field is not valid because:", - SourceLine(_doc, "output_name", str), - [e], - detailed_message=f"the `output_name` field with value `{val}` " - "is not valid because:", - ) - ) - uuid = None - if "uuid" in _doc: + address = None + if "address" in _doc: try: - uuid = load_field( - _doc.get("uuid"), + address = load_field( + _doc.get("address"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("uuid") + lc=_doc.get("address") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `uuid`": + if str(e) == "missing required field `address`": _errors__.append( ValidationException( str(e), @@ -3201,13 +2997,13 @@ def fromDoc( ) ) else: - val = _doc.get("uuid") + val = _doc.get("address") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `uuid` field is not valid because:", - SourceLine(_doc, "uuid", str), + "the `address` field is not valid because:", + SourceLine(_doc, "address", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3219,251 +3015,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `uuid` field is not valid because:", - SourceLine(_doc, "uuid", str), + "the `address` field is not valid because:", + SourceLine(_doc, "address", str), [e], - detailed_message=f"the `uuid` field with value `{val}` " + detailed_message=f"the `address` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `output_name`, `uuid`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - output_name=output_name, - uuid=uuid, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.output_name is not None: - r["output_name"] = save( - self.output_name, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.uuid is not None: - r["uuid"] = save( - self.uuid, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["label", "output_name", "uuid"]) - - -class NativeInputConnection(Saveable): - """ - Describes a connection from one step's output to another step's input. - These objects appear as values in the ``input_connections`` dictionary. - - For multi-valued inputs, the value is an array of these objects rather - than a single object. - - """ - - def __init__( - self, - id: Any, - output_name: Any, - input_subworkflow_step_id: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id - self.output_name = output_name - self.input_subworkflow_step_id = input_subworkflow_step_id - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeInputConnection): - return bool( - self.id == other.id - and self.output_name == other.output_name - and self.input_subworkflow_step_id == other.input_subworkflow_step_id - ) - return False - - def __hash__(self) -> int: - return hash((self.id, self.output_name, self.input_subworkflow_step_id)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeInputConnection": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("id") is None: - raise ValidationException("missing required field `id`", None, []) - - id = load_field( - _doc.get("id"), - inttype, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("output_name") is None: - raise ValidationException("missing required field `output_name`", None, []) - - output_name = load_field( - _doc.get("output_name"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("output_name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `output_name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("output_name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `output_name` field is not valid because:", - SourceLine(_doc, "output_name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `output_name` field is not valid because:", - SourceLine(_doc, "output_name", str), - [e], - detailed_message=f"the `output_name` field with value `{val}` " - "is not valid because:", - ) - ) - input_subworkflow_step_id = None - if "input_subworkflow_step_id" in _doc: + alternateName = None + if "alternateName" in _doc: try: - input_subworkflow_step_id = load_field( - _doc.get("input_subworkflow_step_id"), - union_of_None_type_or_inttype, + alternateName = load_field( + _doc.get("alternateName"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("input_subworkflow_step_id") + lc=_doc.get("alternateName") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `input_subworkflow_step_id`": + if str(e) == "missing required field `alternateName`": _errors__.append( ValidationException( str(e), @@ -3471,13 +3044,13 @@ def fromDoc( ) ) else: - val = _doc.get("input_subworkflow_step_id") + val = _doc.get("alternateName") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `input_subworkflow_step_id` field is not valid because:", - SourceLine(_doc, "input_subworkflow_step_id", str), + "the `alternateName` field is not valid because:", + SourceLine(_doc, "alternateName", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3489,257 +3062,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `input_subworkflow_step_id` field is not valid because:", - SourceLine(_doc, "input_subworkflow_step_id", str), + "the `alternateName` field is not valid because:", + SourceLine(_doc, "alternateName", str), [e], - detailed_message=f"the `input_subworkflow_step_id` field with value `{val}` " + detailed_message=f"the `alternateName` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `id`, `output_name`, `input_subworkflow_step_id`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - id=id, - output_name=output_name, - input_subworkflow_step_id=input_subworkflow_step_id, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - r["id"] = save( - self.id, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.output_name is not None: - r["output_name"] = save( - self.output_name, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.input_subworkflow_step_id is not None: - r["input_subworkflow_step_id"] = save( - self.input_subworkflow_step_id, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["id", "output_name", "input_subworkflow_step_id"]) - - -class NativePostJobAction(Saveable): - """ - An action applied to a step's output after tool execution. These objects - appear as values in the ``post_job_actions`` dictionary, keyed by - compound strings of the form ``{ActionType}{OutputName}`` - (e.g. ``HideDatasetActionout_pairs``). - - Common action types: ``HideDatasetAction``, ``RenameDatasetAction``, - ``DeleteIntermediatesAction``, ``ChangeDatatypeAction``, - ``TagDatasetAction``, ``ColumnSetAction``. - - """ - - def __init__( - self, - action_type: Any, - output_name: Any, - action_arguments: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.action_type = action_type - self.output_name = output_name - self.action_arguments = action_arguments - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativePostJobAction): - return bool( - self.action_type == other.action_type - and self.output_name == other.output_name - and self.action_arguments == other.action_arguments - ) - return False - - def __hash__(self) -> int: - return hash((self.action_type, self.output_name, self.action_arguments)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativePostJobAction": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("action_type") is None: - raise ValidationException("missing required field `action_type`", None, []) - - action_type = load_field( - _doc.get("action_type"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("action_type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `action_type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("action_type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `action_type` field is not valid because:", - SourceLine(_doc, "action_type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `action_type` field is not valid because:", - SourceLine(_doc, "action_type", str), - [e], - detailed_message=f"the `action_type` field with value `{val}` " - "is not valid because:", - ) - ) - try: - if _doc.get("output_name") is None: - raise ValidationException("missing required field `output_name`", None, []) - - output_name = load_field( - _doc.get("output_name"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("output_name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `output_name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("output_name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `output_name` field is not valid because:", - SourceLine(_doc, "output_name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `output_name` field is not valid because:", - SourceLine(_doc, "output_name", str), - [e], - detailed_message=f"the `output_name` field with value `{val}` " - "is not valid because:", - ) - ) - action_arguments = None - if "action_arguments" in _doc: + telephone = None + if "telephone" in _doc: try: - action_arguments = load_field( - _doc.get("action_arguments"), - union_of_None_type_or_Any_type, + telephone = load_field( + _doc.get("telephone"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("action_arguments") + lc=_doc.get("telephone") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `action_arguments`": + if str(e) == "missing required field `telephone`": _errors__.append( ValidationException( str(e), @@ -3747,13 +3091,13 @@ def fromDoc( ) ) else: - val = _doc.get("action_arguments") + val = _doc.get("telephone") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `action_arguments` field is not valid because:", - SourceLine(_doc, "action_arguments", str), + "the `telephone` field is not valid because:", + SourceLine(_doc, "telephone", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3765,160 +3109,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `action_arguments` field is not valid because:", - SourceLine(_doc, "action_arguments", str), + "the `telephone` field is not valid because:", + SourceLine(_doc, "telephone", str), [e], - detailed_message=f"the `action_arguments` field with value `{val}` " + detailed_message=f"the `telephone` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `action_type`, `output_name`, `action_arguments`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - action_type=action_type, - output_name=output_name, - action_arguments=action_arguments, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.action_type is not None: - r["action_type"] = save( - self.action_type, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.output_name is not None: - r["output_name"] = save( - self.output_name, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - if self.action_arguments is not None: - r["action_arguments"] = save( - self.action_arguments, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["action_type", "output_name", "action_arguments"]) - - -class NativeTextCommentData(Saveable): - """ - Data payload for a text comment. - - """ - - def __init__( - self, - text: Optional[Any] = None, - bold: Optional[Any] = None, - italic: Optional[Any] = None, - size: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.text = text - self.bold = bold - self.italic = italic - self.size = size - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeTextCommentData): - return bool( - self.text == other.text - and self.bold == other.bold - and self.italic == other.italic - and self.size == other.size - ) - return False - - def __hash__(self) -> int: - return hash((self.text, self.bold, self.italic, self.size)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeTextCommentData": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - text = None - if "text" in _doc: + faxNumber = None + if "faxNumber" in _doc: try: - text = load_field( - _doc.get("text"), + faxNumber = load_field( + _doc.get("faxNumber"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("text") + lc=_doc.get("faxNumber") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `text`": + if str(e) == "missing required field `faxNumber`": _errors__.append( ValidationException( str(e), @@ -3926,13 +3138,13 @@ def fromDoc( ) ) else: - val = _doc.get("text") + val = _doc.get("faxNumber") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `text` field is not valid because:", - SourceLine(_doc, "text", str), + "the `faxNumber` field is not valid because:", + SourceLine(_doc, "faxNumber", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3944,28 +3156,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `text` field is not valid because:", - SourceLine(_doc, "text", str), + "the `faxNumber` field is not valid because:", + SourceLine(_doc, "faxNumber", str), [e], - detailed_message=f"the `text` field with value `{val}` " + detailed_message=f"the `faxNumber` field with value `{val}` " "is not valid because:", ) ) - bold = None - if "bold" in _doc: + givenName = None + if "givenName" in _doc: try: - bold = load_field( - _doc.get("bold"), - union_of_None_type_or_booltype, + givenName = load_field( + _doc.get("givenName"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("bold") + lc=_doc.get("givenName") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `bold`": + if str(e) == "missing required field `givenName`": _errors__.append( ValidationException( str(e), @@ -3973,13 +3185,13 @@ def fromDoc( ) ) else: - val = _doc.get("bold") + val = _doc.get("givenName") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `bold` field is not valid because:", - SourceLine(_doc, "bold", str), + "the `givenName` field is not valid because:", + SourceLine(_doc, "givenName", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3991,28 +3203,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `bold` field is not valid because:", - SourceLine(_doc, "bold", str), + "the `givenName` field is not valid because:", + SourceLine(_doc, "givenName", str), [e], - detailed_message=f"the `bold` field with value `{val}` " + detailed_message=f"the `givenName` field with value `{val}` " "is not valid because:", ) ) - italic = None - if "italic" in _doc: + familyName = None + if "familyName" in _doc: try: - italic = load_field( - _doc.get("italic"), - union_of_None_type_or_booltype, + familyName = load_field( + _doc.get("familyName"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("italic") + lc=_doc.get("familyName") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `italic`": + if str(e) == "missing required field `familyName`": _errors__.append( ValidationException( str(e), @@ -4020,13 +3232,13 @@ def fromDoc( ) ) else: - val = _doc.get("italic") + val = _doc.get("familyName") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `italic` field is not valid because:", - SourceLine(_doc, "italic", str), + "the `familyName` field is not valid because:", + SourceLine(_doc, "familyName", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4038,28 +3250,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `italic` field is not valid because:", - SourceLine(_doc, "italic", str), + "the `familyName` field is not valid because:", + SourceLine(_doc, "familyName", str), [e], - detailed_message=f"the `italic` field with value `{val}` " + detailed_message=f"the `familyName` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + honorificPrefix = None + if "honorificPrefix" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_floattype_or_inttype, + honorificPrefix = load_field( + _doc.get("honorificPrefix"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("honorificPrefix") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `honorificPrefix`": _errors__.append( ValidationException( str(e), @@ -4067,13 +3279,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("honorificPrefix") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `honorificPrefix` field is not valid because:", + SourceLine(_doc, "honorificPrefix", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4085,145 +3297,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `honorificPrefix` field is not valid because:", + SourceLine(_doc, "honorificPrefix", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `honorificPrefix` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + honorificSuffix = None + if "honorificSuffix" in _doc: + try: + honorificSuffix = load_field( + _doc.get("honorificSuffix"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("honorificSuffix") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `honorificSuffix`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `text`, `bold`, `italic`, `size`".format( - k - ), - SourceLine(_doc, k, str), + val = _doc.get("honorificSuffix") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `honorificSuffix` field is not valid because:", + SourceLine(_doc, "honorificSuffix", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - text=text, - bold=bold, - italic=italic, - size=size, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.text is not None: - r["text"] = save( - self.text, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.bold is not None: - r["bold"] = save( - self.bold, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.italic is not None: - r["italic"] = save( - self.italic, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["text", "bold", "italic", "size"]) - - -class NativeMarkdownCommentData(Saveable): - """ - Data payload for a markdown comment. - - """ - - def __init__( - self, - text: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.text = text - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeMarkdownCommentData): - return bool(self.text == other.text) - return False - - def __hash__(self) -> int: - return hash((self.text)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeMarkdownCommentData": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - text = None - if "text" in _doc: + else: + _errors__.append( + ValidationException( + "the `honorificSuffix` field is not valid because:", + SourceLine(_doc, "honorificSuffix", str), + [e], + detailed_message=f"the `honorificSuffix` field with value `{val}` " + "is not valid because:", + ) + ) + jobTitle = None + if "jobTitle" in _doc: try: - text = load_field( - _doc.get("text"), + jobTitle = load_field( + _doc.get("jobTitle"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("text") + lc=_doc.get("jobTitle") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `text`": + if str(e) == "missing required field `jobTitle`": _errors__.append( ValidationException( str(e), @@ -4231,13 +3373,13 @@ def fromDoc( ) ) else: - val = _doc.get("text") + val = _doc.get("jobTitle") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `text` field is not valid because:", - SourceLine(_doc, "text", str), + "the `jobTitle` field is not valid because:", + SourceLine(_doc, "jobTitle", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4249,10 +3391,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `text` field is not valid because:", - SourceLine(_doc, "text", str), + "the `jobTitle` field is not valid because:", + SourceLine(_doc, "jobTitle", str), [e], - detailed_message=f"the `text` field with value `{val}` " + detailed_message=f"the `jobTitle` field with value `{val}` " "is not valid because:", ) ) @@ -4271,7 +3413,9 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `text`".format(k), + "invalid field `{}`, expected one of: `name`, `identifier`, `url`, `email`, `image`, `address`, `alternateName`, `telephone`, `faxNumber`, `class`, `givenName`, `familyName`, `honorificPrefix`, `honorificSuffix`, `jobTitle`".format( + k + ), SourceLine(_doc, k, str), ) ) @@ -4279,10 +3423,24 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - text=text, + name=name, + identifier=identifier, + url=url, + email=email, + image=image, + address=address, + alternateName=alternateName, + telephone=telephone, + faxNumber=faxNumber, + givenName=givenName, + familyName=familyName, + honorificPrefix=honorificPrefix, + honorificSuffix=honorificSuffix, + jobTitle=jobTitle, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -4296,156 +3454,95 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.text is not None: - r["text"] = save( - self.text, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.class_ is not None: + uri = self.loadingOptions.vocab[self.class_] + if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, self.name, False, None, relative_uris) + r["class"] = u + if self.identifier is not None: + r["identifier"] = save( + self.identifier, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["text"]) - - -class NativeFrameCommentData(Saveable): - """ - Data payload for a frame comment. - - """ - - def __init__( - self, - title: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.title = title - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeFrameCommentData): - return bool(self.title == other.title) - return False - - def __hash__(self) -> int: - return hash((self.title)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeFrameCommentData": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - title = None - if "title" in _doc: - try: - title = load_field( - _doc.get("title"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("title") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `title`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("title") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `title` field is not valid because:", - SourceLine(_doc, "title", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `title` field is not valid because:", - SourceLine(_doc, "title", str), - [e], - detailed_message=f"the `title` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `title`".format(k), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - title=title, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.title is not None: - r["title"] = save( - self.title, top=False, base_url=base_url, relative_uris=relative_uris + if self.url is not None: + r["url"] = save( + self.url, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.email is not None: + r["email"] = save( + self.email, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.image is not None: + r["image"] = save( + self.image, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.address is not None: + r["address"] = save( + self.address, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.alternateName is not None: + r["alternateName"] = save( + self.alternateName, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.telephone is not None: + r["telephone"] = save( + self.telephone, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.faxNumber is not None: + r["faxNumber"] = save( + self.faxNumber, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.givenName is not None: + r["givenName"] = save( + self.givenName, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.familyName is not None: + r["familyName"] = save( + self.familyName, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.honorificPrefix is not None: + r["honorificPrefix"] = save( + self.honorificPrefix, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.honorificSuffix is not None: + r["honorificSuffix"] = save( + self.honorificSuffix, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.jobTitle is not None: + r["jobTitle"] = save( + self.jobTitle, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) # top refers to the directory level @@ -4456,19 +3553,47 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["title"]) + attrs = frozenset( + [ + "name", + "identifier", + "url", + "email", + "image", + "address", + "alternateName", + "telephone", + "faxNumber", + "class", + "givenName", + "familyName", + "honorificPrefix", + "honorificSuffix", + "jobTitle", + ] + ) -class NativeFreehandCommentData(Saveable): +class CreatorOrganization(BaseCreator): """ - Data payload for a freehand comment. + An organization that created or contributed to the workflow. + Corresponds to a `schema.org Organization `_. """ + name: str + def __init__( self, - line: Optional[Any] = None, - thickness: Optional[Any] = None, + name: Optional[Any] = None, + identifier: Optional[Any] = None, + url: Optional[Any] = None, + email: Optional[Any] = None, + image: Optional[Any] = None, + address: Optional[Any] = None, + alternateName: Optional[Any] = None, + telephone: Optional[Any] = None, + faxNumber: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -4480,16 +3605,48 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.line = line - self.thickness = thickness + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.identifier = identifier + self.url = url + self.email = email + self.image = image + self.address = address + self.alternateName = alternateName + self.telephone = telephone + self.faxNumber = faxNumber + self.class_ = "CreatorOrganization" def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeFreehandCommentData): - return bool(self.line == other.line and self.thickness == other.thickness) + if isinstance(other, CreatorOrganization): + return bool( + self.name == other.name + and self.identifier == other.identifier + and self.url == other.url + and self.email == other.email + and self.image == other.image + and self.address == other.address + and self.alternateName == other.alternateName + and self.telephone == other.telephone + and self.faxNumber == other.faxNumber + and self.class_ == other.class_ + ) return False def __hash__(self) -> int: - return hash((self.line, self.thickness)) + return hash( + ( + self.name, + self.identifier, + self.url, + self.email, + self.image, + self.address, + self.alternateName, + self.telephone, + self.faxNumber, + self.class_, + ) + ) @classmethod def fromDoc( @@ -4498,28 +3655,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "NativeFreehandCommentData": + ) -> "CreatorOrganization": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - line = None - if "line" in _doc: + name = None + if "name" in _doc: try: - line = load_field( - _doc.get("line"), - union_of_None_type_or_Any_type, + name = load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("line") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `line`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -4527,13 +3684,13 @@ def fromDoc( ) ) else: - val = _doc.get("line") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `line` field is not valid because:", - SourceLine(_doc, "line", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4545,28 +3702,53 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `line` field is not valid because:", - SourceLine(_doc, "line", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `line` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - thickness = None - if "thickness" in _doc: + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + if not __original_name_is_none: + baseuri = cast(str, name) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = load_field( + _doc.get("class"), + uri_CreatorOrganizationTypeLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + identifier = None + if "identifier" in _doc: try: - thickness = load_field( - _doc.get("thickness"), - union_of_None_type_or_floattype_or_inttype, + identifier = load_field( + _doc.get("identifier"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("thickness") + lc=_doc.get("identifier") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `thickness`": + if str(e) == "missing required field `identifier`": _errors__.append( ValidationException( str(e), @@ -4574,13 +3756,13 @@ def fromDoc( ) ) else: - val = _doc.get("thickness") + val = _doc.get("identifier") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `thickness` field is not valid because:", - SourceLine(_doc, "thickness", str), + "the `identifier` field is not valid because:", + SourceLine(_doc, "identifier", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4592,214 +3774,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `thickness` field is not valid because:", - SourceLine(_doc, "thickness", str), + "the `identifier` field is not valid because:", + SourceLine(_doc, "identifier", str), [e], - detailed_message=f"the `thickness` field with value `{val}` " + detailed_message=f"the `identifier` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `line`, `thickness`".format( - k - ), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - line=line, - thickness=thickness, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.line is not None: - r["line"] = save( - self.line, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.thickness is not None: - r["thickness"] = save( - self.thickness, - top=False, - base_url=base_url, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["line", "thickness"]) - - -class BaseNativeComment(Saveable): - """ - Base fields shared by all comment types. - - """ - - pass - - -class NativeTextComment(BaseNativeComment): - """ - A plain text annotation in the workflow editor. - - """ - - def __init__( - self, - id: Any, - type_: Any, - position: Optional[Any] = None, - size: Optional[Any] = None, - color: Optional[Any] = None, - data: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id - self.position = position - self.size = size - self.color = color - self.type_ = type_ - self.data = data - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeTextComment): - return bool( - self.id == other.id - and self.position == other.position - and self.size == other.size - and self.color == other.color - and self.type_ == other.type_ - and self.data == other.data - ) - return False - - def __hash__(self) -> int: - return hash( - (self.id, self.position, self.size, self.color, self.type_, self.data) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeTextComment": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("id") is None: - raise ValidationException("missing required field `id`", None, []) - - id = load_field( - _doc.get("id"), - inttype, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - position = None - if "position" in _doc: + url = None + if "url" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_Any_type, + url = load_field( + _doc.get("url"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("url") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `url`": _errors__.append( ValidationException( str(e), @@ -4807,13 +3803,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("url") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `url` field is not valid because:", + SourceLine(_doc, "url", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4825,28 +3821,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `url` field is not valid because:", + SourceLine(_doc, "url", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `url` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + email = None + if "email" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_Any_type, + email = load_field( + _doc.get("email"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("email") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `email`": _errors__.append( ValidationException( str(e), @@ -4854,13 +3850,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("email") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `email` field is not valid because:", + SourceLine(_doc, "email", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4872,28 +3868,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `email` field is not valid because:", + SourceLine(_doc, "email", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `email` field with value `{val}` " "is not valid because:", ) ) - color = None - if "color" in _doc: + image = None + if "image" in _doc: try: - color = load_field( - _doc.get("color"), + image = load_field( + _doc.get("image"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("color") + lc=_doc.get("image") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `color`": + if str(e) == "missing required field `image`": _errors__.append( ValidationException( str(e), @@ -4901,13 +3897,13 @@ def fromDoc( ) ) else: - val = _doc.get("color") + val = _doc.get("image") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `image` field is not valid because:", + SourceLine(_doc, "image", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4919,76 +3915,169 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `image` field is not valid because:", + SourceLine(_doc, "image", str), [e], - detailed_message=f"the `color` field with value `{val}` " + detailed_message=f"the `image` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + address = None + if "address" in _doc: + try: + address = load_field( + _doc.get("address"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("address") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None + if str(e) == "missing required field `address`": + _errors__.append( + ValidationException( + str(e), + None + ) ) + else: + val = _doc.get("address") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `address` field is not valid because:", + SourceLine(_doc, "address", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `address` field is not valid because:", + SourceLine(_doc, "address", str), + [e], + detailed_message=f"the `address` field with value `{val}` " + "is not valid because:", + ) + ) + alternateName = None + if "alternateName" in _doc: + try: + alternateName = load_field( + _doc.get("alternateName"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("alternateName") ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `alternateName`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("alternateName") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `alternateName` field is not valid because:", + SourceLine(_doc, "alternateName", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `alternateName` field is not valid because:", + SourceLine(_doc, "alternateName", str), + [e], + detailed_message=f"the `alternateName` field with value `{val}` " + "is not valid because:", + ) + ) + telephone = None + if "telephone" in _doc: + try: + telephone = load_field( + _doc.get("telephone"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("telephone") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `telephone`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - data = None - if "data" in _doc: + else: + val = _doc.get("telephone") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `telephone` field is not valid because:", + SourceLine(_doc, "telephone", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `telephone` field is not valid because:", + SourceLine(_doc, "telephone", str), + [e], + detailed_message=f"the `telephone` field with value `{val}` " + "is not valid because:", + ) + ) + faxNumber = None + if "faxNumber" in _doc: try: - data = load_field( - _doc.get("data"), - union_of_None_type_or_NativeTextCommentDataLoader, + faxNumber = load_field( + _doc.get("faxNumber"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("data") + lc=_doc.get("faxNumber") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `data`": + if str(e) == "missing required field `faxNumber`": _errors__.append( ValidationException( str(e), @@ -4996,13 +4085,13 @@ def fromDoc( ) ) else: - val = _doc.get("data") + val = _doc.get("faxNumber") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `data` field is not valid because:", - SourceLine(_doc, "data", str), + "the `faxNumber` field is not valid because:", + SourceLine(_doc, "faxNumber", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5014,10 +4103,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `data` field is not valid because:", - SourceLine(_doc, "data", str), + "the `faxNumber` field is not valid because:", + SourceLine(_doc, "faxNumber", str), [e], - detailed_message=f"the `data` field with value `{val}` " + detailed_message=f"the `faxNumber` field with value `{val}` " "is not valid because:", ) ) @@ -5036,7 +4125,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `position`, `size`, `color`, `type`, `data`".format( + "invalid field `{}`, expected one of: `name`, `identifier`, `url`, `email`, `image`, `address`, `alternateName`, `telephone`, `faxNumber`, `class`".format( k ), SourceLine(_doc, k, str), @@ -5046,16 +4135,20 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, - position=position, - size=size, - color=color, - type_=type_, - data=data, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed + name=name, + identifier=identifier, + url=url, + email=email, + image=image, + address=address, + alternateName=alternateName, + telephone=telephone, + faxNumber=faxNumber, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + return _constructed def save( self, top: bool = False, base_url: str = "", relative_uris: bool = True @@ -5068,29 +4161,60 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - r["id"] = save( - self.id, top=False, base_url=base_url, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.class_ is not None: + uri = self.loadingOptions.vocab[self.class_] + if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, self.name, False, None, relative_uris) + r["class"] = u + if self.identifier is not None: + r["identifier"] = save( + self.identifier, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris + if self.url is not None: + r["url"] = save( + self.url, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris + if self.email is not None: + r["email"] = save( + self.email, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.color is not None: - r["color"] = save( - self.color, top=False, base_url=base_url, relative_uris=relative_uris + if self.image is not None: + r["image"] = save( + self.image, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.address is not None: + r["address"] = save( + self.address, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.data is not None: - r["data"] = save( - self.data, top=False, base_url=base_url, relative_uris=relative_uris + if self.alternateName is not None: + r["alternateName"] = save( + self.alternateName, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.telephone is not None: + r["telephone"] = save( + self.telephone, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.faxNumber is not None: + r["faxNumber"] = save( + self.faxNumber, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) # top refers to the directory level @@ -5101,23 +4225,35 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["id", "position", "size", "color", "type", "data"]) + attrs = frozenset( + [ + "name", + "identifier", + "url", + "email", + "image", + "address", + "alternateName", + "telephone", + "faxNumber", + "class", + ] + ) -class NativeMarkdownComment(BaseNativeComment): +class NativeStepInput(Saveable): """ - A Markdown-rendered annotation in the workflow editor. + Describes an input parameter on a step. This is metadata about the input, + not the connection wiring (which is in ``input_connections``). """ + name: str + def __init__( self, - id: Any, - type_: Any, - position: Optional[Any] = None, - size: Optional[Any] = None, - color: Optional[Any] = None, - data: Optional[Any] = None, + name: Any, + description: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -5129,29 +4265,18 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id - self.position = position - self.size = size - self.color = color - self.type_ = type_ - self.data = data + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.description = description def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeMarkdownComment): + if isinstance(other, NativeStepInput): return bool( - self.id == other.id - and self.position == other.position - and self.size == other.size - and self.color == other.color - and self.type_ == other.type_ - and self.data == other.data + self.name == other.name and self.description == other.description ) return False def __hash__(self) -> int: - return hash( - (self.id, self.position, self.size, self.color, self.type_, self.data) - ) + return hash((self.name, self.description)) @classmethod def fromDoc( @@ -5160,76 +4285,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "NativeMarkdownComment": + ) -> "NativeStepInput": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("id") is None: - raise ValidationException("missing required field `id`", None, []) - - id = load_field( - _doc.get("id"), - inttype, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - position = None - if "position" in _doc: + name = None + if "name" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_Any_type, + name = load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -5237,13 +4314,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5255,28 +4332,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + _errors__.append(ValidationException("missing name")) + if not __original_name_is_none: + baseuri = cast(str, name) + description = None + if "description" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_Any_type, + description = load_field( + _doc.get("description"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("description") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `description`": _errors__.append( ValidationException( str(e), @@ -5284,13 +4370,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("description") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `description` field is not valid because:", + SourceLine(_doc, "description", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5302,28 +4388,142 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `description` field is not valid because:", + SourceLine(_doc, "description", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `description` field with value `{val}` " "is not valid because:", ) ) - color = None - if "color" in _doc: - try: - color = load_field( - _doc.get("color"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("color") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `name`, `description`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) - if str(e) == "missing required field `color`": + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + description=description, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.description is not None: + r["description"] = save( + self.description, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["name", "description"]) + + +class NativeStepOutput(Saveable): + """ + Declares an output produced by a step, with its name and datatype. + + """ + + name: str + + def __init__( + self, + name: Any, + type_: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.type_ = type_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeStepOutput): + return bool(self.name == other.name and self.type_ == other.type_) + return False + + def __hash__(self) -> int: + return hash((self.name, self.type_)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeStepOutput": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: + try: + name = load_field( + _doc.get("name"), + uri_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -5331,13 +4531,13 @@ def fromDoc( ) ) else: - val = _doc.get("color") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5349,76 +4549,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `color` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - data = None - if "data" in _doc: + _errors__.append(ValidationException("missing name")) + if not __original_name_is_none: + baseuri = cast(str, name) + type_ = None + if "type" in _doc: try: - data = load_field( - _doc.get("data"), - union_of_None_type_or_NativeMarkdownCommentDataLoader, + type_ = load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_strtype_2, baseuri, loadingOptions, - lc=_doc.get("data") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `data`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -5426,13 +4587,13 @@ def fromDoc( ) ) else: - val = _doc.get("data") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `data` field is not valid because:", - SourceLine(_doc, "data", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5444,10 +4605,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `data` field is not valid because:", - SourceLine(_doc, "data", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `data` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) @@ -5466,7 +4627,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `position`, `size`, `color`, `type`, `data`".format( + "invalid field `{}`, expected one of: `name`, `type`".format( k ), SourceLine(_doc, k, str), @@ -5476,15 +4637,12 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, - position=position, - size=size, - color=color, + name=name, type_=type_, - data=data, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -5498,29 +4656,12 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - r["id"] = save( - self.id, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.color is not None: - r["color"] = save( - self.color, top=False, base_url=base_url, relative_uris=relative_uris - ) + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u if self.type_ is not None: r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.data is not None: - r["data"] = save( - self.data, top=False, base_url=base_url, relative_uris=relative_uris + self.type_, top=False, base_url=self.name, relative_uris=relative_uris ) # top refers to the directory level @@ -5531,25 +4672,21 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["id", "position", "size", "color", "type", "data"]) + attrs = frozenset(["name", "type"]) -class NativeFrameComment(BaseNativeComment): +class NativeWorkflowOutput(Saveable): """ - A rectangular grouping box that visually contains steps and other comments. + Designates a step output as a workflow-level output. These appear in the + ``workflow_outputs`` array on each step. """ def __init__( self, - id: Any, - type_: Any, - position: Optional[Any] = None, - size: Optional[Any] = None, - color: Optional[Any] = None, - data: Optional[Any] = None, - child_steps: Optional[Any] = None, - child_comments: Optional[Any] = None, + output_name: Any, + label: Optional[Any] = None, + uuid: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -5561,42 +4698,21 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id - self.position = position - self.size = size - self.color = color - self.type_ = type_ - self.data = data - self.child_steps = child_steps - self.child_comments = child_comments + self.label = label + self.output_name = output_name + self.uuid = uuid def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeFrameComment): + if isinstance(other, NativeWorkflowOutput): return bool( - self.id == other.id - and self.position == other.position - and self.size == other.size - and self.color == other.color - and self.type_ == other.type_ - and self.data == other.data - and self.child_steps == other.child_steps - and self.child_comments == other.child_comments + self.label == other.label + and self.output_name == other.output_name + and self.uuid == other.uuid ) return False def __hash__(self) -> int: - return hash( - ( - self.id, - self.position, - self.size, - self.color, - self.type_, - self.data, - self.child_steps, - self.child_comments, - ) - ) + return hash((self.label, self.output_name, self.uuid)) @classmethod def fromDoc( @@ -5605,76 +4721,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "NativeFrameComment": + ) -> "NativeWorkflowOutput": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - try: - if _doc.get("id") is None: - raise ValidationException("missing required field `id`", None, []) - - id = load_field( - _doc.get("id"), - inttype, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("id") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), - [e], - detailed_message=f"the `id` field with value `{val}` " - "is not valid because:", - ) - ) - position = None - if "position" in _doc: + label = None + if "label" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_Any_type, + label = load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -5682,13 +4750,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5700,75 +4768,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: - try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_Any_type, - baseuri, - loadingOptions, - lc=_doc.get("size") - ) + try: + if _doc.get("output_name") is None: + raise ValidationException("missing required field `output_name`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + output_name = load_field( + _doc.get("output_name"), + strtype, + baseuri, + loadingOptions, + lc=_doc.get("output_name") + ) - if str(e) == "missing required field `size`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `output_name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("output_name") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `output_name` field is not valid because:", + SourceLine(_doc, "output_name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("size") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), - [e], - detailed_message=f"the `size` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `output_name` field is not valid because:", + SourceLine(_doc, "output_name", str), + [e], + detailed_message=f"the `output_name` field with value `{val}` " + "is not valid because:", ) - color = None - if "color" in _doc: + ) + uuid = None + if "uuid" in _doc: try: - color = load_field( - _doc.get("color"), + uuid = load_field( + _doc.get("uuid"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("color") + lc=_doc.get("uuid") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `color`": + if str(e) == "missing required field `uuid`": _errors__.append( ValidationException( str(e), @@ -5776,13 +4845,13 @@ def fromDoc( ) ) else: - val = _doc.get("color") + val = _doc.get("uuid") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `uuid` field is not valid because:", + SourceLine(_doc, "uuid", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5794,29 +4863,156 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `uuid` field is not valid because:", + SourceLine(_doc, "uuid", str), [e], - detailed_message=f"the `color` field with value `{val}` " + detailed_message=f"the `uuid` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `label`, `output_name`, `uuid`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) - type_ = load_field( - _doc.get("type"), - typedsl_strtype_2, + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + label=label, + output_name=output_name, + uuid=uuid, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.output_name is not None: + r["output_name"] = save( + self.output_name, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.uuid is not None: + r["uuid"] = save( + self.uuid, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["label", "output_name", "uuid"]) + + +class NativeInputConnection(Saveable): + """ + Describes a connection from one step's output to another step's input. + These objects appear as values in the ``input_connections`` dictionary. + + For multi-valued inputs, the value is an array of these objects rather + than a single object. + + """ + + def __init__( + self, + id: Any, + output_name: Any, + input_subworkflow_step_id: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id + self.output_name = output_name + self.input_subworkflow_step_id = input_subworkflow_step_id + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeInputConnection): + return bool( + self.id == other.id + and self.output_name == other.output_name + and self.input_subworkflow_step_id == other.input_subworkflow_step_id + ) + return False + + def __hash__(self) -> int: + return hash((self.id, self.output_name, self.input_subworkflow_step_id)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeInputConnection": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("id") is None: + raise ValidationException("missing required field `id`", None, []) + + id = load_field( + _doc.get("id"), + inttype, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -5824,13 +5020,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5842,75 +5038,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - data = None - if "data" in _doc: - try: - data = load_field( - _doc.get("data"), - union_of_None_type_or_NativeFrameCommentDataLoader, - baseuri, - loadingOptions, - lc=_doc.get("data") - ) + try: + if _doc.get("output_name") is None: + raise ValidationException("missing required field `output_name`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + output_name = load_field( + _doc.get("output_name"), + strtype, + baseuri, + loadingOptions, + lc=_doc.get("output_name") + ) - if str(e) == "missing required field `data`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `output_name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("output_name") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `output_name` field is not valid because:", + SourceLine(_doc, "output_name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("data") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `data` field is not valid because:", - SourceLine(_doc, "data", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `data` field is not valid because:", - SourceLine(_doc, "data", str), - [e], - detailed_message=f"the `data` field with value `{val}` " - "is not valid because:", - ) + _errors__.append( + ValidationException( + "the `output_name` field is not valid because:", + SourceLine(_doc, "output_name", str), + [e], + detailed_message=f"the `output_name` field with value `{val}` " + "is not valid because:", ) - child_steps = None - if "child_steps" in _doc: + ) + input_subworkflow_step_id = None + if "input_subworkflow_step_id" in _doc: try: - child_steps = load_field( - _doc.get("child_steps"), - union_of_None_type_or_array_of_inttype, + input_subworkflow_step_id = load_field( + _doc.get("input_subworkflow_step_id"), + union_of_None_type_or_inttype, baseuri, loadingOptions, - lc=_doc.get("child_steps") + lc=_doc.get("input_subworkflow_step_id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `child_steps`": + if str(e) == "missing required field `input_subworkflow_step_id`": _errors__.append( ValidationException( str(e), @@ -5918,13 +5115,13 @@ def fromDoc( ) ) else: - val = _doc.get("child_steps") + val = _doc.get("input_subworkflow_step_id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `child_steps` field is not valid because:", - SourceLine(_doc, "child_steps", str), + "the `input_subworkflow_step_id` field is not valid because:", + SourceLine(_doc, "input_subworkflow_step_id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5936,64 +5133,17 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `child_steps` field is not valid because:", - SourceLine(_doc, "child_steps", str), + "the `input_subworkflow_step_id` field is not valid because:", + SourceLine(_doc, "input_subworkflow_step_id", str), [e], - detailed_message=f"the `child_steps` field with value `{val}` " + detailed_message=f"the `input_subworkflow_step_id` field with value `{val}` " "is not valid because:", ) ) - child_comments = None - if "child_comments" in _doc: - try: - child_comments = load_field( - _doc.get("child_comments"), - union_of_None_type_or_array_of_inttype, - baseuri, - loadingOptions, - lc=_doc.get("child_comments") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `child_comments`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("child_comments") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `child_comments` field is not valid because:", - SourceLine(_doc, "child_comments", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `child_comments` field is not valid because:", - SourceLine(_doc, "child_comments", str), - [e], - detailed_message=f"the `child_comments` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( ValidationException("mapping with implicit null key") ) @@ -6005,7 +5155,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `position`, `size`, `color`, `type`, `data`, `child_steps`, `child_comments`".format( + "invalid field `{}`, expected one of: `id`, `output_name`, `input_subworkflow_step_id`".format( k ), SourceLine(_doc, k, str), @@ -6016,13 +5166,8 @@ def fromDoc( raise ValidationException("", None, _errors__, "*") _constructed = cls( id=id, - position=position, - size=size, - color=color, - type_=type_, - data=data, - child_steps=child_steps, - child_comments=child_comments, + output_name=output_name, + input_subworkflow_step_id=input_subworkflow_step_id, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -6043,36 +5188,16 @@ def save( r["id"] = save( self.id, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.color is not None: - r["color"] = save( - self.color, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.data is not None: - r["data"] = save( - self.data, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.child_steps is not None: - r["child_steps"] = save( - self.child_steps, + if self.output_name is not None: + r["output_name"] = save( + self.output_name, top=False, base_url=base_url, relative_uris=relative_uris, ) - if self.child_comments is not None: - r["child_comments"] = save( - self.child_comments, + if self.input_subworkflow_step_id is not None: + r["input_subworkflow_step_id"] = save( + self.input_subworkflow_step_id, top=False, base_url=base_url, relative_uris=relative_uris, @@ -6086,34 +5211,27 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "id", - "position", - "size", - "color", - "type", - "data", - "child_steps", - "child_comments", - ] - ) + attrs = frozenset(["id", "output_name", "input_subworkflow_step_id"]) -class NativeFreehandComment(BaseNativeComment): +class NativePostJobAction(Saveable): """ - A freehand drawn line on the editor canvas. + An action applied to a step's output after tool execution. These objects + appear as values in the ``post_job_actions`` dictionary, keyed by + compound strings of the form ``{ActionType}{OutputName}`` + (e.g. ``HideDatasetActionout_pairs``). + + Common action types: ``HideDatasetAction``, ``RenameDatasetAction``, + ``DeleteIntermediatesAction``, ``ChangeDatatypeAction``, + ``TagDatasetAction``, ``ColumnSetAction``. """ def __init__( self, - id: Any, - type_: Any, - position: Optional[Any] = None, - size: Optional[Any] = None, - color: Optional[Any] = None, - data: Optional[Any] = None, + action_type: Any, + output_name: Any, + action_arguments: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -6125,29 +5243,21 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id - self.position = position - self.size = size - self.color = color - self.type_ = type_ - self.data = data + self.action_type = action_type + self.output_name = output_name + self.action_arguments = action_arguments def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeFreehandComment): + if isinstance(other, NativePostJobAction): return bool( - self.id == other.id - and self.position == other.position - and self.size == other.size - and self.color == other.color - and self.type_ == other.type_ - and self.data == other.data + self.action_type == other.action_type + and self.output_name == other.output_name + and self.action_arguments == other.action_arguments ) return False def __hash__(self) -> int: - return hash( - (self.id, self.position, self.size, self.color, self.type_, self.data) - ) + return hash((self.action_type, self.output_name, self.action_arguments)) @classmethod def fromDoc( @@ -6156,7 +5266,7 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "NativeFreehandComment": + ) -> "NativePostJobAction": _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -6164,21 +5274,21 @@ def fromDoc( _doc.lc.filename = doc.lc.filename _errors__ = [] try: - if _doc.get("id") is None: - raise ValidationException("missing required field `id`", None, []) + if _doc.get("action_type") is None: + raise ValidationException("missing required field `action_type`", None, []) - id = load_field( - _doc.get("id"), - inttype, + action_type = load_field( + _doc.get("action_type"), + strtype, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("action_type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `action_type`": _errors__.append( ValidationException( str(e), @@ -6186,13 +5296,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("action_type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `action_type` field is not valid because:", + SourceLine(_doc, "action_type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6204,28 +5314,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `action_type` field is not valid because:", + SourceLine(_doc, "action_type", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `action_type` field with value `{val}` " "is not valid because:", ) ) - position = None - if "position" in _doc: + try: + if _doc.get("output_name") is None: + raise ValidationException("missing required field `output_name`", None, []) + + output_name = load_field( + _doc.get("output_name"), + strtype, + baseuri, + loadingOptions, + lc=_doc.get("output_name") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `output_name`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("output_name") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `output_name` field is not valid because:", + SourceLine(_doc, "output_name", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `output_name` field is not valid because:", + SourceLine(_doc, "output_name", str), + [e], + detailed_message=f"the `output_name` field with value `{val}` " + "is not valid because:", + ) + ) + action_arguments = None + if "action_arguments" in _doc: try: - position = load_field( - _doc.get("position"), + action_arguments = load_field( + _doc.get("action_arguments"), union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("action_arguments") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `action_arguments`": _errors__.append( ValidationException( str(e), @@ -6233,13 +5391,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("action_arguments") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `action_arguments` field is not valid because:", + SourceLine(_doc, "action_arguments", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6251,42 +5409,174 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `action_arguments` field is not valid because:", + SourceLine(_doc, "action_arguments", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `action_arguments` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: - try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_Any_type, - baseuri, - loadingOptions, - lc=_doc.get("size") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `size`": + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `action_type`, `output_name`, `action_arguments`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + action_type=action_type, + output_name=output_name, + action_arguments=action_arguments, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.action_type is not None: + r["action_type"] = save( + self.action_type, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.output_name is not None: + r["output_name"] = save( + self.output_name, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + if self.action_arguments is not None: + r["action_arguments"] = save( + self.action_arguments, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["action_type", "output_name", "action_arguments"]) + + +class NativeTextCommentData(Saveable): + """ + Data payload for a text comment. + + """ + + def __init__( + self, + text: Optional[Any] = None, + bold: Optional[Any] = None, + italic: Optional[Any] = None, + size: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.text = text + self.bold = bold + self.italic = italic + self.size = size + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeTextCommentData): + return bool( + self.text == other.text + and self.bold == other.bold + and self.italic == other.italic + and self.size == other.size + ) + return False + + def __hash__(self) -> int: + return hash((self.text, self.bold, self.italic, self.size)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeTextCommentData": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + text = None + if "text" in _doc: + try: + text = load_field( + _doc.get("text"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("text") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `text`": + _errors__.append( + ValidationException( + str(e), None ) ) else: - val = _doc.get("size") + val = _doc.get("text") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `text` field is not valid because:", + SourceLine(_doc, "text", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6298,28 +5588,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `text` field is not valid because:", + SourceLine(_doc, "text", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `text` field with value `{val}` " "is not valid because:", ) ) - color = None - if "color" in _doc: + bold = None + if "bold" in _doc: try: - color = load_field( - _doc.get("color"), - union_of_None_type_or_strtype, + bold = load_field( + _doc.get("bold"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("color") + lc=_doc.get("bold") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `color`": + if str(e) == "missing required field `bold`": _errors__.append( ValidationException( str(e), @@ -6327,13 +5617,13 @@ def fromDoc( ) ) else: - val = _doc.get("color") + val = _doc.get("bold") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `bold` field is not valid because:", + SourceLine(_doc, "bold", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6345,76 +5635,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `bold` field is not valid because:", + SourceLine(_doc, "bold", str), [e], - detailed_message=f"the `color` field with value `{val}` " + detailed_message=f"the `bold` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - data = None - if "data" in _doc: + italic = None + if "italic" in _doc: try: - data = load_field( - _doc.get("data"), - union_of_None_type_or_NativeFreehandCommentDataLoader, + italic = load_field( + _doc.get("italic"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("data") + lc=_doc.get("italic") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `data`": + if str(e) == "missing required field `italic`": _errors__.append( ValidationException( str(e), @@ -6422,13 +5664,13 @@ def fromDoc( ) ) else: - val = _doc.get("data") + val = _doc.get("italic") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `data` field is not valid because:", - SourceLine(_doc, "data", str), + "the `italic` field is not valid because:", + SourceLine(_doc, "italic", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6440,10 +5682,57 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `data` field is not valid because:", - SourceLine(_doc, "data", str), + "the `italic` field is not valid because:", + SourceLine(_doc, "italic", str), [e], - detailed_message=f"the `data` field with value `{val}` " + detailed_message=f"the `italic` field with value `{val}` " + "is not valid because:", + ) + ) + size = None + if "size" in _doc: + try: + size = load_field( + _doc.get("size"), + union_of_None_type_or_floattype_or_inttype, + baseuri, + loadingOptions, + lc=_doc.get("size") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `size`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("size") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), + [e], + detailed_message=f"the `size` field with value `{val}` " "is not valid because:", ) ) @@ -6462,7 +5751,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `position`, `size`, `color`, `type`, `data`".format( + "invalid field `{}`, expected one of: `text`, `bold`, `italic`, `size`".format( k ), SourceLine(_doc, k, str), @@ -6472,12 +5761,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, - position=position, + text=text, + bold=bold, + italic=italic, size=size, - color=color, - type_=type_, - data=data, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -6494,30 +5781,22 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - r["id"] = save( - self.id, top=False, base_url=base_url, relative_uris=relative_uris + if self.text is not None: + r["text"] = save( + self.text, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris + if self.bold is not None: + r["bold"] = save( + self.bold, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.italic is not None: + r["italic"] = save( + self.italic, top=False, base_url=base_url, relative_uris=relative_uris ) if self.size is not None: r["size"] = save( self.size, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.color is not None: - r["color"] = save( - self.color, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.data is not None: - r["data"] = save( - self.data, top=False, base_url=base_url, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -6527,57 +5806,18 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["id", "position", "size", "color", "type", "data"]) + attrs = frozenset(["text", "bold", "italic", "size"]) -class NativeStep(HasStepErrors, HasStepPosition, HasUUID, ReferencesTool): +class NativeMarkdownCommentData(Saveable): """ - A step in a native Galaxy workflow. Steps are keyed by string integers - (``"0"``, ``"1"``, ...) in the ``steps`` dictionary. The key serves as - an external ID for connection wiring. - - The ``type`` field determines the step's behavior. All step types share - common fields; type-specific fields are optional and only relevant for - their respective type. - - # Tool State - - The ``tool_state`` field contains the tool's parameter configuration. - Traditionally this is a JSON-encoded string (double-encoded: each top-level - value is itself a JSON string), but it may also be a plain dictionary when - unencoded tool state is used. Connected parameters are represented as - ``{"__class__": "ConnectedValue"}``, runtime parameters as - ``{"__class__": "RuntimeValue"}``. + Data payload for a markdown comment. """ - name: str - def __init__( self, - errors: Optional[Any] = None, - position: Optional[Any] = None, - uuid: Optional[Any] = None, - tool_id: Optional[Any] = None, - tool_shed_repository: Optional[Any] = None, - tool_version: Optional[Any] = None, - id: Optional[Any] = None, - type_: Optional[Any] = None, - name: Optional[Any] = None, - label: Optional[Any] = None, - annotation: Optional[Any] = None, - when: Optional[Any] = None, - content_id: Optional[Any] = None, - tool_state: Optional[Any] = None, - tool_uuid: Optional[Any] = None, - input_connections: Optional[Any] = None, - inputs: Optional[Any] = None, - outputs: Optional[Any] = None, - workflow_outputs: Optional[Any] = None, - post_job_actions: Optional[Any] = None, - subworkflow: Optional[Any] = None, - tool_representation: Optional[Any] = None, - in_: Optional[Any] = None, + text: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -6589,87 +5829,15 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.errors = errors - self.position = position - self.uuid = uuid - self.tool_id = tool_id - self.tool_shed_repository = tool_shed_repository - self.tool_version = tool_version - self.id = id - self.type_ = type_ - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.annotation = annotation - self.when = when - self.content_id = content_id - self.tool_state = tool_state - self.tool_uuid = tool_uuid - self.input_connections = input_connections - self.inputs = inputs - self.outputs = outputs - self.workflow_outputs = workflow_outputs - self.post_job_actions = post_job_actions - self.subworkflow = subworkflow - self.tool_representation = tool_representation - self.in_ = in_ + self.text = text def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeStep): - return bool( - self.errors == other.errors - and self.position == other.position - and self.uuid == other.uuid - and self.tool_id == other.tool_id - and self.tool_shed_repository == other.tool_shed_repository - and self.tool_version == other.tool_version - and self.id == other.id - and self.type_ == other.type_ - and self.name == other.name - and self.label == other.label - and self.annotation == other.annotation - and self.when == other.when - and self.content_id == other.content_id - and self.tool_state == other.tool_state - and self.tool_uuid == other.tool_uuid - and self.input_connections == other.input_connections - and self.inputs == other.inputs - and self.outputs == other.outputs - and self.workflow_outputs == other.workflow_outputs - and self.post_job_actions == other.post_job_actions - and self.subworkflow == other.subworkflow - and self.tool_representation == other.tool_representation - and self.in_ == other.in_ - ) + if isinstance(other, NativeMarkdownCommentData): + return bool(self.text == other.text) return False def __hash__(self) -> int: - return hash( - ( - self.errors, - self.position, - self.uuid, - self.tool_id, - self.tool_shed_repository, - self.tool_version, - self.id, - self.type_, - self.name, - self.label, - self.annotation, - self.when, - self.content_id, - self.tool_state, - self.tool_uuid, - self.input_connections, - self.inputs, - self.outputs, - self.workflow_outputs, - self.post_job_actions, - self.subworkflow, - self.tool_representation, - self.in_, - ) - ) + return hash((self.text)) @classmethod def fromDoc( @@ -6678,28 +5846,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "NativeStep": + ) -> "NativeMarkdownCommentData": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + text = None + if "text" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + text = load_field( + _doc.get("text"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("text") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `text`": _errors__.append( ValidationException( str(e), @@ -6707,13 +5875,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("text") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `text` field is not valid because:", + SourceLine(_doc, "text", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6725,37 +5893,128 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `text` field is not valid because:", + SourceLine(_doc, "text", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `text` field with value `{val}` " "is not valid because:", ) ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - union_of_None_type_or_inttype, + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `text`".format(k), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + text=text, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.text is not None: + r["text"] = save( + self.text, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["text"]) + + +class NativeFrameCommentData(Saveable): + """ + Data payload for a frame comment. + + """ + + def __init__( + self, + title: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.title = title + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeFrameCommentData): + return bool(self.title == other.title) + return False + + def __hash__(self) -> int: + return hash((self.title)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeFrameCommentData": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + title = None + if "title" in _doc: + try: + title = load_field( + _doc.get("title"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("title") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `title`": _errors__.append( ValidationException( str(e), @@ -6763,13 +6022,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("title") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `title` field is not valid because:", + SourceLine(_doc, "title", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6781,28 +6040,130 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `title` field is not valid because:", + SourceLine(_doc, "title", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `title` field with value `{val}` " "is not valid because:", ) ) - errors = None - if "errors" in _doc: + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `title`".format(k), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + title=title, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.title is not None: + r["title"] = save( + self.title, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["title"]) + + +class NativeFreehandCommentData(Saveable): + """ + Data payload for a freehand comment. + + """ + + def __init__( + self, + line: Optional[Any] = None, + thickness: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.line = line + self.thickness = thickness + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeFreehandCommentData): + return bool(self.line == other.line and self.thickness == other.thickness) + return False + + def __hash__(self) -> int: + return hash((self.line, self.thickness)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeFreehandCommentData": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + line = None + if "line" in _doc: try: - errors = load_field( - _doc.get("errors"), - union_of_None_type_or_strtype, + line = load_field( + _doc.get("line"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("errors") + lc=_doc.get("line") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `errors`": + if str(e) == "missing required field `line`": _errors__.append( ValidationException( str(e), @@ -6810,13 +6171,13 @@ def fromDoc( ) ) else: - val = _doc.get("errors") + val = _doc.get("line") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `errors` field is not valid because:", - SourceLine(_doc, "errors", str), + "the `line` field is not valid because:", + SourceLine(_doc, "line", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6828,28 +6189,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `errors` field is not valid because:", - SourceLine(_doc, "errors", str), + "the `line` field is not valid because:", + SourceLine(_doc, "line", str), [e], - detailed_message=f"the `errors` field with value `{val}` " + detailed_message=f"the `line` field with value `{val}` " "is not valid because:", ) ) - position = None - if "position" in _doc: + thickness = None + if "thickness" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_StepPositionLoader, + thickness = load_field( + _doc.get("thickness"), + union_of_None_type_or_floattype_or_inttype, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("thickness") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `thickness`": _errors__.append( ValidationException( str(e), @@ -6857,13 +6218,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("thickness") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `thickness` field is not valid because:", + SourceLine(_doc, "thickness", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6875,28 +6236,214 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `thickness` field is not valid because:", + SourceLine(_doc, "thickness", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `thickness` field with value `{val}` " "is not valid because:", ) ) - uuid = None - if "uuid" in _doc: + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `line`, `thickness`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + line=line, + thickness=thickness, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.line is not None: + r["line"] = save( + self.line, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.thickness is not None: + r["thickness"] = save( + self.thickness, + top=False, + base_url=base_url, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["line", "thickness"]) + + +class BaseNativeComment(Saveable): + """ + Base fields shared by all comment types. + + """ + + pass + + +class NativeTextComment(BaseNativeComment): + """ + A plain text annotation in the workflow editor. + + """ + + def __init__( + self, + id: Any, + type_: Any, + position: Optional[Any] = None, + size: Optional[Any] = None, + color: Optional[Any] = None, + data: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id + self.position = position + self.size = size + self.color = color + self.type_ = type_ + self.data = data + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeTextComment): + return bool( + self.id == other.id + and self.position == other.position + and self.size == other.size + and self.color == other.color + and self.type_ == other.type_ + and self.data == other.data + ) + return False + + def __hash__(self) -> int: + return hash( + (self.id, self.position, self.size, self.color, self.type_, self.data) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeTextComment": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("id") is None: + raise ValidationException("missing required field `id`", None, []) + + id = load_field( + _doc.get("id"), + inttype, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + position = None + if "position" in _doc: try: - uuid = load_field( - _doc.get("uuid"), - union_of_None_type_or_strtype, + position = load_field( + _doc.get("position"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("uuid") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `uuid`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -6904,13 +6451,13 @@ def fromDoc( ) ) else: - val = _doc.get("uuid") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `uuid` field is not valid because:", - SourceLine(_doc, "uuid", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6922,28 +6469,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `uuid` field is not valid because:", - SourceLine(_doc, "uuid", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `uuid` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - tool_id = None - if "tool_id" in _doc: + size = None + if "size" in _doc: try: - tool_id = load_field( - _doc.get("tool_id"), - union_of_None_type_or_strtype, + size = load_field( + _doc.get("size"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("tool_id") + lc=_doc.get("size") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_id`": + if str(e) == "missing required field `size`": _errors__.append( ValidationException( str(e), @@ -6951,13 +6498,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_id") + val = _doc.get("size") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_id` field is not valid because:", - SourceLine(_doc, "tool_id", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6969,28 +6516,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_id` field is not valid because:", - SourceLine(_doc, "tool_id", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [e], - detailed_message=f"the `tool_id` field with value `{val}` " + detailed_message=f"the `size` field with value `{val}` " "is not valid because:", ) ) - tool_shed_repository = None - if "tool_shed_repository" in _doc: + color = None + if "color" in _doc: try: - tool_shed_repository = load_field( - _doc.get("tool_shed_repository"), - union_of_None_type_or_ToolShedRepositoryLoader, + color = load_field( + _doc.get("color"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("tool_shed_repository") + lc=_doc.get("color") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_shed_repository`": + if str(e) == "missing required field `color`": _errors__.append( ValidationException( str(e), @@ -6998,13 +6545,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_shed_repository") + val = _doc.get("color") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_shed_repository` field is not valid because:", - SourceLine(_doc, "tool_shed_repository", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7016,122 +6563,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_shed_repository` field is not valid because:", - SourceLine(_doc, "tool_shed_repository", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [e], - detailed_message=f"the `tool_shed_repository` field with value `{val}` " + detailed_message=f"the `color` field with value `{val}` " "is not valid because:", ) ) - tool_version = None - if "tool_version" in _doc: - try: - tool_version = load_field( - _doc.get("tool_version"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("tool_version") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = load_field( + _doc.get("type"), + typedsl_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `tool_version`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("tool_version") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `tool_version` field is not valid because:", - SourceLine(_doc, "tool_version", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `tool_version` field is not valid because:", - SourceLine(_doc, "tool_version", str), - [e], - detailed_message=f"the `tool_version` field with value `{val}` " - "is not valid because:", - ) - ) - type_ = None - if "type" in _doc: - try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_None_type_or_NativeStepTypeLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - label = None - if "label" in _doc: + data = None + if "data" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + data = load_field( + _doc.get("data"), + union_of_None_type_or_NativeTextCommentDataLoader, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("data") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `data`": _errors__.append( ValidationException( str(e), @@ -7139,13 +6640,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("data") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `data` field is not valid because:", + SourceLine(_doc, "data", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7157,122 +6658,222 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `data` field is not valid because:", + SourceLine(_doc, "data", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `data` field with value `{val}` " "is not valid because:", ) ) - annotation = None - if "annotation" in _doc: - try: - annotation = load_field( - _doc.get("annotation"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("annotation") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `annotation`": + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("annotation") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `annotation` field is not valid because:", - SourceLine(_doc, "annotation", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `annotation` field is not valid because:", - SourceLine(_doc, "annotation", str), - [e], - detailed_message=f"the `annotation` field with value `{val}` " - "is not valid because:", - ) - ) - when = None - if "when" in _doc: - try: - when = load_field( - _doc.get("when"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("when") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `when`": _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `id`, `position`, `size`, `color`, `type`, `data`".format( + k + ), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("when") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `when` field is not valid because:", - SourceLine(_doc, "when", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + id=id, + position=position, + size=size, + color=color, + type_=type_, + data=data, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.id is not None: + r["id"] = save( + self.id, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.color is not None: + r["color"] = save( + self.color, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.data is not None: + r["data"] = save( + self.data, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["id", "position", "size", "color", "type", "data"]) + + +class NativeMarkdownComment(BaseNativeComment): + """ + A Markdown-rendered annotation in the workflow editor. + + """ + + def __init__( + self, + id: Any, + type_: Any, + position: Optional[Any] = None, + size: Optional[Any] = None, + color: Optional[Any] = None, + data: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id + self.position = position + self.size = size + self.color = color + self.type_ = type_ + self.data = data + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeMarkdownComment): + return bool( + self.id == other.id + and self.position == other.position + and self.size == other.size + and self.color == other.color + and self.type_ == other.type_ + and self.data == other.data + ) + return False + + def __hash__(self) -> int: + return hash( + (self.id, self.position, self.size, self.color, self.type_, self.data) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeMarkdownComment": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("id") is None: + raise ValidationException("missing required field `id`", None, []) + + id = load_field( + _doc.get("id"), + inttype, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) - else: - _errors__.append( - ValidationException( - "the `when` field is not valid because:", - SourceLine(_doc, "when", str), - [e], - detailed_message=f"the `when` field with value `{val}` " - "is not valid because:", - ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", ) - content_id = None - if "content_id" in _doc: + ) + position = None + if "position" in _doc: try: - content_id = load_field( - _doc.get("content_id"), - union_of_None_type_or_strtype, + position = load_field( + _doc.get("position"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("content_id") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `content_id`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -7280,13 +6881,13 @@ def fromDoc( ) ) else: - val = _doc.get("content_id") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `content_id` field is not valid because:", - SourceLine(_doc, "content_id", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7298,28 +6899,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `content_id` field is not valid because:", - SourceLine(_doc, "content_id", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `content_id` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - tool_state = None - if "tool_state" in _doc: + size = None + if "size" in _doc: try: - tool_state = load_field( - _doc.get("tool_state"), - union_of_None_type_or_strtype_or_Any_type, + size = load_field( + _doc.get("size"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("tool_state") + lc=_doc.get("size") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_state`": + if str(e) == "missing required field `size`": _errors__.append( ValidationException( str(e), @@ -7327,13 +6928,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_state") + val = _doc.get("size") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_state` field is not valid because:", - SourceLine(_doc, "tool_state", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7345,28 +6946,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_state` field is not valid because:", - SourceLine(_doc, "tool_state", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [e], - detailed_message=f"the `tool_state` field with value `{val}` " + detailed_message=f"the `size` field with value `{val}` " "is not valid because:", ) ) - tool_uuid = None - if "tool_uuid" in _doc: + color = None + if "color" in _doc: try: - tool_uuid = load_field( - _doc.get("tool_uuid"), + color = load_field( + _doc.get("color"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("tool_uuid") + lc=_doc.get("color") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_uuid`": + if str(e) == "missing required field `color`": _errors__.append( ValidationException( str(e), @@ -7374,13 +6975,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_uuid") + val = _doc.get("color") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_uuid` field is not valid because:", - SourceLine(_doc, "tool_uuid", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7392,122 +6993,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_uuid` field is not valid because:", - SourceLine(_doc, "tool_uuid", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [e], - detailed_message=f"the `tool_uuid` field with value `{val}` " + detailed_message=f"the `color` field with value `{val}` " "is not valid because:", ) ) - input_connections = None - if "input_connections" in _doc: - try: - input_connections = load_field( - _doc.get("input_connections"), - union_of_None_type_or_Any_type, - baseuri, - loadingOptions, - lc=_doc.get("input_connections") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = load_field( + _doc.get("type"), + typedsl_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `input_connections`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("input_connections") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `input_connections` field is not valid because:", - SourceLine(_doc, "input_connections", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `input_connections` field is not valid because:", - SourceLine(_doc, "input_connections", str), - [e], - detailed_message=f"the `input_connections` field with value `{val}` " - "is not valid because:", - ) - ) - inputs = None - if "inputs" in _doc: - try: - inputs = load_field( - _doc.get("inputs"), - union_of_None_type_or_array_of_NativeStepInputLoader, - baseuri, - loadingOptions, - lc=_doc.get("inputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `inputs`": _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("inputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `inputs` field is not valid because:", - SourceLine(_doc, "inputs", str), - [e], - detailed_message=f"the `inputs` field with value `{val}` " - "is not valid because:", - ) - ) - outputs = None - if "outputs" in _doc: + data = None + if "data" in _doc: try: - outputs = load_field( - _doc.get("outputs"), - union_of_None_type_or_array_of_NativeStepOutputLoader, + data = load_field( + _doc.get("data"), + union_of_None_type_or_NativeMarkdownCommentDataLoader, baseuri, loadingOptions, - lc=_doc.get("outputs") + lc=_doc.get("data") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `outputs`": + if str(e) == "missing required field `data`": _errors__.append( ValidationException( str(e), @@ -7515,13 +7070,13 @@ def fromDoc( ) ) else: - val = _doc.get("outputs") + val = _doc.get("data") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), + "the `data` field is not valid because:", + SourceLine(_doc, "data", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7533,122 +7088,237 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `outputs` field is not valid because:", - SourceLine(_doc, "outputs", str), + "the `data` field is not valid because:", + SourceLine(_doc, "data", str), [e], - detailed_message=f"the `outputs` field with value `{val}` " + detailed_message=f"the `data` field with value `{val}` " "is not valid because:", ) ) - workflow_outputs = None - if "workflow_outputs" in _doc: - try: - workflow_outputs = load_field( - _doc.get("workflow_outputs"), - union_of_None_type_or_array_of_NativeWorkflowOutputLoader, - baseuri, - loadingOptions, - lc=_doc.get("workflow_outputs") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `workflow_outputs`": + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("workflow_outputs") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `workflow_outputs` field is not valid because:", - SourceLine(_doc, "workflow_outputs", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `workflow_outputs` field is not valid because:", - SourceLine(_doc, "workflow_outputs", str), - [e], - detailed_message=f"the `workflow_outputs` field with value `{val}` " - "is not valid because:", - ) - ) - post_job_actions = None - if "post_job_actions" in _doc: - try: - post_job_actions = load_field( - _doc.get("post_job_actions"), - union_of_None_type_or_Any_type, - baseuri, - loadingOptions, - lc=_doc.get("post_job_actions") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `post_job_actions`": _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `id`, `position`, `size`, `color`, `type`, `data`".format( + k + ), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("post_job_actions") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `post_job_actions` field is not valid because:", - SourceLine(_doc, "post_job_actions", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `post_job_actions` field is not valid because:", - SourceLine(_doc, "post_job_actions", str), - [e], - detailed_message=f"the `post_job_actions` field with value `{val}` " - "is not valid because:", - ) - ) - subworkflow = None - if "subworkflow" in _doc: + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + id=id, + position=position, + size=size, + color=color, + type_=type_, + data=data, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.id is not None: + r["id"] = save( + self.id, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.color is not None: + r["color"] = save( + self.color, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.data is not None: + r["data"] = save( + self.data, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["id", "position", "size", "color", "type", "data"]) + + +class NativeFrameComment(BaseNativeComment): + """ + A rectangular grouping box that visually contains steps and other comments. + + """ + + def __init__( + self, + id: Any, + type_: Any, + position: Optional[Any] = None, + size: Optional[Any] = None, + color: Optional[Any] = None, + data: Optional[Any] = None, + child_steps: Optional[Any] = None, + child_comments: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.id = id + self.position = position + self.size = size + self.color = color + self.type_ = type_ + self.data = data + self.child_steps = child_steps + self.child_comments = child_comments + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeFrameComment): + return bool( + self.id == other.id + and self.position == other.position + and self.size == other.size + and self.color == other.color + and self.type_ == other.type_ + and self.data == other.data + and self.child_steps == other.child_steps + and self.child_comments == other.child_comments + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.id, + self.position, + self.size, + self.color, + self.type_, + self.data, + self.child_steps, + self.child_comments, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeFrameComment": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("id") is None: + raise ValidationException("missing required field `id`", None, []) + + id = load_field( + _doc.get("id"), + inttype, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + position = None + if "position" in _doc: try: - subworkflow = load_field( - _doc.get("subworkflow"), + position = load_field( + _doc.get("position"), union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("subworkflow") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `subworkflow`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -7656,13 +7326,13 @@ def fromDoc( ) ) else: - val = _doc.get("subworkflow") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `subworkflow` field is not valid because:", - SourceLine(_doc, "subworkflow", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7674,28 +7344,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `subworkflow` field is not valid because:", - SourceLine(_doc, "subworkflow", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `subworkflow` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - tool_representation = None - if "tool_representation" in _doc: + size = None + if "size" in _doc: try: - tool_representation = load_field( - _doc.get("tool_representation"), + size = load_field( + _doc.get("size"), union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("tool_representation") + lc=_doc.get("size") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_representation`": + if str(e) == "missing required field `size`": _errors__.append( ValidationException( str(e), @@ -7703,13 +7373,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_representation") + val = _doc.get("size") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_representation` field is not valid because:", - SourceLine(_doc, "tool_representation", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7721,28 +7391,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_representation` field is not valid because:", - SourceLine(_doc, "tool_representation", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [e], - detailed_message=f"the `tool_representation` field with value `{val}` " + detailed_message=f"the `size` field with value `{val}` " "is not valid because:", ) ) - in_ = None - if "in" in _doc: + color = None + if "color" in _doc: try: - in_ = load_field( - _doc.get("in"), - union_of_None_type_or_Any_type, + color = load_field( + _doc.get("color"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("in") + lc=_doc.get("color") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `in`": + if str(e) == "missing required field `color`": _errors__.append( ValidationException( str(e), @@ -7750,13 +7420,13 @@ def fromDoc( ) ) else: - val = _doc.get("in") + val = _doc.get("color") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7768,10 +7438,199 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [e], - detailed_message=f"the `in` field with value `{val}` " + detailed_message=f"the `color` field with value `{val}` " + "is not valid because:", + ) + ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + data = None + if "data" in _doc: + try: + data = load_field( + _doc.get("data"), + union_of_None_type_or_NativeFrameCommentDataLoader, + baseuri, + loadingOptions, + lc=_doc.get("data") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `data`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("data") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `data` field is not valid because:", + SourceLine(_doc, "data", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `data` field is not valid because:", + SourceLine(_doc, "data", str), + [e], + detailed_message=f"the `data` field with value `{val}` " + "is not valid because:", + ) + ) + child_steps = None + if "child_steps" in _doc: + try: + child_steps = load_field( + _doc.get("child_steps"), + union_of_None_type_or_array_of_inttype, + baseuri, + loadingOptions, + lc=_doc.get("child_steps") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `child_steps`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("child_steps") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `child_steps` field is not valid because:", + SourceLine(_doc, "child_steps", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `child_steps` field is not valid because:", + SourceLine(_doc, "child_steps", str), + [e], + detailed_message=f"the `child_steps` field with value `{val}` " + "is not valid because:", + ) + ) + child_comments = None + if "child_comments" in _doc: + try: + child_comments = load_field( + _doc.get("child_comments"), + union_of_None_type_or_array_of_inttype, + baseuri, + loadingOptions, + lc=_doc.get("child_comments") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `child_comments`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("child_comments") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `child_comments` field is not valid because:", + SourceLine(_doc, "child_comments", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `child_comments` field is not valid because:", + SourceLine(_doc, "child_comments", str), + [e], + detailed_message=f"the `child_comments` field with value `{val}` " "is not valid because:", ) ) @@ -7790,7 +7649,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `errors`, `position`, `uuid`, `tool_id`, `tool_shed_repository`, `tool_version`, `id`, `type`, `name`, `label`, `annotation`, `when`, `content_id`, `tool_state`, `tool_uuid`, `input_connections`, `inputs`, `outputs`, `workflow_outputs`, `post_job_actions`, `subworkflow`, `tool_representation`, `in`".format( + "invalid field `{}`, expected one of: `id`, `position`, `size`, `color`, `type`, `data`, `child_steps`, `child_comments`".format( k ), SourceLine(_doc, k, str), @@ -7800,33 +7659,17 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - errors=errors, - position=position, - uuid=uuid, - tool_id=tool_id, - tool_shed_repository=tool_shed_repository, - tool_version=tool_version, id=id, + position=position, + size=size, + color=color, type_=type_, - name=name, - label=label, - annotation=annotation, - when=when, - content_id=content_id, - tool_state=tool_state, - tool_uuid=tool_uuid, - input_connections=input_connections, - inputs=inputs, - outputs=outputs, - workflow_outputs=workflow_outputs, - post_job_actions=post_job_actions, - subworkflow=subworkflow, - tool_representation=tool_representation, - in_=in_, + data=data, + child_steps=child_steps, + child_comments=child_comments, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -7840,133 +7683,44 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u if self.id is not None: r["id"] = save( - self.id, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.errors is not None: - r["errors"] = save( - self.errors, top=False, base_url=self.name, relative_uris=relative_uris + self.id, top=False, base_url=base_url, relative_uris=relative_uris ) if self.position is not None: r["position"] = save( - self.position, - top=False, - base_url=self.name, - relative_uris=relative_uris, + self.position, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.uuid is not None: - r["uuid"] = save( - self.uuid, top=False, base_url=self.name, relative_uris=relative_uris + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.tool_id is not None: - r["tool_id"] = save( - self.tool_id, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.tool_shed_repository is not None: - r["tool_shed_repository"] = save( - self.tool_shed_repository, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.tool_version is not None: - r["tool_version"] = save( - self.tool_version, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.color is not None: + r["color"] = save( + self.color, top=False, base_url=base_url, relative_uris=relative_uris ) if self.type_ is not None: r["type"] = save( - self.type_, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.annotation is not None: - r["annotation"] = save( - self.annotation, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.when is not None: - r["when"] = save( - self.when, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.content_id is not None: - r["content_id"] = save( - self.content_id, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.tool_state is not None: - r["tool_state"] = save( - self.tool_state, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.tool_uuid is not None: - r["tool_uuid"] = save( - self.tool_uuid, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.input_connections is not None: - r["input_connections"] = save( - self.input_connections, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.inputs is not None: - r["inputs"] = save( - self.inputs, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.outputs is not None: - r["outputs"] = save( - self.outputs, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.workflow_outputs is not None: - r["workflow_outputs"] = save( - self.workflow_outputs, - top=False, - base_url=self.name, - relative_uris=relative_uris, + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.post_job_actions is not None: - r["post_job_actions"] = save( - self.post_job_actions, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.data is not None: + r["data"] = save( + self.data, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.subworkflow is not None: - r["subworkflow"] = save( - self.subworkflow, + if self.child_steps is not None: + r["child_steps"] = save( + self.child_steps, top=False, - base_url=self.name, + base_url=base_url, relative_uris=relative_uris, ) - if self.tool_representation is not None: - r["tool_representation"] = save( - self.tool_representation, + if self.child_comments is not None: + r["child_comments"] = save( + self.child_comments, top=False, - base_url=self.name, + base_url=base_url, relative_uris=relative_uris, ) - if self.in_ is not None: - r["in"] = save( - self.in_, top=False, base_url=self.name, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -7978,42 +7732,32 @@ def save( attrs = frozenset( [ - "errors", - "position", - "uuid", - "tool_id", - "tool_shed_repository", - "tool_version", "id", + "position", + "size", + "color", "type", - "name", - "label", - "annotation", - "when", - "content_id", - "tool_state", - "tool_uuid", - "input_connections", - "inputs", - "outputs", - "workflow_outputs", - "post_job_actions", - "subworkflow", - "tool_representation", - "in", + "data", + "child_steps", + "child_comments", ] ) -class NativeReport(Saveable): +class NativeFreehandComment(BaseNativeComment): """ - Workflow invocation report template. + A freehand drawn line on the editor canvas. """ def __init__( self, - markdown: Any, + id: Any, + type_: Any, + position: Optional[Any] = None, + size: Optional[Any] = None, + color: Optional[Any] = None, + data: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -8025,15 +7769,29 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.markdown = markdown + self.id = id + self.position = position + self.size = size + self.color = color + self.type_ = type_ + self.data = data def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeReport): - return bool(self.markdown == other.markdown) + if isinstance(other, NativeFreehandComment): + return bool( + self.id == other.id + and self.position == other.position + and self.size == other.size + and self.color == other.color + and self.type_ == other.type_ + and self.data == other.data + ) return False def __hash__(self) -> int: - return hash((self.markdown)) + return hash( + (self.id, self.position, self.size, self.color, self.type_, self.data) + ) @classmethod def fromDoc( @@ -8042,7 +7800,7 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "NativeReport": + ) -> "NativeFreehandComment": _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -8050,21 +7808,21 @@ def fromDoc( _doc.lc.filename = doc.lc.filename _errors__ = [] try: - if _doc.get("markdown") is None: - raise ValidationException("missing required field `markdown`", None, []) + if _doc.get("id") is None: + raise ValidationException("missing required field `id`", None, []) - markdown = load_field( - _doc.get("markdown"), - strtype, + id = load_field( + _doc.get("id"), + inttype, baseuri, loadingOptions, - lc=_doc.get("markdown") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `markdown`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -8072,13 +7830,13 @@ def fromDoc( ) ) else: - val = _doc.get("markdown") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `markdown` field is not valid because:", - SourceLine(_doc, "markdown", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8090,202 +7848,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `markdown` field is not valid because:", - SourceLine(_doc, "markdown", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `markdown` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + position = None + if "position" in _doc: + try: + position = load_field( + _doc.get("position"), + union_of_None_type_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("position") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `position`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `markdown`".format(k), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - markdown=markdown, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.markdown is not None: - r["markdown"] = save( - self.markdown, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["markdown"]) - - -class BaseNativeCreator(Saveable): - """ - Base fields shared by all creator types, corresponding to schema.org - Thing properties common to both Person and Organization. - - """ - - pass - - -class NativeCreatorPerson(BaseNativeCreator): - """ - A person who created or contributed to the workflow. - Corresponds to a `schema.org Person `_. - - """ - - name: str - - def __init__( - self, - name: Optional[Any] = None, - identifier: Optional[Any] = None, - url: Optional[Any] = None, - email: Optional[Any] = None, - image: Optional[Any] = None, - address: Optional[Any] = None, - alternateName: Optional[Any] = None, - telephone: Optional[Any] = None, - faxNumber: Optional[Any] = None, - givenName: Optional[Any] = None, - familyName: Optional[Any] = None, - honorificPrefix: Optional[Any] = None, - honorificSuffix: Optional[Any] = None, - jobTitle: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.identifier = identifier - self.url = url - self.email = email - self.image = image - self.address = address - self.alternateName = alternateName - self.telephone = telephone - self.faxNumber = faxNumber - self.class_ = "NativeCreatorPerson" - self.givenName = givenName - self.familyName = familyName - self.honorificPrefix = honorificPrefix - self.honorificSuffix = honorificSuffix - self.jobTitle = jobTitle - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeCreatorPerson): - return bool( - self.name == other.name - and self.identifier == other.identifier - and self.url == other.url - and self.email == other.email - and self.image == other.image - and self.address == other.address - and self.alternateName == other.alternateName - and self.telephone == other.telephone - and self.faxNumber == other.faxNumber - and self.class_ == other.class_ - and self.givenName == other.givenName - and self.familyName == other.familyName - and self.honorificPrefix == other.honorificPrefix - and self.honorificSuffix == other.honorificSuffix - and self.jobTitle == other.jobTitle - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.name, - self.identifier, - self.url, - self.email, - self.image, - self.address, - self.alternateName, - self.telephone, - self.faxNumber, - self.class_, - self.givenName, - self.familyName, - self.honorificPrefix, - self.honorificSuffix, - self.jobTitle, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeCreatorPerson": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) + else: + val = _doc.get("position") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), + [e], + detailed_message=f"the `position` field with value `{val}` " + "is not valid because:", + ) + ) + size = None + if "size" in _doc: + try: + size = load_field( + _doc.get("size"), + union_of_None_type_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("size") + ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `size`": _errors__.append( ValidationException( str(e), @@ -8293,13 +7924,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("size") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8311,53 +7942,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `size` field with value `{val}` " "is not valid because:", ) ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_NativeCreatorPersonTypeLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - identifier = None - if "identifier" in _doc: + color = None + if "color" in _doc: try: - identifier = load_field( - _doc.get("identifier"), + color = load_field( + _doc.get("color"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("identifier") + lc=_doc.get("color") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `identifier`": + if str(e) == "missing required field `color`": _errors__.append( ValidationException( str(e), @@ -8365,13 +7971,13 @@ def fromDoc( ) ) else: - val = _doc.get("identifier") + val = _doc.get("color") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `identifier` field is not valid because:", - SourceLine(_doc, "identifier", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8383,122 +7989,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `identifier` field is not valid because:", - SourceLine(_doc, "identifier", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [e], - detailed_message=f"the `identifier` field with value `{val}` " + detailed_message=f"the `color` field with value `{val}` " "is not valid because:", ) ) - url = None - if "url" in _doc: - try: - url = load_field( - _doc.get("url"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("url") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = load_field( + _doc.get("type"), + typedsl_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `url`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("url") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `url` field is not valid because:", - SourceLine(_doc, "url", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `url` field is not valid because:", - SourceLine(_doc, "url", str), - [e], - detailed_message=f"the `url` field with value `{val}` " - "is not valid because:", - ) - ) - email = None - if "email" in _doc: - try: - email = load_field( - _doc.get("email"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("email") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `email`": _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("email") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `email` field is not valid because:", - SourceLine(_doc, "email", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `email` field is not valid because:", - SourceLine(_doc, "email", str), - [e], - detailed_message=f"the `email` field with value `{val}` " - "is not valid because:", - ) - ) - image = None - if "image" in _doc: + data = None + if "data" in _doc: try: - image = load_field( - _doc.get("image"), - union_of_None_type_or_strtype, + data = load_field( + _doc.get("data"), + union_of_None_type_or_NativeFreehandCommentDataLoader, baseuri, loadingOptions, - lc=_doc.get("image") + lc=_doc.get("data") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `image`": + if str(e) == "missing required field `data`": _errors__.append( ValidationException( str(e), @@ -8506,13 +8066,13 @@ def fromDoc( ) ) else: - val = _doc.get("image") + val = _doc.get("data") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `image` field is not valid because:", - SourceLine(_doc, "image", str), + "the `data` field is not valid because:", + SourceLine(_doc, "data", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8524,169 +8084,266 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `image` field is not valid because:", - SourceLine(_doc, "image", str), + "the `data` field is not valid because:", + SourceLine(_doc, "data", str), [e], - detailed_message=f"the `image` field with value `{val}` " + detailed_message=f"the `data` field with value `{val}` " "is not valid because:", ) ) - address = None - if "address" in _doc: - try: - address = load_field( - _doc.get("address"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("address") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `address`": + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: _errors__.append( - ValidationException( - str(e), - None - ) + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False ) + extension_fields[ex] = _doc[k] else: - val = _doc.get("address") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `address` field is not valid because:", - SourceLine(_doc, "address", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `address` field is not valid because:", - SourceLine(_doc, "address", str), - [e], - detailed_message=f"the `address` field with value `{val}` " - "is not valid because:", - ) - ) - alternateName = None - if "alternateName" in _doc: - try: - alternateName = load_field( - _doc.get("alternateName"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("alternateName") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `alternateName`": _errors__.append( ValidationException( - str(e), - None + "invalid field `{}`, expected one of: `id`, `position`, `size`, `color`, `type`, `data`".format( + k + ), + SourceLine(_doc, k, str), ) ) - else: - val = _doc.get("alternateName") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `alternateName` field is not valid because:", - SourceLine(_doc, "alternateName", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `alternateName` field is not valid because:", - SourceLine(_doc, "alternateName", str), - [e], - detailed_message=f"the `alternateName` field with value `{val}` " - "is not valid because:", - ) - ) - telephone = None - if "telephone" in _doc: - try: - telephone = load_field( - _doc.get("telephone"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("telephone") - ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + id=id, + position=position, + size=size, + color=color, + type_=type_, + data=data, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed - if str(e) == "missing required field `telephone`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("telephone") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `telephone` field is not valid because:", - SourceLine(_doc, "telephone", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `telephone` field is not valid because:", - SourceLine(_doc, "telephone", str), - [e], - detailed_message=f"the `telephone` field with value `{val}` " - "is not valid because:", - ) - ) - faxNumber = None - if "faxNumber" in _doc: + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.id is not None: + r["id"] = save( + self.id, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.color is not None: + r["color"] = save( + self.color, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.data is not None: + r["data"] = save( + self.data, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["id", "position", "size", "color", "type", "data"]) + + +class NativeStep(HasStepErrors, HasStepPosition, HasUUID, ReferencesTool): + """ + A step in a native Galaxy workflow. Steps are keyed by string integers + (``"0"``, ``"1"``, ...) in the ``steps`` dictionary. The key serves as + an external ID for connection wiring. + + The ``type`` field determines the step's behavior. All step types share + common fields; type-specific fields are optional and only relevant for + their respective type. + + # Tool State + + The ``tool_state`` field contains the tool's parameter configuration. + Traditionally this is a JSON-encoded string (double-encoded: each top-level + value is itself a JSON string), but it may also be a plain dictionary when + unencoded tool state is used. Connected parameters are represented as + ``{"__class__": "ConnectedValue"}``, runtime parameters as + ``{"__class__": "RuntimeValue"}``. + + """ + + name: str + + def __init__( + self, + errors: Optional[Any] = None, + position: Optional[Any] = None, + uuid: Optional[Any] = None, + tool_id: Optional[Any] = None, + tool_shed_repository: Optional[Any] = None, + tool_version: Optional[Any] = None, + id: Optional[Any] = None, + type_: Optional[Any] = None, + name: Optional[Any] = None, + label: Optional[Any] = None, + annotation: Optional[Any] = None, + when: Optional[Any] = None, + content_id: Optional[Any] = None, + tool_state: Optional[Any] = None, + tool_uuid: Optional[Any] = None, + input_connections: Optional[Any] = None, + inputs: Optional[Any] = None, + outputs: Optional[Any] = None, + workflow_outputs: Optional[Any] = None, + post_job_actions: Optional[Any] = None, + subworkflow: Optional[Any] = None, + tool_representation: Optional[Any] = None, + in_: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.errors = errors + self.position = position + self.uuid = uuid + self.tool_id = tool_id + self.tool_shed_repository = tool_shed_repository + self.tool_version = tool_version + self.id = id + self.type_ = type_ + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.label = label + self.annotation = annotation + self.when = when + self.content_id = content_id + self.tool_state = tool_state + self.tool_uuid = tool_uuid + self.input_connections = input_connections + self.inputs = inputs + self.outputs = outputs + self.workflow_outputs = workflow_outputs + self.post_job_actions = post_job_actions + self.subworkflow = subworkflow + self.tool_representation = tool_representation + self.in_ = in_ + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeStep): + return bool( + self.errors == other.errors + and self.position == other.position + and self.uuid == other.uuid + and self.tool_id == other.tool_id + and self.tool_shed_repository == other.tool_shed_repository + and self.tool_version == other.tool_version + and self.id == other.id + and self.type_ == other.type_ + and self.name == other.name + and self.label == other.label + and self.annotation == other.annotation + and self.when == other.when + and self.content_id == other.content_id + and self.tool_state == other.tool_state + and self.tool_uuid == other.tool_uuid + and self.input_connections == other.input_connections + and self.inputs == other.inputs + and self.outputs == other.outputs + and self.workflow_outputs == other.workflow_outputs + and self.post_job_actions == other.post_job_actions + and self.subworkflow == other.subworkflow + and self.tool_representation == other.tool_representation + and self.in_ == other.in_ + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.errors, + self.position, + self.uuid, + self.tool_id, + self.tool_shed_repository, + self.tool_version, + self.id, + self.type_, + self.name, + self.label, + self.annotation, + self.when, + self.content_id, + self.tool_state, + self.tool_uuid, + self.input_connections, + self.inputs, + self.outputs, + self.workflow_outputs, + self.post_job_actions, + self.subworkflow, + self.tool_representation, + self.in_, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeStep": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + name = None + if "name" in _doc: try: - faxNumber = load_field( - _doc.get("faxNumber"), - union_of_None_type_or_strtype, + name = load_field( + _doc.get("name"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("faxNumber") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `faxNumber`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -8694,13 +8351,13 @@ def fromDoc( ) ) else: - val = _doc.get("faxNumber") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `faxNumber` field is not valid because:", - SourceLine(_doc, "faxNumber", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8712,42 +8369,51 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `faxNumber` field is not valid because:", - SourceLine(_doc, "faxNumber", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `faxNumber` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - givenName = None - if "givenName" in _doc: - try: - givenName = load_field( - _doc.get("givenName"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("givenName") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `givenName`": - _errors__.append( - ValidationException( + __original_name_is_none = name is None + if name is None: + if docRoot is not None: + name = docRoot + else: + name = "_:" + str(_uuid__.uuid4()) + if not __original_name_is_none: + baseuri = cast(str, name) + id = None + if "id" in _doc: + try: + id = load_field( + _doc.get("id"), + union_of_None_type_or_inttype, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( str(e), None ) ) else: - val = _doc.get("givenName") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `givenName` field is not valid because:", - SourceLine(_doc, "givenName", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8759,28 +8425,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `givenName` field is not valid because:", - SourceLine(_doc, "givenName", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `givenName` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - familyName = None - if "familyName" in _doc: + errors = None + if "errors" in _doc: try: - familyName = load_field( - _doc.get("familyName"), + errors = load_field( + _doc.get("errors"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("familyName") + lc=_doc.get("errors") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `familyName`": + if str(e) == "missing required field `errors`": _errors__.append( ValidationException( str(e), @@ -8788,13 +8454,13 @@ def fromDoc( ) ) else: - val = _doc.get("familyName") + val = _doc.get("errors") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `familyName` field is not valid because:", - SourceLine(_doc, "familyName", str), + "the `errors` field is not valid because:", + SourceLine(_doc, "errors", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8806,28 +8472,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `familyName` field is not valid because:", - SourceLine(_doc, "familyName", str), + "the `errors` field is not valid because:", + SourceLine(_doc, "errors", str), [e], - detailed_message=f"the `familyName` field with value `{val}` " + detailed_message=f"the `errors` field with value `{val}` " "is not valid because:", ) ) - honorificPrefix = None - if "honorificPrefix" in _doc: + position = None + if "position" in _doc: try: - honorificPrefix = load_field( - _doc.get("honorificPrefix"), - union_of_None_type_or_strtype, + position = load_field( + _doc.get("position"), + union_of_None_type_or_StepPositionLoader, baseuri, loadingOptions, - lc=_doc.get("honorificPrefix") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `honorificPrefix`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -8835,13 +8501,13 @@ def fromDoc( ) ) else: - val = _doc.get("honorificPrefix") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `honorificPrefix` field is not valid because:", - SourceLine(_doc, "honorificPrefix", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8853,28 +8519,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `honorificPrefix` field is not valid because:", - SourceLine(_doc, "honorificPrefix", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `honorificPrefix` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - honorificSuffix = None - if "honorificSuffix" in _doc: + uuid = None + if "uuid" in _doc: try: - honorificSuffix = load_field( - _doc.get("honorificSuffix"), + uuid = load_field( + _doc.get("uuid"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("honorificSuffix") + lc=_doc.get("uuid") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `honorificSuffix`": + if str(e) == "missing required field `uuid`": _errors__.append( ValidationException( str(e), @@ -8882,13 +8548,13 @@ def fromDoc( ) ) else: - val = _doc.get("honorificSuffix") + val = _doc.get("uuid") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `honorificSuffix` field is not valid because:", - SourceLine(_doc, "honorificSuffix", str), + "the `uuid` field is not valid because:", + SourceLine(_doc, "uuid", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8900,28 +8566,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `honorificSuffix` field is not valid because:", - SourceLine(_doc, "honorificSuffix", str), + "the `uuid` field is not valid because:", + SourceLine(_doc, "uuid", str), [e], - detailed_message=f"the `honorificSuffix` field with value `{val}` " + detailed_message=f"the `uuid` field with value `{val}` " "is not valid because:", ) ) - jobTitle = None - if "jobTitle" in _doc: + tool_id = None + if "tool_id" in _doc: try: - jobTitle = load_field( - _doc.get("jobTitle"), + tool_id = load_field( + _doc.get("tool_id"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("jobTitle") + lc=_doc.get("tool_id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `jobTitle`": + if str(e) == "missing required field `tool_id`": _errors__.append( ValidationException( str(e), @@ -8929,13 +8595,13 @@ def fromDoc( ) ) else: - val = _doc.get("jobTitle") + val = _doc.get("tool_id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `jobTitle` field is not valid because:", - SourceLine(_doc, "jobTitle", str), + "the `tool_id` field is not valid because:", + SourceLine(_doc, "tool_id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8947,292 +8613,122 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `jobTitle` field is not valid because:", - SourceLine(_doc, "jobTitle", str), + "the `tool_id` field is not valid because:", + SourceLine(_doc, "tool_id", str), [e], - detailed_message=f"the `jobTitle` field with value `{val}` " + detailed_message=f"the `tool_id` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + tool_shed_repository = None + if "tool_shed_repository" in _doc: + try: + tool_shed_repository = load_field( + _doc.get("tool_shed_repository"), + union_of_None_type_or_ToolShedRepositoryLoader, + baseuri, + loadingOptions, + lc=_doc.get("tool_shed_repository") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tool_shed_repository`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("tool_shed_repository") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `tool_shed_repository` field is not valid because:", + SourceLine(_doc, "tool_shed_repository", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tool_shed_repository` field is not valid because:", + SourceLine(_doc, "tool_shed_repository", str), + [e], + detailed_message=f"the `tool_shed_repository` field with value `{val}` " + "is not valid because:", + ) + ) + tool_version = None + if "tool_version" in _doc: + try: + tool_version = load_field( + _doc.get("tool_version"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("tool_version") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tool_version`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `identifier`, `url`, `email`, `image`, `address`, `alternateName`, `telephone`, `faxNumber`, `class`, `givenName`, `familyName`, `honorificPrefix`, `honorificSuffix`, `jobTitle`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - name=name, - identifier=identifier, - url=url, - email=email, - image=image, - address=address, - alternateName=alternateName, - telephone=telephone, - faxNumber=faxNumber, - givenName=givenName, - familyName=familyName, - honorificPrefix=honorificPrefix, - honorificSuffix=honorificSuffix, - jobTitle=jobTitle, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.name, False, None, relative_uris) - r["class"] = u - if self.identifier is not None: - r["identifier"] = save( - self.identifier, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.url is not None: - r["url"] = save( - self.url, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.email is not None: - r["email"] = save( - self.email, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.image is not None: - r["image"] = save( - self.image, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.address is not None: - r["address"] = save( - self.address, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.alternateName is not None: - r["alternateName"] = save( - self.alternateName, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.telephone is not None: - r["telephone"] = save( - self.telephone, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.faxNumber is not None: - r["faxNumber"] = save( - self.faxNumber, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.givenName is not None: - r["givenName"] = save( - self.givenName, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.familyName is not None: - r["familyName"] = save( - self.familyName, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.honorificPrefix is not None: - r["honorificPrefix"] = save( - self.honorificPrefix, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.honorificSuffix is not None: - r["honorificSuffix"] = save( - self.honorificSuffix, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.jobTitle is not None: - r["jobTitle"] = save( - self.jobTitle, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "name", - "identifier", - "url", - "email", - "image", - "address", - "alternateName", - "telephone", - "faxNumber", - "class", - "givenName", - "familyName", - "honorificPrefix", - "honorificSuffix", - "jobTitle", - ] - ) - - -class NativeCreatorOrganization(BaseNativeCreator): - """ - An organization that created or contributed to the workflow. - Corresponds to a `schema.org Organization `_. - - """ - - name: str - - def __init__( - self, - name: Optional[Any] = None, - identifier: Optional[Any] = None, - url: Optional[Any] = None, - email: Optional[Any] = None, - image: Optional[Any] = None, - address: Optional[Any] = None, - alternateName: Optional[Any] = None, - telephone: Optional[Any] = None, - faxNumber: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.identifier = identifier - self.url = url - self.email = email - self.image = image - self.address = address - self.alternateName = alternateName - self.telephone = telephone - self.faxNumber = faxNumber - self.class_ = "NativeCreatorOrganization" - - def __eq__(self, other: Any) -> bool: - if isinstance(other, NativeCreatorOrganization): - return bool( - self.name == other.name - and self.identifier == other.identifier - and self.url == other.url - and self.email == other.email - and self.image == other.image - and self.address == other.address - and self.alternateName == other.alternateName - and self.telephone == other.telephone - and self.faxNumber == other.faxNumber - and self.class_ == other.class_ - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.name, - self.identifier, - self.url, - self.email, - self.image, - self.address, - self.alternateName, - self.telephone, - self.faxNumber, - self.class_, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "NativeCreatorOrganization": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) + else: + val = _doc.get("tool_version") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `tool_version` field is not valid because:", + SourceLine(_doc, "tool_version", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tool_version` field is not valid because:", + SourceLine(_doc, "tool_version", str), + [e], + detailed_message=f"the `tool_version` field with value `{val}` " + "is not valid because:", + ) + ) + type_ = None + if "type" in _doc: + try: + type_ = load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_NativeStepTypeLoader_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -9240,13 +8736,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9258,53 +8754,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) + label = None + if "label" in _doc: + try: + label = load_field( + _doc.get("label"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("label") + ) - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_NativeCreatorOrganizationTypeLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - identifier = None - if "identifier" in _doc: + if str(e) == "missing required field `label`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("label") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), + [e], + detailed_message=f"the `label` field with value `{val}` " + "is not valid because:", + ) + ) + annotation = None + if "annotation" in _doc: try: - identifier = load_field( - _doc.get("identifier"), + annotation = load_field( + _doc.get("annotation"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("identifier") + lc=_doc.get("annotation") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `identifier`": + if str(e) == "missing required field `annotation`": _errors__.append( ValidationException( str(e), @@ -9312,13 +8830,13 @@ def fromDoc( ) ) else: - val = _doc.get("identifier") + val = _doc.get("annotation") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `identifier` field is not valid because:", - SourceLine(_doc, "identifier", str), + "the `annotation` field is not valid because:", + SourceLine(_doc, "annotation", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9330,28 +8848,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `identifier` field is not valid because:", - SourceLine(_doc, "identifier", str), + "the `annotation` field is not valid because:", + SourceLine(_doc, "annotation", str), [e], - detailed_message=f"the `identifier` field with value `{val}` " + detailed_message=f"the `annotation` field with value `{val}` " "is not valid because:", ) ) - url = None - if "url" in _doc: + when = None + if "when" in _doc: try: - url = load_field( - _doc.get("url"), + when = load_field( + _doc.get("when"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("url") + lc=_doc.get("when") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `url`": + if str(e) == "missing required field `when`": _errors__.append( ValidationException( str(e), @@ -9359,13 +8877,13 @@ def fromDoc( ) ) else: - val = _doc.get("url") + val = _doc.get("when") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `url` field is not valid because:", - SourceLine(_doc, "url", str), + "the `when` field is not valid because:", + SourceLine(_doc, "when", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9377,28 +8895,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `url` field is not valid because:", - SourceLine(_doc, "url", str), + "the `when` field is not valid because:", + SourceLine(_doc, "when", str), [e], - detailed_message=f"the `url` field with value `{val}` " + detailed_message=f"the `when` field with value `{val}` " "is not valid because:", ) ) - email = None - if "email" in _doc: + content_id = None + if "content_id" in _doc: try: - email = load_field( - _doc.get("email"), + content_id = load_field( + _doc.get("content_id"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("email") + lc=_doc.get("content_id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `email`": + if str(e) == "missing required field `content_id`": _errors__.append( ValidationException( str(e), @@ -9406,13 +8924,13 @@ def fromDoc( ) ) else: - val = _doc.get("email") + val = _doc.get("content_id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `email` field is not valid because:", - SourceLine(_doc, "email", str), + "the `content_id` field is not valid because:", + SourceLine(_doc, "content_id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9424,28 +8942,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `email` field is not valid because:", - SourceLine(_doc, "email", str), + "the `content_id` field is not valid because:", + SourceLine(_doc, "content_id", str), [e], - detailed_message=f"the `email` field with value `{val}` " + detailed_message=f"the `content_id` field with value `{val}` " "is not valid because:", ) ) - image = None - if "image" in _doc: + tool_state = None + if "tool_state" in _doc: try: - image = load_field( - _doc.get("image"), - union_of_None_type_or_strtype, + tool_state = load_field( + _doc.get("tool_state"), + union_of_None_type_or_strtype_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("image") + lc=_doc.get("tool_state") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `image`": + if str(e) == "missing required field `tool_state`": _errors__.append( ValidationException( str(e), @@ -9453,13 +8971,13 @@ def fromDoc( ) ) else: - val = _doc.get("image") + val = _doc.get("tool_state") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `image` field is not valid because:", - SourceLine(_doc, "image", str), + "the `tool_state` field is not valid because:", + SourceLine(_doc, "tool_state", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9471,28 +8989,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `image` field is not valid because:", - SourceLine(_doc, "image", str), + "the `tool_state` field is not valid because:", + SourceLine(_doc, "tool_state", str), [e], - detailed_message=f"the `image` field with value `{val}` " + detailed_message=f"the `tool_state` field with value `{val}` " "is not valid because:", ) ) - address = None - if "address" in _doc: + tool_uuid = None + if "tool_uuid" in _doc: try: - address = load_field( - _doc.get("address"), + tool_uuid = load_field( + _doc.get("tool_uuid"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("address") + lc=_doc.get("tool_uuid") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `address`": + if str(e) == "missing required field `tool_uuid`": _errors__.append( ValidationException( str(e), @@ -9500,13 +9018,13 @@ def fromDoc( ) ) else: - val = _doc.get("address") + val = _doc.get("tool_uuid") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `address` field is not valid because:", - SourceLine(_doc, "address", str), + "the `tool_uuid` field is not valid because:", + SourceLine(_doc, "tool_uuid", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9518,154 +9036,711 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `address` field is not valid because:", - SourceLine(_doc, "address", str), + "the `tool_uuid` field is not valid because:", + SourceLine(_doc, "tool_uuid", str), [e], - detailed_message=f"the `address` field with value `{val}` " + detailed_message=f"the `tool_uuid` field with value `{val}` " "is not valid because:", ) ) - alternateName = None - if "alternateName" in _doc: + input_connections = None + if "input_connections" in _doc: try: - alternateName = load_field( - _doc.get("alternateName"), - union_of_None_type_or_strtype, + input_connections = load_field( + _doc.get("input_connections"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("alternateName") + lc=_doc.get("input_connections") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `input_connections`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("input_connections") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `input_connections` field is not valid because:", + SourceLine(_doc, "input_connections", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `input_connections` field is not valid because:", + SourceLine(_doc, "input_connections", str), + [e], + detailed_message=f"the `input_connections` field with value `{val}` " + "is not valid because:", + ) + ) + inputs = None + if "inputs" in _doc: + try: + inputs = load_field( + _doc.get("inputs"), + union_of_None_type_or_array_of_NativeStepInputLoader, + baseuri, + loadingOptions, + lc=_doc.get("inputs") ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `inputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("inputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `inputs` field is not valid because:", + SourceLine(_doc, "inputs", str), + [e], + detailed_message=f"the `inputs` field with value `{val}` " + "is not valid because:", + ) + ) + outputs = None + if "outputs" in _doc: + try: + outputs = load_field( + _doc.get("outputs"), + union_of_None_type_or_array_of_NativeStepOutputLoader, + baseuri, + loadingOptions, + lc=_doc.get("outputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("outputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `outputs` field is not valid because:", + SourceLine(_doc, "outputs", str), + [e], + detailed_message=f"the `outputs` field with value `{val}` " + "is not valid because:", + ) + ) + workflow_outputs = None + if "workflow_outputs" in _doc: + try: + workflow_outputs = load_field( + _doc.get("workflow_outputs"), + union_of_None_type_or_array_of_NativeWorkflowOutputLoader, + baseuri, + loadingOptions, + lc=_doc.get("workflow_outputs") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `workflow_outputs`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("workflow_outputs") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `workflow_outputs` field is not valid because:", + SourceLine(_doc, "workflow_outputs", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `workflow_outputs` field is not valid because:", + SourceLine(_doc, "workflow_outputs", str), + [e], + detailed_message=f"the `workflow_outputs` field with value `{val}` " + "is not valid because:", + ) + ) + post_job_actions = None + if "post_job_actions" in _doc: + try: + post_job_actions = load_field( + _doc.get("post_job_actions"), + union_of_None_type_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("post_job_actions") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `post_job_actions`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("post_job_actions") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `post_job_actions` field is not valid because:", + SourceLine(_doc, "post_job_actions", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `post_job_actions` field is not valid because:", + SourceLine(_doc, "post_job_actions", str), + [e], + detailed_message=f"the `post_job_actions` field with value `{val}` " + "is not valid because:", + ) + ) + subworkflow = None + if "subworkflow" in _doc: + try: + subworkflow = load_field( + _doc.get("subworkflow"), + union_of_None_type_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("subworkflow") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `subworkflow`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("subworkflow") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `subworkflow` field is not valid because:", + SourceLine(_doc, "subworkflow", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `subworkflow` field is not valid because:", + SourceLine(_doc, "subworkflow", str), + [e], + detailed_message=f"the `subworkflow` field with value `{val}` " + "is not valid because:", + ) + ) + tool_representation = None + if "tool_representation" in _doc: + try: + tool_representation = load_field( + _doc.get("tool_representation"), + union_of_None_type_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("tool_representation") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tool_representation`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("tool_representation") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `tool_representation` field is not valid because:", + SourceLine(_doc, "tool_representation", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tool_representation` field is not valid because:", + SourceLine(_doc, "tool_representation", str), + [e], + detailed_message=f"the `tool_representation` field with value `{val}` " + "is not valid because:", + ) + ) + in_ = None + if "in" in _doc: + try: + in_ = load_field( + _doc.get("in"), + union_of_None_type_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("in") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `in`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("in") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), + [e], + detailed_message=f"the `in` field with value `{val}` " + "is not valid because:", + ) + ) + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `errors`, `position`, `uuid`, `tool_id`, `tool_shed_repository`, `tool_version`, `id`, `type`, `name`, `label`, `annotation`, `when`, `content_id`, `tool_state`, `tool_uuid`, `input_connections`, `inputs`, `outputs`, `workflow_outputs`, `post_job_actions`, `subworkflow`, `tool_representation`, `in`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + errors=errors, + position=position, + uuid=uuid, + tool_id=tool_id, + tool_shed_repository=tool_shed_repository, + tool_version=tool_version, + id=id, + type_=type_, + name=name, + label=label, + annotation=annotation, + when=when, + content_id=content_id, + tool_state=tool_state, + tool_uuid=tool_uuid, + input_connections=input_connections, + inputs=inputs, + outputs=outputs, + workflow_outputs=workflow_outputs, + post_job_actions=post_job_actions, + subworkflow=subworkflow, + tool_representation=tool_representation, + in_=in_, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.id is not None: + r["id"] = save( + self.id, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.errors is not None: + r["errors"] = save( + self.errors, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.position is not None: + r["position"] = save( + self.position, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.uuid is not None: + r["uuid"] = save( + self.uuid, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.tool_id is not None: + r["tool_id"] = save( + self.tool_id, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.tool_shed_repository is not None: + r["tool_shed_repository"] = save( + self.tool_shed_repository, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.tool_version is not None: + r["tool_version"] = save( + self.tool_version, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.annotation is not None: + r["annotation"] = save( + self.annotation, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.when is not None: + r["when"] = save( + self.when, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.content_id is not None: + r["content_id"] = save( + self.content_id, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.tool_state is not None: + r["tool_state"] = save( + self.tool_state, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.tool_uuid is not None: + r["tool_uuid"] = save( + self.tool_uuid, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.input_connections is not None: + r["input_connections"] = save( + self.input_connections, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.inputs is not None: + r["inputs"] = save( + self.inputs, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.outputs is not None: + r["outputs"] = save( + self.outputs, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.workflow_outputs is not None: + r["workflow_outputs"] = save( + self.workflow_outputs, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.post_job_actions is not None: + r["post_job_actions"] = save( + self.post_job_actions, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.subworkflow is not None: + r["subworkflow"] = save( + self.subworkflow, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.tool_representation is not None: + r["tool_representation"] = save( + self.tool_representation, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.in_ is not None: + r["in"] = save( + self.in_, top=False, base_url=self.name, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset( + [ + "errors", + "position", + "uuid", + "tool_id", + "tool_shed_repository", + "tool_version", + "id", + "type", + "name", + "label", + "annotation", + "when", + "content_id", + "tool_state", + "tool_uuid", + "input_connections", + "inputs", + "outputs", + "workflow_outputs", + "post_job_actions", + "subworkflow", + "tool_representation", + "in", + ] + ) + + +class NativeReport(Saveable): + """ + Workflow invocation report template. + + """ + + def __init__( + self, + markdown: Any, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.markdown = markdown + + def __eq__(self, other: Any) -> bool: + if isinstance(other, NativeReport): + return bool(self.markdown == other.markdown) + return False + + def __hash__(self) -> int: + return hash((self.markdown)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "NativeReport": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + try: + if _doc.get("markdown") is None: + raise ValidationException("missing required field `markdown`", None, []) + + markdown = load_field( + _doc.get("markdown"), + strtype, + baseuri, + loadingOptions, + lc=_doc.get("markdown") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `alternateName`": - _errors__.append( - ValidationException( - str(e), - None - ) + if str(e) == "missing required field `markdown`": + _errors__.append( + ValidationException( + str(e), + None ) - else: - val = _doc.get("alternateName") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `alternateName` field is not valid because:", - SourceLine(_doc, "alternateName", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `alternateName` field is not valid because:", - SourceLine(_doc, "alternateName", str), - [e], - detailed_message=f"the `alternateName` field with value `{val}` " - "is not valid because:", - ) - ) - telephone = None - if "telephone" in _doc: - try: - telephone = load_field( - _doc.get("telephone"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("telephone") ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `telephone`": + else: + val = _doc.get("markdown") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `markdown` field is not valid because:", + SourceLine(_doc, "markdown", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("telephone") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `telephone` field is not valid because:", - SourceLine(_doc, "telephone", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `telephone` field is not valid because:", - SourceLine(_doc, "telephone", str), - [e], - detailed_message=f"the `telephone` field with value `{val}` " - "is not valid because:", - ) - ) - faxNumber = None - if "faxNumber" in _doc: - try: - faxNumber = load_field( - _doc.get("faxNumber"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("faxNumber") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `faxNumber`": _errors__.append( ValidationException( - str(e), - None + "the `markdown` field is not valid because:", + SourceLine(_doc, "markdown", str), + [e], + detailed_message=f"the `markdown` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("faxNumber") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `faxNumber` field is not valid because:", - SourceLine(_doc, "faxNumber", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `faxNumber` field is not valid because:", - SourceLine(_doc, "faxNumber", str), - [e], - detailed_message=f"the `faxNumber` field with value `{val}` " - "is not valid because:", - ) - ) extension_fields: dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: @@ -9681,9 +9756,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `identifier`, `url`, `email`, `image`, `address`, `alternateName`, `telephone`, `faxNumber`, `class`".format( - k - ), + "invalid field `{}`, expected one of: `markdown`".format(k), SourceLine(_doc, k, str), ) ) @@ -9691,19 +9764,10 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, - identifier=identifier, - url=url, - email=email, - image=image, - address=address, - alternateName=alternateName, - telephone=telephone, - faxNumber=faxNumber, + markdown=markdown, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -9717,60 +9781,9 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.name, False, None, relative_uris) - r["class"] = u - if self.identifier is not None: - r["identifier"] = save( - self.identifier, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.url is not None: - r["url"] = save( - self.url, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.email is not None: - r["email"] = save( - self.email, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.image is not None: - r["image"] = save( - self.image, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.address is not None: - r["address"] = save( - self.address, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.alternateName is not None: - r["alternateName"] = save( - self.alternateName, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.telephone is not None: - r["telephone"] = save( - self.telephone, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.faxNumber is not None: - r["faxNumber"] = save( - self.faxNumber, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.markdown is not None: + r["markdown"] = save( + self.markdown, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -9781,20 +9794,7 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset( - [ - "name", - "identifier", - "url", - "email", - "image", - "address", - "alternateName", - "telephone", - "faxNumber", - "class", - ] - ) + attrs = frozenset(["markdown"]) class NativeSourceMetadata(Saveable): @@ -11449,19 +11449,18 @@ def save( _vocab = { "Any": "https://w3id.org/cwl/salad#Any", "ArraySchema": "https://w3id.org/cwl/salad#ArraySchema", + "BaseCreator": "https://galaxyproject.org/gxformat2/gxformat2common#BaseCreator", "BaseNativeComment": "https://galaxyproject.org/gxformat2/native_v0_1#BaseNativeComment", - "BaseNativeCreator": "https://galaxyproject.org/gxformat2/native_v0_1#BaseNativeCreator", + "CreatorOrganization": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganization", + "CreatorOrganizationType": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganizationType", + "CreatorPerson": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPerson", + "CreatorPersonType": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPersonType", "Documented": "https://w3id.org/cwl/salad#Documented", "EnumSchema": "https://w3id.org/cwl/salad#EnumSchema", "HasStepErrors": "https://galaxyproject.org/gxformat2/gxformat2common#HasStepErrors", "HasStepPosition": "https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition", "HasUUID": "https://galaxyproject.org/gxformat2/gxformat2common#HasUUID", "NativeComment": "https://galaxyproject.org/gxformat2/native_v0_1#NativeComment", - "NativeCreator": "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreator", - "NativeCreatorOrganization": "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorOrganization", - "NativeCreatorOrganizationType": "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorOrganizationType", - "NativeCreatorPerson": "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorPerson", - "NativeCreatorPersonType": "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorPersonType", "NativeFrameComment": "https://galaxyproject.org/gxformat2/native_v0_1#NativeFrameComment", "NativeFrameCommentData": "https://galaxyproject.org/gxformat2/native_v0_1#NativeFrameCommentData", "NativeFreehandComment": "https://galaxyproject.org/gxformat2/native_v0_1#NativeFreehandComment", @@ -11480,8 +11479,8 @@ def save( "NativeTextComment": "https://galaxyproject.org/gxformat2/native_v0_1#NativeTextComment", "NativeTextCommentData": "https://galaxyproject.org/gxformat2/native_v0_1#NativeTextCommentData", "NativeWorkflowOutput": "https://galaxyproject.org/gxformat2/native_v0_1#NativeWorkflowOutput", - "Organization": "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorOrganizationType/Organization", - "Person": "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorPersonType/Person", + "Organization": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganizationType/Organization", + "Person": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPersonType/Person", "PrimitiveType": "https://w3id.org/cwl/salad#PrimitiveType", "RecordField": "https://w3id.org/cwl/salad#RecordField", "RecordSchema": "https://w3id.org/cwl/salad#RecordSchema", @@ -11509,19 +11508,18 @@ def save( _rvocab = { "https://w3id.org/cwl/salad#Any": "Any", "https://w3id.org/cwl/salad#ArraySchema": "ArraySchema", + "https://galaxyproject.org/gxformat2/gxformat2common#BaseCreator": "BaseCreator", "https://galaxyproject.org/gxformat2/native_v0_1#BaseNativeComment": "BaseNativeComment", - "https://galaxyproject.org/gxformat2/native_v0_1#BaseNativeCreator": "BaseNativeCreator", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganization": "CreatorOrganization", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganizationType": "CreatorOrganizationType", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPerson": "CreatorPerson", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPersonType": "CreatorPersonType", "https://w3id.org/cwl/salad#Documented": "Documented", "https://w3id.org/cwl/salad#EnumSchema": "EnumSchema", "https://galaxyproject.org/gxformat2/gxformat2common#HasStepErrors": "HasStepErrors", "https://galaxyproject.org/gxformat2/gxformat2common#HasStepPosition": "HasStepPosition", "https://galaxyproject.org/gxformat2/gxformat2common#HasUUID": "HasUUID", "https://galaxyproject.org/gxformat2/native_v0_1#NativeComment": "NativeComment", - "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreator": "NativeCreator", - "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorOrganization": "NativeCreatorOrganization", - "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorOrganizationType": "NativeCreatorOrganizationType", - "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorPerson": "NativeCreatorPerson", - "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorPersonType": "NativeCreatorPersonType", "https://galaxyproject.org/gxformat2/native_v0_1#NativeFrameComment": "NativeFrameComment", "https://galaxyproject.org/gxformat2/native_v0_1#NativeFrameCommentData": "NativeFrameCommentData", "https://galaxyproject.org/gxformat2/native_v0_1#NativeFreehandComment": "NativeFreehandComment", @@ -11540,8 +11538,8 @@ def save( "https://galaxyproject.org/gxformat2/native_v0_1#NativeTextComment": "NativeTextComment", "https://galaxyproject.org/gxformat2/native_v0_1#NativeTextCommentData": "NativeTextCommentData", "https://galaxyproject.org/gxformat2/native_v0_1#NativeWorkflowOutput": "NativeWorkflowOutput", - "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorOrganizationType/Organization": "Organization", - "https://galaxyproject.org/gxformat2/native_v0_1#NativeCreatorPersonType/Person": "Person", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganizationType/Organization": "Organization", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPersonType/Person": "Person", "https://w3id.org/cwl/salad#PrimitiveType": "PrimitiveType", "https://w3id.org/cwl/salad#RecordField": "RecordField", "https://w3id.org/cwl/salad#RecordSchema": "RecordSchema", @@ -11608,6 +11606,18 @@ def save( ArraySchemaLoader = _RecordLoader(ArraySchema, None, None) StepPositionLoader = _RecordLoader(StepPosition, None, None) ToolShedRepositoryLoader = _RecordLoader(ToolShedRepository, None, None) +CreatorPersonTypeLoader = _EnumLoader(("Person",), "CreatorPersonType") +""" +Discriminator for schema.org Person creators. +""" +CreatorOrganizationTypeLoader = _EnumLoader( + ("Organization",), "CreatorOrganizationType" +) +""" +Discriminator for schema.org Organization creators. +""" +CreatorPersonLoader = _RecordLoader(CreatorPerson, None, None) +CreatorOrganizationLoader = _RecordLoader(CreatorOrganization, None, None) NativeStepTypeLoader = _EnumLoader( ( "data_input", @@ -11646,19 +11656,6 @@ def save( NativeCommentLoader = _UnionLoader((), "NativeCommentLoader") NativeStepLoader = _RecordLoader(NativeStep, None, None) NativeReportLoader = _RecordLoader(NativeReport, None, None) -NativeCreatorPersonTypeLoader = _EnumLoader(("Person",), "NativeCreatorPersonType") -""" -Discriminator for schema.org Person creators. -""" -NativeCreatorOrganizationTypeLoader = _EnumLoader( - ("Organization",), "NativeCreatorOrganizationType" -) -""" -Discriminator for schema.org Organization creators. -""" -NativeCreatorPersonLoader = _RecordLoader(NativeCreatorPerson, None, None) -NativeCreatorOrganizationLoader = _RecordLoader(NativeCreatorOrganization, None, None) -NativeCreatorLoader = _UnionLoader((), "NativeCreatorLoader") NativeSourceMetadataLoader = _RecordLoader(NativeSourceMetadata, None, None) NativeGalaxyWorkflowLoader = _RecordLoader(NativeGalaxyWorkflow, None, None) array_of_strtype = _ArrayLoader(strtype) @@ -11759,6 +11756,15 @@ def save( ToolShedRepositoryLoader, ) ) +uri_union_of_None_type_or_strtype_True_False_None_None = _URILoader( + union_of_None_type_or_strtype, True, False, None, None +) +uri_CreatorPersonTypeLoader_False_True_None_None = _URILoader( + CreatorPersonTypeLoader, False, True, None, None +) +uri_CreatorOrganizationTypeLoader_False_True_None_None = _URILoader( + CreatorOrganizationTypeLoader, False, True, None, None +) typedsl_union_of_None_type_or_strtype_2 = _TypeDSLLoader( union_of_None_type_or_strtype, 2, "v1.1" ) @@ -11819,9 +11825,6 @@ def save( NativeFreehandCommentDataLoader, ) ) -uri_union_of_None_type_or_strtype_True_False_None_None = _URILoader( - union_of_None_type_or_strtype, True, False, None, None -) union_of_None_type_or_NativeStepTypeLoader = _UnionLoader( ( None_type, @@ -11859,12 +11862,6 @@ def save( array_of_NativeWorkflowOutputLoader, ) ) -uri_NativeCreatorPersonTypeLoader_False_True_None_None = _URILoader( - NativeCreatorPersonTypeLoader, False, True, None, None -) -uri_NativeCreatorOrganizationTypeLoader_False_True_None_None = _URILoader( - NativeCreatorOrganizationTypeLoader, False, True, None, None -) NativeGalaxyWorkflow_classLoader = _EnumLoader( ("NativeGalaxyWorkflow",), "NativeGalaxyWorkflow_class" ) @@ -11917,12 +11914,6 @@ def save( NativeFreehandCommentLoader, ) ) -NativeCreatorLoader.add_loaders( - ( - NativeCreatorPersonLoader, - NativeCreatorOrganizationLoader, - ) -) def load_document( diff --git a/gxformat2/schema/v19_09.py b/gxformat2/schema/v19_09.py index f045f999..37953f36 100644 --- a/gxformat2/schema/v19_09.py +++ b/gxformat2/schema/v19_09.py @@ -2634,20 +2634,41 @@ def save( attrs = frozenset(["changeset_revision", "name", "owner", "tool_shed"]) -class WorkflowInputParameter(InputParameter, HasStepPosition): - id: str +class BaseCreator(Saveable): + """ + Base fields shared by all creator types, corresponding to schema.org + Thing properties common to both Person and Organization. + + """ + + pass + + +class CreatorPerson(BaseCreator): + """ + A person who created or contributed to the workflow. + Corresponds to a `schema.org Person `_. + + """ + + name: str def __init__( self, - type_: Any, - optional: Any, - label: Optional[Any] = None, - doc: Optional[Any] = None, - id: Optional[Any] = None, - default: Optional[Any] = None, - position: Optional[Any] = None, - format: Optional[Any] = None, - collection_type: Optional[Any] = None, + name: Optional[Any] = None, + identifier: Optional[Any] = None, + url: Optional[Any] = None, + email: Optional[Any] = None, + image: Optional[Any] = None, + address: Optional[Any] = None, + alternateName: Optional[Any] = None, + telephone: Optional[Any] = None, + faxNumber: Optional[Any] = None, + givenName: Optional[Any] = None, + familyName: Optional[Any] = None, + honorificPrefix: Optional[Any] = None, + honorificSuffix: Optional[Any] = None, + jobTitle: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -2659,43 +2680,61 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.label = label - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.default = default - self.position = position - self.type_ = type_ - self.optional = optional - self.format = format - self.collection_type = collection_type + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.identifier = identifier + self.url = url + self.email = email + self.image = image + self.address = address + self.alternateName = alternateName + self.telephone = telephone + self.faxNumber = faxNumber + self.class_ = "CreatorPerson" + self.givenName = givenName + self.familyName = familyName + self.honorificPrefix = honorificPrefix + self.honorificSuffix = honorificSuffix + self.jobTitle = jobTitle def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowInputParameter): + if isinstance(other, CreatorPerson): return bool( - self.label == other.label - and self.doc == other.doc - and self.id == other.id - and self.default == other.default - and self.position == other.position - and self.type_ == other.type_ - and self.optional == other.optional - and self.format == other.format - and self.collection_type == other.collection_type + self.name == other.name + and self.identifier == other.identifier + and self.url == other.url + and self.email == other.email + and self.image == other.image + and self.address == other.address + and self.alternateName == other.alternateName + and self.telephone == other.telephone + and self.faxNumber == other.faxNumber + and self.class_ == other.class_ + and self.givenName == other.givenName + and self.familyName == other.familyName + and self.honorificPrefix == other.honorificPrefix + and self.honorificSuffix == other.honorificSuffix + and self.jobTitle == other.jobTitle ) return False def __hash__(self) -> int: return hash( ( - self.label, - self.doc, - self.id, - self.default, - self.position, - self.type_, - self.optional, - self.format, - self.collection_type, + self.name, + self.identifier, + self.url, + self.email, + self.image, + self.address, + self.alternateName, + self.telephone, + self.faxNumber, + self.class_, + self.givenName, + self.familyName, + self.honorificPrefix, + self.honorificSuffix, + self.jobTitle, ) ) @@ -2706,28 +2745,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "WorkflowInputParameter": + ) -> "CreatorPerson": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: + name = None + if "name" in _doc: try: - id = load_field( - _doc.get("id"), + name = load_field( + _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -2735,13 +2774,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2753,37 +2792,53 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - __original_id_is_none = id is None - if id is None: + __original_name_is_none = name is None + if name is None: if docRoot is not None: - id = docRoot + name = docRoot else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + name = "_:" + str(_uuid__.uuid4()) + if not __original_name_is_none: + baseuri = cast(str, name) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = load_field( + _doc.get("class"), + uri_CreatorPersonTypeLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + identifier = None + if "identifier" in _doc: try: - label = load_field( - _doc.get("label"), + identifier = load_field( + _doc.get("identifier"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("identifier") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `identifier`": _errors__.append( ValidationException( str(e), @@ -2791,13 +2846,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("identifier") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `identifier` field is not valid because:", + SourceLine(_doc, "identifier", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2809,28 +2864,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `identifier` field is not valid because:", + SourceLine(_doc, "identifier", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `identifier` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + url = None + if "url" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + url = load_field( + _doc.get("url"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("url") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `url`": _errors__.append( ValidationException( str(e), @@ -2838,13 +2893,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("url") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `url` field is not valid because:", + SourceLine(_doc, "url", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2856,28 +2911,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `url` field is not valid because:", + SourceLine(_doc, "url", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `url` field with value `{val}` " "is not valid because:", ) ) - default = None - if "default" in _doc: + email = None + if "email" in _doc: try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_Any_type, + email = load_field( + _doc.get("email"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("default") + lc=_doc.get("email") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `default`": + if str(e) == "missing required field `email`": _errors__.append( ValidationException( str(e), @@ -2885,13 +2940,13 @@ def fromDoc( ) ) else: - val = _doc.get("default") + val = _doc.get("email") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `email` field is not valid because:", + SourceLine(_doc, "email", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2903,28 +2958,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `email` field is not valid because:", + SourceLine(_doc, "email", str), [e], - detailed_message=f"the `default` field with value `{val}` " + detailed_message=f"the `email` field with value `{val}` " "is not valid because:", ) ) - position = None - if "position" in _doc: + image = None + if "image" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_StepPositionLoader, - baseuri, - loadingOptions, - lc=_doc.get("position") + image = load_field( + _doc.get("image"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("image") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `image`": _errors__.append( ValidationException( str(e), @@ -2932,13 +2987,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("image") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `image` field is not valid because:", + SourceLine(_doc, "image", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2950,28 +3005,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `image` field is not valid because:", + SourceLine(_doc, "image", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `image` field with value `{val}` " "is not valid because:", ) ) - type_ = None - if "type" in _doc: + address = None + if "address" in _doc: try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_GalaxyTypeLoader_or_None_type_or_array_of_union_of_GalaxyTypeLoader_2, + address = load_field( + _doc.get("address"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("address") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `address`": _errors__.append( ValidationException( str(e), @@ -2979,13 +3034,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("address") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `address` field is not valid because:", + SourceLine(_doc, "address", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -2997,28 +3052,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `address` field is not valid because:", + SourceLine(_doc, "address", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `address` field with value `{val}` " "is not valid because:", ) ) - optional = None - if "optional" in _doc: + alternateName = None + if "alternateName" in _doc: try: - optional = load_field( - _doc.get("optional"), - union_of_booltype_or_None_type, + alternateName = load_field( + _doc.get("alternateName"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("optional") + lc=_doc.get("alternateName") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `optional`": + if str(e) == "missing required field `alternateName`": _errors__.append( ValidationException( str(e), @@ -3026,13 +3081,13 @@ def fromDoc( ) ) else: - val = _doc.get("optional") + val = _doc.get("alternateName") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `optional` field is not valid because:", - SourceLine(_doc, "optional", str), + "the `alternateName` field is not valid because:", + SourceLine(_doc, "alternateName", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3044,28 +3099,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `optional` field is not valid because:", - SourceLine(_doc, "optional", str), + "the `alternateName` field is not valid because:", + SourceLine(_doc, "alternateName", str), [e], - detailed_message=f"the `optional` field with value `{val}` " + detailed_message=f"the `alternateName` field with value `{val}` " "is not valid because:", ) ) - format = None - if "format" in _doc: + telephone = None + if "telephone" in _doc: try: - format = load_field( - _doc.get("format"), - union_of_None_type_or_array_of_strtype, + telephone = load_field( + _doc.get("telephone"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("format") + lc=_doc.get("telephone") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `format`": + if str(e) == "missing required field `telephone`": _errors__.append( ValidationException( str(e), @@ -3073,13 +3128,13 @@ def fromDoc( ) ) else: - val = _doc.get("format") + val = _doc.get("telephone") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `telephone` field is not valid because:", + SourceLine(_doc, "telephone", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3091,28 +3146,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `format` field is not valid because:", - SourceLine(_doc, "format", str), + "the `telephone` field is not valid because:", + SourceLine(_doc, "telephone", str), [e], - detailed_message=f"the `format` field with value `{val}` " + detailed_message=f"the `telephone` field with value `{val}` " "is not valid because:", ) ) - collection_type = None - if "collection_type" in _doc: + faxNumber = None + if "faxNumber" in _doc: try: - collection_type = load_field( - _doc.get("collection_type"), + faxNumber = load_field( + _doc.get("faxNumber"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("collection_type") + lc=_doc.get("faxNumber") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `collection_type`": + if str(e) == "missing required field `faxNumber`": _errors__.append( ValidationException( str(e), @@ -3120,13 +3175,13 @@ def fromDoc( ) ) else: - val = _doc.get("collection_type") + val = _doc.get("faxNumber") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `collection_type` field is not valid because:", - SourceLine(_doc, "collection_type", str), + "the `faxNumber` field is not valid because:", + SourceLine(_doc, "faxNumber", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3138,204 +3193,122 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `collection_type` field is not valid because:", - SourceLine(_doc, "collection_type", str), + "the `faxNumber` field is not valid because:", + SourceLine(_doc, "faxNumber", str), [e], - detailed_message=f"the `collection_type` field with value `{val}` " + detailed_message=f"the `faxNumber` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: + givenName = None + if "givenName" in _doc: + try: + givenName = load_field( + _doc.get("givenName"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("givenName") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `givenName`": _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False + ValidationException( + str(e), + None + ) ) - extension_fields[ex] = _doc[k] else: + val = _doc.get("givenName") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `givenName` field is not valid because:", + SourceLine(_doc, "givenName", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `givenName` field is not valid because:", + SourceLine(_doc, "givenName", str), + [e], + detailed_message=f"the `givenName` field with value `{val}` " + "is not valid because:", + ) + ) + familyName = None + if "familyName" in _doc: + try: + familyName = load_field( + _doc.get("familyName"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("familyName") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `familyName`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `label`, `doc`, `id`, `default`, `position`, `type`, `optional`, `format`, `collection_type`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) + else: + val = _doc.get("familyName") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `familyName` field is not valid because:", + SourceLine(_doc, "familyName", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `familyName` field is not valid because:", + SourceLine(_doc, "familyName", str), + [e], + detailed_message=f"the `familyName` field with value `{val}` " + "is not valid because:", + ) + ) + honorificPrefix = None + if "honorificPrefix" in _doc: + try: + honorificPrefix = load_field( + _doc.get("honorificPrefix"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("honorificPrefix") + ) - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - label=label, - doc=doc, - id=id, - default=default, - position=position, - type_=type_, - optional=optional, - format=format, - collection_type=collection_type, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.optional is not None: - r["optional"] = save( - self.optional, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.format is not None: - r["format"] = save( - self.format, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.collection_type is not None: - r["collection_type"] = save( - self.collection_type, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "label", - "doc", - "id", - "default", - "position", - "type", - "optional", - "format", - "collection_type", - ] - ) - - -class WorkflowOutputParameter(OutputParameter): - """ - Describe an output parameter of a workflow. The parameter must be - connected to one parameter defined in the workflow that - will provide the value of the output parameter. It is legal to - connect a WorkflowInputParameter to a WorkflowOutputParameter. - - """ - - id: str - - def __init__( - self, - label: Optional[Any] = None, - doc: Optional[Any] = None, - id: Optional[Any] = None, - outputSource: Optional[Any] = None, - type_: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.label = label - self.doc = doc - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.outputSource = outputSource - self.type_ = type_ - - def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowOutputParameter): - return bool( - self.label == other.label - and self.doc == other.doc - and self.id == other.id - and self.outputSource == other.outputSource - and self.type_ == other.type_ - ) - return False - - def __hash__(self) -> int: - return hash((self.label, self.doc, self.id, self.outputSource, self.type_)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "WorkflowOutputParameter": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - id = None - if "id" in _doc: - try: - id = load_field( - _doc.get("id"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("id") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `id`": + if str(e) == "missing required field `honorificPrefix`": _errors__.append( ValidationException( str(e), @@ -3343,13 +3316,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("honorificPrefix") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `honorificPrefix` field is not valid because:", + SourceLine(_doc, "honorificPrefix", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3361,37 +3334,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `honorificPrefix` field is not valid because:", + SourceLine(_doc, "honorificPrefix", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `honorificPrefix` field with value `{val}` " "is not valid because:", ) ) - - __original_id_is_none = id is None - if id is None: - if docRoot is not None: - id = docRoot - else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + honorificSuffix = None + if "honorificSuffix" in _doc: try: - label = load_field( - _doc.get("label"), + honorificSuffix = load_field( + _doc.get("honorificSuffix"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("honorificSuffix") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `honorificSuffix`": _errors__.append( ValidationException( str(e), @@ -3399,13 +3363,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("honorificSuffix") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `honorificSuffix` field is not valid because:", + SourceLine(_doc, "honorificSuffix", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3417,28 +3381,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `honorificSuffix` field is not valid because:", + SourceLine(_doc, "honorificSuffix", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `honorificSuffix` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + jobTitle = None + if "jobTitle" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + jobTitle = load_field( + _doc.get("jobTitle"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("jobTitle") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `jobTitle`": _errors__.append( ValidationException( str(e), @@ -3446,13 +3410,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("jobTitle") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `jobTitle` field is not valid because:", + SourceLine(_doc, "jobTitle", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3464,141 +3428,56 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `jobTitle` field is not valid because:", + SourceLine(_doc, "jobTitle", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `jobTitle` field with value `{val}` " "is not valid because:", ) ) - outputSource = None - if "outputSource" in _doc: - try: - outputSource = load_field( - _doc.get("outputSource"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("outputSource") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `outputSource`": + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: _errors__.append( ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("outputSource") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `outputSource` field is not valid because:", - SourceLine(_doc, "outputSource", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `outputSource` field is not valid because:", - SourceLine(_doc, "outputSource", str), - [e], - detailed_message=f"the `outputSource` field with value `{val}` " - "is not valid because:", - ) - ) - type_ = None - if "type" in _doc: - try: - type_ = load_field( - _doc.get("type"), - typedsl_union_of_None_type_or_GalaxyTypeLoader_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `label`, `doc`, `id`, `outputSource`, `type`".format( - k - ), - SourceLine(_doc, k, str), + "invalid field `{}`, expected one of: `name`, `identifier`, `url`, `email`, `image`, `address`, `alternateName`, `telephone`, `faxNumber`, `class`, `givenName`, `familyName`, `honorificPrefix`, `honorificSuffix`, `jobTitle`".format( + k + ), + SourceLine(_doc, k, str), ) ) if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - label=label, - doc=doc, - id=id, - outputSource=outputSource, - type_=type_, + name=name, + identifier=identifier, + url=url, + email=email, + image=image, + address=address, + alternateName=alternateName, + telephone=telephone, + faxNumber=faxNumber, + givenName=givenName, + familyName=familyName, + honorificPrefix=honorificPrefix, + honorificSuffix=honorificSuffix, + jobTitle=jobTitle, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -3612,27 +3491,95 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=self.id, relative_uris=relative_uris + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.class_ is not None: + uri = self.loadingOptions.vocab[self.class_] + if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, self.name, False, None, relative_uris) + r["class"] = u + if self.identifier is not None: + r["identifier"] = save( + self.identifier, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) - if self.doc is not None: - r["doc"] = save( - self.doc, top=False, base_url=self.id, relative_uris=relative_uris + if self.url is not None: + r["url"] = save( + self.url, top=False, base_url=self.name, relative_uris=relative_uris ) - if self.outputSource is not None: - r["outputSource"] = save( - self.outputSource, + if self.email is not None: + r["email"] = save( + self.email, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.image is not None: + r["image"] = save( + self.image, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.address is not None: + r["address"] = save( + self.address, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.alternateName is not None: + r["alternateName"] = save( + self.alternateName, top=False, - base_url=self.id, + base_url=self.name, relative_uris=relative_uris, ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=self.id, relative_uris=relative_uris + if self.telephone is not None: + r["telephone"] = save( + self.telephone, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.faxNumber is not None: + r["faxNumber"] = save( + self.faxNumber, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.givenName is not None: + r["givenName"] = save( + self.givenName, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.familyName is not None: + r["familyName"] = save( + self.familyName, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.honorificPrefix is not None: + r["honorificPrefix"] = save( + self.honorificPrefix, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.honorificSuffix is not None: + r["honorificSuffix"] = save( + self.honorificSuffix, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.jobTitle is not None: + r["jobTitle"] = save( + self.jobTitle, + top=False, + base_url=self.name, + relative_uris=relative_uris, ) # top refers to the directory level @@ -3643,58 +3590,47 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["label", "doc", "id", "outputSource", "type"]) + attrs = frozenset( + [ + "name", + "identifier", + "url", + "email", + "image", + "address", + "alternateName", + "telephone", + "faxNumber", + "class", + "givenName", + "familyName", + "honorificPrefix", + "honorificSuffix", + "jobTitle", + ] + ) -class WorkflowStep( - Identified, - Labeled, - Documented, - HasStepPosition, - ReferencesTool, - HasStepErrors, - HasUUID, -): +class CreatorOrganization(BaseCreator): """ - This represents a non-input step a Galaxy Workflow. - - # A note about `state` and `tool_state` fields. - - Only one or the other should be specified. These are two ways to represent the "state" - of a tool at this workflow step. Both are essentially maps from parameter names to - parameter values. - - `tool_state` is much more low-level and expects a flat dictionary with each value a JSON - dump. Nested tool structures such as conditionals and repeats should have all their values - in the JSON dumped string. In general `tool_state` may be present in workflows exported from - Galaxy but shouldn't be written by humans. - - `state` can contained a typed map. Repeat values can be represented as YAML arrays. An alternative - to representing `state` this way is defining inputs with default values. + An organization that created or contributed to the workflow. + Corresponds to a `schema.org Organization `_. """ - id: str + name: str def __init__( self, - out: Any, - id: Optional[Any] = None, - label: Optional[Any] = None, - doc: Optional[Any] = None, - position: Optional[Any] = None, - tool_id: Optional[Any] = None, - tool_shed_repository: Optional[Any] = None, - tool_version: Optional[Any] = None, - errors: Optional[Any] = None, - uuid: Optional[Any] = None, - in_: Optional[Any] = None, - state: Optional[Any] = None, - tool_state: Optional[Any] = None, - type_: Optional[Any] = None, - run: Optional[Any] = None, - runtime_inputs: Optional[Any] = None, - when: Optional[Any] = None, + name: Optional[Any] = None, + identifier: Optional[Any] = None, + url: Optional[Any] = None, + email: Optional[Any] = None, + image: Optional[Any] = None, + address: Optional[Any] = None, + alternateName: Optional[Any] = None, + telephone: Optional[Any] = None, + faxNumber: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -3706,67 +3642,46 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.label = label - self.doc = doc - self.position = position - self.tool_id = tool_id - self.tool_shed_repository = tool_shed_repository - self.tool_version = tool_version - self.errors = errors - self.uuid = uuid - self.in_ = in_ - self.out = out - self.state = state - self.tool_state = tool_state - self.type_ = type_ - self.run = run - self.runtime_inputs = runtime_inputs - self.when = when + self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) + self.identifier = identifier + self.url = url + self.email = email + self.image = image + self.address = address + self.alternateName = alternateName + self.telephone = telephone + self.faxNumber = faxNumber + self.class_ = "CreatorOrganization" def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStep): + if isinstance(other, CreatorOrganization): return bool( - self.id == other.id - and self.label == other.label - and self.doc == other.doc - and self.position == other.position - and self.tool_id == other.tool_id - and self.tool_shed_repository == other.tool_shed_repository - and self.tool_version == other.tool_version - and self.errors == other.errors - and self.uuid == other.uuid - and self.in_ == other.in_ - and self.out == other.out - and self.state == other.state - and self.tool_state == other.tool_state - and self.type_ == other.type_ - and self.run == other.run - and self.runtime_inputs == other.runtime_inputs - and self.when == other.when + self.name == other.name + and self.identifier == other.identifier + and self.url == other.url + and self.email == other.email + and self.image == other.image + and self.address == other.address + and self.alternateName == other.alternateName + and self.telephone == other.telephone + and self.faxNumber == other.faxNumber + and self.class_ == other.class_ ) return False def __hash__(self) -> int: return hash( ( - self.id, - self.label, - self.doc, - self.position, - self.tool_id, - self.tool_shed_repository, - self.tool_version, - self.errors, - self.uuid, - self.in_, - self.out, - self.state, - self.tool_state, - self.type_, - self.run, - self.runtime_inputs, - self.when, + self.name, + self.identifier, + self.url, + self.email, + self.image, + self.address, + self.alternateName, + self.telephone, + self.faxNumber, + self.class_, ) ) @@ -3777,28 +3692,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "WorkflowStep": + ) -> "CreatorOrganization": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - id = None - if "id" in _doc: + name = None + if "name" in _doc: try: - id = load_field( - _doc.get("id"), + name = load_field( + _doc.get("name"), uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("id") + lc=_doc.get("name") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `id`": + if str(e) == "missing required field `name`": _errors__.append( ValidationException( str(e), @@ -3806,13 +3721,13 @@ def fromDoc( ) ) else: - val = _doc.get("id") + val = _doc.get("name") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3824,37 +3739,53 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `id` field is not valid because:", - SourceLine(_doc, "id", str), + "the `name` field is not valid because:", + SourceLine(_doc, "name", str), [e], - detailed_message=f"the `id` field with value `{val}` " + detailed_message=f"the `name` field with value `{val}` " "is not valid because:", ) ) - __original_id_is_none = id is None - if id is None: + __original_name_is_none = name is None + if name is None: if docRoot is not None: - id = docRoot + name = docRoot else: - id = "_:" + str(_uuid__.uuid4()) - if not __original_id_is_none: - baseuri = cast(str, id) - label = None - if "label" in _doc: + name = "_:" + str(_uuid__.uuid4()) + if not __original_name_is_none: + baseuri = cast(str, name) + try: + if _doc.get("class") is None: + raise ValidationException("missing required field `class`", None, []) + + class_ = load_field( + _doc.get("class"), + uri_CreatorOrganizationTypeLoader_False_True_None_None, + baseuri, + loadingOptions, + lc=_doc.get("class") + ) + + if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): + raise ValidationException(f"tried `{cls.__name__}` but") + except ValidationException as e: + raise e + identifier = None + if "identifier" in _doc: try: - label = load_field( - _doc.get("label"), + identifier = load_field( + _doc.get("identifier"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("identifier") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `identifier`": _errors__.append( ValidationException( str(e), @@ -3862,13 +3793,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("identifier") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `identifier` field is not valid because:", + SourceLine(_doc, "identifier", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3880,28 +3811,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `identifier` field is not valid because:", + SourceLine(_doc, "identifier", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `identifier` field with value `{val}` " "is not valid because:", ) ) - doc = None - if "doc" in _doc: + url = None + if "url" in _doc: try: - doc = load_field( - _doc.get("doc"), - union_of_None_type_or_strtype_or_array_of_strtype, + url = load_field( + _doc.get("url"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("doc") + lc=_doc.get("url") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `doc`": + if str(e) == "missing required field `url`": _errors__.append( ValidationException( str(e), @@ -3909,13 +3840,13 @@ def fromDoc( ) ) else: - val = _doc.get("doc") + val = _doc.get("url") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `url` field is not valid because:", + SourceLine(_doc, "url", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3927,28 +3858,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `doc` field is not valid because:", - SourceLine(_doc, "doc", str), + "the `url` field is not valid because:", + SourceLine(_doc, "url", str), [e], - detailed_message=f"the `doc` field with value `{val}` " + detailed_message=f"the `url` field with value `{val}` " "is not valid because:", ) ) - position = None - if "position" in _doc: + email = None + if "email" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_StepPositionLoader, + email = load_field( + _doc.get("email"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("email") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `email`": _errors__.append( ValidationException( str(e), @@ -3956,13 +3887,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("email") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `email` field is not valid because:", + SourceLine(_doc, "email", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -3974,28 +3905,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `email` field is not valid because:", + SourceLine(_doc, "email", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `email` field with value `{val}` " "is not valid because:", ) ) - tool_id = None - if "tool_id" in _doc: + image = None + if "image" in _doc: try: - tool_id = load_field( - _doc.get("tool_id"), + image = load_field( + _doc.get("image"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("tool_id") + lc=_doc.get("image") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_id`": + if str(e) == "missing required field `image`": _errors__.append( ValidationException( str(e), @@ -4003,13 +3934,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_id") + val = _doc.get("image") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_id` field is not valid because:", - SourceLine(_doc, "tool_id", str), + "the `image` field is not valid because:", + SourceLine(_doc, "image", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4021,28 +3952,122 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_id` field is not valid because:", - SourceLine(_doc, "tool_id", str), + "the `image` field is not valid because:", + SourceLine(_doc, "image", str), [e], - detailed_message=f"the `tool_id` field with value `{val}` " + detailed_message=f"the `image` field with value `{val}` " "is not valid because:", ) ) - tool_shed_repository = None - if "tool_shed_repository" in _doc: + address = None + if "address" in _doc: try: - tool_shed_repository = load_field( - _doc.get("tool_shed_repository"), - union_of_None_type_or_ToolShedRepositoryLoader, + address = load_field( + _doc.get("address"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("address") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `address`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("address") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `address` field is not valid because:", + SourceLine(_doc, "address", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `address` field is not valid because:", + SourceLine(_doc, "address", str), + [e], + detailed_message=f"the `address` field with value `{val}` " + "is not valid because:", + ) + ) + alternateName = None + if "alternateName" in _doc: + try: + alternateName = load_field( + _doc.get("alternateName"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("alternateName") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `alternateName`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("alternateName") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `alternateName` field is not valid because:", + SourceLine(_doc, "alternateName", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `alternateName` field is not valid because:", + SourceLine(_doc, "alternateName", str), + [e], + detailed_message=f"the `alternateName` field with value `{val}` " + "is not valid because:", + ) + ) + telephone = None + if "telephone" in _doc: + try: + telephone = load_field( + _doc.get("telephone"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("tool_shed_repository") + lc=_doc.get("telephone") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_shed_repository`": + if str(e) == "missing required field `telephone`": _errors__.append( ValidationException( str(e), @@ -4050,13 +4075,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_shed_repository") + val = _doc.get("telephone") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_shed_repository` field is not valid because:", - SourceLine(_doc, "tool_shed_repository", str), + "the `telephone` field is not valid because:", + SourceLine(_doc, "telephone", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4068,28 +4093,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_shed_repository` field is not valid because:", - SourceLine(_doc, "tool_shed_repository", str), + "the `telephone` field is not valid because:", + SourceLine(_doc, "telephone", str), [e], - detailed_message=f"the `tool_shed_repository` field with value `{val}` " + detailed_message=f"the `telephone` field with value `{val}` " "is not valid because:", ) ) - tool_version = None - if "tool_version" in _doc: + faxNumber = None + if "faxNumber" in _doc: try: - tool_version = load_field( - _doc.get("tool_version"), + faxNumber = load_field( + _doc.get("faxNumber"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("tool_version") + lc=_doc.get("faxNumber") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_version`": + if str(e) == "missing required field `faxNumber`": _errors__.append( ValidationException( str(e), @@ -4097,13 +4122,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_version") + val = _doc.get("faxNumber") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_version` field is not valid because:", - SourceLine(_doc, "tool_version", str), + "the `faxNumber` field is not valid because:", + SourceLine(_doc, "faxNumber", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4115,75 +4140,238 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_version` field is not valid because:", - SourceLine(_doc, "tool_version", str), + "the `faxNumber` field is not valid because:", + SourceLine(_doc, "faxNumber", str), [e], - detailed_message=f"the `tool_version` field with value `{val}` " + detailed_message=f"the `faxNumber` field with value `{val}` " "is not valid because:", ) ) - errors = None - if "errors" in _doc: - try: - errors = load_field( - _doc.get("errors"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("errors") - ) + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `name`, `identifier`, `url`, `email`, `image`, `address`, `alternateName`, `telephone`, `faxNumber`, `class`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + name=name, + identifier=identifier, + url=url, + email=email, + image=image, + address=address, + alternateName=alternateName, + telephone=telephone, + faxNumber=faxNumber, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.name is not None: + u = save_relative_uri(self.name, base_url, True, None, relative_uris) + r["name"] = u + if self.class_ is not None: + uri = self.loadingOptions.vocab[self.class_] + if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): + uri = f"{p}:{self.class_}" + else: + uri = self.class_ + u = save_relative_uri(uri, self.name, False, None, relative_uris) + r["class"] = u + if self.identifier is not None: + r["identifier"] = save( + self.identifier, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.url is not None: + r["url"] = save( + self.url, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.email is not None: + r["email"] = save( + self.email, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.image is not None: + r["image"] = save( + self.image, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.address is not None: + r["address"] = save( + self.address, top=False, base_url=self.name, relative_uris=relative_uris + ) + if self.alternateName is not None: + r["alternateName"] = save( + self.alternateName, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.telephone is not None: + r["telephone"] = save( + self.telephone, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + if self.faxNumber is not None: + r["faxNumber"] = save( + self.faxNumber, + top=False, + base_url=self.name, + relative_uris=relative_uris, + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset( + [ + "name", + "identifier", + "url", + "email", + "image", + "address", + "alternateName", + "telephone", + "faxNumber", + "class", + ] + ) + + +class WorkflowInputParameter(InputParameter, HasStepPosition): + id: str + + def __init__( + self, + type_: Any, + optional: Any, + label: Optional[Any] = None, + doc: Optional[Any] = None, + id: Optional[Any] = None, + default: Optional[Any] = None, + position: Optional[Any] = None, + format: Optional[Any] = None, + collection_type: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.label = label + self.doc = doc + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.default = default + self.position = position + self.type_ = type_ + self.optional = optional + self.format = format + self.collection_type = collection_type + + def __eq__(self, other: Any) -> bool: + if isinstance(other, WorkflowInputParameter): + return bool( + self.label == other.label + and self.doc == other.doc + and self.id == other.id + and self.default == other.default + and self.position == other.position + and self.type_ == other.type_ + and self.optional == other.optional + and self.format == other.format + and self.collection_type == other.collection_type + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.label, + self.doc, + self.id, + self.default, + self.position, + self.type_, + self.optional, + self.format, + self.collection_type, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "WorkflowInputParameter": + _doc = copy.copy(doc) - if str(e) == "missing required field `errors`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("errors") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `errors` field is not valid because:", - SourceLine(_doc, "errors", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `errors` field is not valid because:", - SourceLine(_doc, "errors", str), - [e], - detailed_message=f"the `errors` field with value `{val}` " - "is not valid because:", - ) - ) - uuid = None - if "uuid" in _doc: + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + id = None + if "id" in _doc: try: - uuid = load_field( - _doc.get("uuid"), - union_of_None_type_or_strtype, + id = load_field( + _doc.get("id"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("uuid") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `uuid`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -4191,13 +4379,13 @@ def fromDoc( ) ) else: - val = _doc.get("uuid") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `uuid` field is not valid because:", - SourceLine(_doc, "uuid", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4209,28 +4397,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `uuid` field is not valid because:", - SourceLine(_doc, "uuid", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `uuid` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - in_ = None - if "in" in _doc: + + __original_id_is_none = id is None + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "_:" + str(_uuid__.uuid4()) + if not __original_id_is_none: + baseuri = cast(str, id) + label = None + if "label" in _doc: try: - in_ = load_field( - _doc.get("in"), - idmap_in__union_of_None_type_or_array_of_WorkflowStepInputLoader, + label = load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("in") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `in`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -4238,13 +4435,13 @@ def fromDoc( ) ) else: - val = _doc.get("in") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4256,28 +4453,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `in` field is not valid because:", - SourceLine(_doc, "in", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `in` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - out = None - if "out" in _doc: + doc = None + if "doc" in _doc: try: - out = load_field( - _doc.get("out"), - idmap_out_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_or_None_type, + doc = load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("out") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `out`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -4285,13 +4482,13 @@ def fromDoc( ) ) else: - val = _doc.get("out") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `out` field is not valid because:", - SourceLine(_doc, "out", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4303,28 +4500,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `out` field is not valid because:", - SourceLine(_doc, "out", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `out` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - state = None - if "state" in _doc: + default = None + if "default" in _doc: try: - state = load_field( - _doc.get("state"), + default = load_field( + _doc.get("default"), union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("state") + lc=_doc.get("default") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `state`": + if str(e) == "missing required field `default`": _errors__.append( ValidationException( str(e), @@ -4332,13 +4529,13 @@ def fromDoc( ) ) else: - val = _doc.get("state") + val = _doc.get("default") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `state` field is not valid because:", - SourceLine(_doc, "state", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4350,28 +4547,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `state` field is not valid because:", - SourceLine(_doc, "state", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [e], - detailed_message=f"the `state` field with value `{val}` " + detailed_message=f"the `default` field with value `{val}` " "is not valid because:", ) ) - tool_state = None - if "tool_state" in _doc: + position = None + if "position" in _doc: try: - tool_state = load_field( - _doc.get("tool_state"), - union_of_None_type_or_Any_type, + position = load_field( + _doc.get("position"), + union_of_None_type_or_StepPositionLoader, baseuri, loadingOptions, - lc=_doc.get("tool_state") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `tool_state`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -4379,13 +4576,13 @@ def fromDoc( ) ) else: - val = _doc.get("tool_state") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `tool_state` field is not valid because:", - SourceLine(_doc, "tool_state", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4397,10 +4594,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `tool_state` field is not valid because:", - SourceLine(_doc, "tool_state", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `tool_state` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) @@ -4409,7 +4606,7 @@ def fromDoc( try: type_ = load_field( _doc.get("type"), - typedsl_union_of_None_type_or_WorkflowStepTypeLoader_2, + typedsl_union_of_GalaxyTypeLoader_or_None_type_or_array_of_union_of_GalaxyTypeLoader_2, baseuri, loadingOptions, lc=_doc.get("type") @@ -4451,23 +4648,21 @@ def fromDoc( "is not valid because:", ) ) - run = None - if "run" in _doc: - - subscope_baseuri = expand_url('run', baseuri, loadingOptions, True) + optional = None + if "optional" in _doc: try: - run = load_field( - _doc.get("run"), - uri_union_of_None_type_or_Any_type_False_False_None_None, - subscope_baseuri, + optional = load_field( + _doc.get("optional"), + union_of_booltype_or_None_type, + baseuri, loadingOptions, - lc=_doc.get("run") + lc=_doc.get("optional") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `run`": + if str(e) == "missing required field `optional`": _errors__.append( ValidationException( str(e), @@ -4475,13 +4670,13 @@ def fromDoc( ) ) else: - val = _doc.get("run") + val = _doc.get("optional") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), + "the `optional` field is not valid because:", + SourceLine(_doc, "optional", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4493,28 +4688,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `run` field is not valid because:", - SourceLine(_doc, "run", str), + "the `optional` field is not valid because:", + SourceLine(_doc, "optional", str), [e], - detailed_message=f"the `run` field with value `{val}` " + detailed_message=f"the `optional` field with value `{val}` " "is not valid because:", ) ) - runtime_inputs = None - if "runtime_inputs" in _doc: + format = None + if "format" in _doc: try: - runtime_inputs = load_field( - _doc.get("runtime_inputs"), + format = load_field( + _doc.get("format"), union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("runtime_inputs") + lc=_doc.get("format") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `runtime_inputs`": + if str(e) == "missing required field `format`": _errors__.append( ValidationException( str(e), @@ -4522,13 +4717,13 @@ def fromDoc( ) ) else: - val = _doc.get("runtime_inputs") + val = _doc.get("format") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `runtime_inputs` field is not valid because:", - SourceLine(_doc, "runtime_inputs", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4540,28 +4735,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `runtime_inputs` field is not valid because:", - SourceLine(_doc, "runtime_inputs", str), + "the `format` field is not valid because:", + SourceLine(_doc, "format", str), [e], - detailed_message=f"the `runtime_inputs` field with value `{val}` " + detailed_message=f"the `format` field with value `{val}` " "is not valid because:", ) ) - when = None - if "when" in _doc: + collection_type = None + if "collection_type" in _doc: try: - when = load_field( - _doc.get("when"), + collection_type = load_field( + _doc.get("collection_type"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("when") + lc=_doc.get("collection_type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `when`": + if str(e) == "missing required field `collection_type`": _errors__.append( ValidationException( str(e), @@ -4569,13 +4764,13 @@ def fromDoc( ) ) else: - val = _doc.get("when") + val = _doc.get("collection_type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `when` field is not valid because:", - SourceLine(_doc, "when", str), + "the `collection_type` field is not valid because:", + SourceLine(_doc, "collection_type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4587,10 +4782,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `when` field is not valid because:", - SourceLine(_doc, "when", str), + "the `collection_type` field is not valid because:", + SourceLine(_doc, "collection_type", str), [e], - detailed_message=f"the `when` field with value `{val}` " + detailed_message=f"the `collection_type` field with value `{val}` " "is not valid because:", ) ) @@ -4609,7 +4804,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `label`, `doc`, `position`, `tool_id`, `tool_shed_repository`, `tool_version`, `errors`, `uuid`, `in`, `out`, `state`, `tool_state`, `type`, `run`, `runtime_inputs`, `when`".format( + "invalid field `{}`, expected one of: `label`, `doc`, `id`, `default`, `position`, `type`, `optional`, `format`, `collection_type`".format( k ), SourceLine(_doc, k, str), @@ -4619,23 +4814,15 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, label=label, doc=doc, + id=id, + default=default, position=position, - tool_id=tool_id, - tool_shed_repository=tool_shed_repository, - tool_version=tool_version, - errors=errors, - uuid=uuid, - in_=in_, - out=out, - state=state, - tool_state=tool_state, type_=type_, - run=run, - runtime_inputs=runtime_inputs, - when=when, + optional=optional, + format=format, + collection_type=collection_type, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -4664,73 +4851,33 @@ def save( r["doc"] = save( self.doc, top=False, base_url=self.id, relative_uris=relative_uris ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) if self.position is not None: r["position"] = save( self.position, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.tool_id is not None: - r["tool_id"] = save( - self.tool_id, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.tool_shed_repository is not None: - r["tool_shed_repository"] = save( - self.tool_shed_repository, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.tool_version is not None: - r["tool_version"] = save( - self.tool_version, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.errors is not None: - r["errors"] = save( - self.errors, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.uuid is not None: - r["uuid"] = save( - self.uuid, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.in_ is not None: - r["in"] = save( - self.in_, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.out is not None: - r["out"] = save( - self.out, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.state is not None: - r["state"] = save( - self.state, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.tool_state is not None: - r["tool_state"] = save( - self.tool_state, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) if self.type_ is not None: r["type"] = save( self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.run is not None: - u = save_relative_uri(self.run, self.id, False, None, relative_uris) - r["run"] = u - if self.runtime_inputs is not None: - r["runtime_inputs"] = save( - self.runtime_inputs, + if self.optional is not None: + r["optional"] = save( + self.optional, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.format is not None: + r["format"] = save( + self.format, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.collection_type is not None: + r["collection_type"] = save( + self.collection_type, top=False, base_url=self.id, relative_uris=relative_uris, ) - if self.when is not None: - r["when"] = save( - self.when, top=False, base_url=self.id, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -4742,34 +4889,25 @@ def save( attrs = frozenset( [ - "id", "label", "doc", + "id", + "default", "position", - "tool_id", - "tool_shed_repository", - "tool_version", - "errors", - "uuid", - "in", - "out", - "state", - "tool_state", "type", - "run", - "runtime_inputs", - "when", + "optional", + "format", + "collection_type", ] ) -class Sink(Saveable): - pass - - -class WorkflowStepInput(Identified, Sink, Labeled): +class WorkflowOutputParameter(OutputParameter): """ - TODO: + Describe an output parameter of a workflow. The parameter must be + connected to one parameter defined in the workflow that + will provide the value of the output parameter. It is legal to + connect a WorkflowInputParameter to a WorkflowOutputParameter. """ @@ -4777,10 +4915,11 @@ class WorkflowStepInput(Identified, Sink, Labeled): def __init__( self, - id: Optional[Any] = None, - source: Optional[Any] = None, label: Optional[Any] = None, - default: Optional[Any] = None, + doc: Optional[Any] = None, + id: Optional[Any] = None, + outputSource: Optional[Any] = None, + type_: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -4792,23 +4931,25 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.source = source self.label = label - self.default = default + self.doc = doc + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.outputSource = outputSource + self.type_ = type_ def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStepInput): + if isinstance(other, WorkflowOutputParameter): return bool( - self.id == other.id - and self.source == other.source - and self.label == other.label - and self.default == other.default + self.label == other.label + and self.doc == other.doc + and self.id == other.id + and self.outputSource == other.outputSource + and self.type_ == other.type_ ) return False def __hash__(self) -> int: - return hash((self.id, self.source, self.label, self.default)) + return hash((self.label, self.doc, self.id, self.outputSource, self.type_)) @classmethod def fromDoc( @@ -4817,7 +4958,7 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "WorkflowStepInput": + ) -> "WorkflowOutputParameter": _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -4880,21 +5021,21 @@ def fromDoc( id = "_:" + str(_uuid__.uuid4()) if not __original_id_is_none: baseuri = cast(str, id) - source = None - if "source" in _doc: + label = None + if "label" in _doc: try: - source = load_field( - _doc.get("source"), - uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, + label = load_field( + _doc.get("label"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("source") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `source`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -4902,13 +5043,13 @@ def fromDoc( ) ) else: - val = _doc.get("source") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `source` field is not valid because:", - SourceLine(_doc, "source", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4920,28 +5061,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `source` field is not valid because:", - SourceLine(_doc, "source", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `source` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + doc = None + if "doc" in _doc: try: - label = load_field( - _doc.get("label"), + doc = load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, + baseuri, + loadingOptions, + lc=_doc.get("doc") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `doc`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("doc") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), + [e], + detailed_message=f"the `doc` field with value `{val}` " + "is not valid because:", + ) + ) + outputSource = None + if "outputSource" in _doc: + try: + outputSource = load_field( + _doc.get("outputSource"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("outputSource") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `outputSource`": _errors__.append( ValidationException( str(e), @@ -4949,13 +5137,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("outputSource") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -4967,28 +5155,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `outputSource` field is not valid because:", + SourceLine(_doc, "outputSource", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `outputSource` field with value `{val}` " "is not valid because:", ) ) - default = None - if "default" in _doc: + type_ = None + if "type" in _doc: try: - default = load_field( - _doc.get("default"), - union_of_None_type_or_Any_type, + type_ = load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_GalaxyTypeLoader_2, baseuri, loadingOptions, - lc=_doc.get("default") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `default`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -4996,13 +5184,13 @@ def fromDoc( ) ) else: - val = _doc.get("default") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5014,10 +5202,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `default` field is not valid because:", - SourceLine(_doc, "default", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `default` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) @@ -5036,7 +5224,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `source`, `label`, `default`".format( + "invalid field `{}`, expected one of: `label`, `doc`, `id`, `outputSource`, `type`".format( k ), SourceLine(_doc, k, str), @@ -5046,10 +5234,11 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - id=id, - source=source, label=label, - default=default, + doc=doc, + id=id, + outputSource=outputSource, + type_=type_, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -5070,16 +5259,24 @@ def save( if self.id is not None: u = save_relative_uri(self.id, base_url, True, None, relative_uris) r["id"] = u - if self.source is not None: - u = save_relative_uri(self.source, self.id, False, 2, relative_uris) - r["source"] = u if self.label is not None: r["label"] = save( self.label, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.default is not None: - r["default"] = save( - self.default, top=False, base_url=self.id, relative_uris=relative_uris + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.outputSource is not None: + r["outputSource"] = save( + self.outputSource, + top=False, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris ) # top refers to the directory level @@ -5090,168 +5287,34 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["id", "source", "label", "default"]) - + attrs = frozenset(["label", "doc", "id", "outputSource", "type"]) -class Report(Saveable): - """ - Definition of an invocation report for this workflow. Currently the only - field is 'markdown'. +class WorkflowStep( + Identified, + Labeled, + Documented, + HasStepPosition, + ReferencesTool, + HasStepErrors, + HasUUID, +): """ + This represents a non-input step a Galaxy Workflow. - def __init__( - self, - markdown: Any, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.markdown = markdown - - def __eq__(self, other: Any) -> bool: - if isinstance(other, Report): - return bool(self.markdown == other.markdown) - return False - - def __hash__(self) -> int: - return hash((self.markdown)) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "Report": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - try: - if _doc.get("markdown") is None: - raise ValidationException("missing required field `markdown`", None, []) - - markdown = load_field( - _doc.get("markdown"), - strtype, - baseuri, - loadingOptions, - lc=_doc.get("markdown") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `markdown`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("markdown") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `markdown` field is not valid because:", - SourceLine(_doc, "markdown", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `markdown` field is not valid because:", - SourceLine(_doc, "markdown", str), - [e], - detailed_message=f"the `markdown` field with value `{val}` " - "is not valid because:", - ) - ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: - _errors__.append( - ValidationException( - "invalid field `{}`, expected one of: `markdown`".format(k), - SourceLine(_doc, k, str), - ) - ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - markdown=markdown, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.markdown is not None: - r["markdown"] = save( - self.markdown, top=False, base_url=base_url, relative_uris=relative_uris - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset(["markdown"]) + # A note about `state` and `tool_state` fields. + Only one or the other should be specified. These are two ways to represent the "state" + of a tool at this workflow step. Both are essentially maps from parameter names to + parameter values. -class WorkflowStepOutput(Identified): - """ - Associate an output parameter of the underlying process with a workflow - parameter. The workflow parameter (given in the `id` field) be may be used - as a `source` to connect with input parameters of other workflow steps, or - with an output parameter of the process. + `tool_state` is much more low-level and expects a flat dictionary with each value a JSON + dump. Nested tool structures such as conditionals and repeats should have all their values + in the JSON dumped string. In general `tool_state` may be present in workflows exported from + Galaxy but shouldn't be written by humans. - A unique identifier for this workflow output parameter. This is - the identifier to use in the `source` field of `WorkflowStepInput` - to connect the output value to downstream parameters. + `state` can contained a typed map. Repeat values can be represented as YAML arrays. An alternative + to representing `state` this way is defining inputs with default values. """ @@ -5259,14 +5322,23 @@ class WorkflowStepOutput(Identified): def __init__( self, + out: Any, id: Optional[Any] = None, - add_tags: Optional[Any] = None, - change_datatype: Optional[Any] = None, - delete_intermediate_datasets: Optional[Any] = None, - hide: Optional[Any] = None, - remove_tags: Optional[Any] = None, - rename: Optional[Any] = None, - set_columns: Optional[Any] = None, + label: Optional[Any] = None, + doc: Optional[Any] = None, + position: Optional[Any] = None, + tool_id: Optional[Any] = None, + tool_shed_repository: Optional[Any] = None, + tool_version: Optional[Any] = None, + errors: Optional[Any] = None, + uuid: Optional[Any] = None, + in_: Optional[Any] = None, + state: Optional[Any] = None, + tool_state: Optional[Any] = None, + type_: Optional[Any] = None, + run: Optional[Any] = None, + runtime_inputs: Optional[Any] = None, + when: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -5276,29 +5348,46 @@ def __init__( self.extension_fields = CommentedMap() if loadingOptions: self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) - self.add_tags = add_tags - self.change_datatype = change_datatype - self.delete_intermediate_datasets = delete_intermediate_datasets - self.hide = hide - self.remove_tags = remove_tags - self.rename = rename - self.set_columns = set_columns + else: + self.loadingOptions = LoadingOptions() + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.label = label + self.doc = doc + self.position = position + self.tool_id = tool_id + self.tool_shed_repository = tool_shed_repository + self.tool_version = tool_version + self.errors = errors + self.uuid = uuid + self.in_ = in_ + self.out = out + self.state = state + self.tool_state = tool_state + self.type_ = type_ + self.run = run + self.runtime_inputs = runtime_inputs + self.when = when def __eq__(self, other: Any) -> bool: - if isinstance(other, WorkflowStepOutput): + if isinstance(other, WorkflowStep): return bool( self.id == other.id - and self.add_tags == other.add_tags - and self.change_datatype == other.change_datatype - and self.delete_intermediate_datasets - == other.delete_intermediate_datasets - and self.hide == other.hide - and self.remove_tags == other.remove_tags - and self.rename == other.rename - and self.set_columns == other.set_columns + and self.label == other.label + and self.doc == other.doc + and self.position == other.position + and self.tool_id == other.tool_id + and self.tool_shed_repository == other.tool_shed_repository + and self.tool_version == other.tool_version + and self.errors == other.errors + and self.uuid == other.uuid + and self.in_ == other.in_ + and self.out == other.out + and self.state == other.state + and self.tool_state == other.tool_state + and self.type_ == other.type_ + and self.run == other.run + and self.runtime_inputs == other.runtime_inputs + and self.when == other.when ) return False @@ -5306,13 +5395,22 @@ def __hash__(self) -> int: return hash( ( self.id, - self.add_tags, - self.change_datatype, - self.delete_intermediate_datasets, - self.hide, - self.remove_tags, - self.rename, - self.set_columns, + self.label, + self.doc, + self.position, + self.tool_id, + self.tool_shed_repository, + self.tool_version, + self.errors, + self.uuid, + self.in_, + self.out, + self.state, + self.tool_state, + self.type_, + self.run, + self.runtime_inputs, + self.when, ) ) @@ -5323,7 +5421,7 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "WorkflowStepOutput": + ) -> "WorkflowStep": _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -5386,115 +5484,21 @@ def fromDoc( id = "_:" + str(_uuid__.uuid4()) if not __original_id_is_none: baseuri = cast(str, id) - add_tags = None - if "add_tags" in _doc: - try: - add_tags = load_field( - _doc.get("add_tags"), - union_of_None_type_or_array_of_strtype, - baseuri, - loadingOptions, - lc=_doc.get("add_tags") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `add_tags`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("add_tags") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `add_tags` field is not valid because:", - SourceLine(_doc, "add_tags", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `add_tags` field is not valid because:", - SourceLine(_doc, "add_tags", str), - [e], - detailed_message=f"the `add_tags` field with value `{val}` " - "is not valid because:", - ) - ) - change_datatype = None - if "change_datatype" in _doc: + label = None + if "label" in _doc: try: - change_datatype = load_field( - _doc.get("change_datatype"), + label = load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("change_datatype") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `change_datatype`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("change_datatype") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `change_datatype` field is not valid because:", - SourceLine(_doc, "change_datatype", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `change_datatype` field is not valid because:", - SourceLine(_doc, "change_datatype", str), - [e], - detailed_message=f"the `change_datatype` field with value `{val}` " - "is not valid because:", - ) - ) - delete_intermediate_datasets = None - if "delete_intermediate_datasets" in _doc: - try: - delete_intermediate_datasets = load_field( - _doc.get("delete_intermediate_datasets"), - union_of_None_type_or_booltype, - baseuri, - loadingOptions, - lc=_doc.get("delete_intermediate_datasets") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `delete_intermediate_datasets`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -5502,13 +5506,13 @@ def fromDoc( ) ) else: - val = _doc.get("delete_intermediate_datasets") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `delete_intermediate_datasets` field is not valid because:", - SourceLine(_doc, "delete_intermediate_datasets", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5520,28 +5524,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `delete_intermediate_datasets` field is not valid because:", - SourceLine(_doc, "delete_intermediate_datasets", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `delete_intermediate_datasets` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - hide = None - if "hide" in _doc: + doc = None + if "doc" in _doc: try: - hide = load_field( - _doc.get("hide"), - union_of_None_type_or_booltype, + doc = load_field( + _doc.get("doc"), + union_of_None_type_or_strtype_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("hide") + lc=_doc.get("doc") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `hide`": + if str(e) == "missing required field `doc`": _errors__.append( ValidationException( str(e), @@ -5549,13 +5553,13 @@ def fromDoc( ) ) else: - val = _doc.get("hide") + val = _doc.get("doc") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `hide` field is not valid because:", - SourceLine(_doc, "hide", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5567,28 +5571,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `hide` field is not valid because:", - SourceLine(_doc, "hide", str), + "the `doc` field is not valid because:", + SourceLine(_doc, "doc", str), [e], - detailed_message=f"the `hide` field with value `{val}` " + detailed_message=f"the `doc` field with value `{val}` " "is not valid because:", ) ) - remove_tags = None - if "remove_tags" in _doc: + position = None + if "position" in _doc: try: - remove_tags = load_field( - _doc.get("remove_tags"), - union_of_None_type_or_array_of_strtype, + position = load_field( + _doc.get("position"), + union_of_None_type_or_StepPositionLoader, baseuri, loadingOptions, - lc=_doc.get("remove_tags") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `remove_tags`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -5596,13 +5600,13 @@ def fromDoc( ) ) else: - val = _doc.get("remove_tags") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `remove_tags` field is not valid because:", - SourceLine(_doc, "remove_tags", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5614,28 +5618,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `remove_tags` field is not valid because:", - SourceLine(_doc, "remove_tags", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `remove_tags` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - rename = None - if "rename" in _doc: + tool_id = None + if "tool_id" in _doc: try: - rename = load_field( - _doc.get("rename"), + tool_id = load_field( + _doc.get("tool_id"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("rename") + lc=_doc.get("tool_id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `rename`": + if str(e) == "missing required field `tool_id`": _errors__.append( ValidationException( str(e), @@ -5643,13 +5647,13 @@ def fromDoc( ) ) else: - val = _doc.get("rename") + val = _doc.get("tool_id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `rename` field is not valid because:", - SourceLine(_doc, "rename", str), + "the `tool_id` field is not valid because:", + SourceLine(_doc, "tool_id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5661,28 +5665,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `rename` field is not valid because:", - SourceLine(_doc, "rename", str), + "the `tool_id` field is not valid because:", + SourceLine(_doc, "tool_id", str), [e], - detailed_message=f"the `rename` field with value `{val}` " + detailed_message=f"the `tool_id` field with value `{val}` " "is not valid because:", ) ) - set_columns = None - if "set_columns" in _doc: + tool_shed_repository = None + if "tool_shed_repository" in _doc: try: - set_columns = load_field( - _doc.get("set_columns"), - union_of_None_type_or_Any_type, + tool_shed_repository = load_field( + _doc.get("tool_shed_repository"), + union_of_None_type_or_ToolShedRepositoryLoader, baseuri, loadingOptions, - lc=_doc.get("set_columns") + lc=_doc.get("tool_shed_repository") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `set_columns`": + if str(e) == "missing required field `tool_shed_repository`": _errors__.append( ValidationException( str(e), @@ -5690,13 +5694,13 @@ def fromDoc( ) ) else: - val = _doc.get("set_columns") + val = _doc.get("tool_shed_repository") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `set_columns` field is not valid because:", - SourceLine(_doc, "set_columns", str), + "the `tool_shed_repository` field is not valid because:", + SourceLine(_doc, "tool_shed_repository", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5708,235 +5712,75 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `set_columns` field is not valid because:", - SourceLine(_doc, "set_columns", str), + "the `tool_shed_repository` field is not valid because:", + SourceLine(_doc, "tool_shed_repository", str), [e], - detailed_message=f"the `set_columns` field with value `{val}` " + detailed_message=f"the `tool_shed_repository` field with value `{val}` " "is not valid because:", ) ) - extension_fields: dict[str, Any] = {} - for k in _doc.keys(): - if k not in cls.attrs: - if not k: - _errors__.append( - ValidationException("mapping with implicit null key") - ) - elif ":" in k: - ex = expand_url( - k, "", loadingOptions, scoped_id=False, vocab_term=False - ) - extension_fields[ex] = _doc[k] - else: + tool_version = None + if "tool_version" in _doc: + try: + tool_version = load_field( + _doc.get("tool_version"), + union_of_None_type_or_strtype, + baseuri, + loadingOptions, + lc=_doc.get("tool_version") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tool_version`": _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `id`, `add_tags`, `change_datatype`, `delete_intermediate_datasets`, `hide`, `remove_tags`, `rename`, `set_columns`".format( - k - ), - SourceLine(_doc, k, str), + str(e), + None ) ) - - if _errors__: - raise ValidationException("", None, _errors__, "*") - _constructed = cls( - id=id, - add_tags=add_tags, - change_datatype=change_datatype, - delete_intermediate_datasets=delete_intermediate_datasets, - hide=hide, - remove_tags=remove_tags, - rename=rename, - set_columns=set_columns, - extension_fields=extension_fields, - loadingOptions=loadingOptions, - ) - loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) - return _constructed - - def save( - self, top: bool = False, base_url: str = "", relative_uris: bool = True - ) -> dict[str, Any]: - r: dict[str, Any] = {} - - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.id is not None: - u = save_relative_uri(self.id, base_url, True, None, relative_uris) - r["id"] = u - if self.add_tags is not None: - r["add_tags"] = save( - self.add_tags, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.change_datatype is not None: - r["change_datatype"] = save( - self.change_datatype, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.delete_intermediate_datasets is not None: - r["delete_intermediate_datasets"] = save( - self.delete_intermediate_datasets, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.hide is not None: - r["hide"] = save( - self.hide, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.remove_tags is not None: - r["remove_tags"] = save( - self.remove_tags, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - if self.rename is not None: - r["rename"] = save( - self.rename, top=False, base_url=self.id, relative_uris=relative_uris - ) - if self.set_columns is not None: - r["set_columns"] = save( - self.set_columns, - top=False, - base_url=self.id, - relative_uris=relative_uris, - ) - - # top refers to the directory level - if top: - if self.loadingOptions.namespaces: - r["$namespaces"] = self.loadingOptions.namespaces - if self.loadingOptions.schemas: - r["$schemas"] = self.loadingOptions.schemas - return r - - attrs = frozenset( - [ - "id", - "add_tags", - "change_datatype", - "delete_intermediate_datasets", - "hide", - "remove_tags", - "rename", - "set_columns", - ] - ) - - -class BaseComment(Saveable): - """ - Base fields shared by all comment types. - - """ - - pass - - -class TextComment(BaseComment): - """ - A plain text annotation in the workflow editor. - - """ - - def __init__( - self, - type_: Any, - position: Optional[Any] = None, - size: Optional[Any] = None, - color: Optional[Any] = None, - label: Optional[Any] = None, - text: Optional[Any] = None, - bold: Optional[Any] = None, - italic: Optional[Any] = None, - text_size: Optional[Any] = None, - extension_fields: Optional[dict[str, Any]] = None, - loadingOptions: Optional[LoadingOptions] = None, - ) -> None: - if extension_fields: - self.extension_fields = extension_fields - else: - self.extension_fields = CommentedMap() - if loadingOptions: - self.loadingOptions = loadingOptions - else: - self.loadingOptions = LoadingOptions() - self.position = position - self.size = size - self.color = color - self.label = label - self.type_ = type_ - self.text = text - self.bold = bold - self.italic = italic - self.text_size = text_size - - def __eq__(self, other: Any) -> bool: - if isinstance(other, TextComment): - return bool( - self.position == other.position - and self.size == other.size - and self.color == other.color - and self.label == other.label - and self.type_ == other.type_ - and self.text == other.text - and self.bold == other.bold - and self.italic == other.italic - and self.text_size == other.text_size - ) - return False - - def __hash__(self) -> int: - return hash( - ( - self.position, - self.size, - self.color, - self.label, - self.type_, - self.text, - self.bold, - self.italic, - self.text_size, - ) - ) - - @classmethod - def fromDoc( - cls, - doc: Any, - baseuri: str, - loadingOptions: LoadingOptions, - docRoot: Optional[str] = None - ) -> "TextComment": - _doc = copy.copy(doc) - - if hasattr(doc, "lc"): - _doc.lc.data = doc.lc.data - _doc.lc.filename = doc.lc.filename - _errors__ = [] - position = None - if "position" in _doc: + else: + val = _doc.get("tool_version") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `tool_version` field is not valid because:", + SourceLine(_doc, "tool_version", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tool_version` field is not valid because:", + SourceLine(_doc, "tool_version", str), + [e], + detailed_message=f"the `tool_version` field with value `{val}` " + "is not valid because:", + ) + ) + errors = None + if "errors" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_Any_type, + errors = load_field( + _doc.get("errors"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("errors") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `errors`": _errors__.append( ValidationException( str(e), @@ -5944,13 +5788,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("errors") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `errors` field is not valid because:", + SourceLine(_doc, "errors", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -5962,28 +5806,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `errors` field is not valid because:", + SourceLine(_doc, "errors", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `errors` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + uuid = None + if "uuid" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_Any_type, + uuid = load_field( + _doc.get("uuid"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("uuid") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `uuid`": _errors__.append( ValidationException( str(e), @@ -5991,13 +5835,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("uuid") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `uuid` field is not valid because:", + SourceLine(_doc, "uuid", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6009,28 +5853,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `uuid` field is not valid because:", + SourceLine(_doc, "uuid", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `uuid` field with value `{val}` " "is not valid because:", ) ) - color = None - if "color" in _doc: + in_ = None + if "in" in _doc: try: - color = load_field( - _doc.get("color"), - union_of_None_type_or_strtype, + in_ = load_field( + _doc.get("in"), + idmap_in__union_of_None_type_or_array_of_WorkflowStepInputLoader, baseuri, loadingOptions, - lc=_doc.get("color") + lc=_doc.get("in") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `color`": + if str(e) == "missing required field `in`": _errors__.append( ValidationException( str(e), @@ -6038,13 +5882,13 @@ def fromDoc( ) ) else: - val = _doc.get("color") + val = _doc.get("in") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6056,28 +5900,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `in` field is not valid because:", + SourceLine(_doc, "in", str), [e], - detailed_message=f"the `color` field with value `{val}` " + detailed_message=f"the `in` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + out = None + if "out" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + out = load_field( + _doc.get("out"), + idmap_out_union_of_array_of_union_of_strtype_or_WorkflowStepOutputLoader_or_None_type, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("out") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `out`": _errors__.append( ValidationException( str(e), @@ -6085,13 +5929,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("out") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6103,76 +5947,122 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `out` field is not valid because:", + SourceLine(_doc, "out", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `out` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) + state = None + if "state" in _doc: + try: + state = load_field( + _doc.get("state"), + union_of_None_type_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("state") + ) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) + if str(e) == "missing required field `state`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], + str(e), + None ) ) else: + val = _doc.get("state") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `state` field is not valid because:", + SourceLine(_doc, "state", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `state` field is not valid because:", + SourceLine(_doc, "state", str), + [e], + detailed_message=f"the `state` field with value `{val}` " + "is not valid because:", + ) + ) + tool_state = None + if "tool_state" in _doc: + try: + tool_state = load_field( + _doc.get("tool_state"), + union_of_None_type_or_Any_type, + baseuri, + loadingOptions, + lc=_doc.get("tool_state") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `tool_state`": _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", + str(e), + None ) ) - text = None - if "text" in _doc: + else: + val = _doc.get("tool_state") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `tool_state` field is not valid because:", + SourceLine(_doc, "tool_state", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `tool_state` field is not valid because:", + SourceLine(_doc, "tool_state", str), + [e], + detailed_message=f"the `tool_state` field with value `{val}` " + "is not valid because:", + ) + ) + type_ = None + if "type" in _doc: try: - text = load_field( - _doc.get("text"), - union_of_None_type_or_strtype, + type_ = load_field( + _doc.get("type"), + typedsl_union_of_None_type_or_WorkflowStepTypeLoader_2, baseuri, loadingOptions, - lc=_doc.get("text") + lc=_doc.get("type") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `text`": + if str(e) == "missing required field `type`": _errors__.append( ValidationException( str(e), @@ -6180,13 +6070,13 @@ def fromDoc( ) ) else: - val = _doc.get("text") + val = _doc.get("type") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `text` field is not valid because:", - SourceLine(_doc, "text", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6198,28 +6088,30 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `text` field is not valid because:", - SourceLine(_doc, "text", str), + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), [e], - detailed_message=f"the `text` field with value `{val}` " + detailed_message=f"the `type` field with value `{val}` " "is not valid because:", ) ) - bold = None - if "bold" in _doc: + run = None + if "run" in _doc: + + subscope_baseuri = expand_url('run', baseuri, loadingOptions, True) try: - bold = load_field( - _doc.get("bold"), - union_of_None_type_or_booltype, - baseuri, + run = load_field( + _doc.get("run"), + uri_union_of_None_type_or_Any_type_False_False_None_None, + subscope_baseuri, loadingOptions, - lc=_doc.get("bold") + lc=_doc.get("run") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `bold`": + if str(e) == "missing required field `run`": _errors__.append( ValidationException( str(e), @@ -6227,13 +6119,13 @@ def fromDoc( ) ) else: - val = _doc.get("bold") + val = _doc.get("run") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `bold` field is not valid because:", - SourceLine(_doc, "bold", str), + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6245,28 +6137,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `bold` field is not valid because:", - SourceLine(_doc, "bold", str), + "the `run` field is not valid because:", + SourceLine(_doc, "run", str), [e], - detailed_message=f"the `bold` field with value `{val}` " + detailed_message=f"the `run` field with value `{val}` " "is not valid because:", ) ) - italic = None - if "italic" in _doc: + runtime_inputs = None + if "runtime_inputs" in _doc: try: - italic = load_field( - _doc.get("italic"), - union_of_None_type_or_booltype, + runtime_inputs = load_field( + _doc.get("runtime_inputs"), + union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("italic") + lc=_doc.get("runtime_inputs") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `italic`": + if str(e) == "missing required field `runtime_inputs`": _errors__.append( ValidationException( str(e), @@ -6274,13 +6166,13 @@ def fromDoc( ) ) else: - val = _doc.get("italic") + val = _doc.get("runtime_inputs") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `italic` field is not valid because:", - SourceLine(_doc, "italic", str), + "the `runtime_inputs` field is not valid because:", + SourceLine(_doc, "runtime_inputs", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6292,28 +6184,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `italic` field is not valid because:", - SourceLine(_doc, "italic", str), + "the `runtime_inputs` field is not valid because:", + SourceLine(_doc, "runtime_inputs", str), [e], - detailed_message=f"the `italic` field with value `{val}` " + detailed_message=f"the `runtime_inputs` field with value `{val}` " "is not valid because:", ) ) - text_size = None - if "text_size" in _doc: + when = None + if "when" in _doc: try: - text_size = load_field( - _doc.get("text_size"), - union_of_None_type_or_floattype_or_inttype, + when = load_field( + _doc.get("when"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("text_size") + lc=_doc.get("when") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `text_size`": + if str(e) == "missing required field `when`": _errors__.append( ValidationException( str(e), @@ -6321,13 +6213,13 @@ def fromDoc( ) ) else: - val = _doc.get("text_size") + val = _doc.get("when") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `text_size` field is not valid because:", - SourceLine(_doc, "text_size", str), + "the `when` field is not valid because:", + SourceLine(_doc, "when", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6339,10 +6231,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `text_size` field is not valid because:", - SourceLine(_doc, "text_size", str), + "the `when` field is not valid because:", + SourceLine(_doc, "when", str), [e], - detailed_message=f"the `text_size` field with value `{val}` " + detailed_message=f"the `when` field with value `{val}` " "is not valid because:", ) ) @@ -6361,7 +6253,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `position`, `size`, `color`, `label`, `type`, `text`, `bold`, `italic`, `text_size`".format( + "invalid field `{}`, expected one of: `id`, `label`, `doc`, `position`, `tool_id`, `tool_shed_repository`, `tool_version`, `errors`, `uuid`, `in`, `out`, `state`, `tool_state`, `type`, `run`, `runtime_inputs`, `when`".format( k ), SourceLine(_doc, k, str), @@ -6371,18 +6263,27 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - position=position, - size=size, - color=color, + id=id, label=label, + doc=doc, + position=position, + tool_id=tool_id, + tool_shed_repository=tool_shed_repository, + tool_version=tool_version, + errors=errors, + uuid=uuid, + in_=in_, + out=out, + state=state, + tool_state=tool_state, type_=type_, - text=text, - bold=bold, - italic=italic, - text_size=text_size, + run=run, + runtime_inputs=runtime_inputs, + when=when, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -6396,45 +6297,84 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, base_url, True, None, relative_uris) + r["id"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.doc is not None: + r["doc"] = save( + self.doc, top=False, base_url=self.id, relative_uris=relative_uris + ) if self.position is not None: r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris + self.position, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris + if self.tool_id is not None: + r["tool_id"] = save( + self.tool_id, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.color is not None: - r["color"] = save( - self.color, top=False, base_url=base_url, relative_uris=relative_uris + if self.tool_shed_repository is not None: + r["tool_shed_repository"] = save( + self.tool_shed_repository, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris + if self.tool_version is not None: + r["tool_version"] = save( + self.tool_version, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.errors is not None: + r["errors"] = save( + self.errors, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.text is not None: - r["text"] = save( - self.text, top=False, base_url=base_url, relative_uris=relative_uris + if self.uuid is not None: + r["uuid"] = save( + self.uuid, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.bold is not None: - r["bold"] = save( - self.bold, top=False, base_url=base_url, relative_uris=relative_uris + if self.in_ is not None: + r["in"] = save( + self.in_, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.italic is not None: - r["italic"] = save( - self.italic, top=False, base_url=base_url, relative_uris=relative_uris + if self.out is not None: + r["out"] = save( + self.out, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.text_size is not None: - r["text_size"] = save( - self.text_size, + if self.state is not None: + r["state"] = save( + self.state, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.tool_state is not None: + r["tool_state"] = save( + self.tool_state, top=False, - base_url=base_url, + base_url=self.id, + relative_uris=relative_uris, + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.run is not None: + u = save_relative_uri(self.run, self.id, False, None, relative_uris) + r["run"] = u + if self.runtime_inputs is not None: + r["runtime_inputs"] = save( + self.runtime_inputs, + top=False, + base_url=self.id, relative_uris=relative_uris, ) + if self.when is not None: + r["when"] = save( + self.when, top=False, base_url=self.id, relative_uris=relative_uris + ) # top refers to the directory level if top: @@ -6446,33 +6386,45 @@ def save( attrs = frozenset( [ - "position", - "size", - "color", + "id", "label", + "doc", + "position", + "tool_id", + "tool_shed_repository", + "tool_version", + "errors", + "uuid", + "in", + "out", + "state", + "tool_state", "type", - "text", - "bold", - "italic", - "text_size", + "run", + "runtime_inputs", + "when", ] ) -class MarkdownComment(BaseComment): +class Sink(Saveable): + pass + + +class WorkflowStepInput(Identified, Sink, Labeled): """ - A Markdown-rendered annotation in the workflow editor. + TODO: """ + id: str + def __init__( self, - type_: Any, - position: Optional[Any] = None, - size: Optional[Any] = None, - color: Optional[Any] = None, + id: Optional[Any] = None, + source: Optional[Any] = None, label: Optional[Any] = None, - text: Optional[Any] = None, + default: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -6484,29 +6436,23 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.position = position - self.size = size - self.color = color + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.source = source self.label = label - self.type_ = type_ - self.text = text + self.default = default def __eq__(self, other: Any) -> bool: - if isinstance(other, MarkdownComment): + if isinstance(other, WorkflowStepInput): return bool( - self.position == other.position - and self.size == other.size - and self.color == other.color + self.id == other.id + and self.source == other.source and self.label == other.label - and self.type_ == other.type_ - and self.text == other.text + and self.default == other.default ) return False def __hash__(self) -> int: - return hash( - (self.position, self.size, self.color, self.label, self.type_, self.text) - ) + return hash((self.id, self.source, self.label, self.default)) @classmethod def fromDoc( @@ -6515,28 +6461,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "MarkdownComment": + ) -> "WorkflowStepInput": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - position = None - if "position" in _doc: + id = None + if "id" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_Any_type, + id = load_field( + _doc.get("id"), + uri_union_of_None_type_or_strtype_True_False_None_None, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("id") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `id`": _errors__.append( ValidationException( str(e), @@ -6544,13 +6490,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("id") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6562,28 +6508,37 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `id` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + + __original_id_is_none = id is None + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "_:" + str(_uuid__.uuid4()) + if not __original_id_is_none: + baseuri = cast(str, id) + source = None + if "source" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_Any_type, + source = load_field( + _doc.get("source"), + uri_union_of_None_type_or_strtype_or_array_of_strtype_False_False_2_None, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("source") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `source`": _errors__.append( ValidationException( str(e), @@ -6591,13 +6546,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("source") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6609,28 +6564,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `source` field is not valid because:", + SourceLine(_doc, "source", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `source` field with value `{val}` " "is not valid because:", ) ) - color = None - if "color" in _doc: + label = None + if "label" in _doc: try: - color = load_field( - _doc.get("color"), + label = load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("color") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `color`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -6638,13 +6593,13 @@ def fromDoc( ) ) else: - val = _doc.get("color") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6656,28 +6611,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `color` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + default = None + if "default" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + default = load_field( + _doc.get("default"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("default") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `default`": _errors__.append( ValidationException( str(e), @@ -6685,13 +6640,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("default") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6703,29 +6658,146 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `default` field is not valid because:", + SourceLine(_doc, "default", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `default` field with value `{val}` " "is not valid because:", ) ) + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `id`, `source`, `label`, `default`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + id=id, + source=source, + label=label, + default=default, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, base_url, True, None, relative_uris) + r["id"] = u + if self.source is not None: + u = save_relative_uri(self.source, self.id, False, 2, relative_uris) + r["source"] = u + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.default is not None: + r["default"] = save( + self.default, top=False, base_url=self.id, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["id", "source", "label", "default"]) + + +class Report(Saveable): + """ + Definition of an invocation report for this workflow. Currently the only + field is 'markdown'. + + """ + + def __init__( + self, + markdown: Any, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.markdown = markdown + + def __eq__(self, other: Any) -> bool: + if isinstance(other, Report): + return bool(self.markdown == other.markdown) + return False + + def __hash__(self) -> int: + return hash((self.markdown)) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "Report": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) + if _doc.get("markdown") is None: + raise ValidationException("missing required field `markdown`", None, []) - type_ = load_field( - _doc.get("type"), - typedsl_strtype_2, + markdown = load_field( + _doc.get("markdown"), + strtype, baseuri, loadingOptions, - lc=_doc.get("type") + lc=_doc.get("markdown") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `type`": + if str(e) == "missing required field `markdown`": _errors__.append( ValidationException( str(e), @@ -6733,13 +6805,13 @@ def fromDoc( ) ) else: - val = _doc.get("type") + val = _doc.get("markdown") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `markdown` field is not valid because:", + SourceLine(_doc, "markdown", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -6751,60 +6823,13 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), + "the `markdown` field is not valid because:", + SourceLine(_doc, "markdown", str), [e], - detailed_message=f"the `type` field with value `{val}` " + detailed_message=f"the `markdown` field with value `{val}` " "is not valid because:", ) ) - text = None - if "text" in _doc: - try: - text = load_field( - _doc.get("text"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("text") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `text`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("text") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `text` field is not valid because:", - SourceLine(_doc, "text", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `text` field is not valid because:", - SourceLine(_doc, "text", str), - [e], - detailed_message=f"the `text` field with value `{val}` " - "is not valid because:", - ) - ) extension_fields: dict[str, Any] = {} for k in _doc.keys(): if k not in cls.attrs: @@ -6820,9 +6845,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `position`, `size`, `color`, `label`, `type`, `text`".format( - k - ), + "invalid field `{}`, expected one of: `markdown`".format(k), SourceLine(_doc, k, str), ) ) @@ -6830,12 +6853,7 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - position=position, - size=size, - color=color, - label=label, - type_=type_, - text=text, + markdown=markdown, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -6852,29 +6870,9 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.color is not None: - r["color"] = save( - self.color, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.text is not None: - r["text"] = save( - self.text, top=False, base_url=base_url, relative_uris=relative_uris + if self.markdown is not None: + r["markdown"] = save( + self.markdown, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -6885,25 +6883,34 @@ def save( r["$schemas"] = self.loadingOptions.schemas return r - attrs = frozenset(["position", "size", "color", "label", "type", "text"]) + attrs = frozenset(["markdown"]) -class FrameComment(BaseComment): +class WorkflowStepOutput(Identified): """ - A rectangular grouping box that visually contains steps and other comments. + Associate an output parameter of the underlying process with a workflow + parameter. The workflow parameter (given in the `id` field) be may be used + as a `source` to connect with input parameters of other workflow steps, or + with an output parameter of the process. + + A unique identifier for this workflow output parameter. This is + the identifier to use in the `source` field of `WorkflowStepInput` + to connect the output value to downstream parameters. """ + id: str + def __init__( self, - type_: Any, - position: Optional[Any] = None, - size: Optional[Any] = None, - color: Optional[Any] = None, - label: Optional[Any] = None, - title: Optional[Any] = None, - contains_steps: Optional[Any] = None, - contains_comments: Optional[Any] = None, + id: Optional[Any] = None, + add_tags: Optional[Any] = None, + change_datatype: Optional[Any] = None, + delete_intermediate_datasets: Optional[Any] = None, + hide: Optional[Any] = None, + remove_tags: Optional[Any] = None, + rename: Optional[Any] = None, + set_columns: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -6915,40 +6922,41 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.position = position - self.size = size - self.color = color - self.label = label - self.type_ = type_ - self.title = title - self.contains_steps = contains_steps - self.contains_comments = contains_comments + self.id = id if id is not None else "_:" + str(_uuid__.uuid4()) + self.add_tags = add_tags + self.change_datatype = change_datatype + self.delete_intermediate_datasets = delete_intermediate_datasets + self.hide = hide + self.remove_tags = remove_tags + self.rename = rename + self.set_columns = set_columns def __eq__(self, other: Any) -> bool: - if isinstance(other, FrameComment): + if isinstance(other, WorkflowStepOutput): return bool( - self.position == other.position - and self.size == other.size - and self.color == other.color - and self.label == other.label - and self.type_ == other.type_ - and self.title == other.title - and self.contains_steps == other.contains_steps - and self.contains_comments == other.contains_comments + self.id == other.id + and self.add_tags == other.add_tags + and self.change_datatype == other.change_datatype + and self.delete_intermediate_datasets + == other.delete_intermediate_datasets + and self.hide == other.hide + and self.remove_tags == other.remove_tags + and self.rename == other.rename + and self.set_columns == other.set_columns ) return False def __hash__(self) -> int: return hash( ( - self.position, - self.size, - self.color, - self.label, - self.type_, - self.title, - self.contains_steps, - self.contains_comments, + self.id, + self.add_tags, + self.change_datatype, + self.delete_intermediate_datasets, + self.hide, + self.remove_tags, + self.rename, + self.set_columns, ) ) @@ -6959,28 +6967,84 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "FrameComment": + ) -> "WorkflowStepOutput": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - position = None - if "position" in _doc: + id = None + if "id" in _doc: try: - position = load_field( - _doc.get("position"), - union_of_None_type_or_Any_type, + id = load_field( + _doc.get("id"), + uri_union_of_None_type_or_strtype_True_False_None_None, + baseuri, + loadingOptions, + lc=_doc.get("id") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `id`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("id") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `id` field is not valid because:", + SourceLine(_doc, "id", str), + [e], + detailed_message=f"the `id` field with value `{val}` " + "is not valid because:", + ) + ) + + __original_id_is_none = id is None + if id is None: + if docRoot is not None: + id = docRoot + else: + id = "_:" + str(_uuid__.uuid4()) + if not __original_id_is_none: + baseuri = cast(str, id) + add_tags = None + if "add_tags" in _doc: + try: + add_tags = load_field( + _doc.get("add_tags"), + union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("position") + lc=_doc.get("add_tags") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `position`": + if str(e) == "missing required field `add_tags`": _errors__.append( ValidationException( str(e), @@ -6988,13 +7052,13 @@ def fromDoc( ) ) else: - val = _doc.get("position") + val = _doc.get("add_tags") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `add_tags` field is not valid because:", + SourceLine(_doc, "add_tags", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7006,28 +7070,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `position` field is not valid because:", - SourceLine(_doc, "position", str), + "the `add_tags` field is not valid because:", + SourceLine(_doc, "add_tags", str), [e], - detailed_message=f"the `position` field with value `{val}` " + detailed_message=f"the `add_tags` field with value `{val}` " "is not valid because:", ) ) - size = None - if "size" in _doc: + change_datatype = None + if "change_datatype" in _doc: try: - size = load_field( - _doc.get("size"), - union_of_None_type_or_Any_type, + change_datatype = load_field( + _doc.get("change_datatype"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("size") + lc=_doc.get("change_datatype") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `size`": + if str(e) == "missing required field `change_datatype`": _errors__.append( ValidationException( str(e), @@ -7035,13 +7099,13 @@ def fromDoc( ) ) else: - val = _doc.get("size") + val = _doc.get("change_datatype") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `change_datatype` field is not valid because:", + SourceLine(_doc, "change_datatype", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7053,28 +7117,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `size` field is not valid because:", - SourceLine(_doc, "size", str), + "the `change_datatype` field is not valid because:", + SourceLine(_doc, "change_datatype", str), [e], - detailed_message=f"the `size` field with value `{val}` " + detailed_message=f"the `change_datatype` field with value `{val}` " "is not valid because:", ) ) - color = None - if "color" in _doc: + delete_intermediate_datasets = None + if "delete_intermediate_datasets" in _doc: try: - color = load_field( - _doc.get("color"), - union_of_None_type_or_strtype, + delete_intermediate_datasets = load_field( + _doc.get("delete_intermediate_datasets"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("color") + lc=_doc.get("delete_intermediate_datasets") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `color`": + if str(e) == "missing required field `delete_intermediate_datasets`": _errors__.append( ValidationException( str(e), @@ -7082,13 +7146,13 @@ def fromDoc( ) ) else: - val = _doc.get("color") + val = _doc.get("delete_intermediate_datasets") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `delete_intermediate_datasets` field is not valid because:", + SourceLine(_doc, "delete_intermediate_datasets", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7100,28 +7164,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `color` field is not valid because:", - SourceLine(_doc, "color", str), + "the `delete_intermediate_datasets` field is not valid because:", + SourceLine(_doc, "delete_intermediate_datasets", str), [e], - detailed_message=f"the `color` field with value `{val}` " + detailed_message=f"the `delete_intermediate_datasets` field with value `{val}` " "is not valid because:", ) ) - label = None - if "label" in _doc: + hide = None + if "hide" in _doc: try: - label = load_field( - _doc.get("label"), - union_of_None_type_or_strtype, + hide = load_field( + _doc.get("hide"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("label") + lc=_doc.get("hide") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `label`": + if str(e) == "missing required field `hide`": _errors__.append( ValidationException( str(e), @@ -7129,13 +7193,13 @@ def fromDoc( ) ) else: - val = _doc.get("label") + val = _doc.get("hide") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `hide` field is not valid because:", + SourceLine(_doc, "hide", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7147,76 +7211,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `label` field is not valid because:", - SourceLine(_doc, "label", str), + "the `hide` field is not valid because:", + SourceLine(_doc, "hide", str), [e], - detailed_message=f"the `label` field with value `{val}` " + detailed_message=f"the `hide` field with value `{val}` " "is not valid because:", ) ) - try: - if _doc.get("type") is None: - raise ValidationException("missing required field `type`", None, []) - - type_ = load_field( - _doc.get("type"), - typedsl_strtype_2, - baseuri, - loadingOptions, - lc=_doc.get("type") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `type`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("type") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `type` field is not valid because:", - SourceLine(_doc, "type", str), - [e], - detailed_message=f"the `type` field with value `{val}` " - "is not valid because:", - ) - ) - title = None - if "title" in _doc: + remove_tags = None + if "remove_tags" in _doc: try: - title = load_field( - _doc.get("title"), - union_of_None_type_or_strtype, + remove_tags = load_field( + _doc.get("remove_tags"), + union_of_None_type_or_array_of_strtype, baseuri, loadingOptions, - lc=_doc.get("title") + lc=_doc.get("remove_tags") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `title`": + if str(e) == "missing required field `remove_tags`": _errors__.append( ValidationException( str(e), @@ -7224,13 +7240,13 @@ def fromDoc( ) ) else: - val = _doc.get("title") + val = _doc.get("remove_tags") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `title` field is not valid because:", - SourceLine(_doc, "title", str), + "the `remove_tags` field is not valid because:", + SourceLine(_doc, "remove_tags", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7242,28 +7258,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `title` field is not valid because:", - SourceLine(_doc, "title", str), + "the `remove_tags` field is not valid because:", + SourceLine(_doc, "remove_tags", str), [e], - detailed_message=f"the `title` field with value `{val}` " + detailed_message=f"the `remove_tags` field with value `{val}` " "is not valid because:", ) ) - contains_steps = None - if "contains_steps" in _doc: + rename = None + if "rename" in _doc: try: - contains_steps = load_field( - _doc.get("contains_steps"), - union_of_None_type_or_array_of_union_of_strtype_or_inttype, + rename = load_field( + _doc.get("rename"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("contains_steps") + lc=_doc.get("rename") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `contains_steps`": + if str(e) == "missing required field `rename`": _errors__.append( ValidationException( str(e), @@ -7271,13 +7287,13 @@ def fromDoc( ) ) else: - val = _doc.get("contains_steps") + val = _doc.get("rename") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `contains_steps` field is not valid because:", - SourceLine(_doc, "contains_steps", str), + "the `rename` field is not valid because:", + SourceLine(_doc, "rename", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7289,28 +7305,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `contains_steps` field is not valid because:", - SourceLine(_doc, "contains_steps", str), + "the `rename` field is not valid because:", + SourceLine(_doc, "rename", str), [e], - detailed_message=f"the `contains_steps` field with value `{val}` " + detailed_message=f"the `rename` field with value `{val}` " "is not valid because:", ) ) - contains_comments = None - if "contains_comments" in _doc: + set_columns = None + if "set_columns" in _doc: try: - contains_comments = load_field( - _doc.get("contains_comments"), - union_of_None_type_or_array_of_union_of_strtype_or_inttype, + set_columns = load_field( + _doc.get("set_columns"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("contains_comments") + lc=_doc.get("set_columns") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `contains_comments`": + if str(e) == "missing required field `set_columns`": _errors__.append( ValidationException( str(e), @@ -7318,13 +7334,13 @@ def fromDoc( ) ) else: - val = _doc.get("contains_comments") + val = _doc.get("set_columns") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `contains_comments` field is not valid because:", - SourceLine(_doc, "contains_comments", str), + "the `set_columns` field is not valid because:", + SourceLine(_doc, "set_columns", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7336,10 +7352,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `contains_comments` field is not valid because:", - SourceLine(_doc, "contains_comments", str), + "the `set_columns` field is not valid because:", + SourceLine(_doc, "set_columns", str), [e], - detailed_message=f"the `contains_comments` field with value `{val}` " + detailed_message=f"the `set_columns` field with value `{val}` " "is not valid because:", ) ) @@ -7358,7 +7374,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `position`, `size`, `color`, `label`, `type`, `title`, `contains_steps`, `contains_comments`".format( + "invalid field `{}`, expected one of: `id`, `add_tags`, `change_datatype`, `delete_intermediate_datasets`, `hide`, `remove_tags`, `rename`, `set_columns`".format( k ), SourceLine(_doc, k, str), @@ -7368,17 +7384,18 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - position=position, - size=size, - color=color, - label=label, - type_=type_, - title=title, - contains_steps=contains_steps, - contains_comments=contains_comments, + id=id, + add_tags=add_tags, + change_datatype=change_datatype, + delete_intermediate_datasets=delete_intermediate_datasets, + hide=hide, + remove_tags=remove_tags, + rename=rename, + set_columns=set_columns, extension_fields=extension_fields, loadingOptions=loadingOptions, ) + loadingOptions.idx[cast(str, id)] = (_constructed, loadingOptions) return _constructed def save( @@ -7386,48 +7403,53 @@ def save( ) -> dict[str, Any]: r: dict[str, Any] = {} - if relative_uris: - for ef in self.extension_fields: - r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] - else: - for ef in self.extension_fields: - r[ef] = self.extension_fields[ef] - if self.position is not None: - r["position"] = save( - self.position, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.size is not None: - r["size"] = save( - self.size, top=False, base_url=base_url, relative_uris=relative_uris - ) - if self.color is not None: - r["color"] = save( - self.color, top=False, base_url=base_url, relative_uris=relative_uris + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.id is not None: + u = save_relative_uri(self.id, base_url, True, None, relative_uris) + r["id"] = u + if self.add_tags is not None: + r["add_tags"] = save( + self.add_tags, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.label is not None: - r["label"] = save( - self.label, top=False, base_url=base_url, relative_uris=relative_uris + if self.change_datatype is not None: + r["change_datatype"] = save( + self.change_datatype, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - if self.type_ is not None: - r["type"] = save( - self.type_, top=False, base_url=base_url, relative_uris=relative_uris + if self.delete_intermediate_datasets is not None: + r["delete_intermediate_datasets"] = save( + self.delete_intermediate_datasets, + top=False, + base_url=self.id, + relative_uris=relative_uris, ) - if self.title is not None: - r["title"] = save( - self.title, top=False, base_url=base_url, relative_uris=relative_uris + if self.hide is not None: + r["hide"] = save( + self.hide, top=False, base_url=self.id, relative_uris=relative_uris ) - if self.contains_steps is not None: - r["contains_steps"] = save( - self.contains_steps, + if self.remove_tags is not None: + r["remove_tags"] = save( + self.remove_tags, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) - if self.contains_comments is not None: - r["contains_comments"] = save( - self.contains_comments, + if self.rename is not None: + r["rename"] = save( + self.rename, top=False, base_url=self.id, relative_uris=relative_uris + ) + if self.set_columns is not None: + r["set_columns"] = save( + self.set_columns, top=False, - base_url=base_url, + base_url=self.id, relative_uris=relative_uris, ) @@ -7441,21 +7463,30 @@ def save( attrs = frozenset( [ - "position", - "size", - "color", - "label", - "type", - "title", - "contains_steps", - "contains_comments", + "id", + "add_tags", + "change_datatype", + "delete_intermediate_datasets", + "hide", + "remove_tags", + "rename", + "set_columns", ] ) -class FreehandComment(BaseComment): +class BaseComment(Saveable): """ - A freehand drawn line on the editor canvas. + Base fields shared by all comment types. + + """ + + pass + + +class TextComment(BaseComment): + """ + A plain text annotation in the workflow editor. """ @@ -7466,8 +7497,10 @@ def __init__( size: Optional[Any] = None, color: Optional[Any] = None, label: Optional[Any] = None, - thickness: Optional[Any] = None, - line: Optional[Any] = None, + text: Optional[Any] = None, + bold: Optional[Any] = None, + italic: Optional[Any] = None, + text_size: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -7484,19 +7517,23 @@ def __init__( self.color = color self.label = label self.type_ = type_ - self.thickness = thickness - self.line = line + self.text = text + self.bold = bold + self.italic = italic + self.text_size = text_size def __eq__(self, other: Any) -> bool: - if isinstance(other, FreehandComment): + if isinstance(other, TextComment): return bool( self.position == other.position and self.size == other.size and self.color == other.color and self.label == other.label and self.type_ == other.type_ - and self.thickness == other.thickness - and self.line == other.line + and self.text == other.text + and self.bold == other.bold + and self.italic == other.italic + and self.text_size == other.text_size ) return False @@ -7508,8 +7545,10 @@ def __hash__(self) -> int: self.color, self.label, self.type_, - self.thickness, - self.line, + self.text, + self.bold, + self.italic, + self.text_size, ) ) @@ -7520,7 +7559,7 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "FreehandComment": + ) -> "TextComment": _doc = copy.copy(doc) if hasattr(doc, "lc"): @@ -7763,21 +7802,21 @@ def fromDoc( "is not valid because:", ) ) - thickness = None - if "thickness" in _doc: + text = None + if "text" in _doc: try: - thickness = load_field( - _doc.get("thickness"), - union_of_None_type_or_floattype_or_inttype, + text = load_field( + _doc.get("text"), + union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("thickness") + lc=_doc.get("text") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `thickness`": + if str(e) == "missing required field `text`": _errors__.append( ValidationException( str(e), @@ -7785,13 +7824,13 @@ def fromDoc( ) ) else: - val = _doc.get("thickness") + val = _doc.get("text") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `thickness` field is not valid because:", - SourceLine(_doc, "thickness", str), + "the `text` field is not valid because:", + SourceLine(_doc, "text", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7803,28 +7842,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `thickness` field is not valid because:", - SourceLine(_doc, "thickness", str), + "the `text` field is not valid because:", + SourceLine(_doc, "text", str), [e], - detailed_message=f"the `thickness` field with value `{val}` " + detailed_message=f"the `text` field with value `{val}` " "is not valid because:", ) ) - line = None - if "line" in _doc: + bold = None + if "bold" in _doc: try: - line = load_field( - _doc.get("line"), - union_of_None_type_or_Any_type, + bold = load_field( + _doc.get("bold"), + union_of_None_type_or_booltype, baseuri, loadingOptions, - lc=_doc.get("line") + lc=_doc.get("bold") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `line`": + if str(e) == "missing required field `bold`": _errors__.append( ValidationException( str(e), @@ -7832,13 +7871,13 @@ def fromDoc( ) ) else: - val = _doc.get("line") + val = _doc.get("bold") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `line` field is not valid because:", - SourceLine(_doc, "line", str), + "the `bold` field is not valid because:", + SourceLine(_doc, "bold", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -7850,10 +7889,104 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `line` field is not valid because:", - SourceLine(_doc, "line", str), + "the `bold` field is not valid because:", + SourceLine(_doc, "bold", str), + [e], + detailed_message=f"the `bold` field with value `{val}` " + "is not valid because:", + ) + ) + italic = None + if "italic" in _doc: + try: + italic = load_field( + _doc.get("italic"), + union_of_None_type_or_booltype, + baseuri, + loadingOptions, + lc=_doc.get("italic") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `italic`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("italic") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `italic` field is not valid because:", + SourceLine(_doc, "italic", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `italic` field is not valid because:", + SourceLine(_doc, "italic", str), + [e], + detailed_message=f"the `italic` field with value `{val}` " + "is not valid because:", + ) + ) + text_size = None + if "text_size" in _doc: + try: + text_size = load_field( + _doc.get("text_size"), + union_of_None_type_or_floattype_or_inttype, + baseuri, + loadingOptions, + lc=_doc.get("text_size") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `text_size`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("text_size") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `text_size` field is not valid because:", + SourceLine(_doc, "text_size", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `text_size` field is not valid because:", + SourceLine(_doc, "text_size", str), [e], - detailed_message=f"the `line` field with value `{val}` " + detailed_message=f"the `text_size` field with value `{val}` " "is not valid because:", ) ) @@ -7872,7 +8005,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `position`, `size`, `color`, `label`, `type`, `thickness`, `line`".format( + "invalid field `{}`, expected one of: `position`, `size`, `color`, `label`, `type`, `text`, `bold`, `italic`, `text_size`".format( k ), SourceLine(_doc, k, str), @@ -7887,8 +8020,10 @@ def fromDoc( color=color, label=label, type_=type_, - thickness=thickness, - line=line, + text=text, + bold=bold, + italic=italic, + text_size=text_size, extension_fields=extension_fields, loadingOptions=loadingOptions, ) @@ -7925,17 +8060,25 @@ def save( r["type"] = save( self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.thickness is not None: - r["thickness"] = save( - self.thickness, + if self.text is not None: + r["text"] = save( + self.text, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.bold is not None: + r["bold"] = save( + self.bold, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.italic is not None: + r["italic"] = save( + self.italic, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.text_size is not None: + r["text_size"] = save( + self.text_size, top=False, base_url=base_url, relative_uris=relative_uris, ) - if self.line is not None: - r["line"] = save( - self.line, top=False, base_url=base_url, relative_uris=relative_uris - ) # top refers to the directory level if top: @@ -7946,45 +8089,34 @@ def save( return r attrs = frozenset( - ["position", "size", "color", "label", "type", "thickness", "line"] + [ + "position", + "size", + "color", + "label", + "type", + "text", + "bold", + "italic", + "text_size", + ] ) -class BaseCreator(Saveable): - """ - Base fields shared by all creator types, corresponding to schema.org - Thing properties common to both Person and Organization. - - """ - - pass - - -class CreatorPerson(BaseCreator): +class MarkdownComment(BaseComment): """ - A person who created or contributed to the workflow. - Corresponds to a `schema.org Person `_. + A Markdown-rendered annotation in the workflow editor. """ - name: str - def __init__( self, - name: Optional[Any] = None, - identifier: Optional[Any] = None, - url: Optional[Any] = None, - email: Optional[Any] = None, - image: Optional[Any] = None, - address: Optional[Any] = None, - alternateName: Optional[Any] = None, - telephone: Optional[Any] = None, - faxNumber: Optional[Any] = None, - givenName: Optional[Any] = None, - familyName: Optional[Any] = None, - honorificPrefix: Optional[Any] = None, - honorificSuffix: Optional[Any] = None, - jobTitle: Optional[Any] = None, + type_: Any, + position: Optional[Any] = None, + size: Optional[Any] = None, + color: Optional[Any] = None, + label: Optional[Any] = None, + text: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -7996,62 +8128,28 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.identifier = identifier - self.url = url - self.email = email - self.image = image - self.address = address - self.alternateName = alternateName - self.telephone = telephone - self.faxNumber = faxNumber - self.class_ = "CreatorPerson" - self.givenName = givenName - self.familyName = familyName - self.honorificPrefix = honorificPrefix - self.honorificSuffix = honorificSuffix - self.jobTitle = jobTitle + self.position = position + self.size = size + self.color = color + self.label = label + self.type_ = type_ + self.text = text def __eq__(self, other: Any) -> bool: - if isinstance(other, CreatorPerson): + if isinstance(other, MarkdownComment): return bool( - self.name == other.name - and self.identifier == other.identifier - and self.url == other.url - and self.email == other.email - and self.image == other.image - and self.address == other.address - and self.alternateName == other.alternateName - and self.telephone == other.telephone - and self.faxNumber == other.faxNumber - and self.class_ == other.class_ - and self.givenName == other.givenName - and self.familyName == other.familyName - and self.honorificPrefix == other.honorificPrefix - and self.honorificSuffix == other.honorificSuffix - and self.jobTitle == other.jobTitle + self.position == other.position + and self.size == other.size + and self.color == other.color + and self.label == other.label + and self.type_ == other.type_ + and self.text == other.text ) return False def __hash__(self) -> int: return hash( - ( - self.name, - self.identifier, - self.url, - self.email, - self.image, - self.address, - self.alternateName, - self.telephone, - self.faxNumber, - self.class_, - self.givenName, - self.familyName, - self.honorificPrefix, - self.honorificSuffix, - self.jobTitle, - ) + (self.position, self.size, self.color, self.label, self.type_, self.text) ) @classmethod @@ -8061,28 +8159,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "CreatorPerson": + ) -> "MarkdownComment": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: + position = None + if "position" in _doc: try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, + position = load_field( + _doc.get("position"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("name") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `name`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -8090,13 +8188,13 @@ def fromDoc( ) ) else: - val = _doc.get("name") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8108,53 +8206,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `name` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_CreatorPersonTypeLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - identifier = None - if "identifier" in _doc: + size = None + if "size" in _doc: try: - identifier = load_field( - _doc.get("identifier"), - union_of_None_type_or_strtype, + size = load_field( + _doc.get("size"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("identifier") + lc=_doc.get("size") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `identifier`": + if str(e) == "missing required field `size`": _errors__.append( ValidationException( str(e), @@ -8162,13 +8235,13 @@ def fromDoc( ) ) else: - val = _doc.get("identifier") + val = _doc.get("size") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `identifier` field is not valid because:", - SourceLine(_doc, "identifier", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8180,28 +8253,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `identifier` field is not valid because:", - SourceLine(_doc, "identifier", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [e], - detailed_message=f"the `identifier` field with value `{val}` " + detailed_message=f"the `size` field with value `{val}` " "is not valid because:", ) ) - url = None - if "url" in _doc: + color = None + if "color" in _doc: try: - url = load_field( - _doc.get("url"), + color = load_field( + _doc.get("color"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("url") + lc=_doc.get("color") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `url`": + if str(e) == "missing required field `color`": _errors__.append( ValidationException( str(e), @@ -8209,13 +8282,13 @@ def fromDoc( ) ) else: - val = _doc.get("url") + val = _doc.get("color") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `url` field is not valid because:", - SourceLine(_doc, "url", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8227,28 +8300,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `url` field is not valid because:", - SourceLine(_doc, "url", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [e], - detailed_message=f"the `url` field with value `{val}` " + detailed_message=f"the `color` field with value `{val}` " "is not valid because:", ) ) - email = None - if "email" in _doc: + label = None + if "label" in _doc: try: - email = load_field( - _doc.get("email"), + label = load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("email") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `email`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -8256,13 +8329,13 @@ def fromDoc( ) ) else: - val = _doc.get("email") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `email` field is not valid because:", - SourceLine(_doc, "email", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8274,28 +8347,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `email` field is not valid because:", - SourceLine(_doc, "email", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `email` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - image = None - if "image" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + text = None + if "text" in _doc: try: - image = load_field( - _doc.get("image"), + text = load_field( + _doc.get("text"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("image") + lc=_doc.get("text") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `image`": + if str(e) == "missing required field `text`": _errors__.append( ValidationException( str(e), @@ -8303,13 +8424,13 @@ def fromDoc( ) ) else: - val = _doc.get("image") + val = _doc.get("text") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `image` field is not valid because:", - SourceLine(_doc, "image", str), + "the `text` field is not valid because:", + SourceLine(_doc, "text", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8321,28 +8442,189 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `image` field is not valid because:", - SourceLine(_doc, "image", str), + "the `text` field is not valid because:", + SourceLine(_doc, "text", str), [e], - detailed_message=f"the `image` field with value `{val}` " + detailed_message=f"the `text` field with value `{val}` " "is not valid because:", ) ) - address = None - if "address" in _doc: - try: - address = load_field( - _doc.get("address"), - union_of_None_type_or_strtype, + extension_fields: dict[str, Any] = {} + for k in _doc.keys(): + if k not in cls.attrs: + if not k: + _errors__.append( + ValidationException("mapping with implicit null key") + ) + elif ":" in k: + ex = expand_url( + k, "", loadingOptions, scoped_id=False, vocab_term=False + ) + extension_fields[ex] = _doc[k] + else: + _errors__.append( + ValidationException( + "invalid field `{}`, expected one of: `position`, `size`, `color`, `label`, `type`, `text`".format( + k + ), + SourceLine(_doc, k, str), + ) + ) + + if _errors__: + raise ValidationException("", None, _errors__, "*") + _constructed = cls( + position=position, + size=size, + color=color, + label=label, + type_=type_, + text=text, + extension_fields=extension_fields, + loadingOptions=loadingOptions, + ) + return _constructed + + def save( + self, top: bool = False, base_url: str = "", relative_uris: bool = True + ) -> dict[str, Any]: + r: dict[str, Any] = {} + + if relative_uris: + for ef in self.extension_fields: + r[prefix_url(ef, self.loadingOptions.vocab)] = self.extension_fields[ef] + else: + for ef in self.extension_fields: + r[ef] = self.extension_fields[ef] + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.color is not None: + r["color"] = save( + self.color, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris + ) + if self.text is not None: + r["text"] = save( + self.text, top=False, base_url=base_url, relative_uris=relative_uris + ) + + # top refers to the directory level + if top: + if self.loadingOptions.namespaces: + r["$namespaces"] = self.loadingOptions.namespaces + if self.loadingOptions.schemas: + r["$schemas"] = self.loadingOptions.schemas + return r + + attrs = frozenset(["position", "size", "color", "label", "type", "text"]) + + +class FrameComment(BaseComment): + """ + A rectangular grouping box that visually contains steps and other comments. + + """ + + def __init__( + self, + type_: Any, + position: Optional[Any] = None, + size: Optional[Any] = None, + color: Optional[Any] = None, + label: Optional[Any] = None, + title: Optional[Any] = None, + contains_steps: Optional[Any] = None, + contains_comments: Optional[Any] = None, + extension_fields: Optional[dict[str, Any]] = None, + loadingOptions: Optional[LoadingOptions] = None, + ) -> None: + if extension_fields: + self.extension_fields = extension_fields + else: + self.extension_fields = CommentedMap() + if loadingOptions: + self.loadingOptions = loadingOptions + else: + self.loadingOptions = LoadingOptions() + self.position = position + self.size = size + self.color = color + self.label = label + self.type_ = type_ + self.title = title + self.contains_steps = contains_steps + self.contains_comments = contains_comments + + def __eq__(self, other: Any) -> bool: + if isinstance(other, FrameComment): + return bool( + self.position == other.position + and self.size == other.size + and self.color == other.color + and self.label == other.label + and self.type_ == other.type_ + and self.title == other.title + and self.contains_steps == other.contains_steps + and self.contains_comments == other.contains_comments + ) + return False + + def __hash__(self) -> int: + return hash( + ( + self.position, + self.size, + self.color, + self.label, + self.type_, + self.title, + self.contains_steps, + self.contains_comments, + ) + ) + + @classmethod + def fromDoc( + cls, + doc: Any, + baseuri: str, + loadingOptions: LoadingOptions, + docRoot: Optional[str] = None + ) -> "FrameComment": + _doc = copy.copy(doc) + + if hasattr(doc, "lc"): + _doc.lc.data = doc.lc.data + _doc.lc.filename = doc.lc.filename + _errors__ = [] + position = None + if "position" in _doc: + try: + position = load_field( + _doc.get("position"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("address") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `address`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -8350,13 +8632,13 @@ def fromDoc( ) ) else: - val = _doc.get("address") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `address` field is not valid because:", - SourceLine(_doc, "address", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8368,28 +8650,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `address` field is not valid because:", - SourceLine(_doc, "address", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `address` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - alternateName = None - if "alternateName" in _doc: + size = None + if "size" in _doc: try: - alternateName = load_field( - _doc.get("alternateName"), - union_of_None_type_or_strtype, + size = load_field( + _doc.get("size"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("alternateName") + lc=_doc.get("size") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `alternateName`": + if str(e) == "missing required field `size`": _errors__.append( ValidationException( str(e), @@ -8397,13 +8679,13 @@ def fromDoc( ) ) else: - val = _doc.get("alternateName") + val = _doc.get("size") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `alternateName` field is not valid because:", - SourceLine(_doc, "alternateName", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8415,28 +8697,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `alternateName` field is not valid because:", - SourceLine(_doc, "alternateName", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [e], - detailed_message=f"the `alternateName` field with value `{val}` " + detailed_message=f"the `size` field with value `{val}` " "is not valid because:", ) ) - telephone = None - if "telephone" in _doc: + color = None + if "color" in _doc: try: - telephone = load_field( - _doc.get("telephone"), + color = load_field( + _doc.get("color"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("telephone") + lc=_doc.get("color") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `telephone`": + if str(e) == "missing required field `color`": _errors__.append( ValidationException( str(e), @@ -8444,13 +8726,13 @@ def fromDoc( ) ) else: - val = _doc.get("telephone") + val = _doc.get("color") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `telephone` field is not valid because:", - SourceLine(_doc, "telephone", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8462,28 +8744,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `telephone` field is not valid because:", - SourceLine(_doc, "telephone", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [e], - detailed_message=f"the `telephone` field with value `{val}` " + detailed_message=f"the `color` field with value `{val}` " "is not valid because:", ) ) - faxNumber = None - if "faxNumber" in _doc: + label = None + if "label" in _doc: try: - faxNumber = load_field( - _doc.get("faxNumber"), + label = load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("faxNumber") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `faxNumber`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -8491,13 +8773,13 @@ def fromDoc( ) ) else: - val = _doc.get("faxNumber") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `faxNumber` field is not valid because:", - SourceLine(_doc, "faxNumber", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8509,122 +8791,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `faxNumber` field is not valid because:", - SourceLine(_doc, "faxNumber", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `faxNumber` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - givenName = None - if "givenName" in _doc: - try: - givenName = load_field( - _doc.get("givenName"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("givenName") - ) + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) + type_ = load_field( + _doc.get("type"), + typedsl_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) - if str(e) == "missing required field `givenName`": + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], ) ) else: - val = _doc.get("givenName") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `givenName` field is not valid because:", - SourceLine(_doc, "givenName", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `givenName` field is not valid because:", - SourceLine(_doc, "givenName", str), - [e], - detailed_message=f"the `givenName` field with value `{val}` " - "is not valid because:", - ) - ) - familyName = None - if "familyName" in _doc: - try: - familyName = load_field( - _doc.get("familyName"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("familyName") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `familyName`": _errors__.append( ValidationException( - str(e), - None + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", ) ) - else: - val = _doc.get("familyName") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `familyName` field is not valid because:", - SourceLine(_doc, "familyName", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `familyName` field is not valid because:", - SourceLine(_doc, "familyName", str), - [e], - detailed_message=f"the `familyName` field with value `{val}` " - "is not valid because:", - ) - ) - honorificPrefix = None - if "honorificPrefix" in _doc: + title = None + if "title" in _doc: try: - honorificPrefix = load_field( - _doc.get("honorificPrefix"), + title = load_field( + _doc.get("title"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("honorificPrefix") + lc=_doc.get("title") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `honorificPrefix`": + if str(e) == "missing required field `title`": _errors__.append( ValidationException( str(e), @@ -8632,13 +8868,13 @@ def fromDoc( ) ) else: - val = _doc.get("honorificPrefix") + val = _doc.get("title") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `honorificPrefix` field is not valid because:", - SourceLine(_doc, "honorificPrefix", str), + "the `title` field is not valid because:", + SourceLine(_doc, "title", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8650,28 +8886,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `honorificPrefix` field is not valid because:", - SourceLine(_doc, "honorificPrefix", str), + "the `title` field is not valid because:", + SourceLine(_doc, "title", str), [e], - detailed_message=f"the `honorificPrefix` field with value `{val}` " + detailed_message=f"the `title` field with value `{val}` " "is not valid because:", ) ) - honorificSuffix = None - if "honorificSuffix" in _doc: + contains_steps = None + if "contains_steps" in _doc: try: - honorificSuffix = load_field( - _doc.get("honorificSuffix"), - union_of_None_type_or_strtype, + contains_steps = load_field( + _doc.get("contains_steps"), + union_of_None_type_or_array_of_union_of_strtype_or_inttype, baseuri, loadingOptions, - lc=_doc.get("honorificSuffix") + lc=_doc.get("contains_steps") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `honorificSuffix`": + if str(e) == "missing required field `contains_steps`": _errors__.append( ValidationException( str(e), @@ -8679,13 +8915,13 @@ def fromDoc( ) ) else: - val = _doc.get("honorificSuffix") + val = _doc.get("contains_steps") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `honorificSuffix` field is not valid because:", - SourceLine(_doc, "honorificSuffix", str), + "the `contains_steps` field is not valid because:", + SourceLine(_doc, "contains_steps", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8697,28 +8933,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `honorificSuffix` field is not valid because:", - SourceLine(_doc, "honorificSuffix", str), + "the `contains_steps` field is not valid because:", + SourceLine(_doc, "contains_steps", str), [e], - detailed_message=f"the `honorificSuffix` field with value `{val}` " + detailed_message=f"the `contains_steps` field with value `{val}` " "is not valid because:", ) ) - jobTitle = None - if "jobTitle" in _doc: + contains_comments = None + if "contains_comments" in _doc: try: - jobTitle = load_field( - _doc.get("jobTitle"), - union_of_None_type_or_strtype, + contains_comments = load_field( + _doc.get("contains_comments"), + union_of_None_type_or_array_of_union_of_strtype_or_inttype, baseuri, loadingOptions, - lc=_doc.get("jobTitle") + lc=_doc.get("contains_comments") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `jobTitle`": + if str(e) == "missing required field `contains_comments`": _errors__.append( ValidationException( str(e), @@ -8726,13 +8962,13 @@ def fromDoc( ) ) else: - val = _doc.get("jobTitle") + val = _doc.get("contains_comments") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `jobTitle` field is not valid because:", - SourceLine(_doc, "jobTitle", str), + "the `contains_comments` field is not valid because:", + SourceLine(_doc, "contains_comments", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -8744,10 +8980,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `jobTitle` field is not valid because:", - SourceLine(_doc, "jobTitle", str), + "the `contains_comments` field is not valid because:", + SourceLine(_doc, "contains_comments", str), [e], - detailed_message=f"the `jobTitle` field with value `{val}` " + detailed_message=f"the `contains_comments` field with value `{val}` " "is not valid because:", ) ) @@ -8766,7 +9002,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `identifier`, `url`, `email`, `image`, `address`, `alternateName`, `telephone`, `faxNumber`, `class`, `givenName`, `familyName`, `honorificPrefix`, `honorificSuffix`, `jobTitle`".format( + "invalid field `{}`, expected one of: `position`, `size`, `color`, `label`, `type`, `title`, `contains_steps`, `contains_comments`".format( k ), SourceLine(_doc, k, str), @@ -8776,24 +9012,17 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, - identifier=identifier, - url=url, - email=email, - image=image, - address=address, - alternateName=alternateName, - telephone=telephone, - faxNumber=faxNumber, - givenName=givenName, - familyName=familyName, - honorificPrefix=honorificPrefix, - honorificSuffix=honorificSuffix, - jobTitle=jobTitle, + position=position, + size=size, + color=color, + label=label, + type_=type_, + title=title, + contains_steps=contains_steps, + contains_comments=contains_comments, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -8807,94 +9036,42 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.name, False, None, relative_uris) - r["class"] = u - if self.identifier is not None: - r["identifier"] = save( - self.identifier, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.url is not None: - r["url"] = save( - self.url, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.email is not None: - r["email"] = save( - self.email, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.image is not None: - r["image"] = save( - self.image, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.address is not None: - r["address"] = save( - self.address, top=False, base_url=self.name, relative_uris=relative_uris - ) - if self.alternateName is not None: - r["alternateName"] = save( - self.alternateName, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.telephone is not None: - r["telephone"] = save( - self.telephone, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.faxNumber is not None: - r["faxNumber"] = save( - self.faxNumber, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.color is not None: + r["color"] = save( + self.color, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.givenName is not None: - r["givenName"] = save( - self.givenName, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.familyName is not None: - r["familyName"] = save( - self.familyName, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.honorificPrefix is not None: - r["honorificPrefix"] = save( - self.honorificPrefix, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.title is not None: + r["title"] = save( + self.title, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.honorificSuffix is not None: - r["honorificSuffix"] = save( - self.honorificSuffix, + if self.contains_steps is not None: + r["contains_steps"] = save( + self.contains_steps, top=False, - base_url=self.name, + base_url=base_url, relative_uris=relative_uris, ) - if self.jobTitle is not None: - r["jobTitle"] = save( - self.jobTitle, + if self.contains_comments is not None: + r["contains_comments"] = save( + self.contains_comments, top=False, - base_url=self.name, + base_url=base_url, relative_uris=relative_uris, ) @@ -8908,45 +9085,33 @@ def save( attrs = frozenset( [ - "name", - "identifier", - "url", - "email", - "image", - "address", - "alternateName", - "telephone", - "faxNumber", - "class", - "givenName", - "familyName", - "honorificPrefix", - "honorificSuffix", - "jobTitle", + "position", + "size", + "color", + "label", + "type", + "title", + "contains_steps", + "contains_comments", ] ) -class CreatorOrganization(BaseCreator): +class FreehandComment(BaseComment): """ - An organization that created or contributed to the workflow. - Corresponds to a `schema.org Organization `_. + A freehand drawn line on the editor canvas. """ - name: str - def __init__( self, - name: Optional[Any] = None, - identifier: Optional[Any] = None, - url: Optional[Any] = None, - email: Optional[Any] = None, - image: Optional[Any] = None, - address: Optional[Any] = None, - alternateName: Optional[Any] = None, - telephone: Optional[Any] = None, - faxNumber: Optional[Any] = None, + type_: Any, + position: Optional[Any] = None, + size: Optional[Any] = None, + color: Optional[Any] = None, + label: Optional[Any] = None, + thickness: Optional[Any] = None, + line: Optional[Any] = None, extension_fields: Optional[dict[str, Any]] = None, loadingOptions: Optional[LoadingOptions] = None, ) -> None: @@ -8958,46 +9123,37 @@ def __init__( self.loadingOptions = loadingOptions else: self.loadingOptions = LoadingOptions() - self.name = name if name is not None else "_:" + str(_uuid__.uuid4()) - self.identifier = identifier - self.url = url - self.email = email - self.image = image - self.address = address - self.alternateName = alternateName - self.telephone = telephone - self.faxNumber = faxNumber - self.class_ = "CreatorOrganization" + self.position = position + self.size = size + self.color = color + self.label = label + self.type_ = type_ + self.thickness = thickness + self.line = line def __eq__(self, other: Any) -> bool: - if isinstance(other, CreatorOrganization): + if isinstance(other, FreehandComment): return bool( - self.name == other.name - and self.identifier == other.identifier - and self.url == other.url - and self.email == other.email - and self.image == other.image - and self.address == other.address - and self.alternateName == other.alternateName - and self.telephone == other.telephone - and self.faxNumber == other.faxNumber - and self.class_ == other.class_ + self.position == other.position + and self.size == other.size + and self.color == other.color + and self.label == other.label + and self.type_ == other.type_ + and self.thickness == other.thickness + and self.line == other.line ) return False def __hash__(self) -> int: return hash( - ( - self.name, - self.identifier, - self.url, - self.email, - self.image, - self.address, - self.alternateName, - self.telephone, - self.faxNumber, - self.class_, + ( + self.position, + self.size, + self.color, + self.label, + self.type_, + self.thickness, + self.line, ) ) @@ -9008,194 +9164,28 @@ def fromDoc( baseuri: str, loadingOptions: LoadingOptions, docRoot: Optional[str] = None - ) -> "CreatorOrganization": + ) -> "FreehandComment": _doc = copy.copy(doc) if hasattr(doc, "lc"): _doc.lc.data = doc.lc.data _doc.lc.filename = doc.lc.filename _errors__ = [] - name = None - if "name" in _doc: - try: - name = load_field( - _doc.get("name"), - uri_union_of_None_type_or_strtype_True_False_None_None, - baseuri, - loadingOptions, - lc=_doc.get("name") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `name`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("name") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `name` field is not valid because:", - SourceLine(_doc, "name", str), - [e], - detailed_message=f"the `name` field with value `{val}` " - "is not valid because:", - ) - ) - - __original_name_is_none = name is None - if name is None: - if docRoot is not None: - name = docRoot - else: - name = "_:" + str(_uuid__.uuid4()) - if not __original_name_is_none: - baseuri = cast(str, name) - try: - if _doc.get("class") is None: - raise ValidationException("missing required field `class`", None, []) - - class_ = load_field( - _doc.get("class"), - uri_CreatorOrganizationTypeLoader_False_True_None_None, - baseuri, - loadingOptions, - lc=_doc.get("class") - ) - - if class_ not in (cls.__name__, loadingOptions.vocab.get(cls.__name__)): - raise ValidationException(f"tried `{cls.__name__}` but") - except ValidationException as e: - raise e - identifier = None - if "identifier" in _doc: - try: - identifier = load_field( - _doc.get("identifier"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("identifier") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `identifier`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("identifier") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `identifier` field is not valid because:", - SourceLine(_doc, "identifier", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `identifier` field is not valid because:", - SourceLine(_doc, "identifier", str), - [e], - detailed_message=f"the `identifier` field with value `{val}` " - "is not valid because:", - ) - ) - url = None - if "url" in _doc: - try: - url = load_field( - _doc.get("url"), - union_of_None_type_or_strtype, - baseuri, - loadingOptions, - lc=_doc.get("url") - ) - - except ValidationException as e: - error_message, to_print, verb_tensage = parse_errors(str(e)) - - if str(e) == "missing required field `url`": - _errors__.append( - ValidationException( - str(e), - None - ) - ) - else: - val = _doc.get("url") - if error_message != str(e): - val_type = convert_typing(extract_type(type(val))) - _errors__.append( - ValidationException( - "the `url` field is not valid because:", - SourceLine(_doc, "url", str), - [ValidationException(f"Value is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}", - detailed_message=f"Value `{val}` is a {val_type}, " - f"but valid {to_print} for this field " - f"{verb_tensage} {error_message}")], - ) - ) - else: - _errors__.append( - ValidationException( - "the `url` field is not valid because:", - SourceLine(_doc, "url", str), - [e], - detailed_message=f"the `url` field with value `{val}` " - "is not valid because:", - ) - ) - email = None - if "email" in _doc: + position = None + if "position" in _doc: try: - email = load_field( - _doc.get("email"), - union_of_None_type_or_strtype, + position = load_field( + _doc.get("position"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("email") + lc=_doc.get("position") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `email`": + if str(e) == "missing required field `position`": _errors__.append( ValidationException( str(e), @@ -9203,13 +9193,13 @@ def fromDoc( ) ) else: - val = _doc.get("email") + val = _doc.get("position") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `email` field is not valid because:", - SourceLine(_doc, "email", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9221,28 +9211,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `email` field is not valid because:", - SourceLine(_doc, "email", str), + "the `position` field is not valid because:", + SourceLine(_doc, "position", str), [e], - detailed_message=f"the `email` field with value `{val}` " + detailed_message=f"the `position` field with value `{val}` " "is not valid because:", ) ) - image = None - if "image" in _doc: + size = None + if "size" in _doc: try: - image = load_field( - _doc.get("image"), - union_of_None_type_or_strtype, + size = load_field( + _doc.get("size"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("image") + lc=_doc.get("size") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `image`": + if str(e) == "missing required field `size`": _errors__.append( ValidationException( str(e), @@ -9250,13 +9240,13 @@ def fromDoc( ) ) else: - val = _doc.get("image") + val = _doc.get("size") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `image` field is not valid because:", - SourceLine(_doc, "image", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9268,28 +9258,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `image` field is not valid because:", - SourceLine(_doc, "image", str), + "the `size` field is not valid because:", + SourceLine(_doc, "size", str), [e], - detailed_message=f"the `image` field with value `{val}` " + detailed_message=f"the `size` field with value `{val}` " "is not valid because:", ) ) - address = None - if "address" in _doc: + color = None + if "color" in _doc: try: - address = load_field( - _doc.get("address"), + color = load_field( + _doc.get("color"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("address") + lc=_doc.get("color") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `address`": + if str(e) == "missing required field `color`": _errors__.append( ValidationException( str(e), @@ -9297,13 +9287,13 @@ def fromDoc( ) ) else: - val = _doc.get("address") + val = _doc.get("color") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `address` field is not valid because:", - SourceLine(_doc, "address", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9315,28 +9305,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `address` field is not valid because:", - SourceLine(_doc, "address", str), + "the `color` field is not valid because:", + SourceLine(_doc, "color", str), [e], - detailed_message=f"the `address` field with value `{val}` " + detailed_message=f"the `color` field with value `{val}` " "is not valid because:", ) ) - alternateName = None - if "alternateName" in _doc: + label = None + if "label" in _doc: try: - alternateName = load_field( - _doc.get("alternateName"), + label = load_field( + _doc.get("label"), union_of_None_type_or_strtype, baseuri, loadingOptions, - lc=_doc.get("alternateName") + lc=_doc.get("label") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `alternateName`": + if str(e) == "missing required field `label`": _errors__.append( ValidationException( str(e), @@ -9344,13 +9334,13 @@ def fromDoc( ) ) else: - val = _doc.get("alternateName") + val = _doc.get("label") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `alternateName` field is not valid because:", - SourceLine(_doc, "alternateName", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9362,28 +9352,76 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `alternateName` field is not valid because:", - SourceLine(_doc, "alternateName", str), + "the `label` field is not valid because:", + SourceLine(_doc, "label", str), [e], - detailed_message=f"the `alternateName` field with value `{val}` " + detailed_message=f"the `label` field with value `{val}` " "is not valid because:", ) ) - telephone = None - if "telephone" in _doc: + try: + if _doc.get("type") is None: + raise ValidationException("missing required field `type`", None, []) + + type_ = load_field( + _doc.get("type"), + typedsl_strtype_2, + baseuri, + loadingOptions, + lc=_doc.get("type") + ) + + except ValidationException as e: + error_message, to_print, verb_tensage = parse_errors(str(e)) + + if str(e) == "missing required field `type`": + _errors__.append( + ValidationException( + str(e), + None + ) + ) + else: + val = _doc.get("type") + if error_message != str(e): + val_type = convert_typing(extract_type(type(val))) + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [ValidationException(f"Value is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}", + detailed_message=f"Value `{val}` is a {val_type}, " + f"but valid {to_print} for this field " + f"{verb_tensage} {error_message}")], + ) + ) + else: + _errors__.append( + ValidationException( + "the `type` field is not valid because:", + SourceLine(_doc, "type", str), + [e], + detailed_message=f"the `type` field with value `{val}` " + "is not valid because:", + ) + ) + thickness = None + if "thickness" in _doc: try: - telephone = load_field( - _doc.get("telephone"), - union_of_None_type_or_strtype, + thickness = load_field( + _doc.get("thickness"), + union_of_None_type_or_floattype_or_inttype, baseuri, loadingOptions, - lc=_doc.get("telephone") + lc=_doc.get("thickness") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `telephone`": + if str(e) == "missing required field `thickness`": _errors__.append( ValidationException( str(e), @@ -9391,13 +9429,13 @@ def fromDoc( ) ) else: - val = _doc.get("telephone") + val = _doc.get("thickness") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `telephone` field is not valid because:", - SourceLine(_doc, "telephone", str), + "the `thickness` field is not valid because:", + SourceLine(_doc, "thickness", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9409,28 +9447,28 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `telephone` field is not valid because:", - SourceLine(_doc, "telephone", str), + "the `thickness` field is not valid because:", + SourceLine(_doc, "thickness", str), [e], - detailed_message=f"the `telephone` field with value `{val}` " + detailed_message=f"the `thickness` field with value `{val}` " "is not valid because:", ) ) - faxNumber = None - if "faxNumber" in _doc: + line = None + if "line" in _doc: try: - faxNumber = load_field( - _doc.get("faxNumber"), - union_of_None_type_or_strtype, + line = load_field( + _doc.get("line"), + union_of_None_type_or_Any_type, baseuri, loadingOptions, - lc=_doc.get("faxNumber") + lc=_doc.get("line") ) except ValidationException as e: error_message, to_print, verb_tensage = parse_errors(str(e)) - if str(e) == "missing required field `faxNumber`": + if str(e) == "missing required field `line`": _errors__.append( ValidationException( str(e), @@ -9438,13 +9476,13 @@ def fromDoc( ) ) else: - val = _doc.get("faxNumber") + val = _doc.get("line") if error_message != str(e): val_type = convert_typing(extract_type(type(val))) _errors__.append( ValidationException( - "the `faxNumber` field is not valid because:", - SourceLine(_doc, "faxNumber", str), + "the `line` field is not valid because:", + SourceLine(_doc, "line", str), [ValidationException(f"Value is a {val_type}, " f"but valid {to_print} for this field " f"{verb_tensage} {error_message}", @@ -9456,10 +9494,10 @@ def fromDoc( else: _errors__.append( ValidationException( - "the `faxNumber` field is not valid because:", - SourceLine(_doc, "faxNumber", str), + "the `line` field is not valid because:", + SourceLine(_doc, "line", str), [e], - detailed_message=f"the `faxNumber` field with value `{val}` " + detailed_message=f"the `line` field with value `{val}` " "is not valid because:", ) ) @@ -9478,7 +9516,7 @@ def fromDoc( else: _errors__.append( ValidationException( - "invalid field `{}`, expected one of: `name`, `identifier`, `url`, `email`, `image`, `address`, `alternateName`, `telephone`, `faxNumber`, `class`".format( + "invalid field `{}`, expected one of: `position`, `size`, `color`, `label`, `type`, `thickness`, `line`".format( k ), SourceLine(_doc, k, str), @@ -9488,19 +9526,16 @@ def fromDoc( if _errors__: raise ValidationException("", None, _errors__, "*") _constructed = cls( - name=name, - identifier=identifier, - url=url, - email=email, - image=image, - address=address, - alternateName=alternateName, - telephone=telephone, - faxNumber=faxNumber, + position=position, + size=size, + color=color, + label=label, + type_=type_, + thickness=thickness, + line=line, extension_fields=extension_fields, loadingOptions=loadingOptions, ) - loadingOptions.idx[cast(str, name)] = (_constructed, loadingOptions) return _constructed def save( @@ -9514,60 +9549,36 @@ def save( else: for ef in self.extension_fields: r[ef] = self.extension_fields[ef] - if self.name is not None: - u = save_relative_uri(self.name, base_url, True, None, relative_uris) - r["name"] = u - if self.class_ is not None: - uri = self.loadingOptions.vocab[self.class_] - if p := self.loadingOptions.rvocab.get(uri[: -len(self.class_)]): - uri = f"{p}:{self.class_}" - else: - uri = self.class_ - u = save_relative_uri(uri, self.name, False, None, relative_uris) - r["class"] = u - if self.identifier is not None: - r["identifier"] = save( - self.identifier, - top=False, - base_url=self.name, - relative_uris=relative_uris, - ) - if self.url is not None: - r["url"] = save( - self.url, top=False, base_url=self.name, relative_uris=relative_uris + if self.position is not None: + r["position"] = save( + self.position, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.email is not None: - r["email"] = save( - self.email, top=False, base_url=self.name, relative_uris=relative_uris + if self.size is not None: + r["size"] = save( + self.size, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.image is not None: - r["image"] = save( - self.image, top=False, base_url=self.name, relative_uris=relative_uris + if self.color is not None: + r["color"] = save( + self.color, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.address is not None: - r["address"] = save( - self.address, top=False, base_url=self.name, relative_uris=relative_uris + if self.label is not None: + r["label"] = save( + self.label, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.alternateName is not None: - r["alternateName"] = save( - self.alternateName, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.type_ is not None: + r["type"] = save( + self.type_, top=False, base_url=base_url, relative_uris=relative_uris ) - if self.telephone is not None: - r["telephone"] = save( - self.telephone, + if self.thickness is not None: + r["thickness"] = save( + self.thickness, top=False, - base_url=self.name, + base_url=base_url, relative_uris=relative_uris, ) - if self.faxNumber is not None: - r["faxNumber"] = save( - self.faxNumber, - top=False, - base_url=self.name, - relative_uris=relative_uris, + if self.line is not None: + r["line"] = save( + self.line, top=False, base_url=base_url, relative_uris=relative_uris ) # top refers to the directory level @@ -9579,18 +9590,7 @@ def save( return r attrs = frozenset( - [ - "name", - "identifier", - "url", - "email", - "image", - "address", - "alternateName", - "telephone", - "faxNumber", - "class", - ] + ["position", "size", "color", "label", "type", "thickness", "line"] ) @@ -10494,11 +10494,11 @@ def save( "Any": "https://w3id.org/cwl/salad#Any", "ArraySchema": "https://w3id.org/cwl/salad#ArraySchema", "BaseComment": "https://galaxyproject.org/gxformat2/v19_09#BaseComment", - "BaseCreator": "https://galaxyproject.org/gxformat2/v19_09#BaseCreator", - "CreatorOrganization": "https://galaxyproject.org/gxformat2/v19_09#CreatorOrganization", - "CreatorOrganizationType": "https://galaxyproject.org/gxformat2/v19_09#CreatorOrganizationType", - "CreatorPerson": "https://galaxyproject.org/gxformat2/v19_09#CreatorPerson", - "CreatorPersonType": "https://galaxyproject.org/gxformat2/v19_09#CreatorPersonType", + "BaseCreator": "https://galaxyproject.org/gxformat2/gxformat2common#BaseCreator", + "CreatorOrganization": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganization", + "CreatorOrganizationType": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganizationType", + "CreatorPerson": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPerson", + "CreatorPersonType": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPersonType", "Documented": "https://w3id.org/cwl/salad#Documented", "EnumSchema": "https://w3id.org/cwl/salad#EnumSchema", "File": "https://galaxyproject.org/gxformat2/v19_09#GalaxyType/File", @@ -10513,10 +10513,10 @@ def save( "InputParameter": "https://w3id.org/cwl/cwl#InputParameter", "Labeled": "https://w3id.org/cwl/cwl#Labeled", "MarkdownComment": "https://galaxyproject.org/gxformat2/v19_09#MarkdownComment", - "Organization": "https://galaxyproject.org/gxformat2/v19_09#CreatorOrganizationType/Organization", + "Organization": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganizationType/Organization", "OutputParameter": "https://w3id.org/cwl/cwl#OutputParameter", "Parameter": "https://w3id.org/cwl/cwl#Parameter", - "Person": "https://galaxyproject.org/gxformat2/v19_09#CreatorPersonType/Person", + "Person": "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPersonType/Person", "PrimitiveType": "https://w3id.org/cwl/salad#PrimitiveType", "Process": "https://w3id.org/cwl/cwl#Process", "RecordField": "https://w3id.org/cwl/salad#RecordField", @@ -10557,11 +10557,11 @@ def save( "https://w3id.org/cwl/salad#Any": "Any", "https://w3id.org/cwl/salad#ArraySchema": "ArraySchema", "https://galaxyproject.org/gxformat2/v19_09#BaseComment": "BaseComment", - "https://galaxyproject.org/gxformat2/v19_09#BaseCreator": "BaseCreator", - "https://galaxyproject.org/gxformat2/v19_09#CreatorOrganization": "CreatorOrganization", - "https://galaxyproject.org/gxformat2/v19_09#CreatorOrganizationType": "CreatorOrganizationType", - "https://galaxyproject.org/gxformat2/v19_09#CreatorPerson": "CreatorPerson", - "https://galaxyproject.org/gxformat2/v19_09#CreatorPersonType": "CreatorPersonType", + "https://galaxyproject.org/gxformat2/gxformat2common#BaseCreator": "BaseCreator", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganization": "CreatorOrganization", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganizationType": "CreatorOrganizationType", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPerson": "CreatorPerson", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPersonType": "CreatorPersonType", "https://w3id.org/cwl/salad#Documented": "Documented", "https://w3id.org/cwl/salad#EnumSchema": "EnumSchema", "https://galaxyproject.org/gxformat2/v19_09#GalaxyType/File": "File", @@ -10576,10 +10576,10 @@ def save( "https://w3id.org/cwl/cwl#InputParameter": "InputParameter", "https://w3id.org/cwl/cwl#Labeled": "Labeled", "https://galaxyproject.org/gxformat2/v19_09#MarkdownComment": "MarkdownComment", - "https://galaxyproject.org/gxformat2/v19_09#CreatorOrganizationType/Organization": "Organization", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorOrganizationType/Organization": "Organization", "https://w3id.org/cwl/cwl#OutputParameter": "OutputParameter", "https://w3id.org/cwl/cwl#Parameter": "Parameter", - "https://galaxyproject.org/gxformat2/v19_09#CreatorPersonType/Person": "Person", + "https://galaxyproject.org/gxformat2/gxformat2common#CreatorPersonType/Person": "Person", "https://w3id.org/cwl/salad#PrimitiveType": "PrimitiveType", "https://w3id.org/cwl/cwl#Process": "Process", "https://w3id.org/cwl/salad#RecordField": "RecordField", @@ -10658,6 +10658,18 @@ def save( ArraySchemaLoader = _RecordLoader(ArraySchema, None, None) StepPositionLoader = _RecordLoader(StepPosition, None, None) ToolShedRepositoryLoader = _RecordLoader(ToolShedRepository, None, None) +CreatorPersonTypeLoader = _EnumLoader(("Person",), "CreatorPersonType") +""" +Discriminator for schema.org Person creators. +""" +CreatorOrganizationTypeLoader = _EnumLoader( + ("Organization",), "CreatorOrganizationType" +) +""" +Discriminator for schema.org Organization creators. +""" +CreatorPersonLoader = _RecordLoader(CreatorPerson, None, None) +CreatorOrganizationLoader = _RecordLoader(CreatorOrganization, None, None) GalaxyTypeLoader = _EnumLoader( ( "null", @@ -10712,18 +10724,6 @@ def save( FrameCommentLoader = _RecordLoader(FrameComment, None, None) FreehandCommentLoader = _RecordLoader(FreehandComment, None, None) WorkflowCommentLoader = _UnionLoader((), "WorkflowCommentLoader") -CreatorPersonTypeLoader = _EnumLoader(("Person",), "CreatorPersonType") -""" -Discriminator for schema.org Person creators. -""" -CreatorOrganizationTypeLoader = _EnumLoader( - ("Organization",), "CreatorOrganizationType" -) -""" -Discriminator for schema.org Organization creators. -""" -CreatorPersonLoader = _RecordLoader(CreatorPerson, None, None) -CreatorOrganizationLoader = _RecordLoader(CreatorOrganization, None, None) GalaxyWorkflowLoader = _RecordLoader(GalaxyWorkflow, None, None) array_of_strtype = _ArrayLoader(strtype) union_of_None_type_or_strtype_or_array_of_strtype = _UnionLoader( @@ -10846,6 +10846,12 @@ def save( ToolShedRepositoryLoader, ) ) +uri_CreatorPersonTypeLoader_False_True_None_None = _URILoader( + CreatorPersonTypeLoader, False, True, None, None +) +uri_CreatorOrganizationTypeLoader_False_True_None_None = _URILoader( + CreatorOrganizationTypeLoader, False, True, None, None +) union_of_GalaxyTypeLoader = _UnionLoader((GalaxyTypeLoader,)) array_of_union_of_GalaxyTypeLoader = _ArrayLoader(union_of_GalaxyTypeLoader) union_of_GalaxyTypeLoader_or_None_type_or_array_of_union_of_GalaxyTypeLoader = ( @@ -10957,12 +10963,6 @@ def save( array_of_union_of_strtype_or_inttype, ) ) -uri_CreatorPersonTypeLoader_False_True_None_None = _URILoader( - CreatorPersonTypeLoader, False, True, None, None -) -uri_CreatorOrganizationTypeLoader_False_True_None_None = _URILoader( - CreatorOrganizationTypeLoader, False, True, None, None -) GalaxyWorkflow_classLoader = _EnumLoader(("GalaxyWorkflow",), "GalaxyWorkflow_class") uri_GalaxyWorkflow_classLoader_False_True_None_None = _URILoader( GalaxyWorkflow_classLoader, False, True, None, None diff --git a/schema/common/common.yml b/schema/common/common.yml index d897d48d..2b8ab117 100644 --- a/schema/common/common.yml +++ b/schema/common/common.yml @@ -92,3 +92,133 @@ $graph: type: string doc: | The URI of the tool shed containing the repository this tool can be found in - typically this should be toolshed.g2.bx.psu.edu. + +# --- Creator types (schema.org Person / Organization) --- + +- name: CreatorPersonType + type: enum + symbols: + - Person + doc: "Discriminator for schema.org Person creators." + +- name: CreatorOrganizationType + type: enum + symbols: + - Organization + doc: "Discriminator for schema.org Organization creators." + +- name: BaseCreator + type: record + abstract: true + doc: | + Base fields shared by all creator types, corresponding to schema.org + Thing properties common to both Person and Organization. + fields: + - name: name + type: string? + jsonldPredicate: "@id" + doc: | + Full name of the person or organization. + - name: identifier + type: string? + doc: | + Persistent identifier, typically an ORCID URL + (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID. + - name: url + type: string? + jsonldPredicate: + _id: "gxformat2common:Creator/url" + doc: | + Website or profile URL. + - name: email + type: string? + jsonldPredicate: + _id: "gxformat2common:Creator/email" + doc: | + Email address. May include a ``mailto:`` prefix. + - name: image + type: string? + jsonldPredicate: + _id: "gxformat2common:Creator/image" + doc: | + URL to an image or avatar. + - name: address + type: string? + doc: | + Physical or mailing address. + - name: alternateName + type: string? + jsonldPredicate: + _id: "gxformat2common:Creator/alternateName" + doc: | + An alternate name or alias. + - name: telephone + type: string? + doc: | + Telephone number. + - name: faxNumber + type: string? + jsonldPredicate: + _id: "gxformat2common:Creator/faxNumber" + doc: | + Fax number. + +- name: CreatorPerson + type: record + extends: BaseCreator + doc: | + A person who created or contributed to the workflow. + Corresponds to a `schema.org Person `_. + fields: + - name: class + type: CreatorPersonType + jsonldPredicate: + "_id": "@type" + "_type": "@vocab" + doc: | + Creator type discriminator (``Person``). + - name: givenName + type: string? + jsonldPredicate: + _id: "gxformat2common:CreatorPerson/givenName" + doc: | + Given (first) name. + - name: familyName + type: string? + jsonldPredicate: + _id: "gxformat2common:CreatorPerson/familyName" + doc: | + Family (last) name. + - name: honorificPrefix + type: string? + jsonldPredicate: + _id: "gxformat2common:CreatorPerson/honorificPrefix" + doc: | + Honorific prefix (e.g. ``Dr``, ``Prof``). + - name: honorificSuffix + type: string? + jsonldPredicate: + _id: "gxformat2common:CreatorPerson/honorificSuffix" + doc: | + Honorific suffix (e.g. ``M.D.``, ``PhD``). + - name: jobTitle + type: string? + jsonldPredicate: + _id: "gxformat2common:CreatorPerson/jobTitle" + doc: | + Job title or role. + +- name: CreatorOrganization + type: record + extends: BaseCreator + doc: | + An organization that created or contributed to the workflow. + Corresponds to a `schema.org Organization `_. + fields: + - name: class + type: CreatorOrganizationType + jsonldPredicate: + "_id": "@type" + "_type": "@vocab" + doc: | + Creator type discriminator (``Organization``). diff --git a/schema/native_v0_1/workflow.yml b/schema/native_v0_1/workflow.yml index 30bc1e06..e9d7b7c5 100644 --- a/schema/native_v0_1/workflow.yml +++ b/schema/native_v0_1/workflow.yml @@ -605,147 +605,7 @@ $graph: Galaxy-flavored Markdown content for the invocation report. Supports template directives like ``history_dataset_as_image(output="...")``. -# --- Creator types (schema.org Person / Organization) --- - -- name: NativeCreatorPersonType - type: enum - symbols: - - Person - doc: "Discriminator for schema.org Person creators." - -- name: NativeCreatorOrganizationType - type: enum - symbols: - - Organization - doc: "Discriminator for schema.org Organization creators." - -- name: BaseNativeCreator - type: record - abstract: true - doc: | - Base fields shared by all creator types, corresponding to schema.org - Thing properties common to both Person and Organization. - fields: - - name: name - type: string? - jsonldPredicate: "@id" - doc: | - Full name of the person or organization. - - name: identifier - type: string? - doc: | - Persistent identifier, typically an ORCID URL - (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID. - - name: url - type: string? - jsonldPredicate: - _id: "gxformat2common:Creator/url" - doc: | - Website or profile URL. - - name: email - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreator/email" - doc: | - Email address. May include a ``mailto:`` prefix. - - name: image - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreator/image" - doc: | - URL to an image or avatar. - - name: address - type: string? - doc: | - Physical or mailing address. - - name: alternateName - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreator/alternateName" - doc: | - An alternate name or alias. - - name: telephone - type: string? - doc: | - Telephone number. - - name: faxNumber - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreator/faxNumber" - doc: | - Fax number. - -- name: NativeCreatorPerson - type: record - extends: BaseNativeCreator - docParent: "#NativeGalaxyWorkflow" - doc: | - A person who created or contributed to the workflow. - Corresponds to a `schema.org Person `_. - fields: - - name: class - type: NativeCreatorPersonType - jsonldPredicate: - "_id": "@type" - "_type": "@vocab" - doc: | - Creator type discriminator (``Person``). - - name: givenName - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreatorPerson/givenName" - doc: | - Given (first) name. - - name: familyName - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreatorPerson/familyName" - doc: | - Family (last) name. - - name: honorificPrefix - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreatorPerson/honorificPrefix" - doc: | - Honorific prefix (e.g. ``Dr``, ``Prof``). - - name: honorificSuffix - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreatorPerson/honorificSuffix" - doc: | - Honorific suffix (e.g. ``M.D.``, ``PhD``). - - name: jobTitle - type: string? - jsonldPredicate: - _id: "gxnative:NativeCreatorPerson/jobTitle" - doc: | - Job title or role. - -- name: NativeCreatorOrganization - type: record - extends: BaseNativeCreator - docParent: "#NativeGalaxyWorkflow" - doc: | - An organization that created or contributed to the workflow. - Corresponds to a `schema.org Organization `_. - fields: - - name: class - type: NativeCreatorOrganizationType - jsonldPredicate: - "_id": "@type" - "_type": "@vocab" - doc: | - Creator type discriminator (``Organization``). - -- name: NativeCreator - type: union - names: - - NativeCreatorPerson - - NativeCreatorOrganization - docParent: "#NativeGalaxyWorkflow" - doc: | - A workflow creator, either a person or organization. Dispatched via - the ``class`` field (``Person`` or ``Organization``). +# Creator types are shared from common.yml (CreatorPerson, CreatorOrganization) - name: NativeSourceMetadata type: record @@ -854,15 +714,15 @@ $graph: Semantic version for published workflows. - name: creator type: Any? - pydantic:type: "list[NativeCreatorPerson | NativeCreatorOrganization] | None" + pydantic:type: "list[CreatorPerson | CreatorOrganization] | None" pydantic:discriminator_field: "class" - pydantic:discriminator_map: '{"Person": "NativeCreatorPerson", "Organization": "NativeCreatorOrganization"}' + pydantic:discriminator_map: '{"Person": "CreatorPerson", "Organization": "CreatorOrganization"}' jsonldPredicate: _id: "gxnative:NativeGalaxyWorkflow/creator" noLinkCheck: true doc: | Creator(s) of this workflow. An array of schema.org - NativeCreatorPerson or NativeCreatorOrganization objects, + CreatorPerson or CreatorOrganization objects, dispatched via the ``class`` field (``Person`` or ``Organization``). - name: report type: NativeReport? diff --git a/schema/v19_09/workflow.yml b/schema/v19_09/workflow.yml index 32c3a43e..8eb24bf4 100644 --- a/schema/v19_09/workflow.yml +++ b/schema/v19_09/workflow.yml @@ -510,138 +510,6 @@ $graph: - FreehandComment doc: A visual annotation in the workflow editor, discriminated by type. -# --- Creator type discriminators --- - -- name: CreatorPersonType - type: enum - symbols: - - Person - doc: "Discriminator for schema.org Person creators." - -- name: CreatorOrganizationType - type: enum - symbols: - - Organization - doc: "Discriminator for schema.org Organization creators." - -# --- Creator base and types --- - -- name: BaseCreator - type: record - abstract: true - doc: | - Base fields shared by all creator types, corresponding to schema.org - Thing properties common to both Person and Organization. - fields: - - name: name - type: string? - jsonldPredicate: "@id" - doc: | - Full name of the person or organization. - - name: identifier - type: string? - doc: | - Persistent identifier, typically an ORCID URL - (e.g. ``https://orcid.org/0000-0001-2345-6789``) or bare ORCID. - - name: url - type: string? - jsonldPredicate: - _id: "gxformat2:Creator/url" - doc: | - Website or profile URL. - - name: email - type: string? - jsonldPredicate: - _id: "gxformat2:Creator/email" - doc: | - Email address. May include a ``mailto:`` prefix. - - name: image - type: string? - jsonldPredicate: - _id: "gxformat2:Creator/image" - doc: | - URL to an image or avatar. - - name: address - type: string? - doc: | - Physical or mailing address. - - name: alternateName - type: string? - jsonldPredicate: - _id: "gxformat2:Creator/alternateName" - doc: | - An alternate name or alias. - - name: telephone - type: string? - doc: | - Telephone number. - - name: faxNumber - type: string? - jsonldPredicate: - _id: "gxformat2:Creator/faxNumber" - doc: | - Fax number. - -- name: CreatorPerson - type: record - extends: BaseCreator - doc: | - A person who created or contributed to the workflow. - Corresponds to a `schema.org Person `_. - fields: - - name: class - type: CreatorPersonType - jsonldPredicate: - "_id": "@type" - "_type": "@vocab" - doc: | - Creator type discriminator (``Person``). - - name: givenName - type: string? - jsonldPredicate: - _id: "gxformat2:CreatorPerson/givenName" - doc: | - Given (first) name. - - name: familyName - type: string? - jsonldPredicate: - _id: "gxformat2:CreatorPerson/familyName" - doc: | - Family (last) name. - - name: honorificPrefix - type: string? - jsonldPredicate: - _id: "gxformat2:CreatorPerson/honorificPrefix" - doc: | - Honorific prefix (e.g. ``Dr``, ``Prof``). - - name: honorificSuffix - type: string? - jsonldPredicate: - _id: "gxformat2:CreatorPerson/honorificSuffix" - doc: | - Honorific suffix (e.g. ``M.D.``, ``PhD``). - - name: jobTitle - type: string? - jsonldPredicate: - _id: "gxformat2:CreatorPerson/jobTitle" - doc: | - Job title or role. - -- name: CreatorOrganization - type: record - extends: BaseCreator - doc: | - An organization that created or contributed to the workflow. - Corresponds to a `schema.org Organization `_. - fields: - - name: class - type: CreatorOrganizationType - jsonldPredicate: - "_id": "@type" - "_type": "@vocab" - doc: | - Creator type discriminator (``Organization``). - - name: GalaxyWorkflow type: record extends: