Skip to content

Commit 21f7ad1

Browse files
committed
Merge branch 'master' of https://github.com/datajoint/datajoint-python into switch-to-djtest
2 parents dad27e7 + 1b3fe08 commit 21f7ad1

27 files changed

+558
-46
lines changed

.github/workflows/development.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ on:
99
- '**' # every branch
1010
- '!stage*' # exclude branches beginning with stage
1111
jobs:
12+
build-docs:
13+
runs-on: ubuntu-latest
14+
env:
15+
DOCKER_CLIENT_TIMEOUT: "120"
16+
COMPOSE_HTTP_TIMEOUT: "120"
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Compile docs static artifacts
20+
run: |
21+
export HOST_UID=$(id -u)
22+
docker-compose -f ./docs-api/docker-compose.yaml up --exit-code-from docs-builder --build
23+
- name: Add docs static artifacts
24+
uses: actions/upload-artifact@v2
25+
with:
26+
name: docs-api-static
27+
path: docs-api/build/html
28+
retention-days: 1
1229
test:
1330
if: github.event_name == 'push' || github.event_name == 'pull_request'
1431
runs-on: ubuntu-latest
@@ -52,3 +69,42 @@ jobs:
5269
--count --max-complexity=62 --max-line-length=127 --statistics
5370
black datajoint --check -v
5471
black tests --check -v
72+
publish-docs:
73+
if: |
74+
github.event_name == 'push' &&
75+
(
76+
github.repository_owner == 'datajoint' ||
77+
github.repository_owner == 'datajoint-company' ||
78+
github.repository_owner == 'dj-sciops'
79+
)
80+
needs: build-docs
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v2
84+
- name: Fetch docs static artifacts
85+
uses: actions/download-artifact@v2
86+
with:
87+
name: docs-api-static
88+
path: docs-api/build/html
89+
- name: Commit documentation changes
90+
run: |
91+
git clone https://github.com/${GITHUB_REPOSITORY}.git \
92+
--branch gh-pages --single-branch gh-pages
93+
rm -R gh-pages/*
94+
cp -r docs-api/build/html/* gh-pages/
95+
cp .gitignore gh-pages/
96+
touch gh-pages/.nojekyll
97+
echo "docs-api.datajoint.org" > gh-pages/CNAME
98+
cd gh-pages
99+
git config --local user.email "[email protected]"
100+
git config --local user.name "GitHub Action"
101+
git add . --all
102+
git commit -m "Update documentation" -a || true
103+
# The above command will fail if no changes were present, so we ignore
104+
# the return code.
105+
- name: Push changes
106+
uses: ad-m/github-push-action@master
107+
with:
108+
branch: gh-pages
109+
directory: gh-pages
110+
github_token: ${{secrets.GITHUB_TOKEN}}

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
DataJoint for Python is a framework for scientific workflow management based on relational principles. DataJoint is built on the foundation of the relational data model and prescribes a consistent method for organizing, populating, computing, and querying data.
1010

1111
DataJoint was initially developed in 2009 by Dimitri Yatsenko in Andreas Tolias' Lab at Baylor College of Medicine for the distributed processing and management of large volumes of data streaming from regular experiments. Starting in 2011, DataJoint has been available as an open-source project adopted by other labs and improved through contributions from several developers.
12-
Presently, the primary developer of DataJoint open-source software is the company DataJoint (https://datajoint.com). Related resources are listed at https://datajoint.org
12+
Presently, the primary developer of DataJoint open-source software is the company DataJoint (https://datajoint.com). Related resources are listed at https://datajoint.org.
1313

1414
## Installation
1515
```
@@ -29,6 +29,13 @@ pip3 install --upgrade datajoint
2929
* https://elements.datajoint.org -- catalog of example pipelines
3030
* https://codebook.datajoint.io -- interactive online tutorials
3131

32+
## Citation
33+
+ If your work uses DataJoint for Python, please cite the following Research Resource Identifier (RRID) and manuscript.
34+
35+
+ DataJoint ([RRID:SCR_014543](https://scicrunch.org/resolver/SCR_014543)) - DataJoint for Python (version `<Enter version number>`)
36+
37+
+ Yatsenko D, Reimer J, Ecker AS, Walker EY, Sinz F, Berens P, Hoenselaar A, Cotton RJ, Siapas AS, Tolias AS. DataJoint: managing big scientific data using MATLAB or Python. bioRxiv. 2015 Jan 1:031658. doi: https://doi.org/10.1101/031658
38+
3239
## Python Native Blobs
3340
<details>
3441
<summary>Click to expand details</summary>
@@ -103,6 +110,18 @@ important DataJoint schema or records.
103110

104111
</details>
105112

113+
### API docs
114+
115+
The API documentation can be built using sphinx by running
116+
117+
``` bash
118+
pip install sphinx sphinx_rtd_theme
119+
(cd docs-api/sphinx && make html)
120+
```
121+
122+
Generated docs are written to `docs-api/docs/html/index.html`.
123+
More details in [docs-api/README.md](docs-api/README.md).
124+
106125
## Running Tests Locally
107126
<details>
108127
<summary>Click to expand details</summary>

datajoint/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
that any use of DataJoint leading to a publication be acknowledged in the publication.
1111
1212
Please cite:
13-
http://biorxiv.org/content/early/2015/11/14/031658
14-
http://dx.doi.org/10.1101/031658
13+
14+
- http://biorxiv.org/content/early/2015/11/14/031658
15+
- http://dx.doi.org/10.1101/031658
1516
"""
1617

1718
__author__ = "DataJoint Contributors"

datajoint/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def set_password(
2828
def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
2929
"""
3030
view and kill database connections.
31+
3132
:param restriction: restriction to be applied to processlist
3233
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
3334
:param order_by: order by a single attribute or the list of attributes. defaults to 'id'.
@@ -86,6 +87,7 @@ def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
8687
def kill_quick(restriction=None, connection=None):
8788
"""
8889
Kill database connections without prompting. Returns number of terminated connections.
90+
8991
:param restriction: restriction to be applied to processlist
9092
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
9193

datajoint/attribute_adapter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ def attribute_type(self):
1818
def get(self, value):
1919
"""
2020
convert value retrieved from the the attribute in a table into the adapted type
21+
2122
:param value: value from the database
23+
2224
:return: object of the adapted type
2325
"""
2426
raise NotImplementedError("Undefined attribute adapter")
2527

2628
def put(self, obj):
2729
"""
2830
convert an object of the adapted type into a value that DataJoint can store in a table attribute
31+
2932
:param obj: an object of the adapted type
3033
:return: value to store in the database
3134
"""

datajoint/connection.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
This module contains the Connection class that manages the connection to the database,
3-
and the `conn` function that provides access to a persistent connection in datajoint.
2+
This module contains the Connection class that manages the connection to the database, and
3+
the ``conn`` function that provides access to a persistent connection in datajoint.
44
"""
55
import warnings
66
from contextlib import contextmanager
@@ -52,6 +52,7 @@ def connect_host_hook(connection_obj):
5252
def translate_query_error(client_error, query):
5353
"""
5454
Take client error and original query and return the corresponding DataJoint exception.
55+
5556
:param client_error: the exception raised by the client interface
5657
:param query: sql query with placeholders
5758
:return: an instance of the corresponding subclass of datajoint.errors.DataJointError
@@ -108,11 +109,9 @@ def conn(
108109
:param password: mysql password
109110
:param init_fun: initialization function
110111
:param reset: whether the connection should be reset or not
111-
:param use_tls: TLS encryption option. Valid options are: True (required),
112-
False (required no TLS), None (TLS prefered, default),
113-
dict (Manually specify values per
114-
https://dev.mysql.com/doc/refman/5.7/en/connection-options.html
115-
#encrypted-connection-options).
112+
:param use_tls: TLS encryption option. Valid options are: True (required), False
113+
(required no TLS), None (TLS prefered, default), dict (Manually specify values per
114+
https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#encrypted-connection-options).
116115
"""
117116
if not hasattr(conn, "connection") or reset:
118117
host = host if host is not None else config["database.host"]
@@ -247,6 +246,7 @@ def set_query_cache(self, query_cache=None):
247246
1. Only SELECT queries are allowed.
248247
2. The results of queries are cached under the path indicated by dj.config['query_cache']
249248
3. query_cache is a string that differentiates different cache states.
249+
250250
:param query_cache: a string to initialize the hash for query results
251251
"""
252252
self._query_cache = query_cache
@@ -298,6 +298,7 @@ def query(
298298
):
299299
"""
300300
Execute the specified query and return the tuple generator (cursor).
301+
301302
:param query: SQL query
302303
:param args: additional arguments for the client.cursor
303304
:param as_dict: If as_dict is set to True, the returned cursor objects returns

datajoint/declare.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def build_index_parser():
153153

154154
def is_foreign_key(line):
155155
"""
156+
156157
:param line: a line from the table definition
157158
:return: true if the line appears to be a foreign key definition
158159
"""
@@ -366,6 +367,7 @@ def prepare_declare(definition, context):
366367
def declare(full_table_name, definition, context):
367368
"""
368369
Parse declaration and generate the SQL CREATE TABLE code
370+
369371
:param full_table_name: full name of the table
370372
:param definition: DataJoint table definition
371373
:param context: dictionary of objects that might be referred to in the table
@@ -566,6 +568,7 @@ def substitute_special_type(match, category, foreign_key_sql, context):
566568
def compile_attribute(line, in_key, foreign_key_sql, context):
567569
"""
568570
Convert attribute definition from DataJoint format to SQL
571+
569572
:param line: attribution line
570573
:param in_key: set to True if attribute is in primary key set
571574
:param foreign_key_sql: the list of foreign key declarations to add to

datajoint/diagram.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def __init__(self, source, context=None):
146146
def from_sequence(cls, sequence):
147147
"""
148148
The join Diagram for all objects in sequence
149+
149150
:param sequence: a sequence (e.g. list, tuple)
150151
:return: Diagram(arg1) + ... + Diagram(argn)
151152
"""

datajoint/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, *args):
3434
def suggest(self, *args):
3535
"""
3636
regenerate the exception with additional arguments
37+
3738
:param args: addition arguments
3839
:return: a new exception of the same type with the additional arguments
3940
"""

datajoint/expression.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def where_clause(self):
121121
def make_sql(self, fields=None):
122122
"""
123123
Make the SQL SELECT statement.
124+
124125
:param fields: used to explicitly set the select attributes
125126
"""
126127
return "SELECT {distinct}{fields} FROM {from_}{where}".format(
@@ -323,6 +324,7 @@ def __add__(self, other):
323324
def proj(self, *attributes, **named_attributes):
324325
"""
325326
Projection operator.
327+
326328
:param attributes: attributes to be included in the result. (The primary key is already included).
327329
:param named_attributes: new attributes computed or renamed from existing attributes.
328330
:return: the projected expression.
@@ -481,6 +483,7 @@ def aggr(self, group, *attributes, keep_all_rows=False, **named_attributes):
481483
"""
482484
Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
483485
has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of `group`.
486+
484487
:param group: The query expression to be aggregated.
485488
:param keep_all_rows: True=keep all the rows from self. False=keep only rows that match entries in group.
486489
:param named_attributes: computations of the form new_attribute="sql expression on attributes of group"
@@ -510,6 +513,7 @@ def head(self, limit=25, **fetch_kwargs):
510513
"""
511514
shortcut to fetch the first few entries from query expression.
512515
Equivalent to fetch(order_by="KEY", limit=25)
516+
513517
:param limit: number of entries
514518
:param fetch_kwargs: kwargs for fetch
515519
:return: query result
@@ -520,6 +524,7 @@ def tail(self, limit=25, **fetch_kwargs):
520524
"""
521525
shortcut to fetch the last few entries from query expression.
522526
Equivalent to fetch(order_by="KEY DESC", limit=25)[::-1]
527+
523528
:param limit: number of entries
524529
:param fetch_kwargs: kwargs for fetch
525530
:return: query result
@@ -561,6 +566,7 @@ def __contains__(self, item):
561566
"""
562567
returns True if the restriction in item matches any entries in self
563568
e.g. ``restriction in q1``.
569+
564570
:param item: any restriction
565571
(item in query_expression) is equivalent to bool(query_expression & item) but may be
566572
executed more efficiently.
@@ -907,6 +913,7 @@ def aggr(self, group, **named_attributes):
907913
"""
908914
Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
909915
has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of `group`.
916+
910917
:param group: The query expression to be aggregated.
911918
:param named_attributes: computations of the form new_attribute="sql expression on attributes of group"
912919
:return: The derived query expression

0 commit comments

Comments
 (0)