DiamondLightSource / DiamondLightSource/blueapi
Improve EnvironmentResponse handling API
- Dominant language
- Python
- Stars
- 13
- Forks
- 13
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 25
Description
Currently the `EnvironmentResponse` class contained a boolean `initialized` field and a string `error_message` field, the combination of whic is used to determine what action is taken during `WorkerDispatcher` initialization. At the moment this decision is spread across multiple lines and is not immediately clear on what the acceptable/valid states are without detailed knowledge of the class. The correct interpretation should be as follows:
| `initialized=True` | `initialized=False`
-- | -- | --
`error_message is None` | Return | Block until next poll
`error_message is not None` | Undefined | Raise
This should be encapsulated in e.g. a dedicated `enum` field so that he logic is fixed and can be interpreted based on an explicit set of possibilities
## Acceptance Criteria
- The `EnvironmentResponse` class contains a single field that encapsulates the interpretation logic described as known states which can be directly compared
- The new field is updated automatically by the class when the state of its constituent parts changes
- The affected interpretations of the class have been migrated to use the new field
- Tests have been provided to validate the behaviour for eaxh allowed state of the field
Contributor guide
Assessment
This issue has not been assessed yet.