Skip to content

Commit

Permalink
Merge pull request #407 from pcattori/dataset-types
Browse files Browse the repository at this point in the history
Move dataset types into _types/dataset.py
  • Loading branch information
pcattori committed Jul 2, 2020
2 parents f50fa04 + 472572a commit bcffbc3
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 59 deletions.
10 changes: 8 additions & 2 deletions tamr_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
# types
#######

from tamr_client._types import Attribute, AttributeType, SubAttribute, URL
from tamr_client._types import (
Attribute,
AttributeType,
Dataset,
SubAttribute,
UnifiedDataset,
URL,
)

# functions
###########
Expand All @@ -36,7 +43,6 @@
from tamr_client import session

# datasets
from tamr_client.dataset import AnyDataset, Dataset
from tamr_client import dataset

# records
Expand Down
1 change: 1 addition & 0 deletions tamr_client/_types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
STRING,
SubAttribute,
)
from tamr_client._types.dataset import AnyDataset, Dataset, UnifiedDataset
from tamr_client._types.json import JsonDict
from tamr_client._types.url import URL
45 changes: 45 additions & 0 deletions tamr_client/_types/dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from dataclasses import dataclass
from typing import Optional, Tuple, Union

from tamr_client._types.url import URL


@dataclass(frozen=True)
class Dataset:
"""A Tamr dataset
See https://docs.tamr.com/reference/dataset-models
Args:
url: The canonical dataset-based URL for this dataset e.g. `/datasets/1`
name
key_attribute_names
description
"""

url: URL
name: str
key_attribute_names: Tuple[str, ...]
description: Optional[str] = None


@dataclass(frozen=True)
class UnifiedDataset:
"""A Tamr unified dataset
See https://docs.tamr.com/reference/dataset-models
Args:
url: The project-based alias for this dataset e.g. `/projects/1/unifiedDataset`
name
key_attribute_names
description
"""

url: URL
name: str
key_attribute_names: Tuple[str, ...]
description: Optional[str] = None


AnyDataset = Union[Dataset, UnifiedDataset]
3 changes: 1 addition & 2 deletions tamr_client/attribute/_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
from typing import Optional, Tuple

from tamr_client import response
from tamr_client._types import Attribute, AttributeType, JsonDict, URL
from tamr_client._types import Attribute, AttributeType, Dataset, JsonDict, URL
from tamr_client.attribute import type as attribute_type
from tamr_client.dataset.dataset import Dataset
from tamr_client.session import Session


Expand Down
4 changes: 1 addition & 3 deletions tamr_client/dataset/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
from tamr_client.dataset import dataframe, record, unified
from tamr_client.dataset.dataset import AnyDataset, Dataset
from tamr_client.dataset.dataset import from_resource_id
from tamr_client.dataset.dataset import NotFound
from tamr_client.dataset._dataset import from_resource_id, NotFound
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
See https://docs.tamr.com/reference/dataset-models
"""
from copy import deepcopy
from dataclasses import dataclass
from typing import Optional, Tuple, Union

from tamr_client import response
from tamr_client._types import JsonDict, URL
from tamr_client.dataset.unified import UnifiedDataset
from tamr_client._types import Dataset, JsonDict, URL
from tamr_client.instance import Instance
from tamr_client.session import Session

Expand All @@ -20,28 +17,6 @@ class NotFound(Exception):
pass


@dataclass(frozen=True)
class Dataset:
"""A Tamr dataset
See https://docs.tamr.com/reference/dataset-models
Args:
url
name
key_attribute_names
description
"""

url: URL
name: str
key_attribute_names: Tuple[str, ...]
description: Optional[str] = None


AnyDataset = Union[Dataset, UnifiedDataset]


def from_resource_id(session: Session, instance: Instance, id: str) -> Dataset:
"""Get dataset by resource ID
Expand Down
3 changes: 1 addition & 2 deletions tamr_client/dataset/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import os
from typing import Optional, TYPE_CHECKING

from tamr_client._types import JsonDict
from tamr_client._types import Dataset, JsonDict
from tamr_client.dataset import record
from tamr_client.dataset.dataset import Dataset
from tamr_client.session import Session

BUILDING_DOCS = os.environ.get("TAMR_CLIENT_DOCS") == "1"
Expand Down
3 changes: 1 addition & 2 deletions tamr_client/dataset/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from typing import cast, Dict, IO, Iterable, Iterator, Optional

from tamr_client import response
from tamr_client._types import JsonDict
from tamr_client.dataset.dataset import AnyDataset, Dataset
from tamr_client._types import AnyDataset, Dataset, JsonDict
from tamr_client.session import Session


Expand Down
23 changes: 1 addition & 22 deletions tamr_client/dataset/unified.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
See https://docs.tamr.com/reference/dataset-models
"""
from copy import deepcopy
from dataclasses import dataclass
from typing import Optional, Tuple

from tamr_client import operation, response
from tamr_client._types import JsonDict, URL
from tamr_client._types import JsonDict, UnifiedDataset, URL
from tamr_client.instance import Instance
from tamr_client.operation import Operation
from tamr_client.project import Project
Expand All @@ -21,25 +19,6 @@ class NotFound(Exception):
pass


@dataclass(frozen=True)
class UnifiedDataset:
"""A Tamr unified dataset
See https://docs.tamr.com/reference/dataset-models
Args:
url
name
key_attribute_names
description
"""

url: URL
name: str
key_attribute_names: Tuple[str, ...]
description: Optional[str] = None


def from_project(
session: Session, instance: Instance, project: Project
) -> UnifiedDataset:
Expand Down

0 comments on commit bcffbc3

Please sign in to comment.