From 2bc735a3f01ffd961370f99e5ede46b7bef3ed2a Mon Sep 17 00:00:00 2001 From: Dan Funk Date: Sun, 31 May 2020 13:48:00 -0400 Subject: [PATCH] Kelly wrote a beautiful method for resetting the workflow that doesn't loose data when reset inside a parallel task, all I needed to do was use it. Catching TypeErrors and reporting them back to the UI so we don't 500 in a bad way (but we still 500) --- crc/services/workflow_processor.py | 28 +++-- crc/services/workflow_service.py | 5 +- .../bpmn/research_rampup/research_rampup.bpmn | 104 ++++++++++-------- 3 files changed, 80 insertions(+), 57 deletions(-) diff --git a/crc/services/workflow_processor.py b/crc/services/workflow_processor.py index d032b94a..93590d94 100644 --- a/crc/services/workflow_processor.py +++ b/crc/services/workflow_processor.py @@ -299,21 +299,27 @@ class WorkflowProcessor(object): return WorkflowStatus.waiting def hard_reset(self): - """Recreate this workflow, but keep the data from the last completed task and add it back into the first task. - This may be useful when a workflow specification changes, and users need to review all the - prior steps, but don't need to reenter all the previous data. + """Recreate this workflow, but keep the data from the last completed task and add + it back into the first task. This may be useful when a workflow specification changes, + and users need to review all the prior steps, but they don't need to reenter all the previous data. Returns the new version. """ + + # Create a new workflow based on the latest specs. self.spec_data_files = FileService.get_spec_data_files(workflow_spec_id=self.workflow_spec_id) - spec = WorkflowProcessor.get_spec(self.spec_data_files, self.workflow_spec_id) - # spec = WorkflowProcessor.get_spec(self.workflow_spec_id, version) - bpmn_workflow = BpmnWorkflow(spec, script_engine=self._script_engine) - bpmn_workflow.data = self.bpmn_workflow.data - for task in bpmn_workflow.get_tasks(SpiffTask.READY): - task.data = self.bpmn_workflow.last_task.data - bpmn_workflow.do_engine_steps() - self.bpmn_workflow = bpmn_workflow + new_spec = WorkflowProcessor.get_spec(self.spec_data_files, self.workflow_spec_id) + new_bpmn_workflow = BpmnWorkflow(new_spec, script_engine=self._script_engine) + new_bpmn_workflow.data = self.bpmn_workflow.data + + # Reset the current workflow to the beginning - which we will consider to be the first task after the root + # element. This feels a little sketchy, but I think it is safe to assume root will have one child. + first_task = self.bpmn_workflow.task_tree.children[0] + first_task.reset_token(reset_data=False) + for task in new_bpmn_workflow.get_tasks(SpiffTask.READY): + task.data = first_task.data + new_bpmn_workflow.do_engine_steps() + self.bpmn_workflow = new_bpmn_workflow def get_status(self): return self.status_of(self.bpmn_workflow) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index dc900400..03a23aac 100644 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -294,10 +294,11 @@ class WorkflowService(object): template = Template(raw_doc) return template.render(**spiff_task.data) except jinja2.exceptions.TemplateError as ue: - - # return "Error processing template. %s" % ue.message raise ApiError(code="template_error", message="Error processing template for task %s: %s" % (spiff_task.task_spec.name, str(ue)), status_code=500) + except TypeError as te: + raise ApiError(code="template_error", message="Error processing template for task %s: %s" % + (spiff_task.task_spec.name, str(te)), status_code=500) # TODO: Catch additional errors and report back. @staticmethod diff --git a/crc/static/bpmn/research_rampup/research_rampup.bpmn b/crc/static/bpmn/research_rampup/research_rampup.bpmn index 93c4dd6d..03d82d00 100644 --- a/crc/static/bpmn/research_rampup/research_rampup.bpmn +++ b/crc/static/bpmn/research_rampup/research_rampup.bpmn @@ -72,6 +72,9 @@ Enter the following information for the PI submitting this request + + + @@ -81,6 +84,9 @@ Enter the following information for the PI submitting this request + + + @@ -89,6 +95,9 @@ Enter the following information for the PI submitting this request + + + @@ -97,6 +106,9 @@ Enter the following information for the PI submitting this request + + + @@ -105,6 +117,9 @@ Enter the following information for the PI submitting this request + + + @@ -113,18 +128,25 @@ Enter the following information for the PI submitting this request + + + + + + + @@ -138,42 +160,34 @@ Enter the following information for the PI submitting this request - #### People for whom you are requesting access -Provide information on all researchers you are requesting approval for reentry into the previously entered lab, workspace and/or office space(s) for conducting research on-Grounds. (If there are personnel already working in the space, include them). + #### Personnel for whom you are requesting access +Provide information on all personnel you are requesting approval for reentry into the previously entered lab, workspace and/or office space(s) for conducting research on-Grounds. (If there are personnel already working in the space, include them). **Note: no undergraduates will be allowed to work on-Grounds during Phase I.** #### Exclusive Space previously entered -{% for es in exclusive %} -{{ es.ExclusiveSpaceRoomID + " " + es.ExclusiveSpaceBuilding.label }} -{% else %} -No exclusive space entered -{% endfor %} - +{%+ for es in exclusive %}{{ es.ExclusiveSpaceRoomID + " " + es.ExclusiveSpaceBuilding.label }}{% if loop.last %}{% else %}, {% endif %}{% else %}No exclusive space entered{% endfor %} #### Shared Space previously entered -{% for ss in shared %} -{{ ss.SharedSpaceRoomID + " " + ss.SharedSpaceBuilding.label }} -{% else %} -No shared space entered -{% endfor %} +{%+ for ss in shared %}{{ ss.SharedSpaceRoomID + " " + ss.SharedSpaceBuilding.label }}{% if loop.last %}{% else %}, {% endif %}{% else %}No shared space entered.{% endfor %} - - + + - + + @@ -181,7 +195,7 @@ No shared space entered - + @@ -192,10 +206,8 @@ No shared space entered - - - - + + @@ -206,7 +218,7 @@ No shared space entered - + @@ -218,7 +230,7 @@ No shared space entered Flow_1nbjr72 - #### If applicable, provide a list of any [Core Resources](https://research.virginia.edu/research-core-resources) you will utilize space or instruments in and name/email of contact person in the core you have coordinated your plan with. (Core facility managers are responsible for developing a plan for their space) + If applicable, provide a list of any [Core Resources](https://research.virginia.edu/research-core-resources) utilization of space and/or instruments along with the name(s) and email(s) of contact person(s) in the core with whom you have coordinated your plan. (Core facility managers are responsible for developing a plan for their space) @@ -232,6 +244,7 @@ No shared space entered + @@ -263,6 +276,7 @@ When your Research Ramp-up Plan is complete and ready to submit for review and a + @@ -352,7 +366,8 @@ When your Research Ramp-up Plan is complete and ready to submit for review and a #### Space managed exclusively by {{ PIComputingID.label }} -Submit one entry for each space the PI is the exclusive investigator. If all space is shared with one or more other investigators, Click Save to skip this section and proceed to the Shared Space section. + +Submit one entry for each space the PI is the exclusive investigator. If all space is shared with one or more other investigators, click Save to skip this section and proceed to the Shared Space section. @@ -362,6 +377,7 @@ Submit one entry for each space the PI is the exclusive investigator. If all sp + @@ -465,7 +481,7 @@ Submit one entry for each space the PI is the exclusive investigator. If all sp - + #### Distancing requirements: Maintain social distancing by designing space between people to be at least 9 feet during prolonged work which will be accomplished by restricting the number of people in the lab to a density of ~250 sq. ft. /person in lab areas. When moving around, a minimum of 6 feet social distancing is required. Ideally only one person per lab bench and not more than one person can work at the same time in the same bay. @@ -496,7 +512,7 @@ Maintain social distancing by designing space between people to be at least 9 fe - Describe physical work arrangements for each lab. Show schematic of the lab and space organization to meet the distancing guidelines (see key safety expectations for ramp-up). + Describe physical work arrangements for each lab, workspace and/or office space previously entered. Show schematic of the space organization to meet the distancing guidelines (see key safety expectations for ramp-up). - Show gross dimensions, location of desks, and equipment in blocks (not details) that show available space for work and foot traffic. - Indicate total square footage for every lab/space that you are requesting adding personnel to in this application. If you would like help obtaining a floor plan for your lab, your department or deans office can help. You can also create a hand drawing/block diagram of your space and the location of objects on a graph paper. - Upload your physical layout and workspace organization in the form of a jpg image or a pdf file. This can be hand-drawn or actual floor plans. @@ -508,6 +524,7 @@ Maintain social distancing by designing space between people to be at least 9 fe + @@ -586,7 +603,7 @@ Use the EHS [Lab Safety Plan During COVID 19 template](https://www.google.com/ur #### By submitting this request, you understand that every member listed in this form for on Grounds laboratory access will: -- Complete online COVID awareness & precaution training module (link forthcoming-May 25) +- Complete [online COVID awareness & precaution training module](https://researchcompliance.web.virginia.edu/training_html5/module_content/154/index.cfm) - Complete daily health acknowledgement form signed (electronically) –email generated daily to those listed on your plan for access to on Grounds lab/research space - Fill out daily work attendance log for all lab members following your school process to check-in and out of work each day. Flow_08njvvi @@ -673,20 +690,14 @@ If notification is received that the Research Ramp-up Plan approval process is n Notify the Area Monitor for -#### Exclusive Space Area Monitors -{% for es in exclusive %} -{{ es.ExclusiveSpaceAMComputingID.data.display_name }} -{% else %} -No exclusive space entered -{% endfor %} +#### Exclusive Space previously entered +{%+ for es in exclusive %}{{ es.ExclusiveSpaceRoomID + " " + es.ExclusiveSpaceBuilding.label + " - " }}{% if es.ExclusiveSpaceAMComputingID is none %}No Area Monitor entered{% else %}{{ es.ExclusiveSpaceAMComputingID.label }}{% endif %}{% if loop.last %}{% else %}, {% endif %}{% else %}No exclusive space entered{% endfor %} -#### Shared Space Area Monitors -{% for ss in shared %} -{{ ss.SharedSpaceAMComputingID.data.display_name }} -{% else %} -No shared space entered -{% endfor %} + + +#### Shared Space previously entered +{%+ for ss in shared %}{{ ss.SharedSpaceRoomID + " " + ss.SharedSpaceBuilding.label }}{% if ss.SharedSpaceAMComputingID is none %}No Area Monitor entered{% else %}{{ ss.SharedSpaceAMComputingID.label }}{% endif %}{% if loop.last %}{% else %}, {% endif %}{% else %}No shared space entered.{% endfor %} Flow_1ufh44h Flow_0cpmvcw @@ -709,10 +720,15 @@ This step is internal to the system and do not require and user interactionFlow_1v7r1tg UpdateStudy title:PIComputingID.label pi:PIComputingID.value - - - #### Weekly Schedule -Provide your initial weekly laboratory schedule for all members that you are requesting access for, indicating all shifts as necessary. If any schedule changes after approval, please submit your revised schedule here for re-approval. + + + #### Weekly Personnel Schedule(s) +Provide initial weekly schedule(s) for the PI and all personnel for whom access has been requested, indicating each space they will be working in and all shifts, if applicable. + +##### Personnel and spaces they will work in previously entered +{%+ for p in personnel %}{{ p.PersonnelComputingID.label + " - " + p.PersonnelSpace }}{% if loop.last %}{% else %}; {% endif %}{% endfor %} + +**Note:** If any schedule changes after approval, please re-submit revised schedule(s) here for re-approval. @@ -953,7 +969,7 @@ Provide your initial weekly laboratory schedule for all members that you are req - +