Commit 7027370
committed
refactor: add entrypoint repository
This commit adds the entrypoint repository, which is modeled after patterns in the existing
repositories. It updates the service layer to use the new data access pattern. It adds a new test
suite for the entrypoint repository and adds additional test coverage to the existing entrypoint
integration tests.
It adds the following new repository utility functions:
- get_exact_latest_snapshots: similar to get_latest_snapshots, but raises an error if any snapshots
are not found.
- get_one_resource: similar to get_one but for resources
- get_one_snapshot: similar to get_one but retrieves a specific snapshot by ID instead of the latest
- create_resource_children: similar to set_resource_children, but operates on resources that are not
yet in the database
- unlink_children: removes all children of the provided type
It updates some patterns to prefer performing existence checks in data retrievel functions, instead
of performing existence checks first and then retrieving. This reduces the number of queries since
existence checks also involve querying the database. Examples of this include increased reliance on
get_one (and the new get_one_resource and get_exact_latest_snapshots).
It updates UnitOfWork to use a context manager to handle commiting changes to the database (and
rolling back if an error occurs).
It adds a UnitOfWorkService base class, which handles the injection of the UnitOfWork to a service
class. Once all repositories are completed, no other services should be cross-injected into
eachother, instead all services will access other entities via the UnitOfWork object.
It removes the conditional error (error_if_not_found bool being passed) and the conditional commits
(commit bool being passed) in the services where possible.
It updates the experiments service to use the entrypoint repository instead of injecting entrypoint
services, and use the new UnitOfWorkService base class and the UnitOfWork context manager.
It uses EntityType instead of passing strings where possible, which required refactoring some
repository tests.
It makes the following changes for parameter validation:
- moves validation of entrypoint parameters from the service to schema layer
- adds a new error for input parameter validation
- updates the plugin service layer to use the new error (moving this logic to the schema layer is
left as a future task)
It makes deleted entrypoints accessible through GET /entrypoints (via the showDeleted query
parameter) and GET /entrypoints/{id} to make the behavior consistent with other repositories. It
also updates the frontend to display deleted entrypoints.
It adds an error handler for EntityDeletedError and changes the response code to 423 LOCKED to
differentiate it from NOT_FOUND. This error is raised when attempting to modify a deleted resource.1 parent 202a1f0 commit 7027370
24 files changed
Lines changed: 2892 additions & 1014 deletions
File tree
- src
- dioptra
- client
- restapi
- db
- repository
- utils
- v1
- entrypoints
- experiments
- jobs
- plugins
- frontend/src/views
- tests/unit/restapi
- lib/db
- v1
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
713 | 713 | | |
714 | 714 | | |
715 | 715 | | |
| 716 | + | |
716 | 717 | | |
717 | 718 | | |
718 | 719 | | |
| |||
750 | 751 | | |
751 | 752 | | |
752 | 753 | | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
753 | 757 | | |
754 | 758 | | |
755 | 759 | | |
| |||
0 commit comments