Skip to content

Commit 931fa7a

Browse files
authored
Merge pull request #62 from grok-ai/develop
Version 0.2.0
2 parents 969c36f + e8cad1e commit 931fa7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3520
-946
lines changed

.env.template

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/publish_docs.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish docs
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
build:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
python-version: ['3.9']
14+
include:
15+
- os: ubuntu-20.04
16+
label: linux-64
17+
prefix: /usr/share/miniconda3/envs/
18+
19+
name: ${{ matrix.label }}-py${{ matrix.python-version }}
20+
runs-on: ${{ matrix.os }}
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v1
29+
30+
- name: Install Dependencies
31+
shell: bash -l {0}
32+
run: |
33+
pip install cookiecutter mkdocs mkdocs-material mike
34+
35+
# extract the first two digits from the release note
36+
- name: Set release notes tag
37+
run: |
38+
export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }}
39+
echo "RELEASE_TAG_VERSION=${RELEASE_TAG_VERSION%.*}">> $GITHUB_ENV
40+
41+
- name: Echo release notes tag
42+
run: |
43+
echo "${RELEASE_TAG_VERSION}"
44+
45+
- name: Build docs website
46+
shell: bash -l {0}
47+
run: |
48+
git config user.name ci-bot
49+
git config user.email ci-bot@ci.com
50+
mike deploy --push --rebase --update-aliases ${RELEASE_TAG_VERSION} latest

.github/workflows/test_suite.yml

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
name: Test Suite
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
9+
pull_request:
10+
types:
11+
- opened
12+
- reopened
13+
- synchronize
14+
15+
env:
16+
CACHE_NUMBER: 3 # increase to reset cache manually
17+
CONDA_ENV_FILE: 'env.yaml'
18+
CONDA_ENV_NAME: 'project-test'
19+
COOKIECUTTER_PROJECT_NAME: 'project-test'
20+
21+
jobs:
22+
build:
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
python-version: ['3.8', '3.9']
28+
include:
29+
- os: ubuntu-20.04
30+
label: linux-64
31+
prefix: /usr/share/miniconda3/envs/
32+
33+
# - os: macos-latest
34+
# label: osx-64
35+
# prefix: /Users/runner/miniconda3/envs/$CONDA_ENV_NAME
36+
37+
# - os: windows-latest
38+
# label: win-64
39+
# prefix: C:\Miniconda3\envs\$CONDA_ENV_NAME
40+
41+
name: ${{ matrix.label }}-py${{ matrix.python-version }}
42+
runs-on: ${{ matrix.os }}
43+
44+
steps:
45+
- name: Parametrize conda env name
46+
run: echo "PY_CONDA_ENV_NAME=${{ env.CONDA_ENV_NAME }}-${{ matrix.python-version }}" >> $GITHUB_ENV
47+
- name: echo conda env name
48+
run: echo ${{ env.PY_CONDA_ENV_NAME }}
49+
50+
- name: Parametrize conda prefix
51+
run: echo "PY_PREFIX=${{ matrix.prefix }}${{ env.PY_CONDA_ENV_NAME }}" >> $GITHUB_ENV
52+
- name: echo conda prefix
53+
run: echo ${{ env.PY_PREFIX }}
54+
55+
- name: Define generated project files paths
56+
run: |
57+
echo "PROJECT_SETUPCFG_FILE=${{ env.COOKIECUTTER_PROJECT_NAME }}/setup.cfg" >> $GITHUB_ENV
58+
echo "PROJECT_CONDAENV_FILE=${{ env.COOKIECUTTER_PROJECT_NAME }}/${{ env.CONDA_ENV_FILE }}" >> $GITHUB_ENV
59+
echo "PROJECT_PRECOMMIT_FILE=${{ env.COOKIECUTTER_PROJECT_NAME }}/.pre-commit-config.yaml" >> $GITHUB_ENV
60+
61+
- uses: actions/checkout@v2
62+
63+
# COOKIECUTTER GENERATION
64+
- name: Set up Python
65+
uses: actions/setup-python@v1
66+
67+
- name: Install Dependencies
68+
shell: bash -l {0}
69+
run: |
70+
pip install cookiecutter
71+
72+
- name: Generate Repo
73+
shell: bash -l {0}
74+
run: |
75+
echo -e 'n\nn\nn\n' | cookiecutter . --no-input project_name=${{ env.COOKIECUTTER_PROJECT_NAME }}
76+
77+
- name: Init git into generated repo
78+
shell: bash -l {0}
79+
run: |
80+
git config --global user.name ci-bot
81+
git config --global user.email ci-bot@ci.com
82+
git init
83+
git add --all
84+
git commit -m "Initial commit"
85+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
86+
87+
- name: Define cache key postfix
88+
run: |
89+
echo "CACHE_KEY_POSTFIX=${{ matrix.label }}-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}-${{ env.PY_CONDA_ENV_NAME }}-${{ hashFiles(env.PROJECT_CONDAENV_FILE) }}-${{ hashFiles(env.PROJECT_SETUPCFG_FILE) }}" >> $GITHUB_ENV
90+
91+
- name: Echo cache keys
92+
run: |
93+
echo ${{ env.PROJECT_SETUPCFG_FILE }}
94+
echo ${{ env.PROJECT_CONDAENV_FILE }}
95+
echo ${{ env.PROJECT_PRECOMMIT_FILE }}
96+
echo ${{ env.CACHE_KEY_POSTFIX }}
97+
98+
# GENERATED PROJECT CI/CD
99+
100+
# Remove the python version pin from the env.yml which could be inconsistent
101+
- name: Remove explicit python version from the environment
102+
shell: bash -l {0}
103+
run: |
104+
sed -Ei '/^\s*-?\s*python\s*([#=].*)?$/d' ${{ env.CONDA_ENV_FILE }}
105+
cat ${{ env.CONDA_ENV_FILE }}
106+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
107+
108+
- name: Setup Mambaforge
109+
uses: conda-incubator/setup-miniconda@v2
110+
with:
111+
miniforge-variant: Mambaforge
112+
miniforge-version: latest
113+
activate-environment: ${{ env.PY_CONDA_ENV_NAME }}
114+
python-version: ${{ matrix.python-version }}
115+
use-mamba: true
116+
117+
- uses: actions/cache@v2
118+
name: Conda cache
119+
with:
120+
path: ${{ env.PY_PREFIX }}
121+
key: conda-${{ env.CACHE_KEY_POSTFIX }}
122+
id: conda_cache
123+
124+
- uses: actions/cache@v2
125+
name: Pip cache
126+
with:
127+
path: ~/.cache/pip
128+
key: pip-${{ env.CACHE_KEY_POSTFIX }}
129+
130+
- uses: actions/cache@v2
131+
name: Pre-commit cache
132+
with:
133+
path: ~/.cache/pre-commit
134+
key: pre-commit-${{ hashFiles(env.PROJECT_PRECOMMIT_FILE) }}-conda-${{ env.CACHE_KEY_POSTFIX }}
135+
136+
# Ensure the hack for the python version worked
137+
- name: Ensure we have the right Python
138+
shell: bash -l {0}
139+
run: |
140+
echo "Installed Python: $(python --version)"
141+
echo "Expected: ${{ matrix.python-version }}"
142+
python --version | grep "Python ${{ matrix.python-version }}"
143+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
144+
145+
# https://stackoverflow.com/questions/70520120/attributeerror-module-setuptools-distutils-has-no-attribute-version
146+
# https://github.com/pytorch/pytorch/pull/69904
147+
- name: Downgrade setuptools due to a but in PyTorch 1.10.1
148+
shell: bash -l {0}
149+
run: |
150+
pip install setuptools==59.5.0 --upgrade
151+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
152+
153+
- name: Update conda environment
154+
run: mamba env update -n ${{ env.PY_CONDA_ENV_NAME }} -f ${{ env.CONDA_ENV_FILE }}
155+
if: steps.conda_cache.outputs.cache-hit != 'true'
156+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
157+
158+
# Update pip env whether or not there was a conda cache hit
159+
- name: Update pip environment
160+
shell: bash -l {0}
161+
run: pip install -e ".[dev]"
162+
if: steps.conda_cache.outputs.cache-hit == 'true'
163+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
164+
165+
- run: pip3 list
166+
shell: bash -l {0}
167+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
168+
169+
- run: mamba info
170+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
171+
172+
- run: mamba list
173+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
174+
175+
# Ensure the hack for the python version worked
176+
- name: Ensure we have the right Python
177+
shell: bash -l {0}
178+
run: |
179+
echo "Installed Python: $(python --version)"
180+
echo "Expected: ${{ matrix.python-version }}"
181+
python --version | grep "Python ${{ matrix.python-version }}"
182+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
183+
184+
- name: Run pre-commits
185+
shell: bash -l {0}
186+
run: |
187+
pre-commit install
188+
pre-commit run -v --all-files --show-diff-on-failure
189+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}
190+
191+
- name: Test with pytest
192+
shell: bash -l {0}
193+
run: |
194+
pytest -v
195+
working-directory: ${{ env.COOKIECUTTER_PROJECT_NAME }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
wandb
2+
multirun.yaml
3+
storage
4+
5+
# ignore the _version.py file
6+
_version.py
17

28
# .gitignore defaults for python and pycharm
39
.idea

0 commit comments

Comments
 (0)