- steamship.utils.binary_utils.flexi_create(base64string: Optional[str] = None, data: Optional[Any] = None, string: Optional[str] = None, json: Optional[Any] = None, _bytes: Optional[Union[bytes, _io.BytesIO]] = None, mime_type=None, force_base64=False) Tuple[Any, Union[None, str], Union[None, str]] #
It’s convenient for some constructors to accept a variety of input types: - data (your choice) - string - json - bytes
This class is a helper for plugins to use models hosted on Hugging Face.
It uses asyncio parallelism to make many http requests simultaneously.
A simple key-value store implemented atop Files and Tags.
- class steamship.utils.kv_store.KeyValueStore(client: steamship.client.steamship.Steamship, store_identifier: str = 'KeyValueStore')#
A simple key value store implemented in Steamship.
Instances of the KeyValueStore are identified by its namespace. This store_identifier corresponds to a File that will be created with a special tag identifying it.
- Entries of the KeyValueStore are saved as Tag objects with:
Kind = “KeyValueStore”
Name = the key of the (kv) pair
Value = a dict set to the value
Note that the value is always saved as a dict object. To save a string or int, wrap it in a dict.
This is essentially a clever hack atop Steamship’s tag system to provide mutable key-value storage. It is in the steamship.utils package because it’s proven useful once or twice. But in general, if you find yourself heavily relying upon it, consider reaching out to us at email@example.com to let us know, and we’ll up-prioritize adding a proper key-value API.
- items(filter_keys: Optional[List[str]] = None) List[Tuple[str, Dict[str, Any]]] #
Return all key-value entries as a list of (key, value) tuples.
If filter_keys is provided, only returns keys within that list.
Delete all key-values.
- steamship.utils.metadata.metadata_to_str(m: Union[int, float, bool, str, List, Dict]) Optional[str] #
- steamship.utils.signed_urls.download_from_signed_url(url: str, to_file: Optional[pathlib.Path] = None) pathlib.Path #
Downloads the Signed URL to the filename desired_filename in a temporary directory on disk.
- steamship.utils.signed_urls.upload_to_signed_url(url: str, _bytes: Optional[bytes] = None, filepath: Optional[pathlib.Path] = None)#
Uploads either the bytes or filepath contents to the provided Signed URL.
- steamship.utils.signed_urls.url_to_bytes(url: str) bytes #
Downloads the Signed URL and returns the contents as bytes.
- This is a helper function to consolidate Steamship Client URL fetching to ensure a single point of handling for:
Any required manipulations for URL signed URLs
Any required manipulations for localstack-based environments
Note that the base API Client does not use this method on purpose: in the event of error code, it inspects the contents of the response for a SteamshipError.
- class steamship.utils.url.Verb(value)#
- GET = 'GET'#
- POST = 'POST'#
- steamship.utils.zip_archives.unzip_folder(zip_file: pathlib.Path, into_folder: Optional[pathlib.Path]) pathlib.Path #
Unzips a folder on disk, returning the path to the new folder resulting.
- steamship.utils.zip_archives.zip_folder(folder: pathlib.Path, into_file: Optional[pathlib.Path]) pathlib.Path #
Zips a folder on disk to a co-located zip-file of the same name.
The resulting zip file does not contain the enclosing folder name provided. It contains only the children of that folder as its root elements.
Collection of utility functions.