idmtools.assets.asset module

class idmtools.assets.asset.Asset(absolute_path: Optional[str] = None, relative_path: Optional[str] = <property object>, filename: Optional[str] = None, content: dataclasses.InitVar = <property object>, persisted: bool = False, handler: Callable = <class 'str'>, download_generator_hook: Callable = None, checksum: dataclasses.InitVar = <property object>)

Bases: object

A class representing an asset. An asset can either be related to a physical asset present on the computer or directly specified by a filename and content.

absolute_path: Optional[str] = None

The absolute path of the asset. Optional if filename and content are given.

filename: Optional[str] = None

Name of the file. Optional if absolute_path is given.

persisted: bool = False

Persisted tracks if item has been saved

handler

alias of builtins.str

download_generator_hook: Callable = None

Hook to allow downloading from platform

property checksum

Checksum of asset. Only required for existing assets

property extension
property relative_path

The relative path (compared to the simulation root folder).

property bytes
property length
property content

The content of the file. Optional if absolute_path is given.

deep_equals(other: idmtools.assets.asset.Asset) → bool

Performs a deep comparison of assets, including contents

Parameters

other – Other asset to compare

Returns

True if filename, relative path, and contents are equal, otherwise false

download_generator() → Generator[bytearray, None, None]

A Download Generator that returns chunks of bytes from the file

Returns

Generator of bytearray

download_stream() → _io.BytesIO

Get a bytes IO stream of the asset

Returns

BytesIO of the Asset

download_to_path(dest: str, force: bool = False)

Download an asset to path. This requires loadings the object through the platofrm

Parameters
  • dest – Path to write to. If it is a directory, the asset filename will be added to it

  • force – Force download even if file exists

Returns

None

calculate_checksum() → str

Calculate checksum on asset. If previous checksum was calculated, that value will be returned

Returns

Checksum string

short_remote_path() → str

Returns the short remote path. This is the join of the relative path and filename

Returns

Remote Path + Filename