Skip to content

Commit

Permalink
Merge pull request #603 from Aarhus-Psychiatry-Research/initialise_sp…
Browse files Browse the repository at this point in the history
…ecs_from_primitives

feat: initialise specs from primitives
  • Loading branch information
HLasse authored Sep 3, 2024
2 parents 2d3d7ba + 95608f3 commit 057a1a9
Show file tree
Hide file tree
Showing 26 changed files with 4,279 additions and 675 deletions.
11 changes: 2 additions & 9 deletions .devcontainer/post-start.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
# Setup lefthook
#!/bin/bash
git init
lefthook install

# Disable Graphite pager
gt user pager --disable

# Install dependencies
pip install -e ".[dev, test]"

uv sync --all-extras
170 changes: 170 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Byte-compiled / optimized / DLL files
.git
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
*venv*/
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# Testing
pytest-coverage.txt

# Mac
.DS_Store

#other
*test_load_data.py
wandb
poetry.lock
*.html

# PyCharm
/.idea/*
**/tmp/
**/.tmp/

*nbconvert*
.testmondata*
.benchmark_cache/*
22 changes: 10 additions & 12 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ runs:
- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Replace python version in Dockerfile
- name: Set up uv
shell: bash
run: |
sed -i '/python:.*/c\FROM python:${{ inputs.python-version }}' Dockerfile
# Install a specific uv version using the installer
run: curl -LsSf https://astral.sh/uv/0.4.0/install.sh | sh

- name: Create github hosts file
- name: Set up Python
shell: bash
run: | # If this file is not created, the dev container fails because of non-existent mount
mkdir -p ~/.config/gh
touch ~/.config/gh/hosts.yml
run: uv python install ${{ inputs.python-version }}

- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
runCmd: |
inv test --pytest-args "src/" --pytest-args --pytest-args "--cov=src" --pytest-args "--cov-report term-missing" --pytest-args="--color=yes" --pytest-args="-n auto"
# Installing
- name: Install dependencies
shell: bash
run: |
make test
19 changes: 9 additions & 10 deletions .github/actions/test_tutorials/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,26 @@ runs:
using: "composite"
steps:
### Setup prerequisites
- name: Set up uv
shell: bash
# Install a specific uv version using the installer
run: curl -LsSf https://astral.sh/uv/0.4.0/install.sh | sh

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
shell: bash
run: uv python install

# Installing
- name: Install dependencies
shell: bash
run: |
pip install invoke
inv install
make install-tutorials
### Run tests
- name: Install jupyter
shell: bash
run: |
pip install jupyter
- name: Compile notebooks and check for errors
shell: bash
run: |
inv test-tutorials
make test-tutorials
for notebook in tutorials/*.ipynb; do
if grep -q "\"cell_type\": \"error\"" $notebook; then
echo "Error cell found in $notebook"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
shell: bash
run: |
python -m pip install --upgrade pip
pip install -e ".[docs,tutorials,text]"
pip install -e ".[docs,tutorials]"
- name: Build and Commit
uses: sphinx-notes/[email protected]
Expand Down
19 changes: 10 additions & 9 deletions .github/workflows/static_type_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ jobs:
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Set up uv
shell: bash
run: curl -LsSf https://astral.sh/uv/0.4.0/install.sh | sh

- name: Create github hosts file
run: | # If this file is not created, the dev container fails because of non-existent mount
mkdir -p ~/.config/gh
touch ~/.config/gh/hosts.yml
- name: Set up Python
shell: bash
run: uv python install

- name: Pre-build dev container image
uses: devcontainers/[email protected]
with:
runCmd: |
inv types
- name: Run static type checks
shell: bash
run: make types
12 changes: 1 addition & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,4 @@ repos:
]
types_or: [ python, pyi, jupyter ]
- id: ruff-format
types_or: [ python, pyi, jupyter ]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml

- repo: https://github.com/repo-helper/pyproject-parser
rev: v0.7.0
hooks:
- id: check-pyproject
types_or: [ python, pyi, jupyter ]
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
"python.testing.pytestEnabled": true,
"python.analysis.typeCheckingMode": "standard",
"python.analysis.diagnosticMode": "workspace",
"restructuredtext.pythonRecommendation.disabled": true,
}
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM python:3.9
ENV UV_SYSTEM_PYTHON=true
COPY --from=ghcr.io/astral-sh/uv:0.4.0 /uv /bin/uv

RUN apt-get update && apt-get install -y curl

# NVM and NPM are required for Graphite
# NVM and NPM are required for pyright
# Install nvm
# Explicitly set HOME environment variable
ENV NVM_DIR=$HOME/.nvm
Expand All @@ -19,17 +21,10 @@ RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | b
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH


# Install graphite (PR stacking), experimental, can be deleted without notice
RUN npm install -g @withgraphite/graphite-cli@stable

# Install lefthook (git hooks, e.g. pre-commit)
RUN curl -1sLf 'https://dl.cloudsmith.io/public/evilmartians/lefthook/setup.deb.sh' | bash
RUN apt install lefthook

# Set the working directory to /app
WORKDIR /app
VOLUME psycop-common

COPY . /app
RUN --mount=type=cache,target=/root/.cache/pip pip install .
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync
Loading

0 comments on commit 057a1a9

Please sign in to comment.