Skip to main content

ObjectAPIClient

GitHub source

ObjectAPIClient

evo.objects.client.api_client.ObjectAPIClient

__init__

__init__(environment: Environment, connector: APIConnector, cache: ICache | None = None) -> None

Parameters:

NameTypeDescriptionDefault
environmentEnvironmentThe target Evo environment, providing org and workspace IDs.required
connectorAPIConnectorThe API connector to use for making API calls.required
cacheICache | NoneAn optional cache to use for data downloads.None

from_context classmethod

from_context(context: IContext) -> ObjectAPIClient

Create a ObjectAPIClient from the given context.

The context must have a hub_url, org_id, and workspace_id set.

Parameters:

NameTypeDescriptionDefault
contextIContextThe context to create the client from.required

Returns:

TypeDescription
ObjectAPIClientA ObjectAPIClient instance.

get_service_health async

get_service_health(check_type: HealthCheckType = HealthCheckType.FULL) -> ServiceHealth

Get the health of the geoscience object service.

Parameters:

NameTypeDescriptionDefault
check_typeHealthCheckTypeThe type of health check to perform.FULL

Returns:

TypeDescription
ServiceHealthA ServiceHealth object.

Raises:

TypeDescription
EvoAPIExceptionIf the API returns an unexpected status code.
ClientValueErrorIf the response is not a valid service health check response.

list_objects async

list_objects(
offset: int = 0,
limit: int = 5000,
order_by: dict[ObjectOrderByEnum | str, OrderByOperatorEnum] | None = None,
schema_id: list[str] | None = None,
deleted: bool | None = None,
request_timeout: int | float | tuple[int | float, int | float] | None = None,
) -> Page[ObjectMetadata]

List up to limit geoscience objects, starting at offset.

The geoscience objects will be the latest version of the object. If there are no objects to list, the page will be empty.

Parameters:

NameTypeDescriptionDefault
offsetintThe number of objects to skip before listing.0
limitintMax number of objects to list.5000
order_bydict[ObjectOrderByEnum | str, OrderByOperatorEnum] | NoneA dictionary of fields to order the results by, with the field name as the key and the direction of ordering as the value.None
schema_idlist[str] | NoneA list of schema IDs to filter the objects by. If None, objects of all schema types are returned.None
deletedbool | NoneWhen true, only objects that have been deleted will be returned. If false or None, only non-deleted objects will be returned.None
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
Page[ObjectMetadata]A page of all objects from the query.

list_all_objects async

list_all_objects(
limit_per_request: int = 5000,
order_by: dict[ObjectOrderByEnum | str, OrderByOperatorEnum] | None = None,
schema_id: list[str] | None = None,
deleted: bool | None = None,
request_timeout: int | float | tuple[int | float, int | float] | None = None,
) -> list[ObjectMetadata]

List all geoscience objects in the workspace.

This method makes multiple calls to the list_objects endpoint until all objects have been listed.

Parameters:

NameTypeDescriptionDefault
limit_per_requestintThe maximum number of objects to list in one request.5000
order_bydict[ObjectOrderByEnum | str, OrderByOperatorEnum] | NoneA dictionary of fields to order the results by, with the field name as the key and the direction of ordering as the value.None
schema_idlist[str] | NoneA list of schema IDs to filter the objects by. If None, objects of all schema types are returned.None
deletedbool | NoneWhen true, only objects that have been deleted will be returned. If false or None, only non-deleted objects will be returned.None
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
list[ObjectMetadata]A list of all objects in the workspace.

list_objects_for_instance async

list_objects_for_instance(
offset: int = 0,
limit: int = 5000,
order_by: dict[ObjectOrderByEnum | str, OrderByOperatorEnum] | None = None,
schema_id: list[str] | None = None,
deleted: bool | None = None,
request_timeout: int | float | tuple[int | float, int | float] | None = None,
) -> Page[OrgObjectMetadata]

List up to limit geoscience objects for all accessible workspaces in the instance, starting at offset.

The geoscience objects will be the latest version of the object. If there are no objects to list, the page will be empty.

Parameters:

NameTypeDescriptionDefault
offsetintThe number of objects to skip before listing.0
limitintMax number of objects to list.5000
order_bydict[ObjectOrderByEnum | str, OrderByOperatorEnum] | NoneA dictionary of fields to order the results by, with the field name as the key and the direction of ordering as the value.None
schema_idlist[str] | NoneA list of schema IDs to filter the objects by. If None, objects of all schema types are returned.None
deletedbool | NoneWhen true, only objects that have been deleted will be returned. If false or None, only non-deleted objects will be returned.None
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
Page[OrgObjectMetadata]A page of all objects from the query.

list_versions_by_path async

list_versions_by_path(
path: str, request_timeout: int | float | tuple[int | float, int | float] | None = None
) -> list[ObjectVersion]

List all version for the given object.

Parameters:

NameTypeDescriptionDefault
pathstrThe path to the geoscience object.required
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
list[ObjectVersion]A sorted list of object versions. The latest version is the first element of the list.

list_versions_by_id async

list_versions_by_id(
object_id: UUID, request_timeout: int | float | tuple[int | float, int | float] | None = None
) -> list[ObjectVersion]

List all version for the given object.

Parameters:

NameTypeDescriptionDefault
object_idUUIDThe UUID of the geoscience object.required
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
list[ObjectVersion]A sorted list of object versions. The latest version is the first element of the list.

prepare_data_upload async

prepare_data_upload(data_identifiers: Sequence[str | UUID]) -> AsyncIterator[ObjectDataUpload]

Prepare to upload multiple data files to the geoscience object service.

Referenced data that already exists in the workspace will be skipped.

Parameters:

NameTypeDescriptionDefault
data_identifiersSequence[str | UUID]A list of sha256 digests or UUIDs for the data to be uploaded.required

Returns:

TypeDescription
AsyncIterator[ObjectDataUpload]An async iterator of data upload contexts that can be used to upload the data. Data identifiers that already exist in the workspace will be skipped.

prepare_data_download async

prepare_data_download(
object_id: UUID,
version_id: str,
data_identifiers: Sequence[str | UUID],
request_timeout: int | float | tuple[int | float, int | float] | None = None,
) -> AsyncIterator[ObjectDataDownload]

Prepare to download multiple data files from the geoscience object service.

Any data IDs that are not associated with the requested object will raise a DataNotFoundError.

Parameters:

NameTypeDescriptionDefault
object_idUUIDThe ID of the object to download data from.required
version_idstrThe version ID of the object to download data from.required
data_identifiersSequence[str | UUID]A list of sha256 digests or UUIDs for the data to be downloaded.required
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
AsyncIterator[ObjectDataDownload]An async iterator of data download contexts that can be used to download the data.

Raises:

TypeDescription
DataNotFoundErrorIf any requested data ID is not associated with the referenced object.

get_data_client

get_data_client(cache: ICache) -> ObjectDataClient

Get a data client for the geoscience object service.

The data client provides a high-level interface for uploading and downloading data that is referenced in geoscience objects, and caching the data locally. It depends on the optional dependency pyarrow, which is not installed by default. This dependency can be installed with pip install evo-objects[utils].

Parameters:

NameTypeDescriptionDefault
cacheICacheThe cache to use for data downloads.required

Returns:

TypeDescription
ObjectDataClientAn ObjectDataClient instance.

Raises:

TypeDescription
RuntimeErrorIf the pyarrow package is not installed.

create_geoscience_object async

create_geoscience_object(
path: str, object_dict: dict, request_timeout: int | float | tuple[int | float, int | float] | None = None
) -> ObjectMetadata

Upload a new geoscience object to the geoscience object service.

New geoscience objects must not have a UUID, so that one can be assigned by the Geoscience Object Service. The object_instance that is passed in will be updated with the service-assigned UUID after it has been uploaded, and the metadata of the created object will be returned.

Parameters:

NameTypeDescriptionDefault
pathstrThe path to upload the object to.required
object_dictdictThe geoscience object to be uploaded.required
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
ObjectMetadataThe metadata of the uploaded object.

Raises:

TypeDescription
ObjectUUIDErrorIf the provided object has a UUID.

move_geoscience_object async

move_geoscience_object(
path: str, object_dict: dict, request_timeout: int | float | tuple[int | float, int | float] | None = None
) -> ObjectMetadata

Move an existing geoscience object to a new path in the geoscience object service.

Parameters:

NameTypeDescriptionDefault
pathstrThe new path to move the object to.required
object_dictdictThe geoscience object to be moved.required
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
ObjectMetadataThe metadata of the moved object.

Raises:

TypeDescription
ObjectUUIDErrorIf the provided object does not have a UUID.

update_geoscience_object async

update_geoscience_object(
object_dict: dict, request_timeout: int | float | tuple[int | float, int | float] | None = None
) -> ObjectMetadata

Update an existing geoscience object in the geoscience object service.

Parameters:

NameTypeDescriptionDefault
object_dictdictThe geoscience object to be updated.required
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
ObjectMetadataThe metadata of the updated object.

Raises:

TypeDescription
ObjectUUIDErrorIf the provided object does not have a UUID.

download_object_by_path async

download_object_by_path(
path: str, version: str | None = None, request_timeout: int | float | tuple[int | float, int | float] | None = None
) -> DownloadedObject

Download a geoscience object definition (by path).

Parameters:

NameTypeDescriptionDefault
pathstrThe path to the geoscience object.required
versionstr | NoneThe version of the geoscience object to download. This will download the latest version by default.None
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
DownloadedObjectA tuple containing the object metadata and a data model of the requested geoscience object.

download_object_by_id async

download_object_by_id(
object_id: UUID,
version: str | None = None,
request_timeout: int | float | tuple[int | float, int | float] | None = None,
) -> DownloadedObject

Download a geoscience object definition (by UUID).

Parameters:

NameTypeDescriptionDefault
object_idUUIDThe uuid of the geoscience object.required
versionstr | NoneThe version of the geoscience object to download. This will download the latest version by default.None
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
DownloadedObjectA tuple containing the object metadata and a data model of the requested geoscience object.

get_latest_object_versions async

get_latest_object_versions(
object_ids: list[UUID],
batch_size: int = 500,
request_timeout: int | float | tuple[int | float, int | float] | None = None,
) -> dict[UUID, str]

Get the latest version of each object by uuid.

Parameters:

NameTypeDescriptionDefault
object_idslist[UUID]A list of object uuids.required
batch_sizeintThe maximum number of objects to check in one API call (max 500).500
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
dict[UUID, str]A mapping of uuids to the latest version id.

delete_object_by_path async

delete_object_by_path(path: str, request_timeout: int | float | tuple[int | float, int | float] | None = None) -> None

Soft-delete a geoscience object (by path).

Parameters:

NameTypeDescriptionDefault
pathstrThe path to the geoscience object.required
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
NoneNone

delete_object_by_id async

delete_object_by_id(
object_id: UUID, request_timeout: int | float | tuple[int | float, int | float] | None = None
) -> None

Soft-delete a geoscience object (by UUID).

Parameters:

NameTypeDescriptionDefault
object_idUUIDThe uuid of the geoscience objectrequired
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
NoneNone

restore_geoscience_object async

restore_geoscience_object(
object_id: UUID, request_timeout: int | float | tuple[int | float, int | float] | None = None
) -> None | ObjectMetadata

Restore a soft-deleted geoscience object in the geoscience object service.

Parameters:

NameTypeDescriptionDefault
object_idUUIDThe uuid of the geoscience objectrequired
request_timeoutint | float | tuple[int | float, int | float] | NoneTimeout setting for this request. If one number is provided, it will be the total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.None

Returns:

TypeDescription
None | ObjectMetadataThe metadata of the restored object, if a rename occurred. Otherwise, None.

list_stages async

list_stages() -> list[Stage]

List all available stages in the organisation.

Returns:

TypeDescription
list[Stage]A list of all available stages.

set_stage async

set_stage(object_id: UUID, version_id: int, stage_id: UUID) -> None

Set the stage of a specific version of a geoscience object.

Parameters:

NameTypeDescriptionDefault
object_idUUIDThe UUID of the geoscience object.required
version_idintThe version ID of the geoscience object.required
stage_idUUIDThe UUID of the stage to set.required

Returns:

TypeDescription
NoneNone

What is the reason for your feedback?