Skip to content

Commit 3e3cf0f

Browse files
Merge branch 'master' of https://github.com/datajoint/datajoint-python into key_populate
2 parents 0be55b5 + 0ff34f2 commit 3e3cf0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+6061
-3035
lines changed

.github/workflows/development.yaml

Lines changed: 60 additions & 2 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
@@ -30,7 +47,7 @@ jobs:
3047
- name: Install dependencies
3148
run: |
3249
python -m pip install --upgrade pip
33-
pip install flake8
50+
pip install flake8 black
3451
- name: Run syntax tests
3552
run: flake8 datajoint --count --select=E9,F63,F7,F82 --show-source --statistics
3653
- name: Run primary tests
@@ -47,5 +64,46 @@ jobs:
4764
run: docker-compose -f LNX-docker-compose.yml up --build --exit-code-from app
4865
- name: Run style tests
4966
run: |
50-
flake8 --ignore=E121,E123,E126,E226,E24,E704,W503,W504,E722,F401,W605 datajoint \
67+
flake8 --ignore=E203,E722,F401,W503 datajoint \
5168
--count --max-complexity=62 --max-line-length=127 --statistics
69+
black datajoint --check -v
70+
black tests --check -v
71+
publish-docs:
72+
if: |
73+
github.event_name == 'push' &&
74+
(
75+
github.repository_owner == 'datajoint' ||
76+
github.repository_owner == 'datajoint-company' ||
77+
github.repository_owner == 'dj-sciops'
78+
)
79+
needs: build-docs
80+
runs-on: ubuntu-latest
81+
steps:
82+
- uses: actions/checkout@v2
83+
- name: Fetch docs static artifacts
84+
uses: actions/download-artifact@v2
85+
with:
86+
name: docs-api-static
87+
path: docs-api/build/html
88+
- name: Commit documentation changes
89+
run: |
90+
git clone https://github.com/${GITHUB_REPOSITORY}.git \
91+
--branch gh-pages --single-branch gh-pages
92+
rm -R gh-pages/*
93+
cp -r docs-api/build/html/* gh-pages/
94+
cp .gitignore gh-pages/
95+
touch gh-pages/.nojekyll
96+
echo "docs-api.datajoint.org" > gh-pages/CNAME
97+
cd gh-pages
98+
git config --local user.email "[email protected]"
99+
git config --local user.name "GitHub Action"
100+
git add . --all
101+
git commit -m "Update documentation" -a || true
102+
# The above command will fail if no changes were present, so we ignore
103+
# the return code.
104+
- name: Push changes
105+
uses: ad-m/github-push-action@master
106+
with:
107+
branch: gh-pages
108+
directory: gh-pages
109+
github_token: ${{secrets.GITHUB_TOKEN}}

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
## Release notes
22

3+
### 0.13.5 -- May 19, 2022
4+
* Update - Import ABC from collections.abc for Python 3.10 compatibility
5+
* Bugfix - Fix multiprocessing value error (#1013) PR #1026
6+
7+
### 0.13.4 -- March, 28 2022
8+
* Add - Allow reading blobs produced by legacy 32-bit compiled mYm library for matlab. PR #995
9+
* Bugfix - Add missing `jobs` argument for multiprocessing PR #997
10+
* Add - Test for multiprocessing PR #1008
11+
* Bugfix - Fix external store key name doesn't allow '-' (#1005) PR #1006
12+
* Add - Adopted black formatting into code base PR #998
13+
314
### 0.13.3 -- Feb 9, 2022
415
* Bugfix - Fix error in listing ancestors, descendants with part tables.
516
* Bugfix - Fix Python 3.10 compatibility (#983) PR #972

LNX-docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
interval: 1s
3333
fakeservices.datajoint.io:
3434
<<: *net
35-
image: datajoint/nginx:v0.0.19
35+
image: datajoint/nginx:v0.1.1
3636
environment:
3737
- ADD_db_TYPE=DATABASE
3838
- ADD_db_ENDPOINT=db:3306

README.md

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
# Welcome to DataJoint for Python!
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

11-
DataJoint was initially developed in 2009 by Dimitri Yatsenko in Andreas Tolias' Lab 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-
13-
Vathes LLC supports DataJoint for Python as an open-source project and everyone is welcome to contribute.
14-
Its DataJoint Neuro (https://djneuro.io) business provides support to neuroscience labs for developing and executing custom data pipelines.
11+
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.
1513

1614
## Installation
1715
```
@@ -22,7 +20,25 @@ If you already have an older version of DataJoint installed using `pip`, upgrade
2220
```bash
2321
pip3 install --upgrade datajoint
2422
```
23+
24+
## Documentation and Tutorials
25+
26+
* https://datajoint.org -- start page
27+
* https://docs.datajoint.org -- up-to-date documentation
28+
* https://tutorials.datajoint.io -- step-by-step tutorials
29+
* https://elements.datajoint.org -- catalog of example pipelines
30+
* https://codebook.datajoint.io -- interactive online tutorials
31+
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+
2539
## Python Native Blobs
40+
<details>
41+
<summary>Click to expand details</summary>
2642

2743
DataJoint 0.12 adds full support for all native python data types in blobs: tuples, lists, sets, dicts, strings, bytes, `None`, and all their recursive combinations.
2844
The new blobs are a superset of the old functionality and are fully backward compatible.
@@ -92,16 +108,23 @@ the situation, but generally the following strategies may apply:
92108
As always, be sure that your data is safely backed up before modifying any
93109
important DataJoint schema or records.
94110

95-
## Documentation and Tutorials
96-
A number of labs are currently adopting DataJoint and we are quickly getting the documentation in shape in February 2017.
111+
</details>
97112

98-
* https://datajoint.io -- start page
99-
* https://docs.datajoint.io -- up-to-date documentation
100-
* https://tutorials.datajoint.io -- step-by-step tutorials
101-
* https://catalog.datajoint.io -- catalog of example pipelines
113+
### API docs
102114

103-
## Running Tests Locally
115+
The API documentation can be built using sphinx by running
104116

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+
125+
## Running Tests Locally
126+
<details>
127+
<summary>Click to expand details</summary>
105128

106129
* Create an `.env` with desired development environment values e.g.
107130
``` sh
@@ -136,9 +159,9 @@ GID=1000
136159
* Add entry in `/etc/hosts` for `127.0.0.1 fakeservices.datajoint.io`
137160

138161

139-
140-
141162
### Launch Jupyter Notebook for Interactive Use
142163
* Navigate to `localhost:8888`
143164
* Input Jupyter password
144165
* Launch a notebook i.e. `New > Python 3`
166+
167+
</details>

datajoint/__init__.py

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,47 @@
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"
1819
__date__ = "November 7, 2020"
19-
__all__ = ['__author__', '__version__',
20-
'config', 'conn', 'Connection',
21-
'Schema', 'schema', 'VirtualModule', 'create_virtual_module',
22-
'list_schemas', 'Table', 'FreeTable',
23-
'Manual', 'Lookup', 'Imported', 'Computed', 'Part',
24-
'Not', 'AndList', 'U', 'Diagram', 'Di', 'ERD',
25-
'set_password', 'kill',
26-
'MatCell', 'MatStruct', 'AttributeAdapter',
27-
'errors', 'DataJointError', 'key', 'key_hash']
20+
__all__ = [
21+
"__author__",
22+
"__version__",
23+
"config",
24+
"conn",
25+
"Connection",
26+
"Schema",
27+
"schema",
28+
"VirtualModule",
29+
"create_virtual_module",
30+
"list_schemas",
31+
"Table",
32+
"FreeTable",
33+
"Manual",
34+
"Lookup",
35+
"Imported",
36+
"Computed",
37+
"Part",
38+
"Not",
39+
"AndList",
40+
"U",
41+
"Diagram",
42+
"Di",
43+
"ERD",
44+
"set_password",
45+
"kill",
46+
"MatCell",
47+
"MatStruct",
48+
"AttributeAdapter",
49+
"errors",
50+
"DataJointError",
51+
"key",
52+
"key_hash",
53+
]
2854

2955
from .version import __version__
3056
from .settings import config
@@ -44,6 +70,6 @@
4470
from .errors import DataJointError
4571
from .migrate import migrate_dj011_external_blob_storage_to_dj012
4672

47-
ERD = Di = Diagram # Aliases for Diagram
48-
schema = Schema # Aliases for Schema
49-
create_virtual_module = VirtualModule # Aliases for VirtualModule
73+
ERD = Di = Diagram # Aliases for Diagram
74+
schema = Schema # Aliases for Schema
75+
create_virtual_module = VirtualModule # Aliases for VirtualModule

datajoint/admin.py

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,30 @@
55
from .utils import user_choice
66

77

8-
def set_password(new_password=None, connection=None, update_config=None): # pragma: no cover
8+
def set_password(
9+
new_password=None, connection=None, update_config=None
10+
): # pragma: no cover
911
connection = conn() if connection is None else connection
1012
if new_password is None:
11-
new_password = getpass('New password: ')
12-
confirm_password = getpass('Confirm password: ')
13+
new_password = getpass("New password: ")
14+
confirm_password = getpass("Confirm password: ")
1315
if new_password != confirm_password:
14-
print('Failed to confirm the password! Aborting password change.')
16+
print("Failed to confirm the password! Aborting password change.")
1517
return
1618
connection.query("SET PASSWORD = PASSWORD('%s')" % new_password)
17-
print('Password updated.')
19+
print("Password updated.")
1820

19-
if update_config or (update_config is None and user_choice('Update local setting?') == 'yes'):
20-
config['database.password'] = new_password
21+
if update_config or (
22+
update_config is None and user_choice("Update local setting?") == "yes"
23+
):
24+
config["database.password"] = new_password
2125
config.save_local(verbose=True)
2226

2327

2428
def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
2529
"""
2630
view and kill database connections.
31+
2732
:param restriction: restriction to be applied to processlist
2833
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
2934
:param order_by: order by a single attribute or the list of attributes. defaults to 'id'.
@@ -40,24 +45,32 @@ def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
4045
connection = conn()
4146

4247
if order_by is not None and not isinstance(order_by, str):
43-
order_by = ','.join(order_by)
48+
order_by = ",".join(order_by)
4449

45-
query = 'SELECT * FROM information_schema.processlist WHERE id <> CONNECTION_ID()' + (
46-
"" if restriction is None else ' AND (%s)' % restriction) + (
47-
' ORDER BY %s' % (order_by or 'id'))
50+
query = (
51+
"SELECT * FROM information_schema.processlist WHERE id <> CONNECTION_ID()"
52+
+ ("" if restriction is None else " AND (%s)" % restriction)
53+
+ (" ORDER BY %s" % (order_by or "id"))
54+
)
4855

4956
while True:
50-
print(' ID USER HOST STATE TIME INFO')
51-
print('+--+ +----------+ +-----------+ +-----------+ +-----+')
52-
cur = ({k.lower(): v for k, v in elem.items()}
53-
for elem in connection.query(query, as_dict=True))
57+
print(" ID USER HOST STATE TIME INFO")
58+
print("+--+ +----------+ +-----------+ +-----------+ +-----+")
59+
cur = (
60+
{k.lower(): v for k, v in elem.items()}
61+
for elem in connection.query(query, as_dict=True)
62+
)
5463
for process in cur:
5564
try:
56-
print('{id:>4d} {user:<12s} {host:<12s} {state:<12s} {time:>7d} {info}'.format(**process))
65+
print(
66+
"{id:>4d} {user:<12s} {host:<12s} {state:<12s} {time:>7d} {info}".format(
67+
**process
68+
)
69+
)
5770
except TypeError:
5871
print(process)
5972
response = input('process to kill or "q" to quit > ')
60-
if response == 'q':
73+
if response == "q":
6174
break
6275
if response:
6376
try:
@@ -66,14 +79,15 @@ def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
6679
pass # ignore non-numeric input
6780
else:
6881
try:
69-
connection.query('kill %d' % pid)
82+
connection.query("kill %d" % pid)
7083
except pymysql.err.InternalError:
71-
print('Process not found')
84+
print("Process not found")
7285

7386

7487
def kill_quick(restriction=None, connection=None):
7588
"""
7689
Kill database connections without prompting. Returns number of terminated connections.
90+
7791
:param restriction: restriction to be applied to processlist
7892
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
7993
@@ -86,13 +100,17 @@ def kill_quick(restriction=None, connection=None):
86100
if connection is None:
87101
connection = conn()
88102

89-
query = 'SELECT * FROM information_schema.processlist WHERE id <> CONNECTION_ID()' + (
90-
"" if restriction is None else ' AND (%s)' % restriction)
103+
query = (
104+
"SELECT * FROM information_schema.processlist WHERE id <> CONNECTION_ID()"
105+
+ ("" if restriction is None else " AND (%s)" % restriction)
106+
)
91107

92-
cur = ({k.lower(): v for k, v in elem.items()}
93-
for elem in connection.query(query, as_dict=True))
108+
cur = (
109+
{k.lower(): v for k, v in elem.items()}
110+
for elem in connection.query(query, as_dict=True)
111+
)
94112
nkill = 0
95113
for process in cur:
96-
connection.query('kill %d' % process['id'])
114+
connection.query("kill %d" % process["id"])
97115
nkill += 1
98116
return nkill

0 commit comments

Comments
 (0)