dratio.models.Version#

class dratio.models.Version(code: str, client: Client, **kwargs)#

Version of a dataset in the database

Parameters:
  • code (str) – Unique identifier of the feature in the database.

  • client (Client) – Client object used to perform requests to the database.

  • **kwargs – Additional keyword arguments used to initialize the metadata information.

__init__(code: str, client: Client, **kwargs)#

Initializes the object with the provided code and client instance.

Methods

__init__(code, client, **kwargs)

Initializes the object with the provided code and client instance.

delete()

Deletes the object from the database.

describe()

Returns a string representation of the object's metadata.

fetch([fail_not_found])

Updates the metadata dictionary of the object by performing an HTTP request to the server.

from_dict(metadata)

Updates the internal state of the object with the provided metadata.

keys()

Returns the keys of the metadata dictionary.

list_files([filetype, format])

Returns a list of files associated to the version.

save()

Saves the object's metadata to the database.

upload_file(file[, filetype, update])

Uploads a file to the version.

Attributes

dataset

Dataset to which the version belongs

description

Returns the description of the object.

metadata

Retrieves the metadata associated with the object.

name

Returns the name of the object.

property dataset: Dataset#

Dataset to which the version belongs

delete() None#

Deletes the object from the database.

Raises:

requests.exceptions.RequestException – If the request fails.

describe() str#

Returns a string representation of the object’s metadata.

property description: str#

Returns the description of the object.

fetch(fail_not_found: bool = True) DatabaseResource#

Updates the metadata dictionary of the object by performing an HTTP request to the server.

Returns:

  • self (DatabaseResource) – The object itself.

  • fail_not_found (bool, default True) – Whether to raise an exception if the object is not found in the database.

Notes

This method modifies the object’s internal state.

Raises:
from_dict(metadata)#

Updates the internal state of the object with the provided metadata.

Parameters:

metadata (dict) – Dictionary containing the metadata of the object.

Returns:

self – The object itself.

Return type:

DatabaseResource

Notes

This method modifies the object’s internal state.

keys() List[str]#

Returns the keys of the metadata dictionary.

list_files(filetype: Literal['parquet', 'geoparquet'] | None = None, format: Literal['pandas', 'json', 'api'] = 'pandas') pd.DataFrame | List[Dict[str, Any]] | List[File]#

Returns a list of files associated to the version.

Parameters:
  • filetype (Optional[Literal["parquet", "geoparquet"]]) – Type of file to filter. If None, all files are returned.

  • format (Literal["pandas", "json"]) – Format of the returned list, either a list of dictionaries or a pandas DataFrame.

Returns:

List of files associated to the version.

Return type:

Literal[“pandas”, “json”]

property metadata: Dict[str, Any]#

Retrieves the metadata associated with the object.

Notes

The first time this property is accessed, a request is made to the server to fetch the metadata. Subsequent accesses return the previously loaded information. To update the metadata, create a new instance of the object.

property name: str#

Returns the name of the object.

save() DatabaseResource#

Saves the object’s metadata to the database.

Returns:

self – The object itself.

Return type:

DatabaseResource

Raises:

requests.exceptions.RequestException – If the request fails.

upload_file(file: str | Path | pd.DataFrame | gpd.GeoDataFrame, filetype: Literal['parquet', 'geoparquet'] | None = None, update: bool = False)#

Uploads a file to the version.

Returns:

File object representing the uploaded file.

Return type:

File