-
Notifications
You must be signed in to change notification settings - Fork 0
Asset Pack
[[TOC]]
from mkproject.asset_pack import AssetPack
asset_pack = AssetPack()
asset_pack.register_path('/path/a', 'data-a', {'arbitrary metadata': 'extra information'})
asset_path.register_path('/path/b', 'data-b')
asset_pack.paths()
# ('/path/a', '/path/b')
asset_pack.data('/path/a')
# 'data-a'
asset_pack.meta('/path/a')
# {'arbitrary metadata': 'extra information'}
asset_pack.meta('/path/b')
# {}
asset_pack.assets()
# (('/path/a', 'data-a', {'arbitrary metadata': 'extra information'}),
# ('/path/b', 'data-b', {}))
new_asset_pack = asset_pack.transform()instance.register_path(path, data, meta={})
This interface should only be used by loaders. Append asset data to the pack. Asset data has three properties:
-
path: A key representing the path under which this data is stored -
data: The asset data -
meta: Optional dictionary assigned as arbitrary metadata to the path
instance.paths()
Returns all registered paths as a tuple
instance.data(path)
Returns the data associated with the registered path path.
instance.meta(path)
Returns a dictionary containing all metadata associated with path path
instance.assets()
Returns a tuple of assets, within which each asset is itself
represented as a tuple in the order (path, data, meta).
instance.transform(transform_map={}, cfg={})
Returns a new AssetPack containing copies of the assets in the calling AssetPack.
The method accepts two optional parameters:
-
cfg: The value which will be passed to invoked transformers as thecfgvalue for the transformers interface -
transform_map: A mapping of{ 'transformer_class.name': transformer_class }pairs.
If a transform_map is provided, each asset copy will be transformed using the transformers
specified in its pipeline metadata key. The value for the pipeline metadata key must be an iterable containing the names of all transformers to be invoked.