Skip to content

Isort #7828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft

Isort #7828

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name": "🏃", "description": "Run Docker container to upload Python distribution packages to PyPI", "inputs": {"user": {"description": "PyPI user", "required": false}, "password": {"description": "Password for your PyPI user or an access token", "required": false}, "repository-url": {"description": "The repository URL to use", "required": false}, "packages-dir": {"description": "The target directory for distribution", "required": false}, "verify-metadata": {"description": "Check metadata before uploading", "required": false}, "skip-existing": {"description": "Do not fail if a Python package distribution exists in the target package index", "required": false}, "verbose": {"description": "Show verbose output.", "required": false}, "print-hash": {"description": "Show hash values of files to be uploaded", "required": false}, "attestations": {"description": "[EXPERIMENTAL] Enable experimental support for PEP 740 attestations. Only works with PyPI and TestPyPI via Trusted Publishing.", "required": false}}, "runs": {"using": "docker", "image": "docker://ghcr.io/pypa/gh-action-pypi-publish:release-v1"}}
{"name": "🏃", "description": "Run Docker container to upload Python distribution packages to PyPI", "inputs": {"user": {"description": "PyPI user", "required": false}, "password": {"description": "Password for your PyPI user or an access token", "required": false}, "repository-url": {"description": "The repository URL to use", "required": false}, "packages-dir": {"description": "The target directory for distribution", "required": false}, "verify-metadata": {"description": "Check metadata before uploading", "required": false}, "skip-existing": {"description": "Do not fail if a Python package distribution exists in the target package index", "required": false}, "verbose": {"description": "Show verbose output.", "required": false}, "print-hash": {"description": "Show hash values of files to be uploaded", "required": false}, "attestations": {"description": "[EXPERIMENTAL] Enable experimental support for PEP 740 attestations. Only works with PyPI and TestPyPI via Trusted Publishing.", "required": false}}, "runs": {"using": "docker", "image": "docker://ghcr.io/pypa/gh-action-pypi-publish:release-v1"}}
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ body:
description: "Tell us your DSPy version."
validations:
required: true

20 changes: 10 additions & 10 deletions .github/workflow_scripts/install_testpypi_pkg.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
#!/bin/bash

# The $1 argument is the version number passed from the workflow
# The $1 argument is the version number passed from the workflow
VERSION=$1

echo "version: $VERSION"

for i in {1..5}; do
if python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple dspy-ai-test=="$VERSION"; then
break
else
echo "Attempt $i failed. Waiting before retrying..."
sleep 10
fi
done
for i in {1..5}; do
if python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple dspy-ai-test=="$VERSION"; then
break
else
echo "Attempt $i failed. Waiting before retrying..."
sleep 10
fi
done
82 changes: 41 additions & 41 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ on:
- "*"
jobs:

extract-tag:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract_tag.outputs.tag }}
steps:
extract-tag:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract_tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
- id: extract_tag
name: Extract tag name
run: echo "::set-output name=tag::$(echo $GITHUB_REF | cut -d / -f 3)"
- id: extract_tag
name: Extract tag name
run: echo "::set-output name=tag::$(echo $GITHUB_REF | cut -d / -f 3)"

build-and-publish-test-pypi:
needs: extract-tag
runs-on: ubuntu-latest
environment:
environment:
name: pypi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
Expand All @@ -32,34 +32,34 @@ jobs:
python-version: "3.9"
- name: Install dependencies
run: python3 -m pip install --upgrade setuptools wheel twine semver packaging
- name: Get correct version for TestPyPI release
id: check_version
run: |
VERSION=${{ needs.extract-tag.outputs.version }}
- name: Get correct version for TestPyPI release
id: check_version
run: |
VERSION=${{ needs.extract-tag.outputs.version }}
PACKAGE_NAME="dspy-ai-test"
echo "Checking if $VERSION for $PACKAGE_NAME exists on TestPyPI"
NEW_VERSION=$(python3 .github/workflows/build_utils/test_version.py $PACKAGE_NAME $VERSION)
echo "Version to be used for TestPyPI release: $NEW_VERSION"
echo "::set-output name=version::$NEW_VERSION"
echo "Checking if $VERSION for $PACKAGE_NAME exists on TestPyPI"
NEW_VERSION=$(python3 .github/workflows/build_utils/test_version.py $PACKAGE_NAME $VERSION)
echo "Version to be used for TestPyPI release: $NEW_VERSION"
echo "::set-output name=version::$NEW_VERSION"
- name: Update version in setup.py
run: sed -i '/#replace_package_version_marker/{n;s/__version__="[^"]*"/__version__="${{ steps.check_version.outputs.version }}"/;}' ./dspy/__metadata__.py
- name: Update version in pyproject.toml
run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ steps.check_version.outputs.version }}"/;}' pyproject.toml
run: sed -i '/#replace_package_version_marker/{n;s/version="[^"]*"/version="${{ steps.check_version.outputs.version }}"/;}' pyproject.toml
- name: Update package name in setup.py
run: sed -i '/#replace_package_name_marker/{n;s/__name__="[^"]*"/__name__="dspy-ai-test"/;}' ./dspy/__metadata__.py
- name: Update package name in pyproject.toml
run: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai-test"/;}' pyproject.toml
run: sed -i '/#replace_package_name_marker/{n;s/name="[^"]*"/name="dspy-ai-test"/;}' pyproject.toml
- name: Build a binary wheel
run: python3 setup.py sdist bdist_wheel
- name: Publish distribution 📦 to test-PyPI
uses: pypa/gh-action-pypi-publish@release/v1 # This requires a trusted publisher to be setup in pypi/testpypi
with:
with:
repository-url: https://test.pypi.org/legacy/

build-and-publish-pypi:
needs: [extract-tag, build-and-publish-test-pypi]
runs-on: ubuntu-latest
environment:
environment:
name: pypi
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
Expand All @@ -77,53 +77,53 @@ jobs:
- name: Update version in pyproject.toml
run: sed -i '/#replace_package_version_marker/{n;s/version *= *"[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' pyproject.toml
# Publish to dspy
- name: Update package name in setup.py
- name: Update package name in setup.py
run: |
sed -i '/#replace_package_name_marker/{n;s/__name__ *= *"[^"]*"/__name__="dspy"/;}' ./dspy/__metadata__.py
- name: Update package name in pyproject.toml
run: sed -i '/#replace_package_name_marker/{n;s/name *= *"[^"]*"/name="dspy"/;}' pyproject.toml
# Remove pyproject.toml temporarily to avoid conflicts
- name: Temporarily remove pyproject.toml
run: mv pyproject.toml pyproject.toml.bak
- name: Temporarily remove pyproject.toml
run: mv pyproject.toml pyproject.toml.bak
- name: Build a binary wheel
run: python3 setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI (dspy)
uses: pypa/gh-action-pypi-publish@release/v1 # This requires a trusted publisher to be setup in pypi
with:
with:
attestations: false
# Publish to dspy-ai
- name: Update version in setup.py (dspy-ai)
run: sed -i '/#replace_package_version_marker/{n;s/version *= *"[^"]*"/version="${{ needs.extract-tag.outputs.version }}"/;}' ./dspy/.internal_dspyai/setup.py
- name: Update package name in setup.py
- name: Update package name in setup.py
run: sed -i '/#replace_package_name_marker/{n;s/name *= *"[^"]*"/name="dspy-ai"/;}' ./dspy/.internal_dspyai/setup.py
- name: Update dspy dependency version in setup.py
- name: Update dspy dependency version in setup.py
run: |
sed -i '/#replace_dspy_version_marker/{n;s/dspy>=[^"]*/dspy>=${{ needs.extract-tag.outputs.version }}/;}' ./dspy/.internal_dspyai/setup.py
sed -i '/#replace_dspy_version_marker/{n;s/dspy>=[^"]*/dspy>=${{ needs.extract-tag.outputs.version }}/;}' ./dspy/.internal_dspyai/setup.py
- name: Build a binary wheel
run: python3 ./dspy/.internal_dspyai/setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI (dspy-ai)
uses: pypa/gh-action-pypi-publish@release/v1 # This requires a trusted publisher to be setup in pypi
with:
with:
attestations: false
# Restore pyproject.toml
- name: Restore pyproject.toml
run: mv pyproject.toml.bak pyproject.toml
- name: Restore pyproject.toml
run: mv pyproject.toml.bak pyproject.toml
- uses: stefanzweifel/git-auto-commit-action@v5 # auto commit changes to main
with:
commit_message: Update versions
create_branch: true
branch: release-${{ needs.extract-tag.outputs.version }}
- name: Checkout main branch
run: |
git fetch origin
git checkout main
- name: Checkout main branch
run: |
git fetch origin
git checkout main
- name: Configure git user
run: |
run: |
git config --global user.email "actions@github.com"
git config --global user.name "Github Actions"
- name: Merge release branch into main
run: |
git merge --no-ff release-${{ needs.extract-tag.outputs.version }}
- name: Merge release branch into main
run: |
git merge --no-ff release-${{ needs.extract-tag.outputs.version }}
- name: Push changes to main
run: |
git push origin main
run: |
git push origin main
48 changes: 24 additions & 24 deletions .github/workflows/build_utils/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@
from packaging.version import Version as PyPIVersion


def get_latest_version(package_name, tag_version):
def get_latest_version(package_name, tag_version):
# Returns latest version, and T/F as to whether it needs to be incremented
response = requests.get(f"https://test.pypi.org/pypi/{package_name}/json")
if response.status_code == 200:
data = response.json()
# Flatten the list of files for all releases and get the latest upload
all_uploads = [
(release['upload_time'], release['filename'], version)
for version, releases in data['releases'].items()
for release in releases
]
response = requests.get(f"https://test.pypi.org/pypi/{package_name}/json")
if response.status_code == 200:
data = response.json()
# Flatten the list of files for all releases and get the latest upload
all_uploads = [
(release['upload_time'], release['filename'], version)
for version, releases in data['releases'].items()
for release in releases
]
# If a release with tag_version does not exist, that is the latest version
# Then increment is False, as no need to increment the version
tag_release_exists = any(upload for upload in all_uploads if upload[2] == tag_version)
if not(tag_release_exists):
return tag_version, False
return tag_version, False
# Else, get the latest release version, and set increment to True
else:
# Sort all uploads by upload time in descending order
latest_upload = max(all_uploads, key=lambda x: datetime.fromisoformat(x[0].rstrip('Z')))
return latest_upload[2], True
latest_upload = max(all_uploads, key=lambda x: datetime.fromisoformat(x[0].rstrip('Z')))
return latest_upload[2], True

elif response.status_code == 404:
# If no existing releases can get a 404
return tag_version, False
return None, None
return None, None

def increment_version(curr_version):
pypi_v = PyPIVersion(curr_version)
if pypi_v.pre:
Expand All @@ -42,19 +42,19 @@ def increment_version(curr_version):
parsed_v = semver.Version(*pypi_v.release)
new_v = str(parsed_v.bump_prerelease())
return new_v
if __name__ == "__main__":
if len(sys.argv) != 3:
raise ValueError("Usage: python get_latest_testpypi_version.py <package_name> <tag_version>")

if __name__ == "__main__":
if len(sys.argv) != 3:
raise ValueError("Usage: python get_latest_testpypi_version.py <package_name> <tag_version>")

package_name = sys.argv[1]
tag_v = sys.argv[2]

latest_version, increment = get_latest_version(package_name, tag_v)
latest_version, increment = get_latest_version(package_name, tag_v)
if increment:
new_version = increment_version(latest_version)
else:
else:
new_version = latest_version

# Output new version
print(new_version)
print(new_version)
11 changes: 11 additions & 0 deletions .github/workflows/check_pr_title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Check PR Title
on: pull_request

jobs:
check-pr-title:
runs-on: ubuntu-latest
steps:
- name: Check PR Title
uses: Slashgear/action-check-pr-title@main
with:
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.
2 changes: 1 addition & 1 deletion .github/workflows/docs-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
destination-github-username: 'krypticmouse'
destination-repository-name: 'dspy-docs'
user-email: github-actions@github.com
target-branch: master
target-branch: master
41 changes: 24 additions & 17 deletions .github/workflows/precommits_check.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Pre-commit checks
on:
workflow_dispatch:
push:
branches:
- main
pull_request: ~
workflow_dispatch: ~

jobs:
pre-commit-checks:
Expand All @@ -12,25 +16,28 @@ jobs:
with:
python-version: "3.9"
cache: "pip"
- name: Check Pull Request Title
uses: Slashgear/action-check-pr-title@main
with:
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.
- name: Getting changed files list
id: files
uses: jitterbit/get-changed-files@master
- name: Checking changed files
shell: bash
run: |
echo "Changed files"
echo ${{ steps.files.outputs.all }}
echo "GitHub Client version"
echo $(gh --version)

- name: Pre-Commit Checks
run: |
python -m pip install --upgrade pip
pip install pre-commit
echo "Running pre-commit scans:"
# adding log display in case of pre-commit errors
pre-commit run -v --files ${{ steps.files.outputs.all }}

# Run hooks individually, until we can run them all at once

# isort
pre-commit run isort --all-files

# pre-commit-hooks
pre-commit run check-yaml --all-files
pre-commit run end-of-file-fixer --all-files
pre-commit run trailing-whitespace --all-files
pre-commit run check-docstring-first --all-files
pre-commit run check-toml --all-files
pre-commit run check-added-large-files --all-files
pre-commit run requirements-txt-fixer --all-files
pre-commit run check-merge-conflict --all-files
pre-commit run debug-statements --all-files
pre-commit run pretty-format-json --all-files

shell: bash
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ dummy.csv
docs/docs/**/*.json*
*.index
*.pkl
*.tar.gz
*.tar.gz
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v5.0.0
hooks:
- id: check-yaml
args: ["--allow-multiple-documents", "--unsafe"]
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.github/
.github/
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ If you're looking to understand the framework, please go to the [DSPy Docs at ds

If you're looking to understand the underlying research, this is a set of our papers:

**[Jun'24] [Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs](https://arxiv.org/abs/2406.11695)**
**[Oct'23] [DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines](https://arxiv.org/abs/2310.03714)**
[Jul'24] [Fine-Tuning and Prompt Optimization: Two Great Steps that Work Better Together](https://arxiv.org/abs/2407.10930)
[Jun'24] [Prompts as Auto-Optimized Training Hyperparameters](https://arxiv.org/abs/2406.11706)
[Feb'24] [Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models](https://arxiv.org/abs/2402.14207)
[Jan'24] [In-Context Learning for Extreme Multi-Label Classification](https://arxiv.org/abs/2401.12178)
[Dec'23] [DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines](https://arxiv.org/abs/2312.13382)
**[Jun'24] [Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs](https://arxiv.org/abs/2406.11695)**
**[Oct'23] [DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines](https://arxiv.org/abs/2310.03714)**
[Jul'24] [Fine-Tuning and Prompt Optimization: Two Great Steps that Work Better Together](https://arxiv.org/abs/2407.10930)
[Jun'24] [Prompts as Auto-Optimized Training Hyperparameters](https://arxiv.org/abs/2406.11706)
[Feb'24] [Assisting in Writing Wikipedia-like Articles From Scratch with Large Language Models](https://arxiv.org/abs/2402.14207)
[Jan'24] [In-Context Learning for Extreme Multi-Label Classification](https://arxiv.org/abs/2401.12178)
[Dec'23] [DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines](https://arxiv.org/abs/2312.13382)
[Dec'22] [Demonstrate-Search-Predict: Composing Retrieval & Language Models for Knowledge-Intensive NLP](https://arxiv.org/abs/2212.14024.pdf)

To stay up to date or learn more, follow [@lateinteraction](https://twitter.com/lateinteraction) on Twitter.
Expand All @@ -78,10 +78,9 @@ If you use DSPy or DSP in a research paper, please cite our work as follows:

<!-- You can also read more about the evolution of the framework from Demonstrate-Search-Predict to DSPy:

* [**DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines**](https://arxiv.org/abs/2312.13382) (Academic Paper, Dec 2023)
* [**DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines**](https://arxiv.org/abs/2310.03714) (Academic Paper, Oct 2023)
* [**DSPy Assertions: Computational Constraints for Self-Refining Language Model Pipelines**](https://arxiv.org/abs/2312.13382) (Academic Paper, Dec 2023)
* [**DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines**](https://arxiv.org/abs/2310.03714) (Academic Paper, Oct 2023)
* [**Releasing DSPy, the latest iteration of the framework**](https://twitter.com/lateinteraction/status/1694748401374490946) (Twitter Thread, Aug 2023)
* [**Releasing the DSP Compiler (v0.1)**](https://twitter.com/lateinteraction/status/1625231662849073160) (Twitter Thread, Feb 2023)
* [**Introducing DSP**](https://twitter.com/lateinteraction/status/1617953413576425472) (Twitter Thread, Jan 2023)
* [**Demonstrate-Search-Predict: Composing retrieval and language models for knowledge-intensive NLP**](https://arxiv.org/abs/2212.14024.pdf) (Academic Paper, Dec 2022) -->

Loading
Loading