Skip to content

Improve externally facing class names - #166

Open
jacob-williamson wants to merge 13 commits into
mainfrom
tidy_types
Open

jacob-williamson wants to merge 13 commits into
mainfrom
tidy_types

Conversation

@jacob-williamson

Copy link
Copy Markdown
Collaborator

Changes TaskWithPosition to QueueTask and BlueapiCallResponse to QueueBlueapiCall, to improve clarity when using these types in other repos.

@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.66%. Comparing base (12403b7) to head (5fd4d9b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #166      +/-   ##
==========================================
- Coverage   98.67%   98.66%   -0.02%     
==========================================
  Files          23       23              
  Lines        1287     1271      -16     
==========================================
- Hits         1270     1254      -16     
  Misses         17       17              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DominicOram DominicOram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, I think the change is probably a bit clearer but more docstrings would make it even clearer still.


def to_response(self) -> "BlueapiCallResponse":
return BlueapiCallResponse.from_blueapi_call(self)
def to_response(self) -> "QueueBlueapiCall":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should: This method name now doesn't make much sense



class BlueapiCallResponse(BaseModel):
class QueueBlueapiCall(BaseModel):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should: Can we have a docstring here explaining how this differs from BlueapiCall? It also feels weird that we have two classes with so much repeated info, will #125 tidy this up or maybe we need some other inheritance to tidy it?

@jacob-williamson jacob-williamson Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The reason I didn't use inheritance is because these externally facing classes are intended as snapshot copies of the internally used classes. So none of the fields have defaults for example, as it is expected they are all provided by an instance of the internal class. And properties on the internal class are regular fields on the external one as the internal class calculates them and populates. Maybe a load of over complication for not much benefit, will see if I can refactor

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Looking into it a bit more and remembering things, another reason I didn't use inheritance was because the internal classes have some methods on it which are meaningless for instances passed to plugins, when they are only intended in that case as a blob of information (like BlueapiCall.put_in_progress, which does nothing if called in a plugin but may be confusing to have)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Have refactored a bit, could also roll #125 into the same PR?



class TaskWithPosition(BaseModel):
class QueueTask(BaseModel):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should: Similar to https://github.com/DiamondLightSource/daq-queuing-service/pull/166/changes#r4455793608, a docstring would be good, and we should think about if there's some class hierarchy here

"""
return True

def process_running_task(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Must: This is a change from https://github.com/DiamondLightSource/daq-queuing-service/pull/152/changes, right? Can we make sure we have this PR as just the one thing?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah must have had an dirty base branch, will fix

tiled_ids, scan_ids = get_tiled_and_scan_ids(self._tiled_client, call)
should_pause = self._converter.pause_on_complete_blueapi_call(
call.model_copy(), result
call.to_response(), result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should: Is this also a change from https://github.com/DiamondLightSource/daq-queuing-service/pull/152/changes? It's not clear how this is part of changing the name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Some of these have changed due to typing changes on the plugin, I've made the plugin always receive QueueBlueapiCall instead of BlueapiCall as they never need any of the state change methods on BlueapiCall

This branch has not been deployed

No deployments
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