Credmark uses a simple base class called ‘Model’ class to set up a model.
All Models should import this class
import credmark.cmf.modeland can override the run() method.
@Model.describe()decorator provides a simple interface to define the model properties such as slug, version, display_name, description, developer, input, output etc so that it can be used easily by consumers and other models.
If description is not specified, the
__doc__string of the model's class is used for the model description.
Let's make this model our own by customization.
The in-file instructions are the first things to do. Let's complete them and then remove the instruction comments. The resulting file is more concise.
from credmark.cmf.model import Model
from credmark.dto import EmptyInput
display_name='Count how many transactions in the one block',
description="Use ledger and some counting",
def run(self, input: EmptyInput) -> dict:
credmark-dev describewith the mode slug to check whether we can load the model correctly. yay! There has been no error so far.
> credmark-dev describe contrib.ape-count
- slug: contrib.ape-count
- version: 1.0
- displayName: Count how many transactions in the one block
- description: Use ledger and some counts
- tags: None
- input schema (* for required field):
- input example:
- output schema (* for required field):
- output example:
No defined errors
- class: models.contrib.ape.count.ContribModel