DownloadedObject
DownloadedObject
evo.objects.client.object_client.DownloadedObject
A downloaded geoscience object.
This class also implements the IContext interface, allowing it to be used directly as a context for further API operations.
schema property
The schema of the object.
metadata property
The metadata of the object.
__init__
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_ | GeoscienceObject | The raw geoscience object model. | required |
metadata | ObjectMetadata | The parsed metadata for the object. | required |
urls_by_name | dict[str, str] | A mapping of data names to their initial download URLs. | required |
connector | APIConnector | The API connector to use for downloading data. | required |
cache | ICache | None | An optional cache to use for data downloads. | None |
from_reference async staticmethod
Download a geoscience object from the service, given an object reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connector | APIConnector | The API connector to use for downloading data. | required |
reference | ObjectReference | str | The reference to the object to download, or a URL as a string that can be parsed into a reference. | required |
cache | ICache | None | An optional cache to use for data downloads. | None |
request_timeout | int | float | tuple[int | float, int | float] | None | An optional timeout to use for API requests. See evo.common.APIConnector for details. | None |
Raises:
| Type | Description |
|---|---|
ValueError | If the reference is invalid, or if the connector base URL does not match the reference hub URL. |
from_context async staticmethod
Download a geoscience object from the service using a context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context | IContext | The context providing the connector and cache. | required |
reference | ObjectReference | str | The reference to the object to download, or a URL as a string that can be parsed into a reference. | required |
Raises:
| Type | Description |
|---|---|
ValueError | If the reference is invalid, or if the connector base URL does not match the reference hub URL. |
get_environment
Gets the Environment associated with this object.
Returns:
| Type | Description |
|---|---|
Environment | The Environment. |
get_org_id
Gets the organization ID associated with this object.
Returns:
| Type | Description |
|---|---|
UUID | The organization ID. |
get_connector
Gets the APIConnector associated with this object.
Returns:
| Type | Description |
|---|---|
APIConnector | The APIConnector. |
get_cache
Gets the ICache associated with this object, if any.
Returns:
| Type | Description |
|---|---|
ICache | None | The ICache, or None if no cache is associated. |
as_dict
Get this object as a dictionary.
search
Search the object metadata using a JMESPath expression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expression | str | The JMESPath expression to use for the search. | required |
Returns:
| Type | Description |
|---|---|
Any | The result of the search. |
prepare_data_download
Prepare to download multiple data files from the geoscience object service, for this object.
Any data IDs that are not associated with the requested object will raise a DataNotFoundError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_identifiers | Sequence[str | UUID] | A list of sha256 digests or UUIDs for the data to be downloaded. | required |
Returns:
| Type | Description |
|---|---|
Iterator[ObjectDataDownload] | An iterator of data download contexts that can be used to download the data. |
Raises:
| Type | Description |
|---|---|
DataNotFoundError | If any requested data ID is not associated with this object. |
update async
Update the geoscience object on the geoscience object service. Returning a new DownloadedObject representing the new version of the object.
This will create a new version of the object, that fully replaces the existing properties of the object with those provided in object_dict.
Note, this will not update the "DownloadedObject" instance in-place - it will still represent the original version of the object. You will need to download the updated version separately if you wish to work with it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_dict | dict | The new properties of the object as a dictionary. | required |
check_for_conflict | bool | If True, and if a newer version of the object exists on the geoscience object service, the update will fail with a ObjectModifiedError exception. If False, it will not check whether there is a newer version, so will perform the update regardless. | True |
request_timeout | int | float | tuple[int | float, int | float] | None | An optional timeout to use for API requests. See evo.common.APIConnector for details. | None |
Returns:
| Type | Description |
|---|---|
DownloadedObject | The new version of the object as a DownloadedObject. |
download_table async
Download the data referenced by the given table info as a PyArrow Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_info | TableInfo | str | The table info dict, ot JMESPath to table info within the object. | required |
fb | IFeedback | An optional feedback instance to report download progress to. | NoFeedback |
nan_values | list[int] | list[float] | str | None | An optional list of values to treat as null. Can also be a JMESPath expression to the list of nan values, or the nan_description structure. | None |
column_names | Sequence[str] | None | An optional list of column names for the table, instead of those in the Parquet file. | None |
Returns:
| Type | Description |
|---|---|
Table | A PyArrow Table containing the downloaded data. |
download_category_table async
Download the data referenced by the given category info as a PyArrow Table.
The arrays into the table will be DictionaryArrays constructed from the values and lookup tables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category_info | CategoryInfo | str | The category info dict, or JMESPath to the category info within the object. | required |
nan_values | list[int] | list[float] | str | None | An optional list of values to treat as null. Can also be a JMESPath expression to nan_description structure. | None |
column_names | Sequence[str] | None | An optional list of column names for the table, instead of those in the Parquet file. | None |
fb | IFeedback | An optional feedback instance to report download progress to. | NoFeedback |
Returns:
| Type | Description |
|---|---|
Table | A PyArrow Table containing the downloaded data. |
download_attribute_table async
Download the data referenced by the given attribute as a PyArrow Table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute | AttributeInfo | str | The attribute info dict, or JMESPath to the attribute info within the object. | required |
fb | IFeedback | An optional feedback instance to report download progress to. | NoFeedback |
Returns:
| Type | Description |
|---|---|
Table | A PyArrow Table containing the downloaded data. |
download_dataframe async
Download the data referenced by the given table info as a Pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_info | TableInfo | str | The table info dict, JMESPath to table info within the object. | required |
fb | IFeedback | An optional feedback instance to report download progress to. | NoFeedback |
nan_values | list[int] | list[float] | str | None | An optional list of values to treat as null. Can also be a JMESPath expression to nan_description structure. | None |
column_names | Sequence[str] | None | An optional list of column names for the table, instead of those from the Parquet file. | None |
Returns:
| Type | Description |
|---|---|
DataFrame | A Pandas DataFrame containing the downloaded data. |
download_category_dataframe async
Download the data referenced by the given category info as a Pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category_info | CategoryInfo | str | The category info dict, or JMESPath to the category info within the object. | required |
nan_values | list[int] | list[float] | str | None | An optional list of values to treat as null. Can also be a JMESPath expression to nan_description structure. | None |
column_names | Sequence[str] | None | An optional list of column names for the table, instead of those from the Parquet file. | None |
fb | IFeedback | An optional feedback instance to report download progress to. | NoFeedback |
Returns:
| Type | Description |
|---|---|
DataFrame | A Pandas DataFrame containing the downloaded data. |
download_attribute_dataframe async
Download the data referenced by the given attribute as a Pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute | AttributeInfo | str | The attribute info dict, or JMESPath to the attribute within the object. | required |
fb | IFeedback | An optional feedback instance to report download progress to. | NoFeedback |
Returns:
| Type | Description |
|---|---|
DataFrame | A Pandas DataFrame containing the downloaded data. |
download_array async
Download the data referenced by the given table info as a NumPy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_info | TableInfo | str | The table info dict, JMESPath to table info within the object. | required |
fb | IFeedback | An optional feedback instance to report download progress to. | NoFeedback |
Returns:
| Type | Description |
|---|---|
ndarray | A NumPy array containing the downloaded data. |