clams.appmetadata package

Package providing classes for representing metadata of CLAMS apps.

class clams.appmetadata.AppMetadata(*, name: str, description: str, app_version: str = '', mmif_version: str = '', analyzer_version: str | None = None, analyzer_versions: Dict[str, str] | None = None, app_license: str, analyzer_license: str | None = None, identifier: AnyHttpUrl, url: AnyHttpUrl, input: List[Input | List[Input]] = [], output: List[Output] = [], parameters: List[RuntimeParameter] = [], dependencies: List[str] | None = None, more: Dict[str, str] | None = None, est_gpu_mem_min: int = 0, est_gpu_mem_typ: int = 0)[source]

Data model that describes a CLAMS app.

Can be initialized by simply passing all required key-value pairs.

If you have a pre-generated metadata as an external file, you can read in the file as a dict and use it as keyword arguments for initialization. But be careful with keys of which values are automatically generated by the SDK.

Please refer to <CLAMS App Metadata> for the metadata specification.

add_input(at_type: str | TypesBase, required: bool = True, **properties) Input[source]

Helper method to add an element to the input list.

Parameters:
  • at_type@type of the input object

  • required – whether this type is mandatory or optional

  • properties – additional property specifications

Returns:

the newly added Input object

add_more(key: str, value: str)[source]

Helper method to add a k-v pair to the more map. :param key: key of an additional metadata :param value: value of the additional metadata

add_output(at_type: str | TypesBase, **properties) Output[source]

Helper method to add an element to the output list.

Parameters:
  • at_type@type of the input object

  • properties – additional property specifications

Returns:

the newly added Output object

add_parameter(name: str, description: str, type: Literal['integer', 'number', 'string', 'boolean', 'map'], choices: List[int | float | bool | str] | None = None, multivalued: bool = False, default: None | int | float | bool | str | List[int | float | bool | str] = None)[source]

Helper method to add an element to the parameters list.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'json_schema_extra': <function AppMetadata.<lambda>>, 'title': 'CLAMS AppMetadata', 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class clams.appmetadata.Input(*, at_type: AnyHttpUrl, description: str | None = None, properties: Dict[str, Any] = {}, required: bool | None = None)[source]

Data model that describes input specification of a CLAMS app.

CLAMS apps are expected to have at least one input type, and each type must be defined by a @type URI string. If the type has specific properties and values required by the app, they can be described in the (optional) properties field. Finally, a human-readable verbose description can be provided in the (optional) description field for users.

Developers should take diligent care to include all input types and their properties in the app metadata.

add_description(description: str)[source]

Add description string to the type specification.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'json_schema_extra': <function pop_titles>, 'title': 'CLAMS Input Specification', 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class clams.appmetadata.Output(*, at_type: AnyHttpUrl, description: str | None = None, properties: Dict[str, Any] = {})[source]

Data model that describes output specification of a CLAMS app.

CLAMS apps are expected to have at least one output type, and each type must be defined by a @type URI string. If the type has common properties and values generated by the app, they can be described in the (optional) properties field. Finally, a human-readable verbose description can be provided in the (optional) description field for users.

Developers should take diligent care to include all output types and their properties in the app metadata. To specify the property values, developers can use an actual value (for full match) or '*' (for any value).

add_description(description: str)[source]

Add description string to the type specification.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'json_schema_extra': <function pop_titles>, 'title': 'CLAMS Output Specification', 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class clams.appmetadata.RuntimeParameter(*, name: str, description: str, type: Literal['integer', 'number', 'string', 'boolean', 'map'], choices: List[int | float | bool | str] | None = None, default: Annotated[int | float | bool | str | List[int | float | bool | str] | None, _PydanticGeneralMetadata(union_mode='left_to_right')] = None, multivalued: bool)[source]

Defines a data model that describes a single runtime configuration of a CLAMS app. Usually, an app keeps a list of these configuration specifications in the parameters field. When initializing a RuntimeParameter object in python the value for the default field must be a string. For example, if you want to set a default value for a boolean parameter, use any of 'True', 'true', 't', or their falsy counterpart, instead of True or False

model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'json_schema_extra': <function pop_titles>, 'title': 'CLAMS App Runtime Parameter'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].