From d3010f7125f6d03f5dc0c9a8b38eae20647bb4e7 Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Thu, 11 Jan 2024 15:34:18 -0500 Subject: [PATCH] updated errors --- pepdbagent/_version.py | 2 +- pepdbagent/modules/view.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pepdbagent/_version.py b/pepdbagent/_version.py index 9320b9c..7131288 100644 --- a/pepdbagent/_version.py +++ b/pepdbagent/_version.py @@ -1 +1 @@ -__version__ = "0.7.0a4" +__version__ = "0.7.0a5" diff --git a/pepdbagent/modules/view.py b/pepdbagent/modules/view.py index 11b07af..22517a5 100644 --- a/pepdbagent/modules/view.py +++ b/pepdbagent/modules/view.py @@ -13,7 +13,7 @@ DEFAULT_TAG, PKG_NAME, ) -from pepdbagent.exceptions import ViewNotFoundError, SampleAlreadyInView +from pepdbagent.exceptions import ViewNotFoundError, SampleAlreadyInView, ProjectNotFoundError, SampleNotFoundError from pepdbagent.db_utils import BaseEngine, Samples, Projects, Views, ViewSampleAssociation from pepdbagent.models import ViewAnnotation, CreateViewDictModel, ProjectViews @@ -158,7 +158,7 @@ def create( with Session(self._sa_engine) as sa_session: project = sa_session.scalar(project_statement) if not project: - raise ValueError( + raise ProjectNotFoundError( f"Project {view_dict.project_namespace}/{view_dict.project_name}:{view_dict.project_tag} does not exist" ) view = Views( @@ -177,7 +177,7 @@ def create( ) sample_id = sa_session.execute(sample_statement).one()[0] if not sample_id: - raise ValueError( + raise SampleNotFoundError( f"Sample {view_dict.project_namespace}/{view_dict.project_name}:{view_dict.project_tag}:{sample_name} does not exist" ) sa_session.add(ViewSampleAssociation(sample_id=sample_id, view=view)) @@ -260,7 +260,7 @@ def add_sample( ) sample = sa_session.scalar(sample_statement) if not sample: - raise ValueError( + raise SampleNotFoundError( f"Sample {namespace}/{name}:{tag}:{sample_name} does not exist" ) try: @@ -346,7 +346,7 @@ def get_snap_view( with Session(self._sa_engine) as sa_session: project = sa_session.scalar(project_statement) if not project: - raise ValueError(f"Project {namespace}/{name}:{tag} does not exist") + raise ProjectNotFoundError(f"Project {namespace}/{name}:{tag} does not exist") samples = [] for sample_name in sample_name_list: sample_statement = select(Samples).where( @@ -357,7 +357,7 @@ def get_snap_view( ) sample = sa_session.scalar(sample_statement) if not sample: - raise ValueError( + raise SampleNotFoundError( f"Sample {namespace}/{name}:{tag}:{sample_name} does not exist" ) samples.append(sample.sample)