Skip to content

Commit 9cd53e9

Browse files
committed
updating Docker containers. Synthesis now working on tiny set. starting large scale runs.
1 parent 8b41ed2 commit 9cd53e9

10 files changed

Lines changed: 677 additions & 180 deletions

scratch/context_registry.json

Lines changed: 0 additions & 47 deletions
This file was deleted.

scratch/notebooks/collect_perf_commits.ipynb

Lines changed: 349 additions & 16 deletions
Large diffs are not rendered by default.

scratch/notebooks/compare_benchmarks.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": null,
5+
"execution_count": 1,
66
"id": "7d96c171",
77
"metadata": {},
88
"outputs": [
@@ -631,7 +631,7 @@
631631
"name": "python",
632632
"nbconvert_exporter": "python",
633633
"pygments_lexer": "ipython3",
634-
"version": "3.13.5"
634+
"version": "3.12.11"
635635
}
636636
},
637637
"nbformat": 4,

scratch/scripts/initialize_context_registry.py

Lines changed: 87 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo
2424
# REPO_ROOT="$ROOT_PATH"
2525
# TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}"
26+
# EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}"
2627
# if [[ -z "${TARGET_VERSIONS}" ]]; then
2728
# echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2
2829
# exit 1
@@ -109,8 +110,11 @@
109110
# micromamba run -n "$ENV_NAME" pip install -e . scipy matplotlib
110111

111112
# # Editable install (no build isolation preferrably). Toolchain lives in the env already.
113+
# # $EXTRAS is an optional argument to install all discovered extra dependencies.
114+
# # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies].
115+
# # In case setup.py is used, no need to append $EXTRAS.
112116
# log "Editable install with --no-build-isolation"
113-
# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"
117+
# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS
114118

115119
# # Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1)
116120
# log "Running smoke checks"
@@ -141,6 +145,7 @@
141145
ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo
142146
REPO_ROOT="$ROOT_PATH"
143147
TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}"
148+
EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}"
144149
if [[ -z "${TARGET_VERSIONS}" ]]; then
145150
echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2
146151
exit 1
@@ -226,8 +231,11 @@
226231
micromamba run -n "$ENV_NAME" pip install meson-python cython
227232
228233
# Editable install (no build isolation preferrably). Toolchain lives in the env already.
234+
# $EXTRAS is an optional argument to install all discovered extra dependencies.
235+
# It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies].
236+
# In case setup.py is used, no need to append $EXTRAS.
229237
log "Editable install with --no-build-isolation"
230-
PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"
238+
PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS
231239
232240
# Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1)
233241
log "Running smoke checks"
@@ -258,6 +266,7 @@
258266
ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo
259267
REPO_ROOT="$ROOT_PATH"
260268
TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}"
269+
EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}"
261270
if [[ -z "${TARGET_VERSIONS}" ]]; then
262271
echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2
263272
exit 1
@@ -344,8 +353,11 @@
344353
export CFLAGS="${CFLAGS:-} -Wno-error=incompatible-pointer-types"
345354
346355
# Editable install (no build isolation preferrably). Toolchain lives in the env already.
356+
# $EXTRAS is an optional argument to install all discovered extra dependencies.
357+
# It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies].
358+
# In case setup.py is used, no need to append $EXTRAS.
347359
log "Editable install with --no-build-isolation"
348-
PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"
360+
PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS
349361
350362
# Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1)
351363
log "Running smoke checks"
@@ -377,6 +389,7 @@
377389
ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo
378390
REPO_ROOT="$ROOT_PATH"
379391
TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}"
392+
EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}"
380393
if [[ -z "${TARGET_VERSIONS}" ]]; then
381394
echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2
382395
exit 1
@@ -469,8 +482,11 @@
469482
micromamba run -n "$ENV_NAME" python "${ROOT_PATH}/build_lib.py"
470483
471484
# Editable install (no build isolation preferrably). Toolchain lives in the env already.
485+
# $EXTRAS is an optional argument to install all discovered extra dependencies.
486+
# It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies].
487+
# In case setup.py is used, no need to append $EXTRAS.
472488
log "Editable install with --no-build-isolation"
473-
PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"
489+
PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS
474490
475491
# Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1)
476492
log "Running smoke checks"
@@ -503,6 +519,7 @@
503519
ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo
504520
REPO_ROOT="$ROOT_PATH"
505521
TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}"
522+
EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}"
506523
if [[ -z "${TARGET_VERSIONS}" ]]; then
507524
echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2
508525
exit 1
@@ -590,8 +607,11 @@
590607
fi
591608
592609
# Editable install (no build isolation preferrably). Toolchain lives in the env already.
610+
# $EXTRAS is an optional argument to install all discovered extra dependencies.
611+
# It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies].
612+
# In case setup.py is used, no need to append $EXTRAS.
593613
log "Editable install with --no-build-isolation"
594-
PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"
614+
PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS
595615
596616
# Health checks (import + compiled extension probe; optional pytest smoke with RUN_PYTEST_SMOKE=1)
597617
log "Running smoke checks"
@@ -624,6 +644,7 @@
624644
# ROOT_PATH=${ROOT_PATH:-$PWD} # Usually /workspace/repo
625645
# REPO_ROOT="$ROOT_PATH"
626646
# TARGET_VERSIONS="${PY_VERSION:-${ASV_PY_VERSIONS:-}}"
647+
# EXTRAS="${ALL_EXTRAS:+[$ALL_EXTRAS]}"
627648
# if [[ -z "${TARGET_VERSIONS}" ]]; then
628649
# echo "Error: No PY_VERSION set and ASV_PY_VERSIONS not found." >&2
629650
# exit 1
@@ -715,8 +736,11 @@
715736
# cd "$working_dir" || exit 1
716737
# else
717738
# # Editable install (no build isolation preferrably). Toolchain lives in the env already.
739+
# # $EXTRAS is an optional argument to install all discovered extra dependencies.
740+
# # It will be empty if pyproject.toml does not exist or has no [project.optional-dependencies].
741+
# # In case setup.py is used, no need to append $EXTRAS.
718742
# log "Editable install with --no-build-isolation"
719-
# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"
743+
# PIP_NO_BUILD_ISOLATION=1 micromamba run -n "$ENV_NAME" python -m pip install --no-build-isolation -v -e "$REPO_ROOT"$EXTRAS
720744
# fi
721745

722746

@@ -734,60 +758,60 @@
734758
# )
735759

736760

737-
# if __name__ == "__main__":
738-
# from pathlib import Path
739-
740-
# CONTEXT_REGISTRY.save_to_file(Path("scratch/context_registry_init.json"))
741-
# # for each context, build an image with the context.
742-
# import docker
743-
744-
# from datasmith.docker.context import ContextRegistry, DockerContext, Task
745-
746-
# client = docker.from_env()
747-
748-
# import concurrent.futures
749-
750-
# fails = dict()
751-
752-
# def build_context(task_context):
753-
# task, context = task_context
754-
# if not task.sha:
755-
# import requests
756-
757-
# resp = requests.get(f"https://api.github.com/repos/{task.owner}/{task.repo}")
758-
# resp.raise_for_status()
759-
# commit_sha = resp.json().get("default_branch", "main")
760-
# task = Task(owner=task.owner, repo=task.repo, sha=commit_sha, tag=task.tag)
761-
# print(f"Building image for {task.get_image_name()} at {task.sha}")
762-
# res = context.build_container_streaming(
763-
# client=client,
764-
# image_name=task.get_image_name(),
765-
# build_args={
766-
# "REPO_URL": f"https://www.github.com/{task.owner}/{task.repo}",
767-
# "COMMIT_SHA": task.sha, # pyright: ignore[reportArgumentType]
768-
# },
769-
# force=True,
770-
# timeout_s=1200,
771-
# pull=True,
772-
# )
773-
# return (task, res)
774-
775-
# with concurrent.futures.ProcessPoolExecutor() as executor:
776-
# futures = {executor.submit(build_context, item): item[0] for item in CONTEXT_REGISTRY.registry.items()}
777-
# for future in concurrent.futures.as_completed(futures):
778-
# task = futures[future]
779-
# try:
780-
# task, res = future.result()
781-
# if res.ok:
782-
# print(f"Built image {task.get_image_name()} successfully")
783-
# else:
784-
# print(f"Failed to build image {task.get_image_name()}")
785-
# fails[task] = res
786-
# except Exception as exc:
787-
# print(f"Exception building image {task.get_image_name()}: {exc}")
788-
# fails[task] = exc
789-
790-
# if fails:
791-
# import IPython
792-
793-
# IPython.embed()
761+
if __name__ == "__main__":
762+
from pathlib import Path
763+
764+
CONTEXT_REGISTRY.save_to_file(Path("scratch/context_registry_init.json"))
765+
# # for each context, build an image with the context.
766+
# import docker
767+
768+
# from datasmith.docker.context import ContextRegistry, DockerContext, Task
769+
770+
# client = docker.from_env()
771+
772+
# import concurrent.futures
773+
774+
# fails = dict()
775+
776+
# def build_context(task_context):
777+
# task, context = task_context
778+
# if not task.sha:
779+
# import requests
780+
781+
# resp = requests.get(f"https://api.github.com/repos/{task.owner}/{task.repo}")
782+
# resp.raise_for_status()
783+
# commit_sha = resp.json().get("default_branch", "main")
784+
# task = Task(owner=task.owner, repo=task.repo, sha=commit_sha, tag=task.tag)
785+
# print(f"Building image for {task.get_image_name()} at {task.sha}")
786+
# res = context.build_container_streaming(
787+
# client=client,
788+
# image_name=task.get_image_name(),
789+
# build_args={
790+
# "REPO_URL": f"https://www.github.com/{task.owner}/{task.repo}",
791+
# "COMMIT_SHA": task.sha, # pyright: ignore[reportArgumentType]
792+
# },
793+
# force=True,
794+
# timeout_s=1200,
795+
# pull=True,
796+
# )
797+
# return (task, res)
798+
799+
# with concurrent.futures.ProcessPoolExecutor() as executor:
800+
# futures = {executor.submit(build_context, item): item[0] for item in CONTEXT_REGISTRY.registry.items()}
801+
# for future in concurrent.futures.as_completed(futures):
802+
# task = futures[future]
803+
# try:
804+
# task, res = future.result()
805+
# if res.ok:
806+
# print(f"Built image {task.get_image_name()} successfully")
807+
# else:
808+
# print(f"Failed to build image {task.get_image_name()}")
809+
# fails[task] = res
810+
# except Exception as exc:
811+
# print(f"Exception building image {task.get_image_name()}: {exc}")
812+
# fails[task] = exc
813+
814+
# if fails:
815+
# import IPython
816+
817+
# IPython.embed()

scratch/scripts/synthesize_contexts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
configure_agent_backends(PORTKEY_MODEL_NAME="@anthropic/claude-3-5-sonnet-latest")
2222

2323
logger = configure_logging(level=10)
24-
# logger = configure_logging(level=10, stream=open(Path(__file__).with_suffix(".log"), "w"))
24+
# logger = configure_logging(level=10, stream=open(Path(__file__).with_suffix(".tiny.log"), "w"))
2525

2626

2727
def parse_args() -> argparse.Namespace:
@@ -178,13 +178,13 @@ def main(args: argparse.Namespace) -> None:
178178
for fut in as_completed(futures):
179179
res = fut.result()
180180
results.append(res)
181-
with _err_lock, open(args.output_dir / "results.jsonl", "a") as jf:
182-
jf.write(json.dumps(res) + "\n")
183-
184181
if int(res["rc"]) != 1:
185182
logger.info("main: SUCCESS %s/%s@%s", res["owner"], res["repo"], res["sha"])
186183
context_registry.save_to_file(path=args.context_registry)
187184

185+
with _err_lock, open(args.output_dir / "results.jsonl", "a") as jf:
186+
jf.write(json.dumps(res) + "\n")
187+
188188
# Rollup (minimal, quick to read)
189189
rollup = {
190190
r["image_name"]: {

0 commit comments

Comments
 (0)