Skip to content

Commit d3170cb

Browse files
authored
DOC Surface civis.find and civis.find_one in the Sphinx docs (#250)
* DOC Use the most up-to-date version number in Sphinx docs * DOC Minor typos * DOC Surface find() and find_one() in Sphinx docs * DOC Remove unnecessary Sphinx ref * MAINT Update the changelog
1 parent 6ceb3f8 commit d3170cb

File tree

7 files changed

+49
-21
lines changed

7 files changed

+49
-21
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2525
This allows users to select a subset of a model's outputs for scoring (#241).
2626
- Added `civis.io.export_to_civis_file` to store results of a SQL query
2727
to a Civis file
28+
- Surfaced `civis.find` and `civis.find_one` in the Sphinx docs. (#250)
2829

2930
### Changed
3031
- Moved "Optional Dependencies" doc section to top of ML docs, and

civis/civis.py

+18-14
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,28 @@
1515

1616

1717
def find(object_list, filter_func=None, **kwargs):
18-
"""Return the objects from ``object_list`` that satisfy the filters.
18+
"""Filter :class:`civis.response.Response` objects.
1919
2020
Parameters
2121
----------
2222
object_list : iterable
23-
An iterable of arbitrary objects, particularly those with
24-
attributes that can be targeted by the filters in ``kwargs``.
25-
A major use case is a list of ``civis.response.Response`` objects.
23+
An iterable of arbitrary objects, particularly those with attributes
24+
that can be targeted by the filters in `kwargs`. A major use case is
25+
an iterable of :class:`civis.response.Response` objects.
2626
filter_func : callable, optional
27-
A one-argument function. If specified, ``kwargs`` are ignored.
28-
An ``object`` from the input iterable is kept in the returned list
27+
A one-argument function. If specified, `kwargs` are ignored.
28+
An `object` from the input iterable is kept in the returned list
2929
if and only if ``bool(filter_func(object))`` is ``True``.
3030
**kwargs
3131
Key-value pairs for more fine-grained filtering; they cannot be used
32-
in conjunction with ``filter_func``. All keys must be strings.
33-
For an ``object`` from the input iterable to be included in the
34-
returned list, all the ``key``s must be attributes of ``object``, plus
35-
any one of the following conditions for a given ``key``:
36-
- ``value`` is a one-argument function and
32+
in conjunction with `filter_func`. All keys must be strings.
33+
For an `object` from the input iterable to be included in the
34+
returned list, all the `key`s must be attributes of `object`, plus
35+
any one of the following conditions for a given `key`:
36+
37+
- `value` is a one-argument function and
3738
``bool(value(getattr(object, key)))`` is ``True``
38-
- ``value`` is ``True``
39+
- `value` is ``True``
3940
- ``getattr(object, key)`` is equal to ``value``
4041
4142
Returns
@@ -78,9 +79,12 @@ def default_filter(o):
7879

7980

8081
def find_one(object_list, filter_func=None, **kwargs):
81-
"""Return one object (or ``None``) from ``civis.find``.
82+
"""Return one satisfying :class:`civis.response.Response` object.
8283
83-
The arguments are the same as those for ``civis.find``.
84+
The arguments are the same as those for :func:`civis.find`.
85+
If more than one object satisfies the filtering criteria,
86+
the first one is returned.
87+
If no satisfying objects are found, ``None`` is returned.
8488
8589
Returns
8690
-------

docs/source/conf.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import os
1717
import datetime
1818

19+
import civis
20+
1921
# -- General configuration ------------------------------------------------
2022

2123
# If your documentation needs a minimal Sphinx version, state it here.
@@ -33,7 +35,7 @@
3335

3436
intersphinx_mapping = {
3537
'pandas': ('http://pandas.pydata.org/pandas-docs/stable', None),
36-
'python': ('https://docs.python.org/3.4', None),
38+
'python': ('https://docs.python.org/3', None),
3739
'requests': ('https://requests.readthedocs.io/en/latest/', None),
3840
'sklearn': ('http://scikit-learn.org/stable', None),
3941
'joblib': ('http://pythonhosted.org/joblib', None),
@@ -63,10 +65,11 @@
6365
# |version| and |release|, also used in various other places throughout the
6466
# built documents.
6567
#
68+
major_version, minor_version, _ = civis.__version__.split('.')
6669
# The short X.Y version.
67-
version = '1.0'
70+
version = '%s.%s' % (major_version, minor_version)
6871
# The full version, including alpha/beta/rc tags.
69-
release = '1.0.0'
72+
release = civis.__version__
7073

7174
# The language for content autogenerated by Sphinx. Refer to documentation
7275
# for a list of supported languages.

docs/source/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The recommended install method is pip:
1818
1919
pip install civis
2020
21-
Alternatively, you may clone the code from github and build from source:
21+
Alternatively, you may clone the code from GitHub and build from source:
2222

2323
.. code-block:: bash
2424

docs/source/parallel.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tool for your code:
1818

1919
- Each function call which is parallelized with the Civis joblib backend will run
2020
in a different Civis Platform script. Creating a new script comes with some overhead.
21-
It will take between a few seconds an a few minutes for each script to start,
21+
It will take between a few seconds and a few minutes for each script to start,
2222
depending on whether Civis Platform needs to provision additional resources.
2323
If you expect that each function call will complete quickly, instead consider either
2424
running them in serial or using extra processes in the same Civis Platform script.

docs/source/responses.rst

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
API Response Types
2-
==================
1+
API Responses
2+
=============
3+
4+
Response Types
5+
--------------
36

47
.. autoclass:: civis.response.Response
58
:members:
@@ -9,3 +12,9 @@ API Response Types
912

1013
.. autoclass:: civis.futures.CivisFuture
1114
:members:
15+
16+
Helper Functions
17+
----------------
18+
19+
.. autofunction:: civis.find
20+
.. autofunction:: civis.find_one

docs/source/user_guide.rst

+11
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,14 @@ example, with pandas.
185185
.. code:: python
186186
187187
>>> url = export_result.output[0].path
188+
189+
190+
API Response Types and Functions
191+
================================
192+
193+
Many API requests via an :class:`~civis.APIClient` instance return an iterable
194+
of :class:`civis.response.Response` objects.
195+
For endpoints that support pagination when the `iterator` kwarg is specified,
196+
a :class:`civis.response.PaginatedResponse` object is returned.
197+
To facilitate working with :class:`civis.response.Response` objects,
198+
the helper functions :func:`civis.find` and :func:`civis.find_one` are defined.

0 commit comments

Comments
 (0)