Skip to content

Commit ca41f02

Browse files
Merge pull request #116 from jverswijver/update_dynamic_api
Update dynamic api to support sci viz templating for real time views
2 parents 20a63f2 + 26617a4 commit ca41f02

31 files changed

+1600
-871
lines changed

.github/workflows/development.yaml

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Development
22
on:
33
pull_request:
44
push:
5-
tags:
6-
- '*.*.*'
75
jobs:
86
test-changelog:
97
runs-on: ubuntu-latest
@@ -40,7 +38,7 @@ jobs:
4038
- uses: actions/checkout@v2
4139
- name: Compile docs static artifacts
4240
run: |
43-
export PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
41+
export PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}')
4442
export HOST_UID=$(id -u)
4543
docker-compose -f docker-compose-docs.yaml up --exit-code-from pharus-docs --build
4644
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
@@ -69,7 +67,7 @@ jobs:
6967
- uses: actions/checkout@v2
7068
- name: Compile image
7169
run: |
72-
export PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
70+
export PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}')
7371
export HOST_UID=$(id -u)
7472
docker-compose -f docker-compose-build.yaml up --exit-code-from pharus --build
7573
IMAGE=$(docker images --filter "reference=datajoint/pharus*" \
@@ -112,7 +110,7 @@ jobs:
112110
- uses: actions/checkout@v2
113111
- name: Determine package version
114112
run: |
115-
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
113+
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}')
116114
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
117115
- name: Fetch image artifact
118116
uses: actions/download-artifact@v2
@@ -124,7 +122,13 @@ jobs:
124122
docker load < "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
125123
docker-compose -f docker-compose-test.yaml up --exit-code-from pharus
126124
publish-release:
127-
if: github.event_name == 'push'
125+
if: |
126+
github.event_name == 'push' &&
127+
contains(github.ref, 'refs/tags/*.*.*') &&
128+
(
129+
github.repository_owner == 'datajoint' ||
130+
github.repository_owner == 'vathes'
131+
)
128132
needs: test
129133
runs-on: ubuntu-latest
130134
env:
@@ -136,7 +140,7 @@ jobs:
136140
- uses: actions/checkout@v2
137141
- name: Determine package version
138142
run: |
139-
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
143+
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}')
140144
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
141145
- name: Get changelog entry
142146
id: changelog_reader
@@ -203,7 +207,13 @@ jobs:
203207
asset_name: docker-compose-deploy.yaml
204208
asset_content_type: application/yaml
205209
publish-images:
206-
if: github.event_name == 'push'
210+
if: |
211+
github.event_name == 'push' &&
212+
contains(github.ref, 'refs/tags/*.*.*') &&
213+
(
214+
github.repository_owner == 'datajoint' ||
215+
github.repository_owner == 'vathes'
216+
)
207217
needs: publish-release
208218
runs-on: ubuntu-latest
209219
strategy:
@@ -216,21 +226,23 @@ jobs:
216226
PY_VER: ${{matrix.py_ver}}
217227
DISTRO: ${{matrix.distro}}
218228
IMAGE: ${{matrix.image}}
219-
DOCKER_USERNAME: ${{secrets.docker_username}}
220-
DOCKER_PASSWORD: ${{secrets.docker_password}}
221229
steps:
222230
- uses: actions/checkout@v2
223231
- name: Determine package version
224232
run: |
225-
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
233+
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}')
226234
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
227235
- name: Fetch image artifact
228236
uses: actions/download-artifact@v2
229237
with:
230238
name: image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
239+
- name: Login to DockerHub
240+
uses: docker/login-action@v1
241+
with:
242+
username: ${{secrets.docker_username}}
243+
password: ${{secrets.docker_password}}
231244
- name: Publish image
232245
run: |
233-
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
234246
docker load < "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
235247
IMAGE=$(docker images --filter "reference=datajoint/*" --format "{{.Repository}}")
236248
TAG=$(docker images --filter "reference=datajoint/*" --format "{{.Tag}}")
@@ -253,14 +265,20 @@ jobs:
253265
${{matrix.distro}}.tar.gz"
254266
asset_content_type: application/gzip
255267
publish-docs:
256-
if: github.event_name == 'push'
268+
if: |
269+
github.event_name == 'push' &&
270+
contains(github.ref, 'refs/tags/*.*.*') &&
271+
(
272+
github.repository_owner == 'datajoint' ||
273+
github.repository_owner == 'vathes'
274+
)
257275
needs: publish-release
258276
runs-on: ubuntu-latest
259277
steps:
260278
- uses: actions/checkout@v2
261279
- name: Determine package version
262280
run: |
263-
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
281+
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}')
264282
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
265283
- name: Fetch docs static artifacts
266284
uses: actions/download-artifact@v2

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# Changelog
22

33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
4+
5+
## [0.3.0] - 2022-01-21
6+
### Changed
7+
- Hot-reload mechanism to use `otumat watch` PR #116
8+
- Renamed environment variable defining spec sheet to `PHARUS_SPEC_PATH` PR #116
9+
10+
### Added
11+
- Autoformatting strategy using `black` PR #116
12+
- Support for sci-viz components `metadata`, `image`, `dynamic grid` PR #116
13+
- `component interface` for users to be able to load their own custom interface for sci-viz PR #116
14+
15+
### Fixed
16+
- Various bugs related to datetime PR #116
17+
418
## [0.2.3] - 2021-11-18
519
### Added
620
- Support for plot component PR #155
@@ -88,6 +102,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
88102
- Support for DataJoint attribute types: `varchar`, `int`, `float`, `datetime`, `date`, `time`, `decimal`, `uuid`.
89103
- Check dependency utility to determine child table references.
90104

105+
[0.3.0]: https://github.com/datajoint/pharus/compare/0.2.3...0.3.0
91106
[0.2.3]: https://github.com/datajoint/pharus/compare/0.2.2...0.2.3
92107
[0.2.2]: https://github.com/datajoint/pharus/compare/0.2.1...0.2.2
93108
[0.2.1]: https://github.com/datajoint/pharus/compare/0.2.0...0.2.1

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ HEALTHCHECK \
1515
--retries=5 \
1616
--interval=15s \
1717
CMD \
18-
wget --quiet --tries=1 --spider \
19-
http://localhost:${PHARUS_PORT}${PHARUS_PREFIX}/version > /dev/null 2>&1 || exit 1
18+
wget --quiet --tries=1 --spider \
19+
http://localhost:${PHARUS_PORT}${PHARUS_PREFIX}/version > /dev/null 2>&1 || exit 1
2020
ENV PHARUS_PORT 5000
21+
# ---TEMP---
22+
RUN pip install plotly
23+
# ----------
24+
COPY --chown=anaconda:anaconda ./reload.sh /tmp/
2125
WORKDIR /main
2226

23-
# development service
24-
# CMD ["pharus"]
25-
26-
# production service
27-
CMD ["sh", "-c", "gunicorn --bind 0.0.0.0:${PHARUS_PORT} pharus.server:app"]
27+
CMD ["sh", "-c", "otumat watch -f ${PHARUS_SPEC_PATH} -s /tmp/reload.sh -i 5"]

docker-compose-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PY_VER=3.8 IMAGE=djbase DISTRO=alpine PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-build.yaml up --exit-code-from pharus --build
1+
# PY_VER=3.8 IMAGE=djbase DISTRO=alpine PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-build.yaml up --exit-code-from pharus --build
22
#
33
# Intended for updating dependencies and docker image.
44
# Used to build release artifacts.

docker-compose-deploy.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88
# With this config and the configuration below in NGINX, you should be able to verify it is
99
# running properly with a `curl https://fakeservices.datajoint.io/api/version`.
1010
version: "2.4"
11-
x-net: &net
11+
x-net:
12+
&net
1213
networks:
13-
- main
14+
- main
1415
services:
1516
pharus:
1617
<<: *net
1718
image: datajoint/pharus:${PHARUS_VERSION}
1819
# environment: # configurable values with defaults
1920
# - PHARUS_PORT=5000
2021
# - PHARUS_PREFIX=/
21-
# - API_SPEC_PATH=tests/init/test_dynamic_api_spec.yaml # for dynamic api spec
22+
# - PHARUS_SPEC_PATH=tests/init/test_dynamic_api_spec.yaml # for dynamic api spec
2223
fakeservices.datajoint.io:
2324
<<: *net
2425
image: datajoint/nginx:v0.0.16

docker-compose-dev.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PY_VER=3.8 IMAGE=djbase DISTRO=alpine PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-dev.yaml up
1+
# PY_VER=3.8 IMAGE=djbase DISTRO=alpine PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-dev.yaml up
22
#
33
# Intended for normal development. Supports hot/live reloading.
44
# Note: If requirements or Dockerfile change, will need to add --build flag to docker-compose.
@@ -7,9 +7,10 @@
77
# With this config and the configuration below in NGINX, you should be able to verify it is
88
# running properly with a `curl https://fakeservices.datajoint.io/api/version`.
99
version: "2.4"
10-
x-net: &net
10+
x-net:
11+
&net
1112
networks:
12-
- main
13+
- main
1314
services:
1415
local-db:
1516
<<: *net
@@ -25,7 +26,7 @@ services:
2526
service: pharus
2627
environment:
2728
- FLASK_ENV=development # enables logging to console from Flask
28-
- API_SPEC_PATH=tests/init/test_dynamic_api_spec.yaml # for dynamic api spec
29+
- PHARUS_SPEC_PATH=tests/init/test_dynamic_api_spec.yaml # for dynamic api spec
2930
volumes:
3031
- ./pharus:/opt/conda/lib/python3.8/site-packages/pharus
3132
command: pharus

docker-compose-test.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# PY_VER=3.8 IMAGE=djtest DISTRO=alpine AS_SCRIPT=FALSE PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-test.yaml up --exit-code-from pharus
1+
# PY_VER=3.8 IMAGE=djtest DISTRO=alpine AS_SCRIPT=FALSE PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\" '{print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-test.yaml up --exit-code-from pharus
22
#
33
# Intended for running test suite locally.
44
# Note: If requirements or Dockerfile change, will need to add --build flag.
55
version: "2.4"
6-
x-net: &net
6+
x-net:
7+
&net
78
networks:
8-
- main
9+
- main
910
services:
1011
db:
1112
<<: *net
@@ -23,7 +24,7 @@ services:
2324
- TEST_DB_USER=root
2425
- TEST_DB_PASS=simple
2526
- AS_SCRIPT
26-
- API_SPEC_PATH=tests/init/test_dynamic_api_spec.yaml
27+
- PHARUS_SPEC_PATH=tests/init/test_dynamic_api_spec.yaml
2728
volumes:
2829
- ./requirements_test.txt:/tmp/pip_requirements.txt
2930
- ./pharus:/opt/conda/lib/python3.8/site-packages/pharus
@@ -36,10 +37,14 @@ services:
3637
echo "------ SYNTAX TESTS ------"
3738
PKG_DIR=/opt/conda/lib/python3.8/site-packages/pharus
3839
flake8 $${PKG_DIR} --count --select=E9,F63,F7,F82 --show-source --statistics
40+
flake8 /main/tests --count --select=E9,F63,F7,F82 --show-source --statistics
3941
echo "------ UNIT TESTS ------"
4042
pytest -sv --cov-report term-missing --cov=pharus /main/tests
4143
echo "------ STYLE TESTS ------"
42-
flake8 $${PKG_DIR} --count --max-complexity=20 --max-line-length=95 --statistics
44+
black $${PKG_DIR} --check -v --extend-exclude "^.*dynamic_api.py$$"
45+
flake8 $${PKG_DIR} --count --max-complexity=20 --max-line-length=94 --statistics --exclude=*dynamic_api.py --ignore=W503
46+
black /main/tests --check -v
47+
flake8 /main/tests --count --max-complexity=20 --max-line-length=94 --statistics --ignore=F401,F811,W503
4348
else
4449
echo "=== Running ==="
4550
echo "Please see 'docker-compose-test.yaml' for detail on running tests."

docs/conf.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,41 @@
1212
#
1313
import os
1414
import sys
15-
sys.path.insert(0, os.path.abspath('..'))
15+
16+
sys.path.insert(0, os.path.abspath(".."))
1617

1718

1819
# -- Project information -----------------------------------------------------
1920

20-
project = 'Pharus'
21-
copyright = '2021, DataJoint Contributors'
22-
author = 'DataJoint Contributors'
21+
project = "Pharus"
22+
copyright = "2021, DataJoint Contributors"
23+
author = "DataJoint Contributors"
2324

2425

2526
# -- General configuration ---------------------------------------------------
2627

2728
# Add any Sphinx extension module names here, as strings. They can be
2829
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2930
# ones.
30-
extensions = ['sphinx.ext.autodoc', 'sphinxcontrib.httpdomain']
31+
extensions = ["sphinx.ext.autodoc", "sphinxcontrib.httpdomain"]
3132

3233
# Add any paths that contain templates here, relative to this directory.
33-
templates_path = ['_templates']
34+
templates_path = ["_templates"]
3435

3536
# List of patterns, relative to source directory, that match files and
3637
# directories to ignore when looking for source files.
3738
# This pattern also affects html_static_path and html_extra_path.
38-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
39+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
3940

4041

4142
# -- Options for HTML output -------------------------------------------------
4243

4344
# The theme to use for HTML and HTML Help pages. See the documentation for
4445
# a list of builtin themes.
4546
#
46-
html_theme = 'sphinx_rtd_theme'
47+
html_theme = "sphinx_rtd_theme"
4748

4849
# Add any paths that contain custom static files (such as style sheets) here,
4950
# relative to this directory. They are copied after the builtin static files,
5051
# so a file named "default.css" will overwrite the builtin "default.css".
51-
html_static_path = ['_static']
52+
html_static_path = ["_static"]

docs/dev_notes.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Run Locally w/ Python
3131
- For development, use CLI command ``pharus``. This method supports hot-reloading so probably best coupled with ``pip install -e ...``.
3232
- For production, use ``gunicorn --bind 0.0.0.0:${PHARUS_PORT} pharus.server:app``.
3333

34-
Run Tests for Development w/ Pytest and Flake8
35-
----------------------------------------------
34+
Run Tests for Development w/ Pytest, Flake8, Black
35+
--------------------------------------------------
3636

3737
- Set ``pharus`` testing environment variables:
3838

@@ -45,7 +45,12 @@ Run Tests for Development w/ Pytest and Flake8
4545
4646
- For syntax tests, run ``flake8 ${PKG_DIR} --count --select=E9,F63,F7,F82 --show-source --statistics``
4747
- For pytest integration tests, run ``pytest -sv --cov-report term-missing --cov=${PKG_DIR} /main/tests``
48-
- For style tests, run ``flake8 ${PKG_DIR} --count --max-complexity=20 --max-line-length=95 --statistics``
48+
- For style tests, run:
49+
50+
.. code-block:: bash
51+
52+
black ${PKG_DIR} --check -v --extend-exclude "^.*dynamic_api.py$"
53+
flake8 ${PKG_DIR} --count --max-complexity=20 --max-line-length=94 --statistics --exclude=*dynamic_api.py --ignore=W503
4954
5055
Creating Sphinx Documentation from Scratch
5156
------------------------------------------

pharus/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from os import path, environ
44

55
try:
6-
if path.exists(environ.get('API_SPEC_PATH')):
6+
if path.exists(environ.get("PHARUS_SPEC_PATH")):
77
dynamic_api_gen.populate_api()
88
except TypeError:
9-
print('No Dynamic API path found')
9+
print("No Dynamic API path found")
1010

1111
try:
1212
from .dynamic_api import app
1313
except ImportError:
1414
from .server import app
1515

16-
__all__ = ['__version__', 'app']
16+
__all__ = ["__version__", "app"]

0 commit comments

Comments
 (0)