Skip to content

models: update_custom + delete_custom, fix add/remove filter#169

Merged
m-peko merged 3 commits into
mainfrom
dstepanov/sdk-custom-models
May 15, 2026
Merged

models: update_custom + delete_custom, fix add/remove filter#169
m-peko merged 3 commits into
mainfrom
dstepanov/sdk-custom-models

Conversation

@stepdi

@stepdi stepdi commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New update_custom(model_id, *, api_url, api_key, max_tokens) (sync + async) — repoint a custom model's mutable fields without recreating it. Customer's primary workflow: ephemeral vLLM endpoints behind cloudflared tunnels whose URL rotates between sessions.
  • New delete_custom(model_id) (sync + async) — full teardown that disables the record, strips it from Project.Models, releases the name for reuse.
  • Fix add() / remove() to operate on the full project model list (public + custom). The previous type="public" filter silently dropped custom-model IDs from Project.Models on every call.

Companion to atlas-app PR https://github.com/LayerLens/atlas-app/pull/1916, which lands the matching backend routes (PATCH + DELETE /custom-models/{id} on the API-key router) and the PatchProject validator fix that the SDK depends on. Merge atlas-app first, then this one.

Customer context

client.models.remove(custom_model_id) was returning a 500 referencing a different model. Root cause was the atlas-app PatchProject validator only checking the public ModelsCollection; the new update_custom path lets the customer repoint their tunnel-backed model in place, which is what they actually wanted to do all along. delete_custom is the explicit teardown path for the rare cases where recreate is needed.

What changed

  • src/layerlens/resources/models/models.py — three new flows (sync + async); docstring + behavior change on add / remove.
  • tests/resources/test_models_resource.py — 12 new unit tests covering update_custom (partial / full / error / non-dict response), delete_custom (happy / error envelope), plus regression tests that add/remove now preserve custom models in the PATCH payload.
  • tests/test_models_custom_live.py — new @pytest.mark.live end-to-end (create → update → delete → confirm gone). Auto-skipped without LAYERLENS_STRATIX_API_KEY. Includes best-effort cleanup on failure.
  • tests/test_samples_e2e.py — mocked client fixture grew update_custom / delete_custom stubs.
  • docs/api-reference/models-benchmarks.md — new update_custom and delete_custom sections; add / remove blurbs reworded.
  • docs/examples/models-and-benchmarks.md — two worked examples (repointing api_url; replacing a custom model).
  • samples/core/custom_model.py — extended to exercise update + delete after the existing create flow.

Test plan

  • pytest tests/resources/test_models_resource.py — 68 pass (12 new)
  • pytest tests/test_samples_e2e.py -k custom_model — sample runs cleanly under the mocked client
  • pytest tests/test_models_custom_live.py — skips cleanly without API key
  • mypy src/layerlens/ — 70 files clean
  • Live run against staging once atlas-app PR #1916 is deployed
  • Customer-confirmed repro: models.remove(custom_id) returns success, and update_custom(custom_id, api_url=...) lands the new URL

Notes

  • 24 pre-existing CLI test errors in tests/cli/test_commands.py (CliRunner(mix_stderr=False) is removed in click ≥ 8.2) are unrelated and predate this branch.

🤖 Generated with Claude Code

Companion to atlas-app PR #1916. Three concrete behavior changes:

1. add() / remove() now operate on the full project model list
   (public + custom). The previous type="public" filter silently dropped
   custom-model IDs from Project.Models on every call.

2. New update_custom(model_id, *, api_url, api_key, max_tokens) — the
   customer's primary workflow: repoint api_url for ephemeral vLLM
   endpoints behind cloudflared tunnels whose hostname changes between
   sessions.

3. New delete_custom(model_id) — full teardown: disables the record,
   strips it from Project.Models, releases the name for reuse.

Mirrors all three in AsyncModels. Adds unit tests (12 new in
test_models_resource.py) and a @pytest.mark.live lifecycle test in
test_models_custom_live.py. Docs and the custom_model sample now
exercise update + delete.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@stepdi stepdi marked this pull request as ready for review May 15, 2026 15:40
stepdi and others added 2 commits May 15, 2026 12:42
CI's format check insists on these two cosmetic adjustments. No
behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@m-peko m-peko merged commit 10de2b8 into main May 15, 2026
7 checks passed
@m-peko m-peko deleted the dstepanov/sdk-custom-models branch May 18, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants