Skip to content

Commit

Permalink
Merge pull request #330 from pcattori/attributes-module
Browse files Browse the repository at this point in the history
Attributes module
  • Loading branch information
pcattori committed Feb 6, 2020
2 parents b3f585d + 8c2b9dc commit 5f5b952
Show file tree
Hide file tree
Showing 42 changed files with 1,408 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/

[flake8]
ignore = E203, E266, E501, W503, F403, F401
ignore = E203, E266, E501, W503, F403
max-line-length = 88
max-complexity = 18
select = B,C,E,F,I,W,T4,B9
exclude = build,.venv,*.egg-info

# flake8-import-order plugin
import-order-style = google
application-import-names = tamr_unify_client
application-import-names = tamr_client, tamr_unify_client, tests
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ jobs:
- name: Run black
run: poetry run invoke format

Typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Python
uses: actions/setup-python@v1.1.1
with:
python-version: 3.6
- name: Install Poetry
uses: dschep/install-poetry-action@v1.2
- name: Install dependencies
run: poetry install
- name: Run mypy
run: poetry run invoke typecheck

Test:
strategy:
matrix:
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
## 0.11.0-dev
**NEW FEATURES**
- BETA: New attributes package!
- `tc.attribute` module
- `tc.Attribute` class
- functions: `from_resource_id`, `to_json`, `create`, `update`, `delete`
- `tc.attribute_type` module
- `tc.AttributeType` for type annotations
- Primitive Types: `BOOLEAN`, `DOUBLE`, `INT`, `LONG`, `STRING`
- Complex Types: `Array`, `Map`, `Record`
- Type aliases: `DEFAULT`, `GEOSPATIAL`
- functions: `from_json`, `to_json`
- `tc.subattribute` module
- `tc.SubAttribute` class
- functions: `from_json`, `to_json`
- BETA: New datasets package!
- `tc.dataset` module
- functions: `_attributes`
- BETA: New supporting modules!
- `tc.auth` module
- `tc.UsernamePasswordAuth` class
- `tc.session` function
- `tc.url` module
- `tc.URL` class

**BUG FIXES**
- Links from our docs to the `requests` docs were outdated. Links have been updated to point to the new `requests` docs URL.

## 0.10.0
**BREAKING CHANGES**
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import os
import sys

import recommonmark
from recommonmark.transform import AutoStructify
import toml

Expand Down
9 changes: 4 additions & 5 deletions docs/contributor-guide/bugs-and-features.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# 🐛 Bug Reports & 🙋 Feature Requests
# Submitting Bug Reports and Feature Requests

Please leave bug reports and feature requests as [Github issues](https://github.com/Datatamer/tamr-client/issues/new/choose) .
Submit bug reports and feature requests as [Github issues](https://github.com/Datatamer/tamr-client/issues/new/choose) .

---

Be sure to check through existing issues (open and closed) to confirm that the bug hasn’t been reported before.
Check through existing issues (open and closed) to confirm that the bug hasn’t been reported before.

Duplicate bug reports are a huge drain on the time of other contributors, and
should be avoided as much as possible.
If the bug/feature has been submitted already, leave a like 👍 on the Github Issue.
28 changes: 14 additions & 14 deletions docs/contributor-guide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ If you do not have these installed, checkout the [toolchain guide](toolchain).

1. Clone your fork and `cd` into the project:

```sh
git clone https://github.com/<your-github-username>/tamr-client
cd tamr-client
```
```sh
git clone https://github.com/<your-github-username>/tamr-client
cd tamr-client
```

2. Set a Python version for this project. Must be Python 3.6+ (e.g. `3.7.3`):

```sh
pyenv local 3.7.3
```
```sh
pyenv local 3.7.3
```

3. Check that your Python version matches the version specified in `.python-version`:

```sh
cat .python-version
python --version
```
```sh
cat .python-version
python --version
```

4. Install dependencies via `poetry`:

```sh
poetry install
```
```sh
poetry install
```
40 changes: 25 additions & 15 deletions docs/contributor-guide/run-and-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@ Since `invoke` will be running inside of a `poetry` environment, we recommend ad
alias pri='poetry run invoke'
```

## Tests

To run all tests:

```sh
pri test # with alias
poetry run invoke test # without alias
```

To run specific tests, see [these pytest docs](https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests) and run `pytest` explicitly:

```sh
poetry run pytest tests/unit/test_attribute.py
```

## Linting & Formatting

To run linter:
Expand All @@ -46,6 +31,31 @@ pri format --fix # with alias
poetry run invoke format --fix # without alias
```

## Typechecks

To run typechecks:

```sh
pri typecheck # with alias
poetry run invoke typecheck # without alias
```

## Tests

To run all tests:

```sh
pri test # with alias
poetry run invoke test # without alias
```

To run specific tests, see [these pytest docs](https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests) and run `pytest` explicitly:

```sh
poetry run pytest tests/unit/test_attribute.py
```


## Docs

To build the docs:
Expand Down
10 changes: 9 additions & 1 deletion docs/reference.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Reference
# Reference

* [Attributes](reference/attribute)
* [Auth](reference/auth)
Expand All @@ -9,3 +9,11 @@
* [Mastering](reference/mastering)
* [Operations](reference/operation)
* [Projects](reference/project)

## BETA

**WARNING**: Do not rely on BETA features in production workflows.
Tamr will not offer support for BETA features.

* [Attributes](reference/beta/attributes)
* [Datasets](reference/beta/datasets)
81 changes: 81 additions & 0 deletions docs/reference/beta/attributes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Attributes
==========

Attribute
---------

.. autoclass:: tamr_client.Attribute

.. autofunction:: tamr_client.attribute.from_resource_id
.. autofunction:: tamr_client.attribute.to_json
.. autofunction:: tamr_client.attribute.create
.. autofunction:: tamr_client.attribute.update
.. autofunction:: tamr_client.attribute.delete

Exceptions
^^^^^^^^^^

.. autoclass:: tamr_client.ReservedAttributeName
:no-inherited-members:

.. autoclass:: tamr_client.AttributeExists
:no-inherited-members:

.. autoclass:: tamr_client.AttributeNotFound
:no-inherited-members:

AttributeType
-------------

See https://docs.tamr.com/reference#attribute-types

.. autodata:: tamr_client.attribute_type.BOOLEAN
.. autodata:: tamr_client.attribute_type.DOUBLE
.. autodata:: tamr_client.attribute_type.INT
.. autodata:: tamr_client.attribute_type.LONG
.. autodata:: tamr_client.attribute_type.STRING

.. NOTE(pcattori): Manually write docs for complex attribute types
Complex types recursively reference other attribute types or subattributes
sphinx_autodoc_typehints cannot properly parse types recursively
.. class:: tamr_client.attribute_type.Array(inner_type)

:param inner_type:
:type inner_type: :class:`~tamr_client.AttributeType`

.. class:: tamr_client.attribute_type.Map(inner_type)

:param inner_type:
:type inner_type: :class:`~tamr_client.AttributeType`

.. class:: tamr_client.attribute_type.Record(attributes)

:param attributes:
:type attributes: :class:`~typing.Tuple` [:class:`~tamr_client.SubAttribute`]

.. autofunction:: tamr_client.attribute_type.from_json
.. autofunction:: tamr_client.attribute_type.to_json

Type aliases
^^^^^^^^^^^^

.. autodata:: tamr_client.attribute_type_alias.DEFAULT
.. autodata:: tamr_client.attribute_type_alias.GEOSPATIAL

SubAttribute
------------

.. class:: tamr_client.SubAttribute(name, type, is_nullable, description=None)

:param name:
:type name: :class:`str`
:param type:
:type type: :class:`~tamr_client.AttributeType`
:param is_nullable:
:type is_nullable: :class:`bool`
:param description:
:type description: :class:`~typing.Optional` [:class:`str`]

.. autofunction:: tamr_client.subattribute.from_json
.. autofunction:: tamr_client.subattribute.to_json
7 changes: 7 additions & 0 deletions docs/reference/beta/datasets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Datasets
========

Dataset
-------

.. autofunction:: tamr_client.dataset.attributes
9 changes: 9 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[mypy]
mypy_path = ./stubs
check_untyped_defs = True
ignore_errors = False
namespace_packages = True
strict_optional = True
warn_unused_ignores = True
warn_redundant_casts = True
warn_unused_configs = True

0 comments on commit 5f5b952

Please sign in to comment.