clams.appmetadata package
Package providing classes for representing metadata of CLAMS apps.
- class clams.appmetadata.AppMetadata(*, name: str, description: str, app_version: str = None, mmif_version: str = None, analyzer_version: str = None, app_license: str, analyzer_license: str = None, identifier: AnyHttpUrl, url: AnyHttpUrl, input: List[Input | List[Input]] = [], output: List[Output] = [], parameters: List[RuntimeParameter] = [], dependencies: List[str] = None, more: Dict[str, str] = None)[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 objectrequired – 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 objectproperties – 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: int | float | bool | str | List[int | float | bool | str] | None = None)[source]
Helper method to add an element to the
parameters
list.
- class clams.appmetadata.Input(*args, at_type: AnyHttpUrl, description: str | None = None, properties: Dict[str, int | float | bool | str] = {}, required: bool = 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.
- classmethod construct(_fields_set: SetStr | None = None, **values: Any) Model [source]
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
- copy(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, update: DictStrAny | None = None, deep: bool = False) Model [source]
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters:
include – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep – set to True to make a deep copy of the model
- Returns:
new model instance
- dict(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny [source]
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- json(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode [source]
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- class clams.appmetadata.Output(*, at_type: AnyHttpUrl, description: str | None = None, properties: Dict[str, int | float | bool | str] = {})[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).- classmethod construct(_fields_set: SetStr | None = None, **values: Any) Model [source]
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
- copy(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, update: DictStrAny | None = None, deep: bool = False) Model [source]
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters:
include – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep – set to True to make a deep copy of the model
- Returns:
new model instance
- dict(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny [source]
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- json(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode [source]
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().
- class clams.appmetadata.RuntimeParameter(*, name: str, description: str, type: Literal['integer', 'number', 'string', 'boolean', 'map'], choices: List[int | float | bool | str] = None, default: int | float | bool | str | List[int | float | bool | str] = 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 ofTrue
orFalse
- classmethod construct(_fields_set: SetStr | None = None, **values: Any) Model [source]
Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values
- copy(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, update: DictStrAny | None = None, deep: bool = False) Model [source]
Duplicate a model, optionally choose which fields to include, exclude and change.
- Parameters:
include – fields to include in new model
exclude – fields to exclude from new model, as with values this takes precedence over include
update – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data
deep – set to True to make a deep copy of the model
- Returns:
new model instance
- dict(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny [source]
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.
- json(*, include: AbstractSetIntStr | MappingIntStrAny | None = None, exclude: AbstractSetIntStr | MappingIntStrAny | None = None, by_alias: bool = False, skip_defaults: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Callable[[Any], Any] | None = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode [source]
Generate a JSON representation of the model, include and exclude arguments as per dict().
encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().