Skip to content

Fix error thrown when the task_class of a task is None#156

Merged
backmari merged 2 commits intonextfrom
workflow_task_class
Feb 28, 2024
Merged

Fix error thrown when the task_class of a task is None#156
backmari merged 2 commits intonextfrom
workflow_task_class

Conversation

@backmari
Copy link
Collaborator

Short description of the changes:

Tasks added using the Django admin interface will have task_class equal to None if it is left empty. A task with task_class equal to None caused an error to be thrown in workflow_app in the WebMon test environment. This PR adds a check for None before the call to strip() and a unit test.

INFO:2024-02-27 14:52:37,039 arcs r201562: POSTPROCESS.DATA_READY: {'facility': 'SNS', 'instrument': 'arcs', 'ipts': 'IPTS-27800', 'run_number': 201562, 'data_file': '/SNS/ARCS/IPTS-27800/nexus/ARCS_201562.nxs.h5', 'information': 'Requested by u5z'}
ERROR:2024-02-27 14:52:37,061 Listener failed to process message:
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/workflow/amq_listener.py", line 61, in on_message
    action(headers, message)
  File "/opt/conda/lib/python3.10/site-packages/workflow/state_utilities.py", line 70, in process_function
    return action(self, headers, message)
  File "/opt/conda/lib/python3.10/site-packages/workflow/states.py", line 84, in __call__
    self._call_db_task(task_data, headers, message)
  File "/opt/conda/lib/python3.10/site-packages/workflow/states.py", line 56, in _call_db_task
    if "task_class" in task_def and len(task_def["task_class"].strip()) > 0:
AttributeError: 'NoneType' object has no attribute 'strip'

Check list for the pull request

  • I have read the [CONTRIBUTING]
  • I have read the [CODE_OF_CONDUCT]
  • I have added tests for my changes
  • I have updated the documentation accordingly

Check list for the reviewer

  • I have read the [CONTRIBUTING]
  • I have verified the proposed changes
  • best software practices
    • all internal functions have an underbar, as is python standard
    • clearly named variables (better to be verbose in variable names)
    • code comments explaining the intent of code blocks
  • All the tests are passing
  • The documentation is up to date
  • code comments added when explaining intent

Manual test for the reviewer

References

Story 2822: Test post processing agent v3.0 in test environment

Copy link
Member

@peterfpeterson peterfpeterson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the new tests

@backmari backmari merged commit fd5df89 into next Feb 28, 2024
@backmari backmari deleted the workflow_task_class branch February 28, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants