Skip to content

Commit 225303b

Browse files
authored
chore: cruft update (#71)
1 parent 246364a commit 225303b

16 files changed

+621
-586
lines changed

.cruft.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
{
2-
"template": "[email protected]:radix-ai/poetry-cookiecutter.git",
3-
"commit": "5abbc2191646a2082996a4e59b47b318859cc461",
2+
"template": "[email protected]:radix-ai/poetry-cookiecutter",
3+
"commit": "d789ff6aa6eebc31018020da4373e674d8c3b464",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
77
"package_name": "Graphchain",
88
"package_description": "An efficient cache for the execution of dask graphs.",
99
"package_url": "https://github.com/radix-ai/graphchain",
1010
"author_name": "Laurent Sorber",
11-
"author_email": "[email protected]",
11+
"author_email": "[email protected]",
12+
"python_version": "3.8",
1213
"with_fastapi_api": "0",
1314
"with_jupyter_lab": "0",
1415
"with_pydantic_typing": "0",
16+
"with_sentry_logging": "0",
1517
"with_streamlit_app": "0",
1618
"with_typer_cli": "0",
1719
"continuous_integration": "GitHub",
18-
"sentry_dsn": "",
19-
"sentry_org": "",
20-
"sentry_project": "",
2120
"private_package_repository_name": "",
2221
"private_package_repository_url": "",
23-
"_template": "[email protected]:radix-ai/poetry-cookiecutter.git"
22+
"_template": "[email protected]:radix-ai/poetry-cookiecutter"
2423
}
2524
},
2625
"directory": null
27-
}
26+
}

.devcontainer/devcontainer.json

+8-14
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"dockerComposeFile": "../docker-compose.yml",
44
"service": "dev",
55
"workspaceFolder": "/app/",
6-
"initializeCommand": "mkdir -p ${POETRY_CACHE_DIR:-~/Library/Caches/pypoetry/}",
7-
"onCreateCommand": "poe install",
6+
"initializeCommand": "ssh-add --apple-load-keychain || true",
7+
"overrideCommand": true,
8+
"postStartCommand": "cp --update /var/lib/poetry/poetry.lock /app/ && mkdir -p /app/.git/hooks/ && cp --update /var/lib/git/* /app/.git/hooks/",
89
"extensions": [
910
"bungcip.better-toml",
1011
"eamodio.gitlens",
@@ -16,35 +17,28 @@
1617
],
1718
"settings": {
1819
"coverage-gutters.coverageFileNames": [
19-
"reports/coverage.xml"
20+
"reports/coveragepy.xml"
2021
],
2122
"editor.codeActionsOnSave": {
2223
"source.organizeImports": true
2324
},
24-
"editor.formatOnPaste": false,
2525
"editor.formatOnSave": true,
2626
"editor.rulers": [
2727
100
2828
],
2929
"files.autoSave": "onFocusChange",
30-
"python.analysis.typeCheckingMode": "off",
31-
"python.defaultInterpreterPath": "/usr/local/bin/python",
30+
"python.defaultInterpreterPath": "/opt/app-env/bin/python",
3231
"python.formatting.provider": "black",
33-
"python.languageServer": "Pylance",
3432
"python.linting.flake8Enabled": true,
3533
"python.linting.mypyEnabled": true,
3634
"python.linting.pydocstyleEnabled": true,
3735
"python.linting.pylintEnabled": false,
3836
"python.terminal.activateEnvironment": false,
39-
"python.terminal.activateEnvInCurrentTerminal": false,
40-
"python.testing.nosetestsEnabled": false,
4137
"python.testing.pytestEnabled": true,
42-
"python.testing.unittestEnabled": false,
43-
"terminal.integrated.defaultProfile.linux": "fish",
44-
"terminal.integrated.inheritEnv": false,
38+
"terminal.integrated.defaultProfile.linux": "zsh",
4539
"terminal.integrated.profiles.linux": {
46-
"fish": {
47-
"path": "/usr/bin/fish"
40+
"zsh": {
41+
"path": "/usr/bin/zsh"
4842
}
4943
}
5044
}

.flake8

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
# TODO: https://github.com/PyCQA/flake8/issues/234
2-
# TODO: https://github.com/terrencepreilly/darglint/issues/130
1+
[flake8]
32
# http://flake8.pycqa.org/en/latest/user/configuration.html#project-configuration
43
# https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
5-
[flake8]
4+
# TODO: https://github.com/PyCQA/flake8/issues/234
5+
doctests = True
6+
ignore = B019,DAR103,E203,E501,FS003,S101,W503
67
max_line_length = 100
78
max_complexity = 10
9+
10+
# https://github.com/terrencepreilly/darglint#flake8
11+
# TODO: https://github.com/terrencepreilly/darglint/issues/130
812
docstring_style = numpy
9-
doctests = True
10-
ignore = DAR103,E203,E501,FS003,S101,W503
11-
strictness = long
13+
strictness = long

.github/dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ updates:
88
- package-ecosystem: pip
99
directory: /
1010
schedule:
11-
interval: weekly
11+
interval: monthly

.github/workflows/publish.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
steps:
1515

1616
- name: Checkout
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818

1919
- name: Set up Python
20-
uses: actions/setup-python@v2
20+
uses: actions/setup-python@v3
2121
with:
2222
python-version: "3.8"
2323

@@ -26,5 +26,5 @@ jobs:
2626

2727
- name: Publish package
2828
run: |
29-
poetry config http-basic.pypi "__token__" "${{ secrets.POETRY_PYPI_TOKEN_PYPI }}"
29+
poetry config pypi-token.pypi "${{ secrets.POETRY_PYPI_TOKEN_PYPI }}"
3030
poetry publish --build

.github/workflows/test.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ jobs:
2222
steps:
2323

2424
- name: Checkout
25-
uses: actions/checkout@v2
25+
uses: actions/checkout@v3
2626

2727
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v2
28+
uses: actions/setup-python@v3
2929
with:
3030
python-version: ${{ matrix.python-version }}
3131

3232
- name: Cache Python environment
33-
uses: actions/cache@v2
33+
uses: actions/cache@v3
3434
with:
35-
path: .venv
35+
path: .venv/
3636
key: venv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
3737

3838
- name: Install Poetry
@@ -50,6 +50,6 @@ jobs:
5050
run: poetry run poe test
5151

5252
- name: Upload coverage
53-
uses: codecov/codecov-action@v2
53+
uses: codecov/codecov-action@v3
5454
with:
5555
files: reports/coverage.xml

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ dist/
4646
# PyCharm
4747
.idea/
4848

49+
# pyenv
50+
.python-version
51+
4952
# pytest
5053
.pytest_cache/
5154

.pre-commit-config.yaml

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# https://pre-commit.com
2+
default_install_hook_types: [commit-msg, pre-commit]
23
default_stages: [commit, manual]
34
fail_fast: true
45
repos:
@@ -48,18 +49,18 @@ repos:
4849
require_serial: true
4950
language: system
5051
stages: [commit-msg]
51-
- id: isort
52-
name: isort
53-
entry: isort
54-
require_serial: true
55-
language: system
56-
types: [python]
5752
- id: pyupgrade
5853
name: pyupgrade
5954
entry: pyupgrade --py38-plus
6055
require_serial: true
6156
language: system
6257
types: [python]
58+
- id: isort
59+
name: isort
60+
entry: isort
61+
require_serial: true
62+
language: system
63+
types: [python]
6364
- id: black
6465
name: black
6566
entry: black
@@ -76,11 +77,6 @@ repos:
7677
entry: flake8
7778
language: system
7879
types: [python]
79-
- id: mypy
80-
name: mypy
81-
entry: mypy
82-
language: system
83-
types: [python]
8480
- id: pydocstyle
8581
name: pydocstyle
8682
entry: pydocstyle
@@ -92,3 +88,8 @@ repos:
9288
language: system
9389
files: pyproject.toml
9490
pass_filenames: false
91+
- id: mypy
92+
name: mypy
93+
entry: mypy
94+
language: system
95+
types: [python]

Dockerfile

+36-30
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
11
# syntax=docker/dockerfile:experimental
2-
3-
FROM python:3.8-slim AS dev
4-
5-
# Install development tools: compilers, curl, fish, git, ssh, and starship.
6-
RUN apt-get update && \
7-
apt-get install --no-install-recommends --yes build-essential curl git fish ssh && \
8-
chsh --shell /usr/bin/fish && \
9-
sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- "--yes" && \
10-
mkdir -p ~/.config/fish/completions/ && \
11-
echo "set fish_greeting" >> ~/.config/fish/config.fish && \
12-
echo "starship init fish | source" >> ~/.config/fish/config.fish && \
13-
rm -rf /var/lib/apt/lists/*
2+
FROM python:3.8-slim AS base
143

154
# Configure Python to print tracebacks on crash [1], and to not buffer stdout and stderr [2].
165
# [1] https://docs.python.org/3/using/cmdline.html#envvar-PYTHONFAULTHANDLER
176
# [2] https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUNBUFFERED
187
ENV PYTHONFAULTHANDLER 1
198
ENV PYTHONUNBUFFERED 1
209

10+
# Install Poetry.
11+
ENV POETRY_VERSION 1.1.13
12+
RUN --mount=type=cache,id=poetry,target=/root/.cache/ pip install poetry==$POETRY_VERSION
13+
14+
# Create and activate a virtual environment.
15+
RUN python -m venv /opt/app-env
16+
ENV PATH /opt/app-env/bin:$PATH
17+
ENV VIRTUAL_ENV /opt/app-env
18+
2119
# Set the working directory.
2220
WORKDIR /app/
2321

24-
# Install base development environment with Poetry and Poe the Poet.
25-
ENV PATH /root/.local/bin/:$PATH
26-
RUN --mount=type=cache,target=/root/.cache \
27-
pip install --no-input --upgrade pip poethepoet && \
28-
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - && \
29-
poetry config virtualenvs.create false && \
30-
poetry completions fish > ~/.config/fish/completions/poetry.fish && \
31-
poe _fish_completion > ~/.config/fish/completions/poe.fish
32-
33-
# Let Poe the Poet know it doesn't need to activate the Python environment.
34-
ENV POETRY_ACTIVE 1
22+
FROM base as dev
3523

36-
# Enable Poetry to publish to PyPI [1].
37-
# [1] https://pythonspeed.com/articles/build-secrets-docker-compose/
38-
ARG POETRY_PYPI_TOKEN_PYPI
39-
ENV POETRY_PYPI_TOKEN_PYPI $POETRY_PYPI_TOKEN_PYPI
24+
# Install development tools: compilers, curl, git, gpg, ssh, starship, vim, and zsh.
25+
RUN rm /etc/apt/apt.conf.d/docker-clean
26+
RUN --mount=type=cache,id=apt-cache,target=/var/cache/apt/ \
27+
--mount=type=cache,id=apt-lib,target=/var/lib/apt/ \
28+
apt-get update && \
29+
apt-get install --no-install-recommends --yes build-essential curl git gnupg ssh vim zsh zsh-antigen && \
30+
chsh --shell /usr/bin/zsh && \
31+
sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- "--yes" && \
32+
echo 'source /usr/share/zsh-antigen/antigen.zsh' >> ~/.zshrc && \
33+
echo 'antigen bundle zsh-users/zsh-autosuggestions' >> ~/.zshrc && \
34+
echo 'antigen apply' >> ~/.zshrc && \
35+
echo 'eval "$(starship init zsh)"' >> ~/.zshrc && \
36+
zsh -c 'source ~/.zshrc'
37+
38+
# Install the development Python environment.
39+
COPY .pre-commit-config.yaml poetry.lock* pyproject.toml /app/
40+
RUN --mount=type=cache,id=poetry,target=/root/.cache/ \
41+
mkdir -p src/graphchain/ && touch src/graphchain/__init__.py && touch README.md && \
42+
poetry install --no-interaction && \
43+
mkdir -p /var/lib/poetry/ && cp poetry.lock /var/lib/poetry/ && \
44+
git init && pre-commit install --install-hooks && \
45+
mkdir -p /var/lib/git/ && cp .git/hooks/commit-msg .git/hooks/pre-commit /var/lib/git/
4046

41-
FROM dev as ci
47+
FROM base as ci
4248

43-
# Install the Python environment.
49+
# Install the run time Python environment.
4450
# TODO: Replace `--no-dev` with `--without test` when Poetry 1.2.0 is released.
4551
COPY poetry.lock pyproject.toml /app/
46-
RUN --mount=type=cache,target=/root/.cache \
52+
RUN --mount=type=cache,id=poetry,target=/root/.cache/ \
4753
mkdir -p src/graphchain/ && touch src/graphchain/__init__.py && touch README.md && \
4854
poetry install --no-dev --no-interaction

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ with dask.config.set(scheduler='sync', delayed_optimize=graphchain.optimize):
163163
result.compute(location='s3://mybucket/__graphchain_cache__')
164164
```
165165

166+
## Contributing
167+
168+
1. Clone this repository.
169+
2. Start a [Dev Container](https://code.visualstudio.com/docs/remote/containers) in your preferred development environment:
170+
- _VS Code_: open the cloned repository and run <kbd>⌘</kbd> + <kbd>⇧</kbd> + <kbd>P</kbd> → _Remote-Containers: Reopen in Container_.
171+
- _PyCharm_: open the cloned repository and [configure Docker Compose as a remote interpreter](https://www.jetbrains.com/help/pycharm/using-docker-compose-as-a-remote-interpreter.html#docker-compose-remote).
172+
- _Terminal_: open the cloned repository and run `docker compose run --rm dev` to start an interactive Dev Container.
173+
166174
## Developed by Radix
167175

168176
[Radix](https://radix.ai) is a Belgium-based Machine Learning company.

docker-compose.yml

+16-14
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@ version: "3.9"
33
services:
44
dev:
55
build:
6-
args:
7-
POETRY_PYPI_TOKEN_PYPI: $POETRY_PYPI_TOKEN_PYPI
86
context: .
97
target: dev
10-
command: [ "sleep", "infinity" ]
8+
stdin_open: true
9+
tty: true
10+
entrypoint: []
11+
command:
12+
[
13+
"sh",
14+
"-c",
15+
"cp --update /var/lib/poetry/poetry.lock /app/ && mkdir -p /app/.git/hooks/ && cp --update /var/lib/git/* /app/.git/hooks/ && zsh"
16+
]
1117
environment:
18+
- POETRY_PYPI_TOKEN_PYPI
1219
- SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
1320
volumes:
14-
# app
15-
- .:/app/:cached
16-
# env
17-
- ${POETRY_CACHE_DIR:-~/Library/Caches/pypoetry/}:/root/.cache/pypoetry/:cached
18-
- graphchain-env:/usr/local/
19-
# git
20-
- ~/.gitconfig:/etc/gitconfig:cached
21-
# ssh
22-
- ${SSH_AGENT_AUTH_SOCK:-/run/host-services/ssh-auth.sock}:/run/host-services/ssh-auth.sock:cached
23-
- ~/.ssh/known_hosts:/root/.ssh/known_hosts:cached
21+
- .:/app/
22+
- app-env:/opt/app-env/
23+
- ~/.gitconfig:/etc/gitconfig
24+
- ~/.ssh/known_hosts:/root/.ssh/known_hosts
25+
- ${SSH_AGENT_AUTH_SOCK:-/run/host-services/ssh-auth.sock}:/run/host-services/ssh-auth.sock
2426

2527
volumes:
26-
graphchain-env:
28+
app-env:

0 commit comments

Comments
 (0)