Commit Graph

110 Commits

Author SHA1 Message Date
Danelegend f5201dbc69 . (#40) code-interpreter-0.4.2 2026-05-27 18:48:09 -07:00
Danelegend 9b435c8a6c feat(networking): Net admin configurablity (#39)
* .

* k8s vals

* Fix tests

* Clean up
2026-05-27 18:01:34 -07:00
Danelegend cae7c7940e Merge pull request #38 from onyx-dot-app/0.4.1
chore: Bump to 0.4.1
code-interpreter-0.4.1
2026-05-18 15:51:57 -07:00
Dane Urban dc84e0dda5 . 2026-05-18 15:43:32 -07:00
Danelegend 699e8a1f8a Merge pull request #37 from onyx-dot-app/dane/new-packages
feat: Add fpdf2, pypdf and python-docx
2026-05-18 15:19:24 -07:00
Danelegend f4deba2c77 Merge pull request #36 from civichero/fix/normalize-image-ref-digest-tag
fix(image-ref): preserve digest and tag refs in PYTHON_EXECUTOR_DOCKER_IMAGE
2026-05-18 15:18:04 -07:00
Dane Urban e2200d8223 . 2026-05-18 15:15:48 -07:00
Dane Urban 98ff1d2bd2 Add new packages for better pdf and docx capabilities 2026-05-18 15:01:46 -07:00
civichero f0c0ac8cff fix(image-ref): preserve digest and tag refs in PYTHON_EXECUTOR_DOCKER_IMAGE
`_ensure_docker_image_available` (app/main.py) and
`DockerExecutor.check_health` (app/services/executor_docker.py) both
unconditionally appended `:latest` to whatever value
`PYTHON_EXECUTOR_DOCKER_IMAGE` held. When an operator sets that env var
to a digest reference (e.g. `repo@sha256:abc...`) for reproducible
deploys, the resulting `repo@sha256:abc...:latest` is invalid Docker
syntax: image lookup fails, the FastAPI lifespan aborts, and the
container crashloops.

Refactor both call sites to use a new `normalize_image_ref` helper.
The helper returns the reference unchanged when it already carries a
tag (`:` after the last `/`) or a digest (`@`), and only appends
`:latest` for bare repositories. Registry ports are handled correctly
because a `:` before the last `/` is a port separator, not a tag.

Coverage added in tests/integration_tests/test_image_ref.py:

  * bare repo / namespaced repo / registry/repo all gain :latest
  * tagged refs unchanged at every nesting level
  * digest refs unchanged at every nesting level
  * registry-with-port variants (port + bare, port + tag, port + digest)
  * idempotence

Refs #35
2026-05-15 15:05:51 +02:00
Danelegend bd084c57ce Merge pull request #34 from onyx-dot-app/bump-0.4.0
chore(python-sandbox): Upgrade to 0.4.0
code-interpreter-0.4.0
2026-05-08 12:46:00 -07:00
Dane Urban f7f1aeea0d upgrade to 0.4.0 2026-05-08 12:39:36 -07:00
Danelegend eb7c26dbd5 Merge pull request #33 from onyx-dot-app/dane/health-version
feat(health): include service version in /health response
2026-05-06 14:32:40 -07:00
Dane Urban 5a05056087 . 2026-05-06 14:26:51 -07:00
Dane Urban 60a57c900b test(health): assert SERVICE_VERSION matches the Helm chart version
Catches drift between the Python package version (what /health reports
to clients) and the chart version (what's actually deployed). If they
get out of sync, a client gating on /health's version may try to use
features that aren't actually shipped.

Reads kubernetes/code-interpreter/Chart.yaml directly via a small regex
so the test has no extra dependencies.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 14:25:11 -07:00
Dane Urban 44bbde4983 chore: bump python packages to 0.3.3 to match helm chart
The helm chart at kubernetes/code-interpreter/Chart.yaml has been on
0.3.3 since #27, but both pyproject.toml files were still reporting
0.1.0. Now that /health surfaces the package version to clients, line
the pyproject versions up with the chart so a single number tracks
across artifacts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 14:25:11 -07:00
Dane Urban e48b412c0e feat(health): include service version in /health response
Clients can now read ``version`` from the ``/health`` payload to gate
calls to functionality that's only available in newer releases. The
value is sourced from the installed package metadata rather than a
hardcoded string, so the FastAPI app and the health response stay in
sync with the version declared in pyproject.toml.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 14:25:07 -07:00
Danelegend 8d21be9e98 Merge pull request #32 from onyx-dot-app/dane/bash
feat(bash): Add bash functionality
2026-05-06 13:51:23 -07:00
Dane Urban 1d2e375e10 . 2026-05-06 13:49:05 -07:00
Danelegend 74eb4945e6 Merge pull request #31 from onyx-dot-app/dane/ll-session-ttl
feat(sessions): TTL enforcement and crash-safe cleanup
2026-05-06 13:48:14 -07:00
Dane Urban 352cb5b918 style(executor_docker): use f-string for docker ps --format value
Replaces a string-concatenation expression with an f-string so the
Go-template format string can be read in one go. The doubled braces
(``{{{{`` / ``}}}}``) escape to literal ``{{`` / ``}}`` inside the
f-string, matching Docker's template syntax. Output is byte-identical
to the previous concatenation.

Addresses review feedback on PR #31.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 13:42:38 -07:00
Dane Urban a9cbd51fb5 feat(sessions): TTL enforcement and crash-safe cleanup
Sessions now carry an explicit TTL and are guaranteed to be torn down at
or before that deadline even if the API service crashes.

* CreateSessionRequest gains ``ttl_seconds`` (default 900s, max 24h);
  CreateSessionResponse adds the absolute ``expires_at`` timestamp.
* Docker session containers are launched with ``--rm`` and ``sleep <ttl>``
  so the container self-destructs at the deadline regardless of whether
  the API service is alive. The TTL also goes onto the container as the
  ``code-interpreter.expires-at`` label for the reaper.
* Kubernetes session pods set ``activeDeadlineSeconds=ttl`` so kubelet
  stops the executor container at the deadline; the deadline timestamp
  is also stored as a pod annotation so the reaper knows when to delete.
* A new background reaper task (in main.py's lifespan) runs once at
  startup — handling crash recovery for any sessions whose TTL elapsed
  while the service was down — and then every 30s thereafter.
* Both backends implement ``reap_expired_sessions`` (label-filtered
  list followed by per-session deletion) so the reaper is backend-agnostic.

Tests cover TTL bounds at the route layer, the active_deadline /
expires-at metadata on each backend, and reaper behavior under happy
path, missing annotation, invalid annotation, list failure, and partial
delete-failure scenarios.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 13:39:29 -07:00
Danelegend 2c2207f01f Merge pull request #30 from onyx-dot-app/dane/ll-session-create-delete
feat(sessions): long-lived session pods with manual lifecycle
2026-05-06 13:37:37 -07:00
Dane Urban e7b077a901 feat(sessions): long-lived session pods with manual lifecycle
Adds two new routes:

* POST /v1/sessions       creates a long-lived executor pod/container,
                          optionally pre-staging files from /v1/files.
* DELETE /v1/sessions/{id} tears the session down.

Both Docker and Kubernetes backends are supported. Sessions are labeled
``app=code-interpreter,component=session`` so they can be enumerated for
debugging, and named ``code-session-<uuid>`` so the delete path can
sanity-check that callers aren't accidentally targeting other resources.

Known limitation: this PR has no automatic cleanup. A session that the
caller forgets to DELETE will live for the configured idle window
(``SESSION_MAX_LIFETIME_SECONDS`` = 24h). The follow-up PR adds per-session
TTL enforcement plus a reaper for crash recovery.

Tests cover both backends and the route layer (success, 404 mapping,
501 mapping, file resolution, prefix-based safety check on delete).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-06 13:36:11 -07:00
Danelegend 977a1e4392 Merge pull request #29 from onyx-dot-app/dane/ll-session-refactor
refactor(executors): extract reusable primitives
2026-05-06 11:27:54 -07:00
Dane Urban 59fafdbf98 refactor(executors): extract reusable primitives for upcoming session work
Pure refactor - no behavior change. Existing test suite passes unmodified.

* `DockerExecutor._build_run_command` now takes `sleep_seconds` and an
  optional `labels` mapping, so future callers can spin up containers with
  custom durations and label sets.
* `DockerExecutor._create_tar_archive`'s `code` argument is now optional,
  letting callers stage files without an entrypoint.
* `_upload_tar_to_container` extracted from `_stage_files_in_container`
  for reuse.
* `KubernetesExecutor._create_pod_manifest` is parameterized over
  `command`, `labels`, `annotations`, and `active_deadline_seconds`.
* `KubernetesExecutor._create_tar_archive` mirrors the Docker change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 15:50:38 -07:00
Danelegend 54b9123898 Merge pull request #27 from onyx-dot-app/bump-0.3.3
chore: bump to 0.3.3
code-interpreter-0.3.3
2026-04-08 16:45:25 -07:00
Dane Urban d7df56d598 bump to 0.3.3 2026-04-08 16:42:58 -07:00
Danelegend 976bcb42e1 Merge pull request #25 from onyx-dot-app/iptable-block
fix(k8s): Block network traffic via iptables
2026-04-08 16:41:32 -07:00
Justin Tahara 0be4ab942e Merge pull request #26 from onyx-dot-app/revert-22-jtahara/enforce-strict-networking
Revert "fix(k8s): Locking down networking"
2026-04-08 16:40:57 -07:00
Justin Tahara 4ab5cc50a0 Revert "fix(k8s): Locking down networking" 2026-04-08 16:39:26 -07:00
Dane Urban 7ae4a0807a . 2026-04-08 15:21:18 -07:00
Dane Urban 9a5688a7a8 . 2026-04-08 15:11:13 -07:00
Dane Urban a0b5e5ff46 Add iptable block 2026-04-08 15:02:15 -07:00
Danelegend c43da3f01c Merge pull request #23 from onyx-dot-app/bump-0.3.2
chore: bump to 0.3.2
code-interpreter-0.3.2
2026-04-07 06:54:41 +10:00
Dane Urban 29c5ec7f7e bump 2026-04-06 13:47:47 -07:00
Danelegend 2c267d18b2 Merge pull request #21 from onyx-dot-app/fix-concurrent-streaming
fix(kubernetes): Concurrent request failures from shared ApiClient
2026-04-07 06:46:32 +10:00
Justin Tahara 4dbcaa2ef0 Merge pull request #22 from onyx-dot-app/jtahara/enforce-strict-networking
fix(k8s): Locking down networking
2026-04-06 13:27:15 -07:00
Dane Urban ac3300b2f6 . 2026-04-06 13:16:12 -07:00
justin-tahara f465446ced fix(k8s): Locking down networking 2026-04-06 13:16:03 -07:00
Dane Urban 8dc19e9355 Fix concurrent 2026-04-06 13:15:06 -07:00
Justin Tahara 12b808a4fb Merge pull request #20 from onyx-dot-app/fix/k8s-executor-cleanup
fix(k8s): Kubernetes executor pod cleanup
2026-03-20 10:34:17 -07:00
justin-tahara 73771678bf Fix executor_kubernetes typing 2026-03-19 13:40:18 -07:00
justin-tahara a64266260b Fix Kubernetes executor pod cleanup 2026-03-19 13:37:24 -07:00
Danelegend 53792b4eff Merge pull request #19 from onyx-dot-app/bump
chore: Bump to 0.3.1
code-interpreter-0.3.1
2026-03-02 15:20:53 -08:00
Dane Urban dbcd802e49 Bump to 0.3.1 2026-03-02 15:18:21 -08:00
Danelegend bbe245cf34 Merge pull request #18 from onyx-dot-app/kube_rbac
fix: kubernetes exectutor health check uses out-of-scope command
2026-02-27 16:01:25 -08:00
Dane Urban be36d9c2a9 . 2026-02-27 15:51:11 -08:00
Dane Urban c50c2f8c09 fix health issue 2026-02-27 10:59:47 -08:00
Dane Urban 962e3697fa fix 1 2026-02-27 10:52:55 -08:00
Danelegend 212e39213b Merge pull request #17 from onyx-dot-app/bump-2
chore: bump chart.yaml 0.3.0
code-interpreter-0.3.0
2026-02-24 10:45:39 -08:00