Skip to content

Commit 7027370

Browse files
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

src/dioptra/client/entrypoints.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ def get(
713713
sort_by: str | None = None,
714714
descending: bool | None = None,
715715
search: str | None = None,
716+
show_deleted: bool | None = None,
716717
) -> T:
717718
"""Get a list of entrypoints.
718719
@@ -750,6 +751,9 @@ def get(
750751
if group_id is not None:
751752
params["groupId"] = group_id
752753

754+
if show_deleted is not None:
755+
params["showDeleted"] = show_deleted
756+
753757
return self._session.get(
754758
self.url,
755759
params=params,

0 commit comments

Comments
 (0)