From 3715c839d19d56817a8c8c96390e9d55807d336a Mon Sep 17 00:00:00 2001 From: Tom Gebhardt Date: Thu, 26 Oct 2023 16:32:59 +0200 Subject: [PATCH] process towards task automatation for CSH first sample task almost running --- app/celery/automated_tasks/__init__.py | 2 ++ app/models/session.py | 13 +++++++++++-- app/routers/router.py | 4 +--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/celery/automated_tasks/__init__.py b/app/celery/automated_tasks/__init__.py index 1552b62..ac527ce 100644 --- a/app/celery/automated_tasks/__init__.py +++ b/app/celery/automated_tasks/__init__.py @@ -1,7 +1,9 @@ from .f1_model_persistent_identifier_task import f1_model_persistent_identifier from .f4_model_metadata_harvestable_task import f4_model_metadata_harvestable +from .csh_f2_persistent_identifier_task import csh_f2_persistent_identifier __all__ = [ f1_model_persistent_identifier, f4_model_metadata_harvestable, + csh_f2_persistent_identifier ] diff --git a/app/models/session.py b/app/models/session.py index 6b09708..3d080f5 100644 --- a/app/models/session.py +++ b/app/models/session.py @@ -202,8 +202,13 @@ def __init__(self, session: Session) -> None: self.assessed_data: Optional["CombineArchive"] = None if not session.tasks: - if self.user_input.subject_type not in [SubjectType.manual, SubjectType.csh]: + if self.user_input.subject_type in [SubjectType.file, SubjectType.url]: #url is currently not supported, thus this step wouldn't be reached for URL support self.assessed_data = self.retrieve_data(self.user_input.path) + elif self.user_input.subject_type is SubjectType.csh: + print("---") + print(self.user_input) + print("---") + self.assessed_data = self.user_input.metadata self.create_tasks() else: @@ -583,7 +588,11 @@ def start_automated_tasks(self): task = self.session_model.get_task(task_id) print(task) if isinstance(task, AutomatedTask): - task.do_evaluate(self.assessed_data.dict()) + if self.user_input.subject_type is not SubjectType.csh: + task.do_evaluate(self.assessed_data.dict()) + else: + print("???????????????") + task.do_evaluate(self.assessed_data) def json(self): """Returns the json representation of the session model""" diff --git a/app/routers/router.py b/app/routers/router.py index 61639bb..fcfeac2 100644 --- a/app/routers/router.py +++ b/app/routers/router.py @@ -69,14 +69,12 @@ def create_session( finally: uploaded_file.file.close() elif subject.subject_type is SubjectType.csh: - print(subject) - print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!! SUBJECT TYPE CSH DETECTED!") if subject.metadata is None: raise HTTPException( 422, "No JSON object was attached for assessment. Impossible to process query" ) try: - session_handler = SessionHandler.from_user_input(session_id, subject) #is the only for form input? My impression: i + session_handler = SessionHandler.from_user_input(session_id, subject) except ValueError as e: raise HTTPException(422, str(e)) try: