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>, _length: Optional[int] = None, persisted: bool = False, handler: Callable = <class 'str'>, download_generator_hook: Callable = None, checksum: Optional[str] = <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.
- Parameters
absolute_path – The absolute path of the asset. Optional if filename and content are given.
relative_path – The relative path (compared to the simulation root folder).
filename – Name of the file. Optional if absolute_path is given.
content – The content of the file. Optional if absolute_path is given.
checksum –
Optional. Useful in systems that allow single upload based on checksums and retrieving from those systems
Note: we add this to allow systems who provide asset caching by MD5 opportunity to avoid re-uploading assets
-
absolute_path
: Optional[str] = None¶
-
filename
: Optional[str] = None¶
-
persisted
: bool = False¶
-
handler
¶ alias of
builtins.str
-
download_generator_hook
: Callable = None¶
-
property
checksum
¶ - Returns
None.
-
property
extension
¶
-
property
relative_path
¶
-
property
bytes
¶
-
property
length
¶
-
property
content
¶ - Returns
The content of the file, either from the content attribute or by opening the absolute path.
-
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
path – Path to write to. If it is a directory, the asset filename will be added to it
- Returns
None