Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Pydantic2 and ophyd_async 0.5.x #764

Merged
merged 16 commits into from
Sep 6, 2024
Merged

Update to Pydantic2 and ophyd_async 0.5.x #764

merged 16 commits into from
Sep 6, 2024

Conversation

DiamondJoseph
Copy link
Contributor

@DiamondJoseph DiamondJoseph commented Aug 30, 2024

Fixes #679, paves route to #644 after p4p updated.

Instructions to reviewer on how to test:

  1. Run system tests to ensure devices still connect

Checks for reviewer

  • Would the PR title make sense to a scientist on a set of release notes
  • If a new device has been added does it follow the standards
  • If changing the API for a pre-existing device, ensure that any beamlines using this device have updated their Bluesky plans accordingly
  • Have the connection tests for the relevant beamline(s) been run via dodal connect ${BEAMLINE}

@DiamondJoseph
Copy link
Contributor Author

Tagged 5 reviewers on this because there's a lot of lines changed so would really appreciate a few pairs of eyes over this.

Copy link

codecov bot commented Sep 4, 2024

Codecov Report

Attention: Patch coverage is 96.51741% with 7 lines in your changes missing coverage. Please review.

Project coverage is 94.89%. Comparing base (c4051ba) to head (144682d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/dodal/devices/i22/nxsas.py 81.25% 3 Missing ⚠️
src/dodal/common/udc_directory_provider.py 94.73% 1 Missing ⚠️
src/dodal/devices/CTAB.py 0.00% 1 Missing ⚠️
src/dodal/devices/scintillator.py 0.00% 1 Missing ⚠️
src/dodal/plans/data_session_metadata.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #764      +/-   ##
==========================================
+ Coverage   94.55%   94.89%   +0.33%     
==========================================
  Files         115      115              
  Lines        4631     4640       +9     
==========================================
+ Hits         4379     4403      +24     
+ Misses        252      237      -15     

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

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Great, thank you. Some comments in code. Can we wait for DiamondLightSource/mx-bluesky#454 to be done and merge both at the same time? I'll pick that up now

@@ -61,7 +73,7 @@ async def get_current_collection(self) -> DataCollectionIdentifier:
async with session.get(f"{self._url}/numtracker") as response:
response.raise_for_status()
json = await response.json()
current_collection = DataCollectionIdentifier.parse_obj(json)
current_collection = DataCollectionIdentifier.model_validate_json(json)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: Can we add some unit tests against DirectoryServiceClient whilst we're here to confirm this? Bonus points for refactoring the almost identical create_new_collection and get_current_collection to share common code

src/dodal/devices/detector/detector.py Outdated Show resolved Hide resolved
src/dodal/devices/detector/detector.py Outdated Show resolved Hide resolved
src/dodal/devices/i22/nxsas.py Outdated Show resolved Hide resolved
src/dodal/common/udc_directory_provider.py Show resolved Hide resolved
tests/common/test_udc_directory_provider.py Show resolved Hide resolved
tests/preprocessors/test_filesystem_metadata.py Outdated Show resolved Hide resolved
StaticVisitPathProvider(
BL,
Path("/exports/mybeamline/data"),
client=LocalDirectoryServiceClient(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

n.b. this means the file number will reset each time blueapi is restarted @callumforrester

response.raise_for_status()
json = await response.json()
new_collection = DataCollectionIdentifier.model_validate_json(json)
LOGGER.debug("New DataCollection: %s", new_collection)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should: Sorry, I know I asked you to combine these but now both of them print New DataCollection, which I suspect will be confusing. I will fix this and add tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I thought about making it just "DataCollection %s". I think the new visit service will remove one of the methods, we just mutate a new DCI and cache the return value, which is probably also how this should behave now.

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

Thanks @DiamondJoseph. I'm happy with all the changes here to code that MX uses. I've only done a basic review on:

  • Directory provider stuff
  • Tetramm

As I'm not so familiar with it, if someone else from core wants to review those bits that would be good. Otherwise the only reason I'm blocking merging is I would like DiamondLightSource/mx-bluesky#454 to be at the same time.

Copy link
Contributor

@DominicOram DominicOram left a comment

Choose a reason for hiding this comment

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

I've been convinced that we should merge this now to get out of dependency hell elsewhere. I have also been assure that @callumforrester is happy with the bits of the PR I've not looked at too closely

@DominicOram DominicOram merged commit 350ca72 into main Sep 6, 2024
18 checks passed
@DominicOram DominicOram deleted the pydantic2 branch September 6, 2024 10:13
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.

Move to pydantic v2
4 participants