From 55065b6000e5a64f9c7cae185c8d9b9800091c3a Mon Sep 17 00:00:00 2001 From: Helen Lin Date: Tue, 13 Aug 2024 16:51:06 -0700 Subject: [PATCH 01/14] feat: filter jobs by status --- src/aind_data_transfer_service/models.py | 8 +++++-- src/aind_data_transfer_service/server.py | 4 ++++ .../templates/job_status.html | 23 ++++++++++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/aind_data_transfer_service/models.py b/src/aind_data_transfer_service/models.py index 5e3a656..69f6b56 100644 --- a/src/aind_data_transfer_service/models.py +++ b/src/aind_data_transfer_service/models.py @@ -1,5 +1,5 @@ """Module for data models used in application""" - +import ast from datetime import datetime from typing import List, Optional @@ -37,12 +37,16 @@ class AirflowDagRunsRequestParameters(BaseModel): limit: int = 25 offset: int = 0 + state: Optional[list[str]] = [] order_by: str = "-start_date" @classmethod def from_query_params(cls, query_params: dict): """Maps the query parameters to the model""" - return cls(**query_params) + params = dict(query_params) + if 'state' in params and isinstance(params['state'], str): + params['state'] = ast.literal_eval(params['state']) + return cls(**params) class JobStatus(BaseModel): diff --git a/src/aind_data_transfer_service/server.py b/src/aind_data_transfer_service/server.py index ff8f815..c4d5735 100644 --- a/src/aind_data_transfer_service/server.py +++ b/src/aind_data_transfer_service/server.py @@ -486,6 +486,9 @@ async def jobs(request: Request): default_offset = AirflowDagRunsRequestParameters.model_fields[ "offset" ].default + default_state = AirflowDagRunsRequestParameters.model_fields[ + "state" + ].default return templates.TemplateResponse( name="job_status.html", context=( @@ -493,6 +496,7 @@ async def jobs(request: Request): "request": request, "default_limit": default_limit, "default_offset": default_offset, + "default_state": default_state, "project_names_url": os.getenv( "AIND_METADATA_SERVICE_PROJECT_NAMES_URL" ), diff --git a/src/aind_data_transfer_service/templates/job_status.html b/src/aind_data_transfer_service/templates/job_status.html index 75890f7..8c0694e 100644 --- a/src/aind_data_transfer_service/templates/job_status.html +++ b/src/aind_data_transfer_service/templates/job_status.html @@ -48,6 +48,21 @@

Jobs Submitted:

jobs per page +
+ + status +
@@ -65,7 +80,7 @@

Jobs Submitted:

- + + + + {% block title %} {% endblock %} AIND Data Transfer Service Jobs