Skip to content

Index

Module to interact with the ML Workbench object storage.

ObjectStorage

ObjectStorage(client, workbench_id=None)

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_ID environment variable, which is set inside an ML Workbench.

Raises:

client instance-attribute

client = client

workbench_id instance-attribute

workbench_id = resolved_workbench_id

list_files

list_files(path_prefix='')

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:

upload_file

upload_file(path, file, show_progress=False)

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

download_file(path, show_progress=False)

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

delete_file(path)

Deletes a file from the object storage.

Parameters:

  • path (str) –

    Path of the file in the object storage.