Skip to content

Commit afcc575

Browse files
committed
fixes formatting
1 parent bc51469 commit afcc575

File tree

6 files changed

+384
-663
lines changed

6 files changed

+384
-663
lines changed

commit0/cli.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33
from typing import Union, List
44
from typing_extensions import Annotated
5+
import commit0.harness.batch_run_pytest_ids
56
import commit0.harness.run_pytest_ids
67
import commit0.harness.get_pytest_ids
78
import commit0.harness.build
@@ -300,6 +301,49 @@ def test(
300301
)
301302

302303

304+
@commit0_app.command()
305+
def batch_test(
306+
test_ids: str = typer.Argument(
307+
None,
308+
help='All ways pytest supports to run and select tests. Please provide a single string. Example: "test_mod.py", "testing/", "test_mod.py::test_func", "-k \'MyClass and not method\'"',
309+
),
310+
backend: str = typer.Option("modal", help="Backend to use for testing"),
311+
timeout: int = typer.Option(1800, help="Timeout for tests in seconds"),
312+
num_cpus: int = typer.Option(1, help="Number of CPUs to use"),
313+
reference: Annotated[
314+
bool, typer.Option("--reference", help="Test the reference commit")
315+
] = False,
316+
coverage: Annotated[
317+
bool, typer.Option("--coverage", help="Whether to get coverage information")
318+
] = False,
319+
rebuild: bool = typer.Option(
320+
False, "--rebuild", help="Whether to rebuild an image"
321+
),
322+
commit0_config_file: str = typer.Option(
323+
".commit0.yaml",
324+
help="Path to the commit0 dot file, where the setup config is stored",
325+
),
326+
verbose: int = typer.Option(
327+
1,
328+
"--verbose",
329+
"-v",
330+
help="Set this to 2 for more logging information",
331+
count=True,
332+
),
333+
) -> None:
334+
"""Run tests on a Commit0 repository."""
335+
commit0.harness.batch_run_pytest_ids.main(
336+
test_ids,
337+
reference,
338+
coverage,
339+
backend,
340+
timeout,
341+
num_cpus,
342+
rebuild,
343+
verbose,
344+
)
345+
346+
303347
@commit0_app.command()
304348
def evaluate(
305349
branch: Union[str, None] = typer.Option(

commit0/harness/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def extract_code_blocks(text: str) -> List[str]:
239239
from the text.
240240
241241
"""
242-
pattern = r"```python\n(.*?)```"
242+
pattern = r'(?s)```(?:python|py)?(.*?)```'
243243
matches = re.finditer(pattern, text, re.DOTALL)
244244
return [match.group(1).strip() for match in matches]
245245

examples/star/inference.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from typing import Dict, List
22
from datasets import Dataset
33
from vllm import LLM, SamplingParams
44
from examples.star.utils import generate_prompt, cleanup
@@ -28,14 +28,14 @@ def generate_predictions(
2828
sampling_params = SamplingParams(n=n, temperature=temperature, max_tokens=512)
2929
llm = LLM(model=model_name)
3030

31-
prompts: List[str] = []
31+
prompts: List[List[Dict]] = []
3232
for example in dataset:
3333
prompt = example["prompt"]
3434
test = example["test"]
3535
prompt = generate_prompt(prompt, test)
36-
prompts.append(prompt)
36+
prompts.append([{"role": "user", "content": prompt}])
3737

38-
outputs = llm.generate(prompts, sampling_params)
38+
outputs = llm.chat(prompts, sampling_params)
3939

4040
results: List[List[str]] = []
4141
for output in outputs:

examples/star/run.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
python examples/star/star.py \
22
--model_name_or_path meta-llama/Llama-3.1-8B-Instruct \
33
--dataset_name commit0/mbpp \
4-
-n 10 \
4+
-n 16 \
55
--output_dir outputs \
66
--low_cpu_mem_usage \
77
--with_tracking \
88
--report_to wandb \
99
--iteration 5 \
1010
--learning_rate 1e-6 \
1111
--per_device_train_batch_size 1 \
12-
--gradient_accumulation_steps 8 \
13-
--max_workers 64
12+
--gradient_accumulation_steps 128 \
13+
--max_workers 64 \
14+
--temperature 1
1415

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ packages = ["commit0", "agent"]
3636
agent = [
3737
"import-deps>=0.3.0",
3838
"PyMuPDF>=1.24.5",
39-
"aider-chat",
39+
#"aider-chat>=0.69.1",
4040
]
4141
example = [
42-
"vllm",
43-
"transformers",
42+
"vllm==0.6.5",
43+
"transformers>=4.47.1",
4444
"setuptools",
4545
"accelerate",
4646
"wandb>=0.19.0",
47+
"openai>=1.58.1",
4748
]
4849

4950
[project.urls]

0 commit comments

Comments
 (0)