Skip to content

Commit 4367032

Browse files
Merge pull request #1052 from guzman-raphael/docs
Upgrade documentation to new structure and fix regression with backslashes
2 parents 7747796 + 2510303 commit 4367032

38 files changed

+442
-462
lines changed

.github/workflows/development.yaml

Lines changed: 116 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,45 @@ on:
33
push:
44
branches:
55
- '**' # every branch
6+
- '!gh-pages' # exclude gh-pages branch
67
- '!stage*' # exclude branches beginning with stage
8+
tags:
9+
- '\d+\.\d+\.\d+' # only semver tags
710
pull_request:
811
branches:
912
- '**' # every branch
1013
- '!stage*' # exclude branches beginning with stage
1114
jobs:
12-
build-docs:
15+
build:
1316
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
include:
20+
- py_ver: 3.8
21+
distro: alpine
22+
image: djbase
1423
env:
24+
PY_VER: ${{matrix.py_ver}}
25+
DISTRO: ${{matrix.distro}}
26+
IMAGE: ${{matrix.image}}
1527
DOCKER_CLIENT_TIMEOUT: "120"
1628
COMPOSE_HTTP_TIMEOUT: "120"
1729
steps:
1830
- uses: actions/checkout@v2
19-
- name: Compile docs static artifacts
31+
- name: Build pip artifacts
2032
run: |
33+
export DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
2134
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
35+
docker-compose -f docker-compose-build.yaml up --exit-code-from app --build
36+
echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
37+
- if: matrix.py_ver == '3.8' && matrix.distro == 'alpine'
38+
name: Add pip artifacts
2439
uses: actions/upload-artifact@v2
2540
with:
26-
name: docs-api-static
27-
path: docs-api/build/html
41+
name: pip-datajoint-${{env.DJ_VERSION}}
42+
path: dist
2843
retention-days: 1
2944
test:
30-
if: github.event_name == 'push' || github.event_name == 'pull_request'
3145
runs-on: ubuntu-latest
3246
strategy:
3347
matrix:
@@ -39,7 +53,7 @@ jobs:
3953
steps:
4054
- uses: actions/checkout@v2
4155
- name: Set up Python ${{matrix.py_ver}}
42-
uses: actions/setup-python@v2
56+
uses: actions/setup-python@v4
4357
with:
4458
python-version: ${{matrix.py_ver}}
4559
- name: Install dependencies
@@ -50,58 +64,119 @@ jobs:
5064
run: flake8 datajoint --count --select=E9,F63,F7,F82 --show-source --statistics
5165
- name: Run primary tests
5266
env:
53-
UID: "1001"
54-
GID: "121"
5567
PY_VER: ${{matrix.py_ver}}
5668
MYSQL_VER: ${{matrix.mysql_ver}}
5769
ALPINE_VER: "3.10"
5870
MINIO_VER: RELEASE.2021-09-03T03-56-13Z
5971
COMPOSE_HTTP_TIMEOUT: "120"
6072
COVERALLS_SERVICE_NAME: travis-ci
6173
COVERALLS_REPO_TOKEN: fd0BoXG46TPReEem0uMy7BJO5j0w1MQiY
62-
run: docker-compose -f LNX-docker-compose.yml up --build --exit-code-from app
74+
run: |
75+
export HOST_UID=$(id -u)
76+
export HOST_GID=$(id -g)
77+
docker-compose -f LNX-docker-compose.yml up --build --exit-code-from app
6378
- name: Run style tests
6479
run: |
65-
flake8 --ignore=E203,E722,F401,W503 datajoint \
80+
flake8 --ignore=E203,E722,W503 datajoint \
6681
--count --max-complexity=62 --max-line-length=127 --statistics
6782
black datajoint --check -v
6883
black tests --check -v
6984
publish-docs:
7085
if: |
7186
github.event_name == 'push' &&
72-
(
73-
github.repository_owner == 'datajoint' ||
74-
github.repository_owner == 'datajoint-company' ||
75-
github.repository_owner == 'dj-sciops'
76-
)
77-
needs: build-docs
87+
startsWith(github.ref, 'refs/tags')
88+
needs: test
89+
runs-on: ubuntu-latest
90+
env:
91+
DOCKER_CLIENT_TIMEOUT: "120"
92+
COMPOSE_HTTP_TIMEOUT: "120"
93+
steps:
94+
- uses: actions/checkout@v2
95+
- name: Deploy docs
96+
run: |
97+
export MODE=BUILD
98+
export PACKAGE=datajoint
99+
export UPSTREAM_REPO=https://github.com/${GITHUB_REPOSITORY}.git
100+
export HOST_UID=$(id -u)
101+
docker compose -f docs/docker-compose.yaml up --exit-code-from docs --build
102+
git push origin gh-pages
103+
publish-release:
104+
if: |
105+
github.event_name == 'push' &&
106+
startsWith(github.ref, 'refs/tags')
107+
needs: test
78108
runs-on: ubuntu-latest
109+
strategy:
110+
matrix:
111+
include:
112+
- py_ver: 3.8
113+
distro: alpine
114+
image: djbase
115+
env:
116+
PY_VER: ${{matrix.py_ver}}
117+
DISTRO: ${{matrix.distro}}
118+
IMAGE: ${{matrix.image}}
119+
TWINE_USERNAME: ${{secrets.twine_username}}
120+
TWINE_PASSWORD: ${{secrets.twine_password}}
121+
DOCKER_CLIENT_TIMEOUT: "120"
122+
COMPOSE_HTTP_TIMEOUT: "120"
123+
outputs:
124+
release_upload_url: ${{steps.create_gh_release.outputs.upload_url}}
79125
steps:
80126
- uses: actions/checkout@v2
81-
- name: Fetch docs static artifacts
127+
- name: Set up Python ${{matrix.py_ver}}
128+
uses: actions/setup-python@v4
129+
with:
130+
python-version: ${{matrix.py_ver}}
131+
- name: Determine package version
132+
run: |
133+
DJ_VERSION=$(grep -oP '\d+\.\d+\.\d+' datajoint/version.py)
134+
RELEASE_BODY=$(python -c \
135+
'print(open("./CHANGELOG.md").read().split("\n\n")[1].split("\n", 1)[1])' \
136+
)
137+
echo "DJ_VERSION=${DJ_VERSION}" >> $GITHUB_ENV
138+
echo "RELEASE_BODY=${RELEASE_BODY}" >> $GITHUB_ENV
139+
- name: Create GH release
140+
id: create_gh_release
141+
uses: actions/create-release@v1
142+
env:
143+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
144+
with:
145+
tag_name: ${{env.DJ_VERSION}}
146+
release_name: Release ${{env.DJ_VERSION}}
147+
body: ${{env.RELEASE_BODY}}
148+
prerelease: false
149+
draft: false
150+
- name: Fetch pip artifacts
82151
uses: actions/download-artifact@v2
83152
with:
84-
name: docs-api-static
85-
path: docs-api/build/html
86-
- name: Commit documentation changes
153+
name: pip-datajoint-${{env.DJ_VERSION}}
154+
path: dist
155+
- name: Determine pip artifact paths
87156
run: |
88-
git clone https://github.com/${GITHUB_REPOSITORY}.git \
89-
--branch gh-pages --single-branch gh-pages
90-
rm -R gh-pages/*
91-
cp -r docs-api/build/html/* gh-pages/
92-
cp .gitignore gh-pages/
93-
touch gh-pages/.nojekyll
94-
echo "docs-api.datajoint.org" > gh-pages/CNAME
95-
cd gh-pages
96-
git config --local user.email "[email protected]"
97-
git config --local user.name "GitHub Action"
98-
git add . --all
99-
git commit -m "Update documentation" -a || true
100-
# The above command will fail if no changes were present, so we ignore
101-
# the return code.
102-
- name: Push changes
103-
uses: ad-m/github-push-action@master
157+
echo "DJ_WHEEL_PATH=$(ls dist/datajoint-*.whl)" >> $GITHUB_ENV
158+
echo "DJ_SDIST_PATH=$(ls dist/datajoint-*.tar.gz)" >> $GITHUB_ENV
159+
- name: Upload pip wheel asset to release
160+
uses: actions/upload-release-asset@v1
161+
env:
162+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
104163
with:
105-
branch: gh-pages
106-
directory: gh-pages
107-
github_token: ${{secrets.GITHUB_TOKEN}}
164+
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
165+
asset_path: ${{env.DJ_WHEEL_PATH}}
166+
asset_name: pip-datajoint-${{env.DJ_VERSION}}.whl
167+
asset_content_type: application/zip
168+
- name: Upload pip sdist asset to release
169+
uses: actions/upload-release-asset@v1
170+
env:
171+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
172+
with:
173+
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
174+
asset_path: ${{env.DJ_SDIST_PATH}}
175+
asset_name: pip-datajoint-${{env.DJ_VERSION}}.tar.gz
176+
asset_content_type: application/gzip
177+
- name: Publish pip release
178+
run: |
179+
export HOST_UID=$(id -u)
180+
docker-compose -f docker-compose-build.yaml run \
181+
-e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} app \
182+
sh -lc "pip install twine && python -m twine upload dist/*"

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ notebook
2424
.vscode
2525
__main__.py
2626
jupyter_custom.js
27-
apk_requirements.txt
2827
.eggs
2928
*.code-workspace
29+
docs/site

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
## Release notes
22

3+
### 0.13.8 -- Sep 21, 2022
4+
* Add - New documentation structure based on markdown PR [#1052](https://github.com/datajoint/datajoint-python/pull/1052)
5+
* Bugfix - Fix queries with backslashes ([#999](https://github.com/datajoint/datajoint-python/issues/999)) PR [#1052](https://github.com/datajoint/datajoint-python/pull/1052)
6+
37
### 0.13.7 -- Jul 13, 2022
4-
* Bugfix - Fix networkx incompatable change by version pinning to 2.6.3 PR #1036 (#1035)
5-
* Add - Support for serializing numpy datetime64 types PR #1036 (#1022)
8+
* Bugfix - Fix networkx incompatable change by version pinning to 2.6.3 (#1035) PR #1036
9+
* Add - Support for serializing numpy datetime64 types (#1022) PR #1036
610
* Update - Add traceback to default logging PR #1036
711

812
### 0.13.6 -- Jun 13, 2022

Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
FROM datajoint/pydev
2-
3-
COPY --chown=dja . /tmp/src
4-
RUN pip install --user /tmp/src && \
5-
rm -rf /tmp/src
1+
ARG PY_VER=3.8
2+
ARG DISTRO=alpine
3+
ARG IMAGE=djbase
4+
FROM datajoint/${IMAGE}:py${PY_VER}-${DISTRO}
5+
WORKDIR /main
6+
COPY --chown=anaconda:anaconda ./requirements.txt ./setup.py \
7+
/main/
8+
COPY --chown=anaconda:anaconda ./datajoint/*.py /main/datajoint/
9+
RUN \
10+
umask u+rwx,g+rwx,o-rwx && \
11+
pip install --no-cache-dir . && \
12+
rm -R ./*
13+
CMD ["python"]

LNX-docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# docker-compose -f LNX-docker-compose.yml --env-file LNX.env up --exit-code-from app --build
1+
# docker compose -f LNX-docker-compose.yml --env-file LNX.env up --exit-code-from app --build
22
version: '2.2'
33
x-net: &net
44
networks:
@@ -32,7 +32,7 @@ services:
3232
interval: 1s
3333
fakeservices.datajoint.io:
3434
<<: *net
35-
image: datajoint/nginx:v0.2.1
35+
image: datajoint/nginx:v0.2.3
3636
environment:
3737
- ADD_db_TYPE=DATABASE
3838
- ADD_db_ENDPOINT=db:3306
@@ -85,7 +85,7 @@ services:
8585
# jupyter notebook
8686
# ports:
8787
# - "8888:8888"
88-
user: ${UID}:${GID}
88+
user: ${HOST_UID}:${HOST_GID}
8989
volumes:
9090
- .:/src
9191
- /tmp/.X11-unix:/tmp/.X11-unix:rw

Makefile

Lines changed: 0 additions & 28 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ PY_VER=3.7
132132
ALPINE_VER=3.10
133133
MYSQL_VER=5.7
134134
MINIO_VER=RELEASE.2021-09-03T03-56-13Z
135-
UID=1000
136-
GID=1000
135+
HOST_UID=1000
136+
HOST_GID=1000
137137
```
138138
* `cp local-docker-compose.yml docker-compose.yml`
139139
* `docker-compose up -d` (Note configured `JUPYTER_PASSWORD`)

datajoint/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
"DataJointError",
5151
"key",
5252
"key_hash",
53+
"logger",
54+
"migrate_dj011_external_blob_storage_to_dj012",
5355
]
5456

5557
from .logging import logger

datajoint/condition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def prep_value(k, v):
109109
):
110110
return '"%s"' % v
111111
if isinstance(v, str):
112-
return '"%s"' % v.replace("%", "%%")
112+
return '"%s"' % v.replace("%", "%%").replace("\\", "\\\\")
113113
return "%r" % v
114114

115115
negate = False

datajoint/declare.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import re
66
import pyparsing as pp
77
import logging
8-
import warnings
98
from .errors import DataJointError, _support_filepath_types, FILEPATH_FEATURE_SWITCH
109
from .attribute_adapter import get_adapter
1110

0 commit comments

Comments
 (0)