Add mount_count and unmount_count tracking for samples

Introduced `mount_count` and `unmount_count` fields to track mounting events for samples. Updated models, schemas, and front-end components to support dynamic calculation and display of these counts. Enhanced backend queries and API responses to include the new data.
This commit is contained in:
GotthardG 2025-01-20 13:04:20 +01:00
parent 3b315f2997
commit 4630bcfac5
4 changed files with 131 additions and 47 deletions

View File

@ -149,7 +149,7 @@ class Sample(Base):
dewar_id = Column(Integer, ForeignKey("dewars.id")) dewar_id = Column(Integer, ForeignKey("dewars.id"))
puck_id = Column(Integer, ForeignKey("pucks.id")) puck_id = Column(Integer, ForeignKey("pucks.id"))
puck = relationship("Puck", back_populates="samples") puck = relationship("Puck", back_populates="samples")
events = relationship("SampleEvent", back_populates="sample") events = relationship("SampleEvent", back_populates="sample", lazy="joined")
@property @property
def mount_count(self) -> int: def mount_count(self) -> int:
@ -183,7 +183,7 @@ class LogisticsEvent(Base):
dewar_id = Column(Integer, ForeignKey("dewars.id")) dewar_id = Column(Integer, ForeignKey("dewars.id"))
slot_id = Column(Integer, ForeignKey("slots.id")) slot_id = Column(Integer, ForeignKey("slots.id"))
event_type = Column(String(255), index=True) event_type = Column(String(255), index=True)
timestamp = Column(DateTime, default=datetime.utcnow) timestamp = Column(DateTime, default=datetime.now)
dewar = relationship("Dewar", back_populates="events") dewar = relationship("Dewar", back_populates="events")
slot = relationship("Slot", back_populates="events") slot = relationship("Slot", back_populates="events")
@ -192,9 +192,9 @@ class SampleEvent(Base):
__tablename__ = "sample_events" __tablename__ = "sample_events"
id = Column(Integer, primary_key=True, index=True) id = Column(Integer, primary_key=True, index=True)
sample_id = Column(Integer, ForeignKey("samples.id")) sample_id = Column(Integer, ForeignKey("samples.id"), nullable=False)
event_type = Column(String(255), index=True) event_type = Column(String(255), nullable=False)
timestamp = Column(DateTime, default=datetime.utcnow) timestamp = Column(DateTime, default=datetime.now)
sample = relationship("Sample", back_populates="events") sample = relationship("Sample", back_populates="events")
@ -206,6 +206,6 @@ class PuckEvent(Base):
puck_id = Column(Integer, ForeignKey("pucks.id")) puck_id = Column(Integer, ForeignKey("pucks.id"))
tell_position = Column(String(255), nullable=True) tell_position = Column(String(255), nullable=True)
event_type = Column(String(255), index=True) event_type = Column(String(255), index=True)
timestamp = Column(DateTime, default=datetime.utcnow) timestamp = Column(DateTime, default=datetime.now)
puck = relationship("Puck", back_populates="events") puck = relationship("Puck", back_populates="events")

View File

@ -20,7 +20,6 @@ from app.dependencies import get_db
import logging import logging
from sqlalchemy.orm import joinedload from sqlalchemy.orm import joinedload
router = APIRouter() router = APIRouter()

View File

@ -423,7 +423,7 @@ class Sample(BaseModel):
priority: Optional[int] = None priority: Optional[int] = None
comments: Optional[str] = None comments: Optional[str] = None
data_collection_parameters: Optional[DataCollectionParameters] data_collection_parameters: Optional[DataCollectionParameters]
events: List[SampleEventResponse] = [] events: List[SampleEventResponse]
mount_count: Optional[int] = None mount_count: Optional[int] = None
unmount_count: Optional[int] = None unmount_count: Optional[int] = None
# results: Optional[Results] = None # results: Optional[Results] = None

View File

@ -12,9 +12,15 @@
}, },
"source": [ "source": [
"import json\n", "import json\n",
"\n",
"from nbclient.client import timestamp\n",
"\n",
"import backend.aareDBclient as aareDBclient\n", "import backend.aareDBclient as aareDBclient\n",
"from aareDBclient.rest import ApiException\n", "from aareDBclient.rest import ApiException\n",
"from pprint import pprint\n", "from pprint import pprint\n",
"\n",
"from app.data.data import sample\n",
"\n",
"#from aareDBclient import SamplesApi, ShipmentsApi, PucksApi\n", "#from aareDBclient import SamplesApi, ShipmentsApi, PucksApi\n",
"#from aareDBclient.models import SampleEventCreate, SetTellPosition\n", "#from aareDBclient.models import SampleEventCreate, SetTellPosition\n",
"#from examples.examples import api_response\n", "#from examples.examples import api_response\n",
@ -54,7 +60,7 @@
"source": [ "source": [
"## Fetch all Shipments, list corresponding dewars and pucks\n", "## Fetch all Shipments, list corresponding dewars and pucks\n",
"\n", "\n",
"from datetime import date\n", "from datetime import date, datetime\n",
"from aareDBclient import ShipmentsApi\n", "from aareDBclient import ShipmentsApi\n",
"from aareDBclient.models import Shipment\n", "from aareDBclient.models import Shipment\n",
"\n", "\n",
@ -361,29 +367,41 @@
{ {
"metadata": { "metadata": {
"ExecuteTime": { "ExecuteTime": {
"end_time": "2025-01-16T19:45:40.811948Z", "end_time": "2025-01-20T10:00:34.361066Z",
"start_time": "2025-01-16T19:45:40.798389Z" "start_time": "2025-01-20T10:00:34.339557Z"
} }
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Get puck_id puck_name sample_id sample_name of pucks in the tell\n",
"\n",
"with aareDBclient.ApiClient(configuration) as api_client:\n", "with aareDBclient.ApiClient(configuration) as api_client:\n",
" # Create an instance of the API class\n", " # Create an instance of the API class\n",
" api_instance = aareDBclient.PucksApi(api_client)\n", " api_instance = aareDBclient.PucksApi(api_client)\n",
"\n", "\n",
" # GET request: Fetch all pucks in the tell\n", " # GET request: Fetch all pucks in the tell\n",
" try:\n", " try:\n",
" all_pucks_response = api_instance.get_pucks_with_tell_position_pucks_with_tell_position_get() # Replace with appropriate method\n", " # Call the API method to fetch pucks\n",
" # Convert the response to a JSON-like string for pretty printing\n", " all_pucks_response = api_instance.get_pucks_with_tell_position_pucks_with_tell_position_get()\n",
"\n",
" # Debug response structure by printing it in JSON format\n",
" formatted_response = json.dumps(\n", " formatted_response = json.dumps(\n",
" [puck.to_dict() for puck in all_pucks_response], # .to_dict() assumes API models can convert to Python dict\n", " [p.to_dict() for p in all_pucks_response], # Assuming the API response can be converted to dicts\n",
" indent=4 # Use indentation for readability\n", " indent=4 # Use indentation for readability\n",
" )\n", " )\n",
"\n", " #print(\"The response of PucksApi->get_all_pucks_in_tell (formatted):\\n\")\n",
" print(\"The response of PucksApi->get_all_pucks_in_tell:\\n\")\n",
" #print(formatted_response)\n", " #print(formatted_response)\n",
"\n",
" # Iterate through each puck and print information\n",
" for p in all_pucks_response:\n", " for p in all_pucks_response:\n",
" print(p.puck_name)\n", " print(f\"Puck ID: {p.id}, Puck Name: {p.puck_name}\")\n",
"\n",
" # Check if the puck has any samples\n",
" if hasattr(p, 'samples') and p.samples: # Ensure 'samples' attribute exists and is not empty\n",
" for sample in p.samples:\n",
" print(f\" Sample ID: {sample.id}, Sample Name: {sample.sample_name}\")\n",
" else:\n",
" print(\" No samples found in this puck.\")\n",
"\n", "\n",
" except ApiException as e:\n", " except ApiException as e:\n",
" print(\"Exception when calling PucksApi->get_all_pucks_in_tell: %s\\n\" % e)" " print(\"Exception when calling PucksApi->get_all_pucks_in_tell: %s\\n\" % e)"
@ -391,66 +409,133 @@
"id": "95f8c133359945d5", "id": "95f8c133359945d5",
"outputs": [ "outputs": [
{ {
"ename": "NameError", "name": "stdout",
"evalue": "name 'aareDBclient' is not defined", "output_type": "stream",
"output_type": "error", "text": [
"traceback": [ "Puck ID: 44, Puck Name: CPS-4178\n",
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", " Sample ID: 433, Sample Name: Dtpase_1\n",
"\u001B[0;31mNameError\u001B[0m Traceback (most recent call last)", " Sample ID: 434, Sample Name: Dtpase_2\n",
"Cell \u001B[0;32mIn[5], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[43maareDBclient\u001B[49m\u001B[38;5;241m.\u001B[39mApiClient(configuration) \u001B[38;5;28;01mas\u001B[39;00m api_client:\n\u001B[1;32m 2\u001B[0m \u001B[38;5;66;03m# Create an instance of the API class\u001B[39;00m\n\u001B[1;32m 3\u001B[0m api_instance \u001B[38;5;241m=\u001B[39m aareDBclient\u001B[38;5;241m.\u001B[39mPucksApi(api_client)\n\u001B[1;32m 5\u001B[0m \u001B[38;5;66;03m# GET request: Fetch all pucks in the tell\u001B[39;00m\n", " Sample ID: 435, Sample Name: Dtpase_3\n",
"\u001B[0;31mNameError\u001B[0m: name 'aareDBclient' is not defined" " Sample ID: 436, Sample Name: Dtpase_4\n",
" Sample ID: 437, Sample Name: Dtpase_5\n",
" Sample ID: 438, Sample Name: Dtpase_6\n",
" Sample ID: 439, Sample Name: Dtpase_7\n",
" Sample ID: 440, Sample Name: Fckase_1\n",
" Sample ID: 441, Sample Name: Fckase_2\n",
" Sample ID: 442, Sample Name: Fckase_3\n",
" Sample ID: 443, Sample Name: Fckase_4\n",
" Sample ID: 444, Sample Name: Fckase_5\n",
" Sample ID: 445, Sample Name: Fckase_6\n",
" Sample ID: 446, Sample Name: Fckase_7\n",
" Sample ID: 447, Sample Name: Fckase_8\n",
" Sample ID: 448, Sample Name: Fckase_9\n",
"Puck ID: 45, Puck Name: PSIMX-122\n",
" Sample ID: 449, Sample Name: PopoI_1\n",
" Sample ID: 450, Sample Name: PopoI_2\n",
" Sample ID: 451, Sample Name: PopoI_3\n",
" Sample ID: 452, Sample Name: PopoI_4\n",
" Sample ID: 453, Sample Name: PopoI_5\n",
" Sample ID: 454, Sample Name: PopoI_6\n",
" Sample ID: 455, Sample Name: PopoI_7\n",
" Sample ID: 456, Sample Name: PopoI_8\n",
" Sample ID: 457, Sample Name: PopoI_9\n",
" Sample ID: 458, Sample Name: PopoI_10\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
" warnings.warn(\n"
] ]
} }
], ],
"execution_count": 5 "execution_count": 53
}, },
{ {
"metadata": { "metadata": {
"ExecuteTime": { "ExecuteTime": {
"end_time": "2025-01-16T19:45:44.042534Z", "end_time": "2025-01-20T11:10:20.017201Z",
"start_time": "2025-01-16T19:45:44.030292Z" "start_time": "2025-01-20T11:10:19.953940Z"
} }
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"from aareDBclient import SampleEventCreate\n",
"\n",
"# Create an event for a sample\n",
"\n", "\n",
"with aareDBclient.ApiClient(configuration) as api_client:\n", "with aareDBclient.ApiClient(configuration) as api_client:\n",
" # Create an instance of the Samples API class\n", " # Instance of the API client\n",
" api_instance = aareDBclient.SamplesApi(api_client)\n", " api_instance = aareDBclient.SamplesApi(api_client)\n",
"\n", "\n",
" # Define the sample ID and event payload using the expected model\n", " try:\n",
" sample_id = 261\n", " # Define the payload with only `event_type`\n",
" event_payload = SampleEventCreate(\n", " sample_event_create = SampleEventCreate(\n",
" event_type=\"Failed\" # Replace with actual event type if different\n", " sample_id=433,\n",
" event_type=\"Mounted\" # Valid event type\n",
" )\n", " )\n",
"\n", "\n",
" try:\n", " # Debug the payload before sending\n",
" # Post the sample event\n", " print(\"Payload being sent to API:\")\n",
" print(sample_event_create.json()) # Ensure it matches `SampleEventCreate`\n",
"\n",
" # Call the API\n",
" api_response = api_instance.create_sample_event_samples_samples_sample_id_events_post(\n", " api_response = api_instance.create_sample_event_samples_samples_sample_id_events_post(\n",
" sample_id=sample_id,\n", " sample_id=433, # Ensure this matches a valid sample ID in the database\n",
" sample_event_create=event_payload # Pass the model instance here\n", " sample_event_create=sample_event_create\n",
" )\n", " )\n",
" print(\"The response of post_sample_event:\\n\")\n", "\n",
" print(\"API response:\")\n",
" pprint(api_response)\n", " pprint(api_response)\n",
"\n", "\n",
" except ApiException as e:\n", " except ApiException as e:\n",
" print(\"Exception when calling post_sample_event: %s\\n\" % e)\n" " print(\"Exception when calling post_sample_event:\")\n",
" print(f\"Status Code: {e.status}\")\n",
" if e.body:\n",
" print(f\"Error Details: {e.body}\")\n"
], ],
"id": "ee8abb293096334a", "id": "ee8abb293096334a",
"outputs": [ "outputs": [
{ {
"ename": "NameError", "name": "stdout",
"evalue": "name 'aareDBclient' is not defined", "output_type": "stream",
"text": [
"Payload being sent to API:\n",
"{\"event_type\":\"Mounted\"}\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host '127.0.0.1'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n",
" warnings.warn(\n"
]
},
{
"ename": "ValidationError",
"evalue": "3 validation errors for SampleEventResponse\nsample_id\n Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.9/v/int_type\nevent_type\n Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.9/v/string_type\ntimestamp\n Input should be a valid datetime [type=datetime_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.9/v/datetime_type",
"output_type": "error", "output_type": "error",
"traceback": [ "traceback": [
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m", "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[0;31mNameError\u001B[0m Traceback (most recent call last)", "\u001B[0;31mValidationError\u001B[0m Traceback (most recent call last)",
"Cell \u001B[0;32mIn[6], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[43maareDBclient\u001B[49m\u001B[38;5;241m.\u001B[39mApiClient(configuration) \u001B[38;5;28;01mas\u001B[39;00m api_client:\n\u001B[1;32m 2\u001B[0m \u001B[38;5;66;03m# Create an instance of the Samples API class\u001B[39;00m\n\u001B[1;32m 3\u001B[0m api_instance \u001B[38;5;241m=\u001B[39m aareDBclient\u001B[38;5;241m.\u001B[39mSamplesApi(api_client)\n\u001B[1;32m 5\u001B[0m \u001B[38;5;66;03m# Define the sample ID and event payload using the expected model\u001B[39;00m\n", "Cell \u001B[0;32mIn[110], line 21\u001B[0m\n\u001B[1;32m 18\u001B[0m \u001B[38;5;28mprint\u001B[39m(sample_event_create\u001B[38;5;241m.\u001B[39mjson()) \u001B[38;5;66;03m# Ensure it matches `SampleEventCreate`\u001B[39;00m\n\u001B[1;32m 20\u001B[0m \u001B[38;5;66;03m# Call the API\u001B[39;00m\n\u001B[0;32m---> 21\u001B[0m api_response \u001B[38;5;241m=\u001B[39m \u001B[43mapi_instance\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mcreate_sample_event_samples_samples_sample_id_events_post\u001B[49m\u001B[43m(\u001B[49m\n\u001B[1;32m 22\u001B[0m \u001B[43m \u001B[49m\u001B[43msample_id\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;241;43m433\u001B[39;49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;66;43;03m# Ensure this matches a valid sample ID in the database\u001B[39;49;00m\n\u001B[1;32m 23\u001B[0m \u001B[43m \u001B[49m\u001B[43msample_event_create\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43msample_event_create\u001B[49m\n\u001B[1;32m 24\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 26\u001B[0m \u001B[38;5;28mprint\u001B[39m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mAPI response:\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[1;32m 27\u001B[0m pprint(api_response)\n",
"\u001B[0;31mNameError\u001B[0m: name 'aareDBclient' is not defined" "File \u001B[0;32m/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pydantic/validate_call_decorator.py:60\u001B[0m, in \u001B[0;36mvalidate_call.<locals>.validate.<locals>.wrapper_function\u001B[0;34m(*args, **kwargs)\u001B[0m\n\u001B[1;32m 58\u001B[0m \u001B[38;5;129m@functools\u001B[39m\u001B[38;5;241m.\u001B[39mwraps(function)\n\u001B[1;32m 59\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;21mwrapper_function\u001B[39m(\u001B[38;5;241m*\u001B[39margs, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs):\n\u001B[0;32m---> 60\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[43mvalidate_call_wrapper\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[38;5;241;43m*\u001B[39;49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[0;32m/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pydantic/_internal/_validate_call.py:96\u001B[0m, in \u001B[0;36mValidateCallWrapper.__call__\u001B[0;34m(self, *args, **kwargs)\u001B[0m\n\u001B[1;32m 95\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;21m__call__\u001B[39m(\u001B[38;5;28mself\u001B[39m, \u001B[38;5;241m*\u001B[39margs: Any, \u001B[38;5;241m*\u001B[39m\u001B[38;5;241m*\u001B[39mkwargs: Any) \u001B[38;5;241m-\u001B[39m\u001B[38;5;241m>\u001B[39m Any:\n\u001B[0;32m---> 96\u001B[0m res \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m__pydantic_validator__\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mvalidate_python\u001B[49m\u001B[43m(\u001B[49m\u001B[43mpydantic_core\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mArgsKwargs\u001B[49m\u001B[43m(\u001B[49m\u001B[43margs\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mkwargs\u001B[49m\u001B[43m)\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 97\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m__return_pydantic_validator__:\n\u001B[1;32m 98\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m__return_pydantic_validator__(res)\n",
"File \u001B[0;32m~/PycharmProjects/heidi-v2/backend/aareDBclient/api/samples_api.py:109\u001B[0m, in \u001B[0;36mSamplesApi.create_sample_event_samples_samples_sample_id_events_post\u001B[0;34m(self, sample_id, sample_event_create, _request_timeout, _request_auth, _content_type, _headers, _host_index)\u001B[0m\n\u001B[1;32m 104\u001B[0m response_data \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mapi_client\u001B[38;5;241m.\u001B[39mcall_api(\n\u001B[1;32m 105\u001B[0m \u001B[38;5;241m*\u001B[39m_param,\n\u001B[1;32m 106\u001B[0m _request_timeout\u001B[38;5;241m=\u001B[39m_request_timeout\n\u001B[1;32m 107\u001B[0m )\n\u001B[1;32m 108\u001B[0m response_data\u001B[38;5;241m.\u001B[39mread()\n\u001B[0;32m--> 109\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mapi_client\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mresponse_deserialize\u001B[49m\u001B[43m(\u001B[49m\n\u001B[1;32m 110\u001B[0m \u001B[43m \u001B[49m\u001B[43mresponse_data\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mresponse_data\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 111\u001B[0m \u001B[43m \u001B[49m\u001B[43mresponse_types_map\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43m_response_types_map\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 112\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\u001B[38;5;241m.\u001B[39mdata\n",
"File \u001B[0;32m~/PycharmProjects/heidi-v2/backend/aareDBclient/api_client.py:319\u001B[0m, in \u001B[0;36mApiClient.response_deserialize\u001B[0;34m(self, response_data, response_types_map)\u001B[0m\n\u001B[1;32m 317\u001B[0m encoding \u001B[38;5;241m=\u001B[39m match\u001B[38;5;241m.\u001B[39mgroup(\u001B[38;5;241m1\u001B[39m) \u001B[38;5;28;01mif\u001B[39;00m match \u001B[38;5;28;01melse\u001B[39;00m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mutf-8\u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[1;32m 318\u001B[0m response_text \u001B[38;5;241m=\u001B[39m response_data\u001B[38;5;241m.\u001B[39mdata\u001B[38;5;241m.\u001B[39mdecode(encoding)\n\u001B[0;32m--> 319\u001B[0m return_data \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mdeserialize\u001B[49m\u001B[43m(\u001B[49m\u001B[43mresponse_text\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mresponse_type\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mcontent_type\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 320\u001B[0m \u001B[38;5;28;01mfinally\u001B[39;00m:\n\u001B[1;32m 321\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;241m200\u001B[39m \u001B[38;5;241m<\u001B[39m\u001B[38;5;241m=\u001B[39m response_data\u001B[38;5;241m.\u001B[39mstatus \u001B[38;5;241m<\u001B[39m\u001B[38;5;241m=\u001B[39m \u001B[38;5;241m299\u001B[39m:\n",
"File \u001B[0;32m~/PycharmProjects/heidi-v2/backend/aareDBclient/api_client.py:420\u001B[0m, in \u001B[0;36mApiClient.deserialize\u001B[0;34m(self, response_text, response_type, content_type)\u001B[0m\n\u001B[1;32m 414\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n\u001B[1;32m 415\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m ApiException(\n\u001B[1;32m 416\u001B[0m status\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m0\u001B[39m,\n\u001B[1;32m 417\u001B[0m reason\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mUnsupported content type: \u001B[39m\u001B[38;5;132;01m{0}\u001B[39;00m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;241m.\u001B[39mformat(content_type)\n\u001B[1;32m 418\u001B[0m )\n\u001B[0;32m--> 420\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m__deserialize\u001B[49m\u001B[43m(\u001B[49m\u001B[43mdata\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mresponse_type\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[0;32m~/PycharmProjects/heidi-v2/backend/aareDBclient/api_client.py:467\u001B[0m, in \u001B[0;36mApiClient.__deserialize\u001B[0;34m(self, data, klass)\u001B[0m\n\u001B[1;32m 465\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m__deserialize_enum(data, klass)\n\u001B[1;32m 466\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n\u001B[0;32m--> 467\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m__deserialize_model\u001B[49m\u001B[43m(\u001B[49m\u001B[43mdata\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mklass\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[0;32m~/PycharmProjects/heidi-v2/backend/aareDBclient/api_client.py:788\u001B[0m, in \u001B[0;36mApiClient.__deserialize_model\u001B[0;34m(self, data, klass)\u001B[0m\n\u001B[1;32m 780\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;21m__deserialize_model\u001B[39m(\u001B[38;5;28mself\u001B[39m, data, klass):\n\u001B[1;32m 781\u001B[0m \u001B[38;5;250m \u001B[39m\u001B[38;5;124;03m\"\"\"Deserializes list or dict to model.\u001B[39;00m\n\u001B[1;32m 782\u001B[0m \n\u001B[1;32m 783\u001B[0m \u001B[38;5;124;03m :param data: dict, list.\u001B[39;00m\n\u001B[1;32m 784\u001B[0m \u001B[38;5;124;03m :param klass: class literal.\u001B[39;00m\n\u001B[1;32m 785\u001B[0m \u001B[38;5;124;03m :return: model object.\u001B[39;00m\n\u001B[1;32m 786\u001B[0m \u001B[38;5;124;03m \"\"\"\u001B[39;00m\n\u001B[0;32m--> 788\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[43mklass\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mfrom_dict\u001B[49m\u001B[43m(\u001B[49m\u001B[43mdata\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[0;32m~/PycharmProjects/heidi-v2/backend/aareDBclient/models/sample_event_response.py:86\u001B[0m, in \u001B[0;36mSampleEventResponse.from_dict\u001B[0;34m(cls, obj)\u001B[0m\n\u001B[1;32m 83\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(obj, \u001B[38;5;28mdict\u001B[39m):\n\u001B[1;32m 84\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mcls\u001B[39m\u001B[38;5;241m.\u001B[39mmodel_validate(obj)\n\u001B[0;32m---> 86\u001B[0m _obj \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mcls\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mmodel_validate\u001B[49m\u001B[43m(\u001B[49m\u001B[43m{\u001B[49m\n\u001B[1;32m 87\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mid\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m:\u001B[49m\u001B[43m \u001B[49m\u001B[43mobj\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mget\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mid\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m)\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 88\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43msample_id\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m:\u001B[49m\u001B[43m \u001B[49m\u001B[43mobj\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mget\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43msample_id\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m)\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 89\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mevent_type\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m:\u001B[49m\u001B[43m \u001B[49m\u001B[43mobj\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mget\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mevent_type\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m)\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 90\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mtimestamp\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m:\u001B[49m\u001B[43m \u001B[49m\u001B[43mobj\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mget\u001B[49m\u001B[43m(\u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mtimestamp\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[1;32m 91\u001B[0m \u001B[43m\u001B[49m\u001B[43m}\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 92\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m _obj\n",
"File \u001B[0;32m/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pydantic/main.py:596\u001B[0m, in \u001B[0;36mBaseModel.model_validate\u001B[0;34m(cls, obj, strict, from_attributes, context)\u001B[0m\n\u001B[1;32m 594\u001B[0m \u001B[38;5;66;03m# `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks\u001B[39;00m\n\u001B[1;32m 595\u001B[0m __tracebackhide__ \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;01mTrue\u001B[39;00m\n\u001B[0;32m--> 596\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28;43mcls\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43m__pydantic_validator__\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mvalidate_python\u001B[49m\u001B[43m(\u001B[49m\n\u001B[1;32m 597\u001B[0m \u001B[43m \u001B[49m\u001B[43mobj\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mstrict\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mstrict\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mfrom_attributes\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mfrom_attributes\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mcontext\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mcontext\u001B[49m\n\u001B[1;32m 598\u001B[0m \u001B[43m\u001B[49m\u001B[43m)\u001B[49m\n",
"\u001B[0;31mValidationError\u001B[0m: 3 validation errors for SampleEventResponse\nsample_id\n Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.9/v/int_type\nevent_type\n Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.9/v/string_type\ntimestamp\n Input should be a valid datetime [type=datetime_type, input_value=None, input_type=NoneType]\n For further information visit https://errors.pydantic.dev/2.9/v/datetime_type"
] ]
} }
], ],
"execution_count": 6 "execution_count": 110
}, },
{ {
"metadata": { "metadata": {