Skip to content

Commit 894d2ea

Browse files
[CIVIS-8695] ENH SQL I/O functions accept SQL parameters and arguments (#493)
* ENH civis.io* exposes params and args for client.scripts.post_sql * REF switch to sql_params_arguments * DOC update docs * MAINT update changelog * MAINT update changelog * MAINT update changelog * FIX response eq and repr; resource type hints for 'List' * VER bump to v2.3.0 and update docs * FIX real imports for static type hints * MAINT update changelog * MAINT update changelog
1 parent a8fac5e commit 894d2ea

15 files changed

+2563
-2497
lines changed

CHANGELOG.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## Unreleased
88

9+
### Added
10+
### Changed
11+
### Deprecated
12+
### Removed
13+
### Fixed
14+
### Security
15+
16+
## 2.3.0 - 2024-06-14
17+
918
### Added
1019
- Added a script for checking if the Civis API spec is up-to-date. (#489)
20+
- Added a new keyword argument `sql_params_arguments` to the `civis.io.*` functions that
21+
accept a SQL query, so that the user can run a parameterized SQL script. (#493)
1122

1223
### Changed
1324
- Refactored the `civis.parallel` module and related unit tests due to major changes
@@ -17,19 +28,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1728
- Bumped the minimum required version of `joblib` to v1.3.0,
1829
which is the version where `joblib.parallel_config` was introduced and
1930
`joblib.parallel_backend` was deprecated. (#488)
20-
- Improved the startup time of `import civis` with a 5x speed boost. (#490)
31+
- Improved the startup time of `import civis` with a 5x speed boost. (#490, #493)
2132
- The downloaded API spec due to the `civis.APIClient` instantiation is now
2233
a time-to-live cache in memory (15 minutes for interactive Python, or 24 hours in scripts). (#491)
2334
- Polling at `PollableResult` (and consequently its subclasses as well: `CivisFuture`,
2435
`ContainerFuture`, and `ModelFuture`) now defaults to geometrically increased polling
2536
intervals. Short-running jobs' `future.result()` can now return faster, while
2637
longer-running jobs have a capped polling interval of 15 seconds. (#492)
38+
- Comparing a `Response` object with a non-`Response` object returns `False` now
39+
(this previously raised a `TypeError`). (#493)
2740

28-
### Deprecated
29-
### Removed
3041
### Fixed
3142
- Fixed `civis.parallel.make_backend_template_factory` so that
3243
keyword arguments are now accepted and passed to `client.scripts.post_custom`. (#488)
44+
- For `Response` objects, their "repr" form shows the class name "Response" for both
45+
top-level and nested response objects. (#493)
3346

3447
### Security
3548
- Bumped the minimum required version of `requests` to the latest v2.32.3,

docs/source/cli.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ data types (e.g., arrays, objects/dictionaries) as input. However,
2020
functionality is available for getting information about scripts, logs, etc.,
2121
as well as executing already created scripts.
2222

23-
There are a few extra, CLI-only commands that wrap the Files API
24-
endpoints to make uploading and downloading files easier:
25-
``civis files upload $PATH`` and ``civis files download $FILEID $PATH``.
26-
2723
The default output format is YAML, but the ``--json-output`` allows you to
2824
get output in JSON.
2925

@@ -33,6 +29,16 @@ like ``civis scripts list --help``.
3329
The logging level of the CLI can be configured by setting the ``CIVIS_LOG_LEVEL``
3430
environment variable, e.g., ``CIVIS_LOG_LEVEL=DEBUG civis users list-me``.
3531

32+
Files
33+
-----
34+
35+
There are a few extra, CLI-only commands that wrap the Files API
36+
endpoints to make uploading and downloading files easier:
37+
38+
- ``civis files upload $PATH``
39+
40+
- ``civis files download $FILEID $PATH``
41+
3642
Job Logs
3743
--------
3844

docs/source/index.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ For a more detailed walkthrough, see the :ref:`user_guide`.
3636
:end-before: end-include-marker-retires-section
3737

3838

39-
Client API Reference
40-
--------------------
39+
Table of Contents
40+
-----------------
4141

4242
.. toctree::
4343
:maxdepth: 1
@@ -55,5 +55,4 @@ Indices and tables
5555
------------------
5656

5757
* :ref:`genindex`
58-
* :ref:`modindex`
5958
* :ref:`search`

docs/source/responses.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ A Civis API call from ``client.<endpoint>.<method>`` returns a :class:`civis.res
1414
name='some script name',
1515
created_at='2018-06-11T20:43:07.000Z',
1616
updated_at='2018-06-11T20:43:19.000Z',
17-
author=(id=67890,
18-
name='Platform User Name',
19-
username='platformusername',
20-
initials='PUN',
21-
online=False),
17+
author=Response(id=67890,
18+
name='Platform User Name',
19+
username='platformusername',
20+
initials='PUN',
21+
online=False),
2222
...
2323
2424
To retrieve information from a :class:`civis.response.Response` object,

docs/source/user_guide.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ your user information:
123123
.. code:: python
124124
125125
>>> client.users.list_me()
126-
{'email': '[email protected]',
127-
'feature_flags': {'left_nav_basic': True,
128-
'results': True,
129-
'scripts_notify': True,
130-
'table_person_matching': True},
131-
'id': 1,
132-
'initials': 'UN',
133-
'name': 'User Name',
134-
'username': 'uname'}
126+
Response(email='[email protected]',
127+
feature_flags=Response(left_nav_basic=True,
128+
results=True,
129+
scripts_notify=True,
130+
table_person_matching=True),
131+
id=1,
132+
initials='UN',
133+
name='User Name',
134+
username='uname')
135135
136136
For a complete list of the API endpoints and their methods,
137137
check out :ref:`api_resources`.

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "civis"
7-
version = "2.2.0"
7+
version = "2.3.0"
88
description = "Civis API Python Client"
99
readme = "README.rst"
1010
requires-python = ">= 3.9"
@@ -48,7 +48,7 @@ dev-core = [
4848
"flake8 == 7.0.0",
4949
"pandas == 2.2.2",
5050
"pip-audit", # Install the latest version.
51-
"pytest == 8.2.1",
51+
"pytest == 8.2.2",
5252
"pytest-cov == 5.0.0",
5353
"twine == 5.1.0",
5454
]

src/civis/__init__.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import importlib
22
import sys
33
from importlib.metadata import version
4+
from typing import TYPE_CHECKING
45

56
from civis.client import APIClient
67
from civis.loggers import civis_logger
@@ -19,18 +20,22 @@ def _lazy_import(name):
1920
return module
2021

2122

22-
futures = _lazy_import("civis.futures")
23-
io = _lazy_import("civis.io")
24-
ml = _lazy_import("civis.ml")
25-
parallel = _lazy_import("civis.parallel")
26-
utils = _lazy_import("civis.utils")
23+
if TYPE_CHECKING:
24+
from civis import futures, io, ml, parallel, utils
25+
else:
26+
futures = _lazy_import("civis.futures")
27+
io = _lazy_import("civis.io")
28+
ml = _lazy_import("civis.ml")
29+
parallel = _lazy_import("civis.parallel")
30+
utils = _lazy_import("civis.utils")
2731

2832
__version__ = version("civis")
2933
__all__ = [
3034
"__version__",
3135
"APIClient",
3236
"find",
3337
"find_one",
38+
"futures",
3439
"io",
3540
"civis_logger",
3641
"ml",

0 commit comments

Comments
 (0)