asset¶
- class AssetScope(*values)[source]¶
- runner = 'runner'¶
Asset persists through the entire lifespan of the runner. Can be modified and passed through different epochs.
- process = 'process'¶
Asset persists through the a single process call. Can be modified and passed through different nodes but are re-instantiated at the beginning of each epoch.
- node = 'node'¶
Asset is re-instantiated every node call.
- pydantic model AssetSpecification[source]¶
Specification for a single asset within a tube .yaml file.
Show JSON schema
{ "title": "AssetSpecification", "description": "Specification for a single asset within a tube .yaml file.", "type": "object", "properties": { "id": { "title": "Id", "type": "string" }, "type": { "title": "Type", "type": "string" }, "scope": { "$ref": "#/$defs/AssetScope" }, "params": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Params" }, "depends": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Depends" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" } }, "$defs": { "AssetScope": { "enum": [ "runner", "process", "node" ], "title": "AssetScope", "type": "string" } }, "required": [ "id", "type", "scope" ] }
- Fields:
- Validators:
validate_depends»all fields
- field depends: Annotated[str, AfterValidator(func=_is_signal_slot)] | None = None¶
Roundtrip dependency. Should point to the last node in a given epoch that manipulates the asset.
May only be used with scope == “runner”
Typically this is used with assets that are mutated by multiple nodes in a tube. In that case, nodes should use dependencies to structure the order of mutation: The first node that should have it should depend directly on the asset, and then it and each node should emit the asset so that the successive node can depend on that signal. The node signal that this asset specification depends on will be the version of the asset stored and used in the next processing epoch.
- Validated by:
- field id: Annotated[str, AfterValidator(func=_is_identifier), AfterValidator(func=_not_reserved)] [Required]¶
The unique identifier of the asset
- Constraints:
func = <function _not_reserved at 0x77de2d4389a0>
- Validated by:
- field scope: AssetScope [Required]¶
The scope of the asset. See
AssetScope- Validated by:
- field type_: Annotated[str, AfterValidator(func=_is_absolute_identifier)] [Required] (alias 'type')¶
The python path to the location of the asset e.g. package_name.module_name.ClassName
- Constraints:
func = <function _is_absolute_identifier at 0x77de2d4385e0>
- Validated by:
- pydantic model Asset[source]¶
An asset within a processing tube.
Show JSON schema
{ "title": "Asset", "description": "An asset within a processing tube.", "type": "object", "properties": { "id": { "title": "Id", "type": "string" }, "spec": { "$ref": "#/$defs/AssetSpecification" }, "scope": { "$ref": "#/$defs/AssetScope" }, "params": { "additionalProperties": true, "title": "Params", "type": "object" }, "depends": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Depends" }, "obj": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Obj" }, "stored_at": { "default": -1, "title": "Stored At", "type": "integer" } }, "$defs": { "AssetScope": { "enum": [ "runner", "process", "node" ], "title": "AssetScope", "type": "string" }, "AssetSpecification": { "description": "Specification for a single asset within a tube .yaml file.", "properties": { "id": { "title": "Id", "type": "string" }, "type": { "title": "Type", "type": "string" }, "scope": { "$ref": "#/$defs/AssetScope" }, "params": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Params" }, "depends": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Depends" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" } }, "required": [ "id", "type", "scope" ], "title": "AssetSpecification", "type": "object" } }, "additionalProperties": false, "required": [ "id", "spec", "scope", "depends" ] }
- Config:
extra: str = forbid
- Fields:
- field depends: Annotated[str, AfterValidator(func=_is_signal_slot)] | None [Required]¶
The signal that this asset gets updated by. See
AssetSpecification.depends
- field id: Annotated[str, AfterValidator(func=_is_identifier), AfterValidator(func=_not_reserved)] [Required]¶
The unique identifier of the asset
- Constraints:
func = <function _not_reserved at 0x77de2d4389a0>
- field scope: AssetScope [Required]¶
The scope of the asset. See
AssetScope
- field spec: AssetSpecification [Required]¶
The specs of the asset. See
AssetSpecification
- field stored_at: int = -1¶
The latest epoch the asset was stored at. Only used when depends is not None
- classmethod from_specification(spec: AssetSpecification) Asset[source]¶
Create an asset from its spec
- resolve the asset type
if a subclass of
Asset, just instantiate itif not a subclass
Asset, wrap it inWrapClassAssetif a function, wrap it in
WrapFuncAsset
- deinit() None[source]¶
Deinitialize the asset instance.
Default is a no-op. Subclasses do not need to override if they have no deinit logic.
- pydantic model WrapClassAsset[source]¶
Wrap a non-Asset class.
Wrapping allows us to use arbitrary classes as Assets within noob. Initializes the inner class to hold the class instance as an asset object.
After instantiating the outer wrapping class, instantiate the inner wrapped class using the params given to the outer wrapping class during
init().Show JSON schema
{ "title": "WrapClassAsset", "type": "object", "properties": { "id": { "title": "Id", "type": "string" }, "spec": { "$ref": "#/$defs/AssetSpecification" }, "scope": { "$ref": "#/$defs/AssetScope" }, "params": { "additionalProperties": true, "title": "Params", "type": "object" }, "depends": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Depends" }, "obj": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Obj" }, "stored_at": { "default": -1, "title": "Stored At", "type": "integer" }, "cls": { "default": null, "title": "Cls" } }, "$defs": { "AssetScope": { "enum": [ "runner", "process", "node" ], "title": "AssetScope", "type": "string" }, "AssetSpecification": { "description": "Specification for a single asset within a tube .yaml file.", "properties": { "id": { "title": "Id", "type": "string" }, "type": { "title": "Type", "type": "string" }, "scope": { "$ref": "#/$defs/AssetScope" }, "params": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Params" }, "depends": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Depends" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" } }, "required": [ "id", "type", "scope" ], "title": "AssetSpecification", "type": "object" } }, "additionalProperties": false, "required": [ "id", "spec", "scope", "depends" ] }
- Config:
extra: str = forbid
- Fields:
- pydantic model WrapFuncAsset[source]¶
Wrap a function to build an Asset.
The function effectively takes the role of
__init__(), with the outer wrapping class params being injected as function parameters. The output of the function becomes the asset object.Show JSON schema
{ "title": "WrapFuncAsset", "type": "object", "properties": { "id": { "title": "Id", "type": "string" }, "spec": { "$ref": "#/$defs/AssetSpecification" }, "scope": { "$ref": "#/$defs/AssetScope" }, "params": { "additionalProperties": true, "title": "Params", "type": "object" }, "depends": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "title": "Depends" }, "obj": { "anyOf": [ {}, { "type": "null" } ], "default": null, "title": "Obj" }, "stored_at": { "default": -1, "title": "Stored At", "type": "integer" }, "fn": { "default": null, "title": "Fn" } }, "$defs": { "AssetScope": { "enum": [ "runner", "process", "node" ], "title": "AssetScope", "type": "string" }, "AssetSpecification": { "description": "Specification for a single asset within a tube .yaml file.", "properties": { "id": { "title": "Id", "type": "string" }, "type": { "title": "Type", "type": "string" }, "scope": { "$ref": "#/$defs/AssetScope" }, "params": { "anyOf": [ { "additionalProperties": true, "type": "object" }, { "type": "null" } ], "default": null, "title": "Params" }, "depends": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Depends" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" } }, "required": [ "id", "type", "scope" ], "title": "AssetSpecification", "type": "object" } }, "additionalProperties": false, "required": [ "id", "spec", "scope", "depends" ] }
- Config:
extra: str = forbid
- Fields: