Skip to content

Commit

Permalink
Adopt to pyproject.toml (#122)
Browse files Browse the repository at this point in the history
* Use pyproject.toml

* Use ruff
  • Loading branch information
chezou authored Sep 6, 2024
1 parent 649d69f commit abd3e04
Show file tree
Hide file tree
Showing 21 changed files with 186 additions and 241 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Run tests.

.. code-block:: sh
$ python setup.py test
$ pytest tdclient
Running tests (tox)
^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -303,7 +303,7 @@ If you want to release manually, you can upload by twine.

.. code-block:: sh
$ python setup.py bdist_wheel sdist
$ python -m build
$ twine upload dist/*
License
Expand Down
55 changes: 55 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "td-client"
version = "1.2.2.dev0"
description = "Treasure Data API library for Python"
readme = {file = "README.rst", content-type = "text/x-rst; charset=UTF-8"}
requires-python = ">=3.8"
license = {text = "Apache Software License"}
authors = [{name = "Treasure Data, Inc.", email = "[email protected]"}]
urls = {homepage = "http://treasuredata.com/"}
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Topic :: Internet",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]

dependencies = [
"python-dateutil",
"msgpack>=0.6.2",
"urllib3",
]

[project.optional-dependencies]
dev = ["ruff"]
docs = ["sphinx", "sphinx_rtd_theme"]

[tool.setuptools]
packages = ["tdclient"]

[tool.ruff]
line-length = 88

[tool.ruff.lint]
select = [
"E",
"F",
]
exclude = ["tdclient/test/*"]
ignore = ["E203", "E501"]

[tool.ruff.lint.isort]
known-third-party = ["dateutil","msgpack","pkg_resources","pytest","setuptools","urllib3"]
13 changes: 0 additions & 13 deletions setup.cfg

This file was deleted.

64 changes: 0 additions & 64 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion tdclient/bulk_import_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def bulk_import_upload_file(self, name, part_name, format, file, **kwargs):
The default behaviour is ``"guess"``, which makes a best-effort to decide
the column datatype. See `file import parameters`_ for more details.
.. _`file import parameters`:
https://tdclient.readthedocs.io/en/latest/file_import_parameters.html
"""
Expand Down
53 changes: 21 additions & 32 deletions tdclient/bulk_import_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@


class BulkImport(Model):
"""Bulk-import session on Treasure Data Service
"""
"""Bulk-import session on Treasure Data Service"""

STATUS_UPLOADING = "uploading"
STATUS_PERFORMING = "performing"
Expand Down Expand Up @@ -38,79 +37,66 @@ def update(self):

@property
def name(self):
"""A name of the bulk import session
"""
"""A name of the bulk import session"""
return self._name

@property
def database(self):
"""A database name in a string which the bulk import session is working on
"""
"""A database name in a string which the bulk import session is working on"""
return self._database

@property
def table(self):
"""A table name in a string which the bulk import session is working on
"""
"""A table name in a string which the bulk import session is working on"""
return self._table

@property
def status(self):
"""The status of the bulk import session in a string
"""
"""The status of the bulk import session in a string"""
return self._status

@property
def job_id(self):
"""Job ID
"""
"""Job ID"""
return self._job_id

@property
def valid_records(self):
"""The number of valid records.
"""
"""The number of valid records."""
return self._valid_records

@property
def error_records(self):
"""The number of error records.
"""
"""The number of error records."""
return self._error_records

@property
def valid_parts(self):
"""The number of valid parts.
"""
"""The number of valid parts."""
return self._valid_parts

@property
def error_parts(self):
"""The number of error parts.
"""
"""The number of error parts."""
return self._error_parts

@property
def upload_frozen(self):
"""The number of upload frozen.
"""
"""The number of upload frozen."""
return self._upload_frozen

def delete(self):
"""Delete bulk import
"""
"""Delete bulk import"""
return self._client.delete_bulk_import(self.name)

def freeze(self):
"""Freeze bulk import
"""
"""Freeze bulk import"""
response = self._client.freeze_bulk_import(self.name)
self.update()
return response

def unfreeze(self):
"""Unfreeze bulk import
"""
"""Unfreeze bulk import"""
response = self._client.unfreeze_bulk_import(self.name)
self.update()
return response
Expand All @@ -136,8 +122,7 @@ def perform(self, wait=False, wait_interval=5, wait_callback=None):
return job

def commit(self, wait=False, wait_interval=5, timeout=None):
"""Commit bulk import
"""
"""Commit bulk import"""
response = self._client.commit_bulk_import(self.name)
if wait:
started_at = time.time()
Expand Down Expand Up @@ -201,12 +186,16 @@ def upload_file(self, part_name, fmt, file_like, **kwargs):
The default behaviour is ``"guess"``, which makes a best-effort to decide
the column datatype. See `file import parameters`_ for more details.
.. _`file import parameters`:
https://tdclient.readthedocs.io/en/latest/file_import_parameters.html
"""
response = self._client.bulk_import_upload_file(
self.name, part_name, fmt, file_like, **kwargs,
self.name,
part_name,
fmt,
file_like,
**kwargs,
)
self.update()
return response
Expand Down
2 changes: 1 addition & 1 deletion tdclient/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(
retry_limit=None,
wait_interval=None,
wait_callback=None,
**kwargs
**kwargs,
):
cursor_kwargs = dict()
if type is not None:
Expand Down
5 changes: 2 additions & 3 deletions tdclient/database_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class Database(Model):
"""Database on Treasure Data Service
"""
"""Database on Treasure Data Service"""

PERMISSIONS = ["administrator", "full_access", "import_only", "query_only"]
PERMISSION_LIST_TABLES = ["administrator", "full_access"]
Expand Down Expand Up @@ -50,7 +49,7 @@ def name(self):
str: a name of the database
"""
return self._db_name

@property
def id(self):
"""
Expand Down
3 changes: 2 additions & 1 deletion tdclient/result_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def list_result(self):
self.raise_error("List result table failed", res, body)
js = self.checked_json(body, ["results"])
return [
(m["name"], m["url"], None, m["id"], m["user_id"]) for m in js["results"]
(m["name"], m["url"], None, m["id"], m["user_id"])
for m in js["results"]
] # same as database

def create_result(self, name, url, params=None):
Expand Down
18 changes: 6 additions & 12 deletions tdclient/result_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class Result(Model):
"""Result on Treasure Data Service
"""
"""Result on Treasure Data Service"""

def __init__(self, client, name, url, org_name, id, user_id):
super(Result, self).__init__(client)
Expand All @@ -17,30 +16,25 @@ def __init__(self, client, name, url, org_name, id, user_id):

@property
def name(self):
"""str: a name for a authentication
"""
"""str: a name for a authentication"""
return self._name

@property
def url(self):
"""str: a result output URL
"""
"""str: a result output URL"""
return self._url

@property
def org_name(self):
"""str: organization name
"""
"""str: organization name"""
return self._org_name

@property
def id(self):
"""int: result id
"""
"""int: result id"""
return self._id

@property
def user_id(self):
"""int: result's owner id
"""
"""int: result's owner id"""
return self._user_id
Loading

0 comments on commit abd3e04

Please sign in to comment.