Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 138 additions & 51 deletions .github/workflows/development.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Development
on:
push:
pull_request:
push:
tags:
- '*.*.*'
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -15,27 +17,35 @@ jobs:
PY_VER: ${{matrix.py_ver}}
DISTRO: ${{matrix.distro}}
IMAGE: ${{matrix.image}}
HOST_UID: "1001"
DOCKER_CLIENT_TIMEOUT: "120"
COMPOSE_HTTP_TIMEOUT: "120"
AS_SCRIPT: "TRUE"
steps:
- uses: actions/checkout@v2
- name: Compile image
run: |
export DJGUI_API_VERSION=$(cat dj_gui_api_server/version.py | tail -1 | \
awk -F\' '{print $2}')
docker-compose -f LNX-docker-compose.yaml build
IMAGE=$(docker images --filter "reference=datajoint/djgui*" \
export PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
export HOST_UID=$(id -u)
docker-compose -f docker-compose-build.yaml up --exit-code-from pharus --build
IMAGE=$(docker images --filter "reference=datajoint/pharus*" \
--format "{{.Repository}}")
TAG=$(docker images --filter "reference=datajoint/djgui*" --format "{{.Tag}}")
docker save "${IMAGE}:${TAG}" | gzip > "djgui_api-py${PY_VER}-${DISTRO}.tar.gz"
TAG=$(docker images --filter "reference=datajoint/pharus*" --format "{{.Tag}}")
docker save "${IMAGE}:${TAG}" | \
gzip > "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
- name: Add image artifact
uses: actions/upload-artifact@v2
with:
name: ${{format('{0}-py{1}-{2}', 'djgui_api', matrix.py_ver, matrix.distro)}}
path: >
${{format('{0}-py{1}-{2}.tar.gz', 'djgui_api', matrix.py_ver, matrix.distro)}}
name: image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
path: "image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
${{matrix.distro}}.tar.gz"
retention-days: 1
- if: matrix.py_ver == '3.8' && matrix.distro == 'alpine'
name: Add pip artifacts
uses: actions/upload-artifact@v2
with:
name: pip-pharus-${{env.PHARUS_VERSION}}
path: dist
retention-days: 1
test:
needs: build
Expand All @@ -50,56 +60,133 @@ jobs:
PY_VER: ${{matrix.py_ver}}
DISTRO: ${{matrix.distro}}
IMAGE: ${{matrix.image}}
HOST_UID: "1001"
DOCKER_CLIENT_TIMEOUT: "120"
COMPOSE_HTTP_TIMEOUT: "120"
AS_SCRIPT: "TRUE"
steps:
- uses: actions/checkout@v2
- name: Determine package version
run: |
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
- name: Fetch image artifact
uses: actions/download-artifact@v2
with:
name: ${{format('{0}-py{1}-{2}','djgui_api', matrix.py_ver, matrix.distro)}}
name: image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
- name: Run primary tests
run: |
docker load < "djgui_api-py${PY_VER}-${DISTRO}.tar.gz"
export DJGUI_API_VERSION=$(cat dj_gui_api_server/version.py | tail -1 | \
awk -F\' '{print $2}')
docker-compose -f LNX-docker-compose.yaml up --exit-code-from dj-gui-api-test
# publish:
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# needs: test
# runs-on: ubuntu-latest
# strategy:
# matrix:
# include:
# - py_ver: 3.8
# distro: alpine
# image: djbase
# env:
# PY_VER: ${{matrix.py_ver}}
# DISTRO: ${{matrix.distro}}
# IMAGE: ${{matrix.image}}
# DOCKER_USERNAME: ${{secrets.docker_username}}
# DOCKER_PASSWORD: ${{secrets.docker_password}}
# steps:
# - name: Fetch image artifact
# uses: actions/download-artifact@v2
# with:
# name: ${{format('{0}-py{1}-{2}', matrix.conda_ver, matrix.py_ver, matrix.distro)}}
# - name: Publish image
# run: |
# echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# docker load < "${CONDA_VER}-py${PY_VER}-${DISTRO}.tar.gz"
# IMAGE=$(docker images --filter "reference=datajoint/*" --format "{{.Repository}}")
# TAG=$(docker images --filter "reference=datajoint/*" --format "{{.Tag}}")
# docker push "${IMAGE}:${TAG}"
# docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
# docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
# [ "$PY_VER" == "3.9" ] && [ "$DISTRO" == "debian" ] \
# && docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
# && docker push "${IMAGE}:latest" \
# || echo "skipping 'latest' tag..."
export HOST_UID=$(id -u)
docker load < "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
docker-compose -f docker-compose-test.yaml up --exit-code-from pharus
publish-release:
if: github.event_name == 'push'
needs: test
runs-on: ubuntu-latest
env:
TWINE_USERNAME: ${{secrets.twine_username}}
TWINE_PASSWORD: ${{secrets.twine_password}}
steps:
- uses: actions/checkout@v2
- name: Determine package version
run: |
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
- name: Fetch pip artifacts
uses: actions/download-artifact@v2
with:
name: pip-pharus-${{env.PHARUS_VERSION}}
- name: Publish pip release
run: python -m twine upload dist/*
- name: Get changelog entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_depth: 10
version: ${{steps.tag_name.outputs.current_version}}
path: ./CHANGELOG.md
- name: Create GH release
id: create_gh_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{github.ref}}
release_name: Release ${{steps.changelog_reader.outputs.version}}
body: ${{steps.changelog_reader.outputs.changes}}
prerelease: ${{steps.changelog_reader.outputs.status == 'prereleased'}}
draft: ${{steps.changelog_reader.outputs.status == 'unreleased'}}
- name: Determine pip artifact paths
run: |
echo "PHARUS_WHEEL_PATH=$(ls dist/pharus-*.whl)" >> $GITHUB_ENV
echo "PHARUS_SDIST_PATH=$(ls dist/pharus-*.tar.gz)" >> $GITHUB_ENV
- name: Upload pip wheel asset to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: $${{env.PHARUS_WHEEL_PATH}}
asset_name: pip-pharus-${{env.PHARUS_VERSION}}.whl
asset_content_type: application/zip
- name: Upload pip sdist asset to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_gh_release.outputs.upload_url}}
asset_path: $${{env.PHARUS_SDIST_PATH}}
asset_name: pip-pharus-${{env.PHARUS_VERSION}}.tar.gz
asset_content_type: application/zip
publish-images:
if: github.event_name == 'push'
needs: publish-release
runs-on: ubuntu-latest
strategy:
matrix:
include:
- py_ver: 3.8
distro: alpine
image: djbase
env:
PY_VER: ${{matrix.py_ver}}
DISTRO: ${{matrix.distro}}
IMAGE: ${{matrix.image}}
DOCKER_USERNAME: ${{secrets.docker_username}}
DOCKER_PASSWORD: ${{secrets.docker_password}}
steps:
- uses: actions/checkout@v2
- name: Determine package version
run: |
PHARUS_VERSION=$(cat pharus/version.py | tail -1 | awk -F\' '{print $2}')
echo "PHARUS_VERSION=${PHARUS_VERSION}" >> $GITHUB_ENV
- name: Fetch image artifact
uses: actions/download-artifact@v2
with:
name: image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
- name: Publish image
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker load < "image-pharus-${PHARUS_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
IMAGE=$(docker images --filter "reference=datajoint/*" --format "{{.Repository}}")
TAG=$(docker images --filter "reference=datajoint/*" --format "{{.Tag}}")
docker push "${IMAGE}:${TAG}"
docker tag "${IMAGE}:${TAG}" "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
docker push "${IMAGE}:${TAG}-${GITHUB_SHA:0:7}"
[ "$PY_VER" == "3.8" ] && [ "$DISTRO" == "alpine" ] \
&& docker tag "${IMAGE}:${TAG}" "${IMAGE}:latest" \
&& docker push "${IMAGE}:latest" \
|| echo "skipping 'latest' tag..."
- name: Upload image to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{needs.publish-release.steps.create_gh_release.outputs.upload_url}}
asset_path: "image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
${{matrix.distro}}.tar.gz"
asset_name: "image-pharus-${{env.PHARUS_VERSION}}-py${{matrix.py_ver}}-\
${{matrix.distro}}.tar.gz"
asset_content_type: application/gzip
# publish-docs:
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# runs-on: ubuntu-latest
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
*__pycache__
.vscode
docker-compose.y*ml
.coverage
.coverage
*.egg-info
dist
build
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [0.1.0a1] - 2021-02-16
### Added
- List schemas method.
- List tables method.
- Create, Read, Update, Delete (CRUD) operations for DataJoint table tiers: `dj.Manual`, `dj.Lookup`.
- Read table records with proper paging and compounding restrictions (i.e. filters).
- Read table definition method.
- Support for DataJoint attribute types: `varchar`, `int`, `float`, `datetime`, `date`, `time`, `decimal`, `uuid`.
- Check dependency utility to determine child table references.
File renamed without changes.
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG IMAGE
FROM datajoint/${IMAGE}:py${PY_VER}-${DISTRO}
COPY --chown=dja:anaconda ./README.md ./requirements.txt ./setup.py \
/main/
COPY --chown=dja:anaconda ./dj_gui_api_server/*.py /main/dj_gui_api_server/
COPY --chown=dja:anaconda ./pharus/*.py /main/pharus/
RUN \
cd /main && \
pip install . && \
Expand All @@ -15,5 +15,12 @@ HEALTHCHECK \
--interval=15s \
CMD \
wget --quiet --tries=1 --spider \
http://localhost:5000/api/version > /dev/null 2>&1 || exit 1
CMD ["djgui_api"]
http://localhost:${PHARUS_PORT}${PHARUS_PREFIX}/version > /dev/null 2>&1 || exit 1
ENV PHARUS_PORT 5000
WORKDIR /main

# development service
# CMD ["pharus"]

# production service
CMD ["sh", "-lc", "gunicorn --bind 0.0.0.0:${PHARUS_PORT} pharus.server:app"]
58 changes: 0 additions & 58 deletions LNX-docker-compose.yaml

This file was deleted.

22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,37 @@
</p>
</div>

> :warning: The DJGUI project is still early in its life and the maintainers are currently actively developing with a priority of addressing first critical issues directly related to the deliveries of [Alpha](https://github.com/datajoint/DJ-GUI-API/milestone/1) and [Beta](https://github.com/datajoint/DJ-GUI-API/milestone/2) milestones. Please be advised that while working through our milestones, we may restructure/refactor the codebase without warning until we issue our [Official Release](https://github.com/datajoint/DJ-GUI-API/milestone/3) currently planned as `0.1.0` on `2021-03-31`.
> :warning: The Pharus project is still early in its life and the maintainers are currently actively developing with a priority of addressing first critical issues directly related to the deliveries of [Alpha](https://github.com/datajoint/pharus/milestone/1) and [Beta](https://github.com/datajoint/pharus/milestone/2) milestones. Please be advised that while working through our milestones, we may restructure/refactor the codebase without warning until we issue our [Official Release](https://github.com/datajoint/pharus/milestone/3) currently planned as `0.1.0` on `2021-03-31`.

# DJ-GUI-API Backend
# Pharus

Serves as the REST API backend for DJGUI project complimented by [React frontend](https://github.com/datajoint/DJ-GUI-React).
Built on top of `flask`, `datajoint`, and `pyjwt`.
A generic REST API server backend for DataJoint pipelines built on top of `flask`, `datajoint`, and `pyjwt`.

Requirements:
- [Docker](https://docs.docker.com/get-docker/ )
- [Docker Compose](https://docs.docker.com/compose/install/)

## Run Locally

- Copy `local-docker-compose.yaml` to `docker-compose.yaml`. This file is untracked so feel free to modify as necessary.
- Copy a `*-docker-compose.yaml` file corresponding to your usage to `docker-compose.yaml`. This file is untracked so feel free to modify as necessary.
- Check the first comment which will provide best instruction on how to start the service.

> :warning: The docker-compose file creates a docker network called `dj-gui-api` which is meant to connect the frontend to the backend via reverse proxy for development. Running or installation options currently being considered are [Docker Compose](https://docs.docker.com/compose/install/) and [Electron](https://www.electronjs.org/). Deployment options currently being considered are [Docker Compose](https://docs.docker.com/compose/install/) and [Kubernetes](https://kubernetes.io/docs/tutorials/kubernetes-basics/).
> :warning: Deployment options currently being considered are [Docker Compose](https://docs.docker.com/compose/install/) and [Kubernetes](https://kubernetes.io/docs/tutorials/kubernetes-basics/).

## Run Tests
## Run Tests for Development

- Create a `.env` as appropriate for your setup:
```shell
HOST_UID=1000 # Unix UID associated with non-root login
PY_VER=3.8 # Python version: 3.6|3.7|3.8
IMAGE=djtest # Image type: djbase|djtest|djlab|djlabhub
DISTRO=alpine # Distribution: alpine|debian
AS_SCRIPT= # If 'TRUE', will not keep container alive but run tests and exit
```
- Navigate to `LNX-docker-compose.yaml` and check first comment which will provide best instruction on how to start the service. Yes, the command is a bit long...
- Navigate to `test-docker-compose.yaml` and check first comment which will provide best instruction on how to start the service. Yes, the command is a bit long...

## References

- DJGUI Frontend:
- https://github.com/datajoint/DJ-GUI-React
- Under construction image credits:
- DataJoint LabBook (a companion frontend)
- https://github.com/datajoint/datajoint-labbook
- Under construction image credits
- https://www.pngfind.com/mpng/ooiim_under-construction-tape-png-under-construction-transparent-png/
2 changes: 0 additions & 2 deletions dj_gui_api_server/version.py

This file was deleted.

Loading