Index
Module to interact with the ML Workbench object storage.
ObjectStorage ¶
ObjectStorage class to manage files in the object storage of an ML Workbench.
Examples:
from pycelonis import (
get_celonis,
)
from pycelonis.ml_workbench.object_storage import (
ObjectStorage,
)
celonis = (
get_celonis()
)
object_storage = ObjectStorage(
celonis.client
)
object_storage.upload_file(
"data/input.csv",
"local/input.csv",
)
object_storage.list_files(
path_prefix="data/"
)
content = object_storage.download_file(
"data/input.csv"
)
object_storage.delete_file(
"data/input.csv"
)
Parameters:
-
client(Client) –Client used to call the ML Workbench proxy endpoints.
-
workbench_id(Optional[str], default:None) –Id of the ML Workbench. Defaults to the value of the
CELONIS_ML_APP_IDenvironment variable, which is set inside an ML Workbench.
Raises:
-
PyCelonisValueError–If no workbench id is given and
CELONIS_ML_APP_IDis not set.
list_files ¶
Lists the files and directories of one directory level in the object storage.
Parameters:
-
path_prefix(str, default:'') –Directory to list, e.g.
data/. Defaults to the root directory.
Returns:
-
List[Dict[str, Any]]–List of file entries as returned by the object storage. Empty if no file has been uploaded to the workbench yet.
Raises:
-
PyCelonisValueError–If
path_prefixpoints to a file instead of a directory. -
PyCelonisNotFoundError–If the directory does not exist.
upload_file ¶
Uploads a file to the object storage.
The file is read into memory before it is sent.
Parameters:
-
path(str) –Target path of the file in the object storage.
-
file(LocalFileType) –Local file path, raw bytes, or binary file-like object to upload.
-
show_progress(bool, default:False) –If true, a progress bar of the uploaded bytes is shown.
Returns:
-
str–Path of the imported file in the object storage.
download_file ¶
Downloads a file from the object storage.
Parameters:
-
path(str) –Path of the file in the object storage.
-
show_progress(bool, default:False) –If true, a progress bar of the downloaded bytes is shown.
Returns:
-
BytesIO–Content of the downloaded file.
delete_file ¶
Deletes a file from the object storage.
Parameters:
-
path(str) –Path of the file in the object storage.