dratio.models.Version#
- class dratio.models.Version(code: str, client: Client, **kwargs)#
Version of a dataset in the database
- Parameters:
- __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 to which the version belongs
Returns the description of the object.
Retrieves the metadata associated with the object.
Returns the name of the object.
- delete() None #
Deletes the object from the database.
- Raises:
requests.exceptions.RequestException – If the request fails.
- 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:
requests.exceptions.RequestException – If the request fails.
ObjectNotFound – If the object is not found in the database.
- 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.
- 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.
- 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.