From f985f35e5481870ab94780e1cc694849a01a7283 Mon Sep 17 00:00:00 2001 From: Wen Guan Date: Mon, 23 Dec 2024 15:16:49 +0100 Subject: [PATCH] fix get_processing with request and transform id --- main/lib/idds/core/processings.py | 5 +++-- main/lib/idds/orm/processings.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/main/lib/idds/core/processings.py b/main/lib/idds/core/processings.py index f7a23160..3704bba7 100644 --- a/main/lib/idds/core/processings.py +++ b/main/lib/idds/core/processings.py @@ -65,7 +65,7 @@ def add_processing(request_id, workload_id, transform_id, status, submitter=None @read_session -def get_processing(processing_id=None, to_json=False, session=None): +def get_processing(processing_id=None, request_id=None, transform_id=None, to_json=False, session=None): """ Get processing or raise a NoObject exception. @@ -77,7 +77,8 @@ def get_processing(processing_id=None, to_json=False, session=None): :returns: Processing. """ - return orm_processings.get_processing(processing_id=processing_id, to_json=to_json, session=session) + return orm_processings.get_processing(processing_id=processing_id, request_id=request_id, + transform_id=transform_id, to_json=to_json, session=session) @read_session diff --git a/main/lib/idds/orm/processings.py b/main/lib/idds/orm/processings.py index 69d0a136..92937de2 100644 --- a/main/lib/idds/orm/processings.py +++ b/main/lib/idds/orm/processings.py @@ -111,7 +111,7 @@ def add_processing(request_id, workload_id, transform_id, status=ProcessingStatu @read_session -def get_processing(processing_id, to_json=False, session=None): +def get_processing(processing_id, request_id=None, transform_id=None, to_json=False, session=None): """ Get processing or raise a NoObject exception. @@ -128,6 +128,11 @@ def get_processing(processing_id, to_json=False, session=None): try: query = session.query(models.Processing)\ .filter_by(processing_id=processing_id) + if request_id is not None: + query = query.filter_by(request_id=request_id) + if transform_id is not None: + query = query.filter_by(transform_id=transform_id) + ret = query.first() if not ret: return None