Skip to content

Commit b249146

Browse files
committed
Merge remote-tracking branch 'upstream/main' into model-kwargs-hf
2 parents 430e92b + 4144afa commit b249146

File tree

344 files changed

+61165
-2379
lines changed

Some content is hidden

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

344 files changed

+61165
-2379
lines changed

.devcontainer/devcontainer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"customizations": {
3+
"vscode": {
4+
"extensions": [
5+
"ms-vscode-remote.vscode-remote-extensionpack",
6+
"charliermarsh.ruff",
7+
"ms-azuretools.vscode-docker",
8+
"ms-toolsai.jupyter",
9+
"ms-python.mypy-type-checker",
10+
"ms-vsliveshare.vsliveshare",
11+
"ms-python.python",
12+
"eamodio.gitlens",
13+
"github.vscode-pull-request-github"
14+
],
15+
"settings": {
16+
"git.autofetch": true,
17+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
18+
"python.testing.pytestEnabled": true,
19+
"terminal.integrated.defaultProfile.linux": "zsh"
20+
}
21+
}
22+
},
23+
"features": {
24+
"ghcr.io/devcontainers-contrib/features/tmux-apt-get:1": {},
25+
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
26+
"omzPlugins": "https://github.com/zsh-users/zsh-syntax-highlighting.git https://github.com/zsh-users/zsh-autosuggestions.git",
27+
"plugins": "zsh-syntax-highlighting zsh-autosuggestions"
28+
},
29+
"ghcr.io/devcontainers/features/git:1": {},
30+
"ghcr.io/devcontainers/features/github-cli:1": {},
31+
"ghcr.io/schlich/devcontainer-features/powerlevel10k:1": {}
32+
},
33+
"image": "mcr.microsoft.com/devcontainers/python:3.9",
34+
"name": "Python 3",
35+
"postCreateCommand": "chmod +x ./.devcontainer/post_create.sh && ./.devcontainer/post_create.sh"
36+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from rich.console import Console
2+
from rich.text import Text
3+
4+
text = Text()
5+
console = Console()
6+
7+
text.append(
8+
"Be sure to check that you have the Poetry Python interpreter selected in VSCode otherwise"
9+
" your terminal will not include the necessary packages to develop. If you have the correct interpreter"
10+
" configured, you'll see an interpreter that looks like this: ",
11+
style="bold yellow",
12+
)
13+
text.append("3.9.18 ('.venv': Poetry)", style="code")
14+
text.append(
15+
". If you have previously selected another Python interpreter for the VSCode workspace, you may need to select"
16+
" the Poetry Python interpreter.\n\nTo do so, follow the instructions at the following link and choose the Poetry"
17+
" virtual environment interpreter.",
18+
style="bold yellow",
19+
)
20+
21+
console.print(text)
22+
console.print(
23+
"VSCode Python Interpreter Documentation\n",
24+
style="link https://code.visualstudio.com/docs/python/environments#_working-with-python-interpreters",
25+
)

.devcontainer/post_create.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
set -e # Exit immediately if a command exits with a non-zero status.
4+
5+
git config --global --add safe.directory /workspaces/dspy
6+
7+
pip install poetry==1.7.1
8+
poetry config installer.max-workers 4
9+
poetry config virtualenvs.in-project true
10+
11+
poetry install --with dev
12+
13+
sudo apt update
14+
sudo apt-get -y install python3-distutils
15+
16+
poetry run pre-commit install --install-hooks
17+
18+
personalization_script="./.devcontainer/.personalization.sh"
19+
20+
# Developers can place a personalization script in the location specified above
21+
# to further customize their dev container
22+
if [ -f "$personalization_script" ]; then
23+
echo "File $personalization_script exists. Running the script..."
24+
chmod +x "$personalization_script"
25+
$personalization_script
26+
fi
27+
28+
chmod +x ./.devcontainer/interpreter_warning.py && poetry run python ./.devcontainer/interpreter_warning.py
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## 📝 Changes Description
2+
3+
This MR/PR contains the following changes:
4+
...
5+
6+
## ✅ Contributor Checklist
7+
8+
- [] Pre-Commit checks are passing (locally and remotely)
9+
- [] Title of your PR / MR corresponds to the required format
10+
- [] Commit message follows required format {label}(dspy): {message}
11+
12+
## ⚠️ Warnings
13+
14+
Anything we should be aware of ?
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Pre-commit checks
2+
on:
3+
workflow_dispatch:
4+
5+
jobs:
6+
pre-commit-checks:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: Set up Python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: "3.9"
14+
cache: "pip"
15+
- name: Check Pull Request Title
16+
uses: Slashgear/action-check-pr-title@main
17+
with:
18+
regexp: '(break|build|ci|docs|feat|fix|perf|refactor|style|test|ops|hotfix|release|maint|init|enh|revert)\([a-z,A-Z,0-9,\-,\_,\/,:]+\)(:)\s{1}([\w\s]+)' # Regex the title should match.
19+
- name: Getting changed files list
20+
id: files
21+
uses: jitterbit/get-changed-files@master
22+
- name: Checking changed files
23+
shell: bash
24+
run: |
25+
echo "Changed files"
26+
echo ${{ steps.files.outputs.all }}
27+
echo "Github Client version"
28+
echo $(gh --version)
29+
- name: Pre-Commit Checks
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install pre-commit
33+
echo "Running pre-commit scans:"
34+
# adding log display in case of pre-commit errors
35+
pre-commit run -v --files ${{ steps.files.outputs.all }}
36+
shell: bash

.github/workflows/run_tests.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: Lint, Test, and Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
10+
env:
11+
POETRY_VERSION: "1.7.1"
12+
13+
jobs:
14+
fix:
15+
name: Check Ruff Fix
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-python@v5
23+
- name: Ruff Fix Attempt
24+
id: ruff_fix
25+
uses: chartboost/ruff-action@v1
26+
with:
27+
args: --fix-only --exit-non-zero-on-fix
28+
continue-on-error: true
29+
30+
- name: Fail Workflow if Ruff Fix Failed
31+
if: steps.ruff_fix.outcome == 'failure'
32+
run: |
33+
echo "Ruff fix failed, failing the workflow."
34+
echo "Please run 'ruff check . --fix-only' locally and push the changes."
35+
exit 1
36+
37+
test:
38+
name: Run Tests
39+
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
python-version: ["3.9"]
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Load cached Poetry installation
46+
id: cached-poetry
47+
uses: actions/cache@v3
48+
with:
49+
path: ~/.local
50+
key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
51+
- name: Install Poetry
52+
if: steps.cached-poetry.outputs.cache-hit != 'true'
53+
uses: snok/install-poetry@v1
54+
- name: Set up python ${{ matrix.python-version }}
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: ${{ matrix.python-version }}
58+
cache: "poetry"
59+
- name: Install dependencies
60+
run: poetry install --no-interaction
61+
- name: Run lint with tests
62+
uses: chartboost/ruff-action@v1
63+
with:
64+
args: --fix-only
65+
- name: Run tests with pytest
66+
run: poetry run pytest tests/
67+
68+
build_poetry:
69+
name: Build Poetry
70+
runs-on: ubuntu-latest
71+
strategy:
72+
matrix:
73+
python-version: ["3.9"]
74+
steps:
75+
- uses: actions/checkout@v4
76+
- name: Load cached Poetry installation
77+
id: cached-poetry
78+
uses: actions/cache@v3
79+
with:
80+
path: ~/.local
81+
key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
82+
- name: Install Poetry
83+
if: steps.cached-poetry.outputs.cache-hit != 'true'
84+
uses: snok/install-poetry@v1
85+
- name: Set up python ${{ matrix.python-version }}
86+
uses: actions/setup-python@v5
87+
with:
88+
python-version: ${{ matrix.python-version }}
89+
cache: "poetry"
90+
- name: Build
91+
run: poetry build
92+
- name: Install built package
93+
run: python -m pip install dist/*.whl
94+
- name: Test import dspy
95+
run: python -c "import dspy"
96+
- name: Test import dsp
97+
run: python -c "import dsp"
98+
99+
build_setup:
100+
name: Build Setup
101+
runs-on: ubuntu-latest
102+
strategy:
103+
matrix:
104+
python-version: ["3.9"]
105+
steps:
106+
- uses: actions/checkout@v4
107+
- name: Load cached Poetry installation
108+
id: cached-poetry
109+
uses: actions/cache@v3
110+
with:
111+
path: ~/.local
112+
key: poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
113+
- name: Install Poetry
114+
if: steps.cached-poetry.outputs.cache-hit != 'true'
115+
uses: snok/install-poetry@v1
116+
- name: Set up python ${{ matrix.python-version }}
117+
uses: actions/setup-python@v5
118+
with:
119+
python-version: ${{ matrix.python-version }}
120+
cache: "poetry"
121+
- name: Run setup.py build
122+
run: python setup.py build

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ __pycache__/
1313
*.py[cod]
1414
*$py.class
1515

16+
# Vim
17+
*.swp
18+
1619
# Jupyter Notebook
1720
.ipynb_checkpoints
1821
# notebooks/
@@ -40,3 +43,7 @@ finetuning_ckpts/
4043
# cache/
4144
* copy*
4245
.idea
46+
assertion.log
47+
*.log
48+
*.db
49+
/.devcontainer/.personalization.sh

.pre-commit-config.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
default_language_version:
2+
python: python3.9
3+
4+
default_stages: [commit]
5+
default_install_hook_types: [pre-commit, commit-msg]
6+
7+
repos:
8+
- repo: https://github.com/astral-sh/ruff-pre-commit
9+
rev: v0.1.11
10+
hooks:
11+
- id: ruff
12+
args: [--fix]
13+
- id: ruff-format
14+
15+
- repo: https://github.com/timothycrosley/isort
16+
rev: 5.12.0
17+
hooks:
18+
- id: isort
19+
args:
20+
[
21+
"--profile=black",
22+
"--py=39",
23+
"--line-length=120",
24+
"--multi-line=3",
25+
"--trailing-comma",
26+
"--force-grid-wrap=0",
27+
"--use-parentheses",
28+
"--ensure-newline-before-comments",
29+
"--project=CORE,src,config,preprocess,train,transform,main,model",
30+
]
31+
32+
- repo: https://github.com/pre-commit/pre-commit-hooks
33+
rev: v4.1.0
34+
hooks:
35+
- id: check-yaml
36+
args: ["--allow-multiple-documents", "--unsafe"]
37+
- id: end-of-file-fixer
38+
- id: trailing-whitespace
39+
- id: check-docstring-first
40+
- id: check-toml
41+
- id: check-added-large-files
42+
args: ["--maxkb=1024"]
43+
- id: requirements-txt-fixer
44+
- id: check-merge-conflict
45+
- id: debug-statements
46+
- id: pretty-format-json
47+
args:
48+
- "--autofix"
49+
- "--indent=2"
50+
51+
- repo: local
52+
hooks:
53+
- id: validate-commit-msg
54+
name: Commit Message is Valid
55+
language: pygrep
56+
entry: ^(break|build|ci|docs|feat|fix|perf|refactor|style|test|ops|hotfix|release|maint|init|enh|revert)\([\w,\.,\-,\(,\),\/]+\)(!?)(:)\s{1}([\w,\W,:]+)
57+
stages: [commit-msg]
58+
args: [--negate]
59+
60+
- repo: https://github.com/pre-commit/mirrors-prettier
61+
rev: v3.0.3
62+
hooks:
63+
- id: prettier
64+
additional_dependencies:
65+
- prettier@2.1.2
66+
- "@prettier/plugin-xml@0.12.0"

0 commit comments

Comments
 (0)