Skip to content

Speed up AI container startup.#882

Merged
mtauraso merged 12 commits intomainfrom
codex/optimize-setup-scripts-for-performance
Apr 23, 2026
Merged

Speed up AI container startup.#882
mtauraso merged 12 commits intomainfrom
codex/optimize-setup-scripts-for-performance

Conversation

@mtauraso
Copy link
Copy Markdown
Collaborator

Motivation

  • Avoid installing Hyrax's full dependency set inside constrained agent/container environments by providing a prebuilt Python venv artifact.
  • Centralize and reuse a single environment artifact produced from main to ensure consistent dev dependencies across agent sessions.
  • Clean up older artifacts to prevent clutter and reduce storage/lookup ambiguity.

Description

  • Add GitHub Actions workflow /.github/workflows/build-agent-env-artifact.yml that sets up Python 3.11, creates a venv, runs pip install -e '.[dev]', runs pip check, packs the venv into a tarball, uploads it as artifact hyrax-agent-venv-main, and deletes older artifacts with the same name.
  • Update agent_scripts/claude_code_web_setup_container.sh to download the artifact zip via the GitHub Actions API, extract the contained tarball into a configurable VENV_DIR, activate the venv, and install the repo in editable dev mode; add set -euo pipefail and robust repo root detection.
  • Update agent_scripts/codex_setup_container.sh with the same artifact-download-and-extract flow, activation of the prebuilt venv, and set -euo pipefail, and make artifact repo/name and venv dir configurable via HYRAX_* env vars.
  • Remove previous local venv creation steps and direct pip installs in these scripts so they rely on the prebuilt artifact instead.

Testing

  • No automated tests were executed as part of this PR; CI has not been triggered by this change yet.
  • The new workflow includes a pip check step which will validate installed package dependencies when the workflow runs on CI.

Codex Task

Copilot AI review requested due to automatic review settings April 22, 2026 18:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a GitHub Actions workflow to build a reusable Python environment artifact for agent/container use, and updates agent container setup scripts to download and use that prebuilt venv instead of installing the full dependency set inside the container.

Changes:

  • Introduces a new workflow to build, pack, upload, and prune a “hyrax-agent-venv-main” artifact.
  • Updates Codex and Claude container setup scripts to download/extract the artifact into a configurable venv directory and then install Hyrax in editable mode.
  • Hardens the setup scripts with set -euo pipefail and more robust repo-root detection.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.

File Description
agent_scripts/codex_setup_container.sh Downloads/extracts a prebuilt venv artifact and installs Hyrax dev editable in the container.
agent_scripts/claude_code_web_setup_container.sh Same artifact-based venv bootstrap flow for Claude Code container setup.
.github/workflows/build-agent-env-artifact.yml New workflow to build and publish the prebuilt venv artifact and delete older artifacts with the same name.

Comment thread agent_scripts/claude_code_web_setup_container.sh
Comment thread agent_scripts/claude_code_web_setup_container.sh Outdated
Comment thread .github/workflows/build-agent-env-artifact.yml
Comment on lines +23 to +31
ARTIFACT_ID=$(curl -fsSL "https://api.github.com/repos/${ARTIFACT_REPO}/actions/artifacts?per_page=100" | jq -r ".artifacts[] | select(.name == \"${ARTIFACT_NAME}\") | .id" | head -n1)
curl -fsSL "https://api.github.com/repos/${ARTIFACT_REPO}/actions/artifacts/${ARTIFACT_ID}/zip" -o /tmp/hyrax-agent-venv.zip

rm -rf "$VENV_DIR"
mkdir -p "$VENV_DIR"
rm -rf /tmp/hyrax-agent-venv
unzip -q /tmp/hyrax-agent-venv.zip -d /tmp/hyrax-agent-venv
TARBALL_PATH=$(find /tmp/hyrax-agent-venv -name '*.tar.gz' | head -n1)
tar -xzf "$TARBALL_PATH" -C "$VENV_DIR"
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the artifact name can't be resolved to an ID (or the zip doesn't contain a .tar.gz), ARTIFACT_ID/TARBALL_PATH will be empty and the script will fail later without context. Add explicit validation after computing ARTIFACT_ID and TARBALL_PATH with a clear error message before proceeding.

Copilot uses AI. Check for mistakes.
Comment thread agent_scripts/claude_code_web_setup_container.sh Outdated
Comment thread .github/workflows/build-agent-env-artifact.yml Outdated
Comment thread .github/workflows/build-agent-env-artifact.yml
Comment thread agent_scripts/codex_setup_container.sh
Comment thread agent_scripts/codex_setup_container.sh Outdated
Comment thread agent_scripts/codex_setup_container.sh Outdated
@mtauraso mtauraso marked this pull request as draft April 22, 2026 18:43
@mtauraso mtauraso self-assigned this Apr 22, 2026
mtauraso and others added 7 commits April 22, 2026 12:15
1. Download: curl was forwarding the GitHub Bearer token to the Azure
   Blob Storage redirect target, causing 503. Fix by extracting the
   signed redirect URL first (without following it), then downloading
   from Azure without auth headers.

2. Activation: script called `conda info --base` and `conda activate`,
   but conda is not installed in the Claude Code web environment. The
   packed env is self-contained — use `source "$ENV_DIR/bin/activate"`
   instead.

https://claude.ai/code/session_012Xfp2h6KyrbZ3VXL3jRj2b

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.71%. Comparing base (a377f71) to head (401d327).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #882   +/-   ##
=======================================
  Coverage   66.71%   66.71%           
=======================================
  Files          63       63           
  Lines        6553     6553           
=======================================
  Hits         4372     4372           
  Misses       2181     2181           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mtauraso mtauraso changed the title Build and publish prebuilt agent venv artifact; update container setup scripts to consume it Speed up AI container startup. Apr 22, 2026
* Restrict env artifact workflow to main and add setup docs

* Document internet and domain allow-list requirements

* Condense allow-list instructions for web providers
@mtauraso mtauraso marked this pull request as ready for review April 22, 2026 23:05
@mtauraso mtauraso requested a review from drewoldag April 22, 2026 23:06
Copy link
Copy Markdown
Collaborator

@drewoldag drewoldag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty cool, can we use the packed conda environment for anything else? build-docs, or pre-commit? I suppose the risk is that the deps have changed and the packed venv might be out of date with pre-commit or build-docs?

Either way, this part seems quite useful.

@mtauraso mtauraso merged commit eb92a01 into main Apr 23, 2026
8 checks passed
@mtauraso mtauraso deleted the codex/optimize-setup-scripts-for-performance branch April 23, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants