credmark.cmf.types.series.BlockSeries
- DTO class BlockSeries(*, series=[], errors=None)[source]
Bases:
IterableListGenericDTO[BlockSeriesRow]
,Generic
[DTOCLS
]A DTO for the output of “series.*” models which run another model over a series of blocks.
The generic type specifies the class to use as the output in the
BlockSeriesRow
.For example
blockSeries = BlockSeries[MyOutputClass](**data)
whereblockSeries.series[0].output
will be an instance ofMyOutputClass
If a permanent error occurs during a model run, the block and error will be added to the errors array. If a non-permanent error occurs during a model run, the entire series will generate an error.
Show JSON schema
{ "title": "BlockSeries", "description": "A DTO for the output of \"series.*\" models which run another\nmodel over a series of blocks.\n\nThe generic type specifies the class to use as the output\nin the ``BlockSeriesRow``.\n\nFor example ``blockSeries = BlockSeries[MyOutputClass](**data)``\nwhere ``blockSeries.series[0].output`` will be an instance of ``MyOutputClass``\n\nIf a permanent error occurs during a model run, the block and error\nwill be added to the errors array.\nIf a non-permanent error occurs during a model run, the entire series\nwill generate an error.", "type": "object", "properties": { "series": { "title": "Series", "description": "List of series block outputs", "default": [], "type": "array", "items": { "$ref": "#/definitions/BlockSeriesRow" } }, "errors": { "title": "Errors", "description": "If any permanent (deterministic) errors were returned from model runs, this array will contain blocks with errors", "type": "array", "items": { "$ref": "#/definitions/BlockSeriesErrorRow" } } }, "definitions": { "BlockSeriesRow": { "title": "BlockSeriesRow", "description": "A data row in a block series.\nThe generic type specifies the class to use as the output.\n\nFor example ``row = BlockSeriesRow[MyOutputClass](**data)``\nwhere ``row.output`` will be an instance of ``MyOutputClass``", "type": "object", "properties": { "blockNumber": { "title": "Blocknumber", "description": "Block number in the series", "type": "integer" }, "blockTimestamp": { "title": "Blocktimestamp", "description": "The Timestamp of the Block", "type": "integer" }, "sampleTimestamp": { "title": "Sampletimestamp", "description": "The Sample Block time", "type": "integer" }, "output": { "title": "Output", "description": "Output of the model run for this block" } }, "required": [ "blockNumber", "blockTimestamp", "sampleTimestamp", "output" ] }, "ModelCallStackEntry": { "title": "ModelCallStackEntry", "description": "An item in an error's call stack.", "type": "object", "properties": { "slug": { "title": "Slug", "description": "Model slug", "type": "string" }, "version": { "title": "Version", "description": "Model version", "type": "string" }, "chainId": { "title": "Chainid", "description": "Context chain id", "type": "integer" }, "blockNumber": { "title": "Blocknumber", "description": "Context block number", "type": "integer" }, "input": { "title": "Input", "description": "Context input" }, "trace": { "title": "Trace", "description": "Trace of code that generated the error", "type": "string" } }, "required": [ "slug", "version" ] }, "ModelErrorDTO": { "title": "ModelErrorDTO", "description": "Data fields common to all error types:\nModelDataError, ModelRunError, ModelInputError etc.", "type": "object", "properties": { "type": { "title": "Type", "description": "Error type", "type": "string" }, "message": { "title": "Message", "description": "Error message", "type": "string" }, "stack": { "title": "Stack", "description": "Model call stack. Last element is the model that raised the error.", "default": [], "type": "array", "items": { "$ref": "#/definitions/ModelCallStackEntry" } }, "code": { "title": "Code", "description": "Short identifier for the type of error", "default": "generic", "type": "string" }, "detail": { "title": "Detail", "description": "Arbitrary data object related to the error." }, "permanent": { "title": "Permanent", "description": "If true, the error will always give the same result for the same context.", "default": false, "type": "boolean" } }, "required": [ "type", "message" ] }, "BlockSeriesErrorRow": { "title": "BlockSeriesErrorRow", "description": "An error row in a block series.", "type": "object", "properties": { "blockNumber": { "title": "Blocknumber", "description": "Block number in the series", "type": "integer" }, "blockTimestamp": { "title": "Blocktimestamp", "description": "The Timestamp of the Block", "type": "integer" }, "sampleTimestamp": { "title": "Sampletimestamp", "description": "The Sample Block time", "type": "integer" }, "error": { "title": "Error", "description": "Error DTO of the model run for this block", "allOf": [ { "$ref": "#/definitions/ModelErrorDTO" } ] } }, "required": [ "blockNumber", "blockTimestamp", "sampleTimestamp", "error" ] } } }
- Fields
- Parameters
series (List[BlockSeriesRow]) –
errors (Optional[List[BlockSeriesErrorRow]]) –
- Return type
None
- field errors: Optional[List[BlockSeriesErrorRow]] = None
If any permanent (deterministic) errors were returned from model runs, this array will contain blocks with errors
- field series: List[BlockSeriesRow] = []
List of series block outputs
- append(obj)
- append_error(error_row)[source]
- Parameters
error_row (BlockSeriesErrorRow) –
- extend(obj)
- to_dataframe(fields=None)[source]
- Parameters
fields (List[Tuple[str, Callable]] | None) – List of field name and lambda to extract certain field from output. Leave empty to extract the entire output.
- Return type
DataFrame
Extract tuples from series data
- to_list(fields=None)[source]
- Parameters
fields (List[Callable] | None) – List of lambda to extract certain field from output. Leave empty to extract the entire output.
- Return type
Extract tuples from series data