Skip to content

Commit ecd8266

Browse files
Merge pull request #4 from hertie-data-science-lab/elena-setup
Set up first repository structure
2 parents e387867 + 912e6a3 commit ecd8266

26 files changed

Lines changed: 10441 additions & 37 deletions

.DS_Store

6 KB
Binary file not shown.

.devcontainer/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ARG VARIANT="3.11-bookworm"
2+
# INFO, full list of python devcontainers available:
3+
# https://mcr.microsoft.com/v2/vscode/devcontainers/python/tags/list
4+
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}
5+
6+
ENV PATH="/home/vscode/.local/bin:${PATH}"

.devcontainer/devcontainer.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "Python 3",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "..",
6+
"args": {
7+
"VARIANT": "3.11-bookworm"
8+
}
9+
},
10+
"customizations": {
11+
"vscode": {
12+
"settings": {
13+
"python.defaultInterpreterPath": "/workspaces/tutorial-group-1/.venv/bin/python",
14+
"python.terminal.activateEnvironment": true,
15+
"python.testing.pytestArgs": [
16+
"tests"
17+
],
18+
"python.testing.pytestEnabled": true,
19+
"python.testing.unittestEnabled": false,
20+
"python.testing.pytestPath": "/workspaces/tutorial-group-1/.venv/bin/pytest"
21+
},
22+
"extensions": [
23+
"bierner.markdown-mermaid",
24+
"charliermarsh.ruff",
25+
"EditorConfig.EditorConfig",
26+
"github.vscode-github-actions",
27+
"ms-toolsai.jupyter",
28+
"ms-toolsai.jupyter-keymap",
29+
"ms-toolsai.jupyter-renderers",
30+
"ms-python.python",
31+
"ms-python.vscode-pylance",
32+
"ms-toolsai.vscode-jupyter-cell-tags",
33+
"ms-toolsai.vscode-jupyter-slideshow",
34+
"ms-vsliveshare.vsliveshare",
35+
"ryanluker.vscode-coverage-gutters"
36+
]
37+
}
38+
},
39+
"forwardPorts": [
40+
8888
41+
],
42+
"portsAttributes": {
43+
"8888": {
44+
"label": "Jupyter Notebook"
45+
}
46+
},
47+
"updateContentCommand": "git config --global --add safe.directory /workspaces/tutorial-group-1; make create_venv; echo 'NOTE: PyTorch is NOT installed by default. To install PyTorch (CPU-only), run: source .venv/bin/activate && make install-torch'",
48+
"postCreateCommand": "echo 'source /workspaces/tutorial-group-1/.venv/bin/activate' >> ~/.bashrc; echo 'echo -e \"\\n⚠️ IMPORTANT: PyTorch is not installed by default due to size constraints.\"' >> ~/.bashrc; echo 'echo \"To install PyTorch (CPU-only ~730MB), run:\"' >> ~/.bashrc; echo 'echo \" source .venv/bin/activate && make install-torch\"' >> ~/.bashrc",
49+
"remoteUser": "root",
50+
"features": {
51+
"git": "latest",
52+
"github-cli": "latest"
53+
}
54+
}

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.github/workflows/main.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Linting
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
lint:
15+
name: Linting (Python ${{ matrix.python-version }})
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: true
19+
matrix:
20+
python-version: ['3.11']
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Install dependencies
29+
run: |
30+
python3 -m pip install --upgrade pip
31+
pip install -e .[dev]
32+
# Install PyTorch CPU-only version for CI
33+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
34+
- name: Linting with pre-commit
35+
run: pre-commit run --all-files
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Render Notebook to HTML
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'notebooks/tutorial_few_shot_learning.ipynb'
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- 'notebooks/tutorial_few_shot_learning.ipynb'
14+
workflow_dispatch:
15+
16+
permissions:
17+
contents: write
18+
19+
jobs:
20+
render:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.11'
31+
32+
- name: Install dependencies
33+
run: |
34+
python3 -m pip install --upgrade pip
35+
pip install nbconvert jupyter
36+
37+
- name: Convert notebook to HTML
38+
run: |
39+
jupyter nbconvert \
40+
--to html \
41+
notebooks/tutorial_few_shot_learning.ipynb \
42+
--output tutorial_few_shot_learning.html \
43+
--output-dir docs/
44+
45+
# Only commit on push to main, NOT on PRs
46+
- name: Commit rendered HTML
47+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
48+
run: |
49+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
50+
git config --local user.name "github-actions[bot]"
51+
git add docs/tutorial_few_shot_learning.html
52+
if ! git diff --staged --quiet; then
53+
git commit -m "Auto-render notebook to HTML [skip ci]"
54+
git push
55+
else
56+
echo "No changes to commit"
57+
fi

.gitignore

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/

.pre-commit-config.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# pre-commit: A framework for managing and maintaining multi-language pre-commit hooks
2+
# after configuration is complete, do these steps:
3+
# pre-commit install
4+
# pre-commit run --all-files
5+
# to skip pre-commmit-config when git-committing in terminal, add this: "--no-verify" option.
6+
7+
ci:
8+
autoupdate_commit_msg: "chore: update pre-commit hooks"
9+
autofix_commit_msg: "style: pre-commit fixes"
10+
11+
repos:
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v4.5.0
14+
hooks:
15+
- id: check-added-large-files
16+
- id: check-case-conflict
17+
- id: check-merge-conflict
18+
- id: check-symlinks
19+
- id: mixed-line-ending
20+
- id: name-tests-test
21+
args: [--pytest-test-first]
22+
# pygrep-hooks: a collection of fast, cheap, regex based pre-commit hooks
23+
- repo: https://github.com/pre-commit/pygrep-hooks
24+
rev: v1.10.0
25+
hooks:
26+
- id: python-no-log-warn
27+
- id: python-no-eval
28+
exclude: ^src/few_shot_utils/(train|evaluate)\.py$
29+
- id: rst-directive-colons
30+
- id: rst-inline-touching-normal
31+
# check-manifest: This makes sense only if you have MANIFEST.in (TODO:review)
32+
- repo: https://github.com/mgedmin/check-manifest
33+
rev: "0.47"
34+
hooks:
35+
- id: check-manifest
36+
stages: [manual]
37+
# pip audit to check for known pip vulnerabilities, supports pyproject.toml
38+
- repo: https://github.com/pypa/pip-audit
39+
rev: v2.7.1
40+
hooks:
41+
- id: pip-audit
42+
#Ruff linter and formatter
43+
- repo: https://github.com/astral-sh/ruff-pre-commit
44+
rev: v0.8.2
45+
hooks:
46+
# Recommended to run linter first of automatic fixes are enabled (as some linting fixes might require reformatting)
47+
- id: ruff
48+
#Automatic linting fixes
49+
types_or: [ python, pyi, jupyter ]
50+
args: [ --fix ]
51+
- id: ruff-format
52+
types_or: [ python, pyi, jupyter ]

.vscode/settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"files.trimTrailingWhitespace": true,
3+
"git.autofetch": true,
4+
"[jsonc]": {"editor.defaultFormatter": "vscode.json-language-features"},
5+
"[python]": {
6+
"editor.defaultFormatter": "charliermarsh.ruff",
7+
"editor.formatOnSave": false
8+
},
9+
"[jupyter]": {
10+
"editor.defaultFormatter": "charliermarsh.ruff"
11+
}
12+
}

0 commit comments

Comments
 (0)