From eca776794dcdaf29e411c9cef0a99f27bcfd44f5 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 11 Jul 2024 18:16:40 -0700 Subject: [PATCH] add conditional slim_api for reserialization testing? or maybe unnecessary? --- src/aind_slims_api/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/aind_slims_api/core.py b/src/aind_slims_api/core.py index 5ac76f0..58dfacd 100644 --- a/src/aind_slims_api/core.py +++ b/src/aind_slims_api/core.py @@ -172,7 +172,7 @@ def fetch_attachments_content(self) -> \ class Attachment(SlimsBaseModel): pk: int = Field(..., alias="attm_pk") - slims_api: Slims + slims_api: Optional[Slims] = None _slims_table: SLIMSTABLES = "Attachment" class Config: @@ -180,6 +180,8 @@ class Config: def fetch_content(self) -> Response: """Fetches the content of this attachment""" + if not self.slims_api: + raise ValueError("Initialized without slims_api.") return self.slims_api.get(f"repo/{self.pk}") # attm_pk: SlimsColumn