Datatamer / tamr-client

Programmatically interact with Tamr
https://tamr-client.readthedocs.io
Apache License 2.0
11 stars 25 forks source link

Project attributes #492

Closed skalish closed 3 years ago

skalish commented 3 years ago

↪️ 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 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:

💻 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)

✔️ PR Todo

github-actions[bot] commented 3 years ago

:tada: This PR is included in version 1.5.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: