Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create template for element #1

Merged
merged 16 commits into from
Mar 8, 2022
147 changes: 147 additions & 0 deletions .github/workflow/development.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Development
on:
pull_request:
push:
tags:
- '*.*.*'
jobs:
test-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get changelog entry
id: changelog_reader
uses: guzman-raphael/changelog-reader-action@v5
with:
path: ./CHANGELOG.md
- name: Verify changelog parsing
env:
TAG_NAME: ${{steps.changelog_reader.outputs.version}}
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'}}
run: |
echo "TAG_NAME=${TAG_NAME}"
echo "RELEASE_NAME=${RELEASE_NAME}"
echo "BODY=${BODY}"
echo "PRERELEASE=${PRERELEASE}"
echo "DRAFT=${DRAFT}"
build:
needs: test-changelog
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_CLIENT_TIMEOUT: "120"
COMPOSE_HTTP_TIMEOUT: "120"
steps:
- uses: actions/checkout@v2
- name: Compile image
run: |
export PKG_NAME=$(python3 -c "print([p for p in __import__('setuptools').find_packages() if '.' not in p][0])")
export PKG_VERSION=$(cat ${PKG_NAME}/version.py | awk -F\' '/__version__ = / {print $2}')
export HOST_UID=$(id -u)
docker-compose -f docker-compose-build.yaml up --exit-code-from element --build
IMAGE=$(docker images --filter "reference=datajoint/${PKG_NAME}*" \
--format "{{.Repository}}")
TAG=$(docker images --filter "reference=datajoint/${PKG_NAME}*" --format "{{.Tag}}")
docker save "${IMAGE}:${TAG}" | \
gzip > "image-${PKG_NAME}-${PKG_VERSION}-py${PY_VER}-${DISTRO}.tar.gz"
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_ENV
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_ENV
- name: Add image artifact
uses: actions/upload-artifact@v2
with:
name: image-${{env.PKG_NAME}}-${{env.PKG_VERSION}}-py${{matrix.py_ver}}-${{matrix.distro}}
path: "image-${{env.PKG_NAME}}-${{env.PKG_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-${{env.PKG_NAME}}-${{env.PKG_VERSION}}
path: dist
retention-days: 1
publish-release:
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
env:
TWINE_USERNAME: ${{secrets.twine_username}}
TWINE_PASSWORD: ${{secrets.twine_password}}
outputs:
release_upload_url: ${{steps.create_gh_release.outputs.upload_url}}
steps:
- uses: actions/checkout@v2
- name: Determine package version
run: |
PKG_NAME=$(python3 -c "print([p for p in __import__('setuptools').find_packages() if '.' not in p][0])")
SDIST_PKG_NAME=$(echo ${PKG_NAME} | sed 's|_|-|g')
PKG_VERSION=$(cat ${PKG_NAME}/version.py | awk -F\' '/__version__ = / {print $2}')
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_ENV
echo "PKG_VERSION=${PKG_VERSION}" >> $GITHUB_ENV
echo "SDIST_PKG_NAME=${SDIST_PKG_NAME}" >> $GITHUB_ENV
- name: Get changelog entry
id: changelog_reader
uses: guzman-raphael/changelog-reader-action@v5
with:
path: ./CHANGELOG.md
version: ${{env.PKG_VERSION}}
- name: Create GH release
id: create_gh_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
tag_name: ${{steps.changelog_reader.outputs.version}}
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: Fetch image artifact
uses: actions/download-artifact@v2
with:
name: image-${{env.PKG_NAME}}-${{env.PKG_VERSION}}-py3.8-alpine
- name: Fetch pip artifacts
uses: actions/download-artifact@v2
with:
name: pip-${{env.PKG_NAME}}-${{env.PKG_VERSION}}
path: dist
- name: Publish pip release
run: |
export HOST_UID=$(id -u)
docker load < "image-${{env.PKG_NAME}}-${PKG_VERSION}-py3.8-alpine.tar.gz"
docker-compose -f docker-compose-build.yaml run \
-e TWINE_USERNAME=${TWINE_USERNAME} -e TWINE_PASSWORD=${TWINE_PASSWORD} element \
sh -lc "pip install twine && python -m twine upload dist/*"
- name: Determine pip artifact paths
run: |
echo "PKG_WHEEL_PATH=$(ls dist/${PKG_NAME}-*.whl)" >> $GITHUB_ENV
echo "PKG_SDIST_PATH=$(ls dist/${SDIST_PKG_NAME}-*.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.PKG_WHEEL_PATH}}
asset_name: pip-${{env.PKG_NAME}}-${{env.PKG_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.PKG_SDIST_PATH}}
asset_name: pip-${{env.SDIST_PKG_NAME}}-${{env.PKG_VERSION}}.tar.gz
asset_content_type: application/gzip
74 changes: 74 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution, packaging, PyInstaller
.Python
env/
build/
*egg*/
*dist/
downloads/
lib*/
parts/
var/
wheels/
.installed.cfg
*.egg
*.manifest
*.spec
pip-*.txt

# Unit test / coverage reports
htmlcov/
.tox/
*.cov*
.cache
nosetests.xml
coverage.xml
.hypothesis/
.pytest_cache/
docker-compose.y*ml

# C extension, Translations
# editors: vscode, emacs, Mac
*.so
*.mo
*.pot
.vscode
**/*~
**/#*#
**/.#*
.DS_Store

# Django, Flask, Scrapy, Sphinx, mkdocs
# PyBuilder, Jupyter, SageMath, celery beat
*.log
local_settings.py
instance/
.webassets-cache
.scrapy
scratchpaper.*
docs/_build/
/site
target/
.*checkpoints
celerybeat-schedule
*.sage.py

# dotenv, virtualenv, pyenv, mypy
.*env
venv/
ENV/
.python-version
.mypy_cache/

# Spyder/Rope project settings
.spy*project
.ropeproject

# datajoint, notes, nwb export
dj_local_c*.json
temp*
*nwb
10 changes: 10 additions & 0 deletions Background.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Electrode Localization Element
## Description of modality, user population

## Acquisition tools

## Preprocessing tools

## Precursor projects and interviews

## Pipeline Development
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 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.0.0a1 - unreleased
### Added
+
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contribution Guidelines

This project follows the [DataJoint Contribution Guidelines](https://docs.datajoint.org/python/community/02-Contribute.html). Please reference the link for more full details.
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG PY_VER
CBroz1 marked this conversation as resolved.
Show resolved Hide resolved
ARG DISTRO
ARG IMAGE
ARG PKG_NAME
ARG PKG_VERSION

FROM datajoint/${IMAGE}:py${PY_VER}-${DISTRO}
COPY --chown=anaconda:anaconda ./requirements.txt ./setup.py \
/main/
COPY --chown=anaconda:anaconda ./${PKG_NAME} /main/${PKG_NAME}
RUN \
cd /main && \
pip install . && \
rm -R /main/*
WORKDIR /main
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 DataJoint

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
# element-electrode-localization
# DataJoint Element - Electrode Localization

This repository is currently a work in progress.

See [Background](Background.md) for the background information and development timeline.

## Element architecture
<!-- ![element-electrode-localization](https://github.com/datajoint/element-electrode-localization/blob/main/images/diagram_electrode-localization.svg) -->
## Installation

+ Install `element-electrode-localization`
```
pip install element-electrode-localization
```

+ Upgrade `element-electrode-localization` previously installed with `pip`
```
pip install --upgrade element-electrode-localization
```

+ Install `element-interface`

+ `element-interface` is a dependency of `element-electrode-localization`, however it is not contained within `requirements.txt`.

```
pip install "element-interface @ git+https://github.com/datajoint/element-interface"
```

## Usage

### Element activation

To activate the `element-electrode-localization`, ones need to provide:

1. Schema names
+ schema name for the `electrode` module

2. Upstream tables
+

3. Utility functions. See [example definitions](https://github.com/datajoint/workflow-array-ephys/blob/main/workflow_array_ephys/paths.py).
+ get_ephys_root_data_dir(): Returns your root data directory.
+ get_session_directory(): Returns the path of the session data relative to the root.

For more details, check the docstring of the `element-electrode-localization`:

help(electrode.activate)

### Example usage

See the [workflow-array-ephys project](https://github.com/datajoint/workflow-array-ephys) for an example usage of this Element.
CBroz1 marked this conversation as resolved.
Show resolved Hide resolved
26 changes: 26 additions & 0 deletions docker-compose-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# PY_VER=3.8 IMAGE=djbase DISTRO=alpine PKG_NAME=$(python -c "print([p for p in __import__('setuptools').find_packages() if '.' not in p][0])") PKG_VERSION=$(cat ${PKG_NAME}/version.py | awk -F\' '/__version__/ {print $2}') HOST_UID=$(id -u) docker-compose -f docker-compose-build.yaml up --exit-code-from element --build
CBroz1 marked this conversation as resolved.
Show resolved Hide resolved
#
# Intended for updating dependencies and docker image.
# Used to build release artifacts.
version: "2.4"
services:
element:
build:
context: .
args:
- PY_VER
- DISTRO
- IMAGE
- PKG_NAME
- PKG_VERSION
image: datajoint/${PKG_NAME}:${PKG_VERSION}
user: ${HOST_UID}:anaconda
volumes:
- .:/main
command:
- sh
- -lc
- |
set -e
rm -R build dist *.egg-info || echo "No prev build"
python setup.py bdist_wheel sdist
Empty file.
2 changes: 2 additions & 0 deletions element_electrode_localization/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""Package metadata."""
__version__ = '0.0.0a1'
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
datajoint>=0.13
Loading