Python SDK - Get and modify Data Table Metadata

Modified on Thu, 25 Nov 2021 at 09:33 AM

Provided Methods

Method documentation

All the examples expect that there is already a OneDataApi object initialised and assigned to a variable called "onedata_api".

### Creation of the ONE DATA Api ###
onedata_api = OneDataApi(base_url=base_url, username=user,
                         password=pw, verify=False, timeout=999)

get

Description

Retrieves a Data Table with the given data id XOR by name and project id.

Optional request options (request_transformers, response_transformers, timeout, verify, sleep_after_response_millis, deserializer) can be specified.

Returns: DataTable

Parameters

PropertyTypeRequiredDefaultDescription
idUnion[str, uuid.UUID]falseNoneID of the data table
namestrfalseNonename of the data table
project_idUnion[str, uuid.UUID]falseNoneID of the project
force_exact_matchboolfalseTrueSearch for exact match, False: Data table includes the name
force_distinctboolfalseTrueRaise exception if name is ambiguous, False: execute on first match
create_fallbackboolfalseTruedefines whether a fall back data table should be created (contains all malformed entries)
deleted[Union[str, uuid.UUID]]falseNonelist of row ids, defining the rows that should be deleted
updated[dict]falseNonelist of dictionaries, defining the rows that should be updated
added[dict]falseNonelist of dictionaries, defining the rows that should be added

Usage

### Retrieval of a datatable ###
datatable: DataTable = onedata_api.datatables.get(name=datatable_name, project_id=project_id, force_exact_match=True)

update

Description

Updates a Data Table with the given data id XOR by name and project id.

Optional request options (request_transformers, response_transformers, timeout, verify, sleep_after_response_millis, deserializer) can be specified.

Returns: DataTable

Parameters

PropertyTypeRequiredDefaultDescription
data_idUnion[str, uuid.UUID]falseNoneID of the data table
namestrfalseNonename of the data table
project_idUnion[str, uuid.UUID]falseNoneID of the project the data tables belongs to. When get by id, project_id will be ignored.
force_exact_matchboolfalseTrueSearch for exact match, False: Data table includes the name
force_distinctboolfalseTrueRaise exception if name is ambiguous, False: execute first match
new_namestrfalseNonenew name for the data table
new_tags[str]falseNonenew tags for the data table
new_descriptionstrfalseNonenew description for the data table
new_notesstrfalseNonenew notes for the data table
new_attributesdictfalseNonenew attributes for the data table
new_attributes_operatorAttributesOperatorfalseNonenew attributesOperator for the data table
new_lockedDatasetLockfalseNonenew locked for the data table
new_home_project_idUnion[str, uuid.UUID]falseNonenew home project for the data table

Usage

### Update of datatable by id ###
datatable: DataTable = onedata_api.datatables.get(id=datatable_id)
print(f"datatable.description: {datatable.description}")

###
# datatable.description: ""
###

description = "Hey, I am the new fancy description. Set by Python SDK. COOL, hum? Hum?"
datatable: DataTable = onedata_api.datatables.update_by_id(data_id=datatable.id, new_description=description)
print(f"datatable.description: {datatable.description}")

###
# datatable.description: "Hey, I am the new fancy description. Set by Python SDK. COOL, hum? Hum?"
###

updateByReference

Description

Updates a Data Table with the given data table object.

Optional request options (request_transformers, response_transformers, timeout, verify, sleep_after_response_millis, deserializer) can be specified.

Returns: DataTable

Parameters

PropertyTypeRequiredDefaultDescription
data_tableDataTableTrue-data table to update

Usage

### Update of datatable ###
datatable: DataTable = onedata_api.datatables.get(id=datatable_id)
print(f"datatable.description: {datatable.description}")

###
# datatable.description: ""
###

datatable.description = "Hey, I am the new fancy description. Set by Python SDK. COOL, hum? Hum?"
datatable: DataTable = onedata_api.datatables.update(data_table=datatable)
print(f"datatable.description: {datatable.description}")

###
# datatable.description: "Hey, I am the new fancy description. Set by Python SDK. COOL, hum? Hum?"
###

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article