Extract test set crud module and retire the split - #2620
Merged
Conversation
|
Looks good — nice cleanup finishing the [Improvement] Add a small router-level test for
|
added 2 commits
August 27, 2026 11:54
The crud package is one module per entity now, so the "part of the incremental split, crud/__init__.py still holds the monolith" paragraph in every module docstring describes a state that no longer exists. Same for the AGENTS.md rule, which now states the finished layout instead of a migration in progress.
Finishes the crud split. The TestSet functions move into crud/test_set.py
and crud/__init__.py is left empty, so callers switch to direct submodule
imports.
Emptying __init__.py also removes the names it re-exported by accident,
which several modules were relying on: crud.get_item_detail, crud.include
and crud.delete_item are crud_utils/query_utils names, and
crud.schemas.TestConfigurationUpdate reached schemas through the package.
Each now imports from its real home.
Also restores delete_test_configuration, which went missing when
test_configuration was extracted -- DELETE /test_configurations/{id} has
been raising AttributeError since.
test_service_security.py passed the crud package itself into its table of
functions to check for an organization_id parameter. The loop guards with
hasattr, so an empty __init__.py would not fail it -- the five test set
assertions would just quietly stop checking anything. Points them at
test_set_crud.
akwasigroch
force-pushed
the
crud-extract-testset
branch
from
August 27, 2026 09:58
13d51b6 to
7137cc8
Compare
There was a problem hiding this comment.
Re-reviewed latest commits — the TestSet CRUD extraction and cleanup still look solid, and the delete_test_configuration fix is wired through the router correctly.
Only remaining suggestion is the same as before: please add a minimal router-level test for DELETE /test_configurations/{id} (happy path + 404) so this regression can’t sneak back in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Finishes the
crudmonolith split that #2410 started. TestSet was the last entity left incrud/__init__.py, so after this the file is empty andapp/crud/is simply one module per entity. The second half of the PR removes the now-false "split in progress" narration from the codebase.Stacked on #2617 (Test extraction) — review and merge that one first; this PR's base is
crud-extract-test, and the diff shown here is just the TestSet half.What Changed
The move. All nine TestSet functions (
get_test_set,get_test_sets,create_test_set,update_test_set,delete_test_set,get_test_set_by_nano_id_or_slug,resolve_test_set,get_test_sets_for_test,get_test_set_tests) go intocrud/test_set.py, joining thebulk_delete_test_setsthat already lived there._TEST_SET_RELATED_FIELDSmoves with them, socrud/explorer.pynow imports it fromcrud.test_setrather than from the parent package. Around 90 call sites across routers, services, jobs and tests switch totest_set_crud., and the fivepatch("…app.crud.resolve_test_set")targets intests/backend/services/test_test_set.pybecome…app.crud.test_set.resolve_test_set.crud/__init__.pyis now a single docstring line. That also takes away the names it had been re-exporting by accident, and four modules turned out to be leaning on them.services/experiment.pyreachedcrud.get_item_detailandcrud.include, androuters/experiments.pyreachedcrud.delete_item— all three arecrud_utils/query_utilsnames that only resolved because__init__.pyhappened to import them.jobs/execution/modes.pyreachedschemasthroughcrud.schemas.TestConfigurationUpdate. Each now imports from where the thing actually lives.services/tool/mcp/operations.pyhad acrudimport that nothing in the file used.One real bug fixed.
crud.delete_test_configurationdoes not exist anywhere in the repo — the function was dropped whentest_configurationwas extracted, soDELETE /test_configurations/{id}has been raisingAttributeErroron every call since. This addsdelete_test_configurationtocrud/test_configuration.py(adelete_itemwrapper, matching its siblings) and points the router at it. No test covered the route, which is why it went unnoticed.The history comes out (second commit, reviewable on its own). The "Part of the incremental split of the
crudmonolith:crud/__init__.pystill holds…" paragraph is gone from all 29 crud module docstrings;metric.pyandtelemetry.pykeep their "import the functions directly" guidance but lose the "Split out ofcrud/__init__.py" line; the monolith comment aboveexplorer.py's_TEST_SET_RELATED_FIELDSimport is rewritten. AGENTS.md's CRUD layout rule now describes the finished layout — one module per entity,__init__.pyempty on purpose, a new function goes in its entity's module — instead of a migration in progress. Two stale "doesn't exist in crud.py" comments in tests and threecrud.foo(...)docstring examples inutils/database_exceptions.pyare reworded to the module form so the docs stop teaching the pattern that no longer works.tests/backend/test_secret_equality.pypins its allowlist by line number, and two added imports inservices/experiment.pyshifted the two whitelistedcontent_hashcomparisons from 150/206 to 152/208; the entries are repinned.Additional Context
delete_test_configurationfix.delete_test_configurationrestoration is the one place this PR is not a pure move, and the route still has no test.Testing
DEFAULT_EVALUATION_MODEL not configured, therollback_initial_dataOOM hang).rhesis.backend.appandrhesis.backend.jobsstill imports, and that nocrud.foo()package-level access survives anywhere inapps/ortests/.ruff checkandruff formatclean on all changed files.DELETE /test_configurations/{id}is worth exercising by hand, since nothing in the suite covers it.