credmark.cmf.model.template.ContribModel
- class ContribModel(context)[source]
Bases:
Model
If the description is not set in the decorator above, this doc string is used as the model description.
Methods
A model can call this method to convert a dict of data in a known format into a DTO instance.
Decorator for credmark.cmf.model.Model subclasses to describe the model.
Subclasses may override this method to do any model instance initiation.
run
Attributes
slug
version
- Parameters
context (ModelContext) –
- convert_dict_to_dto(data, dto_class)
A model can call this method to convert a dict of data in a known format into a DTO instance.
- classmethod describe(*, slug, version, display_name=None, description=None, developer=None, category=None, subcategory=None, tags=None, cache=CachePolicy.FULL, input=<class 'credmark.dto.EmptyInput'>, output=None, errors=None)
Decorator for credmark.cmf.model.Model subclasses to describe the model.
Example usage:
from credmark.cmf.model import Model @Model.describe(slug='example.echo', version='1.0', display_name='Echo', description="A test model to echo the message property sent in input.", developer="my_username", category="financial", input=EchoDto, output=EchoDto) class EchoModel(Model):
- Parameters
slug (str) – slug (short unique name) for the model. Can contain alpha-numeric and and underscores. Contributor slugs must start with
"contrib."
Once submitted, the model slug cannot be changed.version (str) – version string, ex.
"1.0"
. The version number can be incremented when the model code is updated.description (Optional[str]) – Description of the model. If description is not set, the doc string (
__doc__
) of the model class is used instead.developer (Optional[str]) – Name or nickname of the developer
category (Optional[str]) – Category of the model (ex. “financial”, “protocol” etc.)
subcategory (Optional[str]) – Optional subcategory (ex. “aave”)
tags (Optional[list[str]]) – optional list of string tags describing the model
input (Union[Type[Union[BaseModel, IntDTO, StrDTO, FloatDTO]], Type[dict]]) – Type that model uses as input; a
DTO
subclass or dict. Defaults toEmptyInput
object.output (Optional[Union[Type[Union[BaseModel, IntDTO, StrDTO, FloatDTO]], Type[dict]]]) – Type that the model run returns; a
DTO
subclass or dict. Defaults to None which will provide no output schema.errors (Optional[Union[List[ModelErrorDesc], ModelErrorDesc]]) – If the model raises
ModelDataError
, set this to a configuredModelDataErrorDesc
instance (or a list of instances) describing the errors. Defaults to None.cache (Literal[<CachePolicy.FULL: 'full'>, <CachePolicy.SKIP: 'skip'>, <CachePolicy.IGNORE_BLOCK: 'ignore_block'>, <CachePolicy.OFF_CHAIN: 'off_chain'>]) –
- init()
Subclasses may override this method to do any model instance initiation.
- inputDTO
alias of
EmptyInput