Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG VARIANT="3.11-bookworm"
# INFO, full list of python devcontainers available:
# https://mcr.microsoft.com/v2/vscode/devcontainers/python/tags/list
FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}

ENV PATH="/home/vscode/.local/bin:${PATH}"
54 changes: 54 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.11-bookworm"
}
},
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/workspaces/tutorial-group-1/.venv/bin/python",
"python.terminal.activateEnvironment": true,
"python.testing.pytestArgs": [
"tests"
],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.pytestPath": "/workspaces/tutorial-group-1/.venv/bin/pytest"
},
"extensions": [
"bierner.markdown-mermaid",
"charliermarsh.ruff",
"EditorConfig.EditorConfig",
"github.vscode-github-actions",
"ms-toolsai.jupyter",
"ms-toolsai.jupyter-keymap",
"ms-toolsai.jupyter-renderers",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.vscode-jupyter-cell-tags",
"ms-toolsai.vscode-jupyter-slideshow",
"ms-vsliveshare.vsliveshare",
"ryanluker.vscode-coverage-gutters"
]
}
},
"forwardPorts": [
8888
],
"portsAttributes": {
"8888": {
"label": "Jupyter Notebook"
}
},
"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'",
"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",
"remoteUser": "root",
"features": {
"git": "latest",
"github-cli": "latest"
}
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Linting
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
lint:
name: Linting (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ['3.11']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install -e .[dev]
# Install PyTorch CPU-only version for CI
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
- name: Linting with pre-commit
run: pre-commit run --all-files
57 changes: 57 additions & 0 deletions .github/workflows/render-notebook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Render Notebook to HTML

on:
push:
branches:
- main
paths:
- 'notebooks/tutorial_few_shot_learning.ipynb'
pull_request:
branches:
- main
paths:
- 'notebooks/tutorial_few_shot_learning.ipynb'
workflow_dispatch:

permissions:
contents: write

jobs:
render:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install nbconvert jupyter

- name: Convert notebook to HTML
run: |
jupyter nbconvert \
--to html \
notebooks/tutorial_few_shot_learning.ipynb \
--output tutorial_few_shot_learning.html \
--output-dir docs/

# Only commit on push to main, NOT on PRs
- name: Commit rendered HTML
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add docs/tutorial_few_shot_learning.html
if ! git diff --staged --quiet; then
git commit -m "Auto-render notebook to HTML [skip ci]"
git push
else
echo "No changes to commit"
fi
153 changes: 153 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Byte-compiled / optimized / DLL files
__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

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# 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

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__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/
52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# pre-commit: A framework for managing and maintaining multi-language pre-commit hooks
# after configuration is complete, do these steps:
# pre-commit install
# pre-commit run --all-files
# to skip pre-commmit-config when git-committing in terminal, add this: "--no-verify" option.

ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: mixed-line-ending
- id: name-tests-test
args: [--pytest-test-first]
# pygrep-hooks: a collection of fast, cheap, regex based pre-commit hooks
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-no-log-warn
- id: python-no-eval
exclude: ^src/few_shot_utils/(train|evaluate)\.py$
- id: rst-directive-colons
- id: rst-inline-touching-normal
# check-manifest: This makes sense only if you have MANIFEST.in (TODO:review)
- repo: https://github.com/mgedmin/check-manifest
rev: "0.47"
hooks:
- id: check-manifest
stages: [manual]
# pip audit to check for known pip vulnerabilities, supports pyproject.toml
- repo: https://github.com/pypa/pip-audit
rev: v2.7.1
hooks:
- id: pip-audit
#Ruff linter and formatter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.2
hooks:
# Recommended to run linter first of automatic fixes are enabled (as some linting fixes might require reformatting)
- id: ruff
#Automatic linting fixes
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
- id: ruff-format
types_or: [ python, pyi, jupyter ]
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files.trimTrailingWhitespace": true,
"git.autofetch": true,
"[jsonc]": {"editor.defaultFormatter": "vscode.json-language-features"},
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": false
},
"[jupyter]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
Loading