Current functionality only supports accessing attributes of datasets (including as unified datasets), but projects have attributes as well. The Tamr server requires attributes be created with project attribute endpoints rather than unified dataset attribute endpoints.
This PR updates type hinting to support the use of Project instances as the parent argument in attribute-fetching functions, and adds a check to prevent the creation of attributes in a unified dataset when creation must be done in the related project.
Also adds function project.attributes(...) to return all attributes of a project.
Open questions:
The ValueError raised when trying to create an attribute for a unified dataset should be changed to a custom exception, but I'm not sure what to call it.
This check is only made in the attribute.create(...) function. Maybe it should be moved into the _create function and also implemented somehow in the update/delete functions.
💻 Examples
import tamr_client as tc
s = tc.Session(...)
instance = tc.Instance(...)
project = tc.MasteringProject(...)
ud = tc.dataset.unified.from_project(s, project) # has type UnifiedDataset
# Will fail
attr = tc.attribute.create(s, ud, name="my_attr", is_nullable=True)
>>> ValueError("Attributes for unified datasets must be created as attributes of the containing project")
# Will succeed
attr = tc.attribute.create(s, project, name="my_attr", is_nullable=True)
↪️ Pull Request
Current functionality only supports accessing attributes of datasets (including as unified datasets), but projects have attributes as well. The Tamr server requires attributes be created with project attribute endpoints rather than unified dataset attribute endpoints.
This PR updates type hinting to support the use of
Project
instances as theparent
argument in attribute-fetching functions, and adds a check to prevent the creation of attributes in a unified dataset when creation must be done in the related project.Also adds function
project.attributes(...)
to return all attributes of a project.Open questions:
ValueError
raised when trying to create an attribute for a unified dataset should be changed to a custom exception, but I'm not sure what to call it.attribute.create(...)
function. Maybe it should be moved into the_create
function and also implemented somehow in theupdate
/delete
functions.💻 Examples
✔️ PR Todo