diff --git a/shared/workspaces/src/workspaces/services.py b/shared/workspaces/src/workspaces/services.py index bcb4e25e66a8ebe05d2e9cc1240e7038770f7275..1046bd8a3fe9aa231009f3bb5ee847c3d2266910 100644 --- a/shared/workspaces/src/workspaces/services.py +++ b/shared/workspaces/src/workspaces/services.py @@ -416,13 +416,15 @@ class WorkflowService(WorkflowServiceIF): definition = self.info.lookup_workflow_definition(workflow_name) # 2. create and save request, return request id - record = self.info.create_workflow_request(workflow_name, argument) + request_id = self.info.create_workflow_request(workflow_name, argument) # 3. render templates to files, returns list of rendered files - contents = definition.render_templates(argument, files) + workflow_files = definition.render_templates(argument, files) + for file in workflow_files: + self.info.save_file(request_id, file.filename, file.content) # 4. prepare files for condor execution - temp_folder = self._prepare_files_for_condor(contents) + temp_folder = self._prepare_files_for_condor(workflow_files) # 5. execute condor and retrieve log file log_file = self._execute_prepared(temp_folder) @@ -434,7 +436,7 @@ class WorkflowService(WorkflowServiceIF): with workflow_events: for e in events: # send amqp event and update database - self.on_workflow_event(e, record, temp_folder) + self.on_workflow_event(e, request_id, temp_folder) @staticmethod def _prepare_files_for_condor(files: List[AbstractFile]) -> Path: @@ -471,12 +473,15 @@ class WorkflowService(WorkflowServiceIF): # some file in here should end in .dag; that file is our dagman input dagman = list(folder.glob("*.dag"))[0] + print(f"dagman file {dagman} exists.") # ensure the log file exists logfile = folder / "condor.log" + print("condor.log exists.") logfile.touch() # submit + print("submitting to condor...") subprocess.run(["condor_submit_dag", str(dagman)], cwd=str(folder.absolute())) # return the logfile @@ -576,19 +581,19 @@ class WorkflowInfo(WorkflowInfoIF): def save_request(self, request: WorkflowRequest): """ - Save a given entity and return an integer identifier for it + Save a given request and return an integer identifier for it :param request: request to save - :return: the entity's identifier + :return: the request id """ self.session.add(request) self.session.flush() def save_file(self, request_id: int, filename: str, content: bytes): """ - Save a given List of request files - :param request_id: - :param content: - :param filename: + Save a given file for the specified request to the database + :param request_id: request id of request to update with new file + :param filename: filename of new file + :param content: contents of new file in bytes :return: """ wrf = WorkflowRequestFile(workflow_request_id=request_id, filename=filename, content=content)