diff --git a/.github/workflows/codeflash.yaml b/.github/workflows/codeflash.yaml new file mode 100644 index 000000000..ffc993d86 --- /dev/null +++ b/.github/workflows/codeflash.yaml @@ -0,0 +1,43 @@ +name: Codeflash + +on: + pull_request: + paths: + # So that this workflow only runs when code within the target module is modified + - 'src/**' + workflow_dispatch: + +concurrency: + # Any new push to the PR will cancel the previous run, so that only the latest code is optimized + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + + +jobs: + optimize: + name: Optimize new Python code + # Don't run codeflash on codeflash-ai[bot] commits, prevent duplicate optimizations + if: ${{ github.actor != 'codeflash-ai[bot]' }} + runs-on: ubuntu-latest + env: + CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }} + CODEFLASH_PR_NUMBER: ${{ github.event.number }} + + steps: + - name: 🛎️ Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: 🐍 Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: 📦 Install Dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + poetry install --all-extras + - name: ⚡️Codeflash Optimization + run: | + poetry env use python + poetry run codeflash diff --git a/pyproject.toml b/pyproject.toml index 29f405a82..a189e27cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,12 +20,6 @@ openai-agents = { version = "<0.0.13", optional = true } galileo-core = "~=3.32.0" -[project.optional-dependencies] -langchain = ["langchain-core"] -openai = ["openai", "packaging (>=24.2,<25.0)", "openai-agents"] -all = ["langchain-core", "openai"] - - [tool.poetry.group.test.dependencies] pytest = "^8.3.5" coverage = "^7.2.3" @@ -55,11 +49,7 @@ mkdocstrings-python = "^1.10.8" griffe-fieldz = "^0.2.0" -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" -# Test. [tool.pytest.ini_options] pythonpath = ["./src/"] env = [ @@ -89,6 +79,7 @@ addopts = [ asyncio_default_fixture_loop_scope = "function" # Linters and formatters. + [tool.ruff] line-length = 120 fix = true @@ -110,6 +101,7 @@ split-on-trailing-comma = false [tool.ruff.lint.pydocstyle] convention = "numpy" + [tool.docformatter] style = "numpy" recursive = true @@ -126,6 +118,7 @@ follow_imports = "skip" plugins = ["pydantic.mypy"] # Release. + [tool.semantic_release] version_variables = ["src/galileo/__init__.py:__version__"] version_toml = ["pyproject.toml:project.version"] @@ -138,8 +131,31 @@ commit_message = "chore(release): v{version}\n\nAutomatically generated by pytho patch_tags = ["fix", "perf", "chore", "docs", "style", "refactor"] + [tool.coverage.run] omit = [ # ignore autogenerated code "./src/galileo/resources/*", ] + +[tool.codeflash] +# All paths are relative to this pyproject.toml's directory. +module-root = "src" +tests-root = "tests" +test-framework = "pytest" +benchmarks-root = "" +ignore-paths = [] +disable-telemetry = false +formatter-cmds = ["ruff check --exit-zero --fix $file", "ruff format $file"] + +[project.optional-dependencies] +langchain = ["langchain-core"] +openai = ["openai", "packaging (>=24.2,<25.0)", "openai-agents"] +all = ["langchain-core", "openai"] + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +# Test.