Skip to content

Make agent dependencies optional #95

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

Closed
wants to merge 10 commits into from
Closed
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
43 changes: 40 additions & 3 deletions .github/workflows/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ on:
branches: [main]

jobs:
system:
system-full:
name: Test Full Installation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -16,8 +17,8 @@ jobs:
run: uv venv --python 3.12
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Install the project
run: uv sync
- name: Install the project (full)
run: uv pip install -e .
- name: Set up commit0
run: uv run commit0 setup simpy
- name: Build docker images
Expand Down Expand Up @@ -45,3 +46,39 @@ jobs:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
run: |
uv run commit0 save test-save-commit0 master

system-core:
name: Test Core Installation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python
run: uv venv --python 3.12
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Install the project (core)
run: uv pip install -e .[core]
- name: Set up commit0
run: uv run commit0 setup simpy
- name: Build docker images
run: uv run commit0 build
- name: Get tests
run: uv run commit0 get-tests simpy
- name: Test
env:
MODAL_TOKEN_ID: ${{secrets.MODAL_TOKEN_ID}}
MODAL_TOKEN_SECRET: ${{secrets.MODAL_TOKEN_SECRET}}
run: |
uv run commit0 test simpy tests/test_event.py::test_succeed --reference --rebuild
uv run commit0 test simpy tests/test_event.py::test_succeed --reference
- name: Evaluate
env:
MODAL_TOKEN_ID: ${{secrets.MODAL_TOKEN_ID}}
MODAL_TOKEN_SECRET: ${{secrets.MODAL_TOKEN_SECRET}}
run: |
uv run commit0 evaluate --reference --rebuild
uv run commit0 evaluate --reference
- name: Lint
run: uv run commit0 lint commit0/harness/
18 changes: 18 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from hatchling.builders.hooks.plugin.interface import BuildHookInterface


class CustomBuildHook(BuildHookInterface):
def initialize(self, version: str, build_data: dict) -> None:
"""Add agent package if not installing core-only."""
# Handle both wheel and editable builds
for build_type in ["wheel", "editable"]:
if build_type not in build_data:
continue

for target in build_data[build_type].get("targets", []):
extras = target.get("options", {}).get("extras", [])
packages = target.get("packages", [])

if "core" not in extras and "commit0.optional.agent" not in packages:
packages.append("commit0.optional.agent")
target["packages"] = packages
1 change: 1 addition & 0 deletions commit0/commit0
Submodule commit0 added at a853f8
1 change: 1 addition & 0 deletions commit0/optional/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Optional packages for commit0."""
File renamed without changes.
2 changes: 1 addition & 1 deletion agent/__main__.py → commit0/optional/agent/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from agent.cli import agent_app
from commit0.optional.agent.cli import agent_app


def main() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from graphlib import TopologicalSorter, CycleError
import yaml

from agent.class_types import AgentConfig
from commit0.optional.agent.class_types import AgentConfig

PROMPT_HEADER = ">>> Here is the Task:\n"
REFERENCE_HEADER = "\n\n>>> Here is the Reference for you to finish the task:\n"
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions agent/cli.py → commit0/optional/agent/cli.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import typer
from agent.run_agent_no_rich import run_agent as run_agent_no_rich
from agent.run_agent import run_agent
from commit0.optional.agent.run_agent_no_rich import run_agent as run_agent_no_rich
from commit0.optional.agent.run_agent import run_agent
from commit0.harness.constants import RUN_AGENT_LOG_DIR
import subprocess
from agent.agent_utils import write_agent_config
from commit0.optional.agent.agent_utils import write_agent_config

agent_app = typer.Typer(
no_args_is_help=True,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions agent/run_agent.py → commit0/optional/agent/run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import multiprocessing
from datasets import load_dataset
from git import Repo
from agent.agent_utils import (
from commit0.optional.agent.agent_utils import (
create_branch,
get_message,
get_target_edit_files,
Expand All @@ -14,17 +14,17 @@
)
import json
import subprocess
from agent.agents import AiderAgents
from commit0.optional.agent.agents import AiderAgents
from typing import Optional, Type, cast
from types import TracebackType
from agent.class_types import AgentConfig
from commit0.optional.agent.class_types import AgentConfig
from commit0.harness.constants import SPLIT
from commit0.harness.get_pytest_ids import main as get_tests
from commit0.harness.constants import RUN_AGENT_LOG_DIR, RepoInstance
from commit0.cli import read_commit0_config_file
from pathlib import Path
from datetime import datetime
from agent.display import TerminalDisplay
from commit0.optional.agent.display import TerminalDisplay
import queue
import time

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from tqdm import tqdm
from datasets import load_dataset
from git import Repo
from agent.agent_utils import (
from commit0.optional.agent.agent_utils import (
create_branch,
get_message,
get_target_edit_files,
Expand All @@ -15,16 +15,16 @@
)
import subprocess
import json
from agent.agents import AiderAgents
from commit0.optional.agent.agents import AiderAgents
from typing import cast
from agent.class_types import AgentConfig
from commit0.optional.agent.class_types import AgentConfig
from commit0.harness.constants import SPLIT
from commit0.harness.get_pytest_ids import main as get_tests
from commit0.harness.constants import RUN_AGENT_LOG_DIR, RepoInstance
from commit0.cli import read_commit0_config_file
from pathlib import Path
from datetime import datetime
from agent.run_agent import DirContext, run_eval_after_each_commit
from commit0.optional.agent.run_agent import DirContext, run_eval_after_each_commit


def run_agent_for_repo(
Expand Down
24 changes: 20 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"pre-commit>=3.8.0",
"import-deps>=0.3.0",
"PyMuPDF>=1.24.5",
"modal==0.64.95",
"modal>=0.64.95",
"typer>=0.12.0",
"tenacity>=8.5.0",
"docker>=7.1.0",
Expand All @@ -30,13 +30,29 @@ classifiers = [

[project.scripts]
commit0 = "commit0.__main__:main"
agent = "agent.__main__:main"

[tool.hatch.build.targets.wheel]
packages = ["commit0", "agent"]
packages = ["commit0"]

[tool.hatch.build.targets.wheel.hooks.custom]
path = "build.py"

[project.optional-dependencies]
agent = []
core = [
"ruff>=0.6.4",
"pre-commit>=3.8.0",
"import-deps>=0.3.0",
"PyMuPDF>=1.24.5",
"modal>=0.64.95",
"typer>=0.12.0",
"tenacity>=8.5.0",
"docker>=7.1.0",
"fastcore>=1.7.8",
"ghapi>=1.0.6",
"gitpython>=3.1.43",
"pytest>=8.3.3",
"datasets==3.0.1",
]

[project.urls]
Homepage = "https://commit-0.github.io/"
Expand Down
51 changes: 47 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.