Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

315 split fgs communicator #357

Merged
merged 38 commits into from
Nov 21, 2022
Merged

315 split fgs communicator #357

merged 38 commits into from
Nov 21, 2022

Conversation

dperl-dls
Copy link
Collaborator

Fixes #315

Separates the FGSCommunicator into three callback classes, adds a collection for easy subscription and handling the connection between the ispyb and zocalo components

To test:

  1. Check the changes make sense
  2. Check the new test makes sense
  3. Confirm tests pass

and add changes from test_fgs_communicator
to appropriate individual callback test files

Squashed commit of the following:

commit 59739c2
Merge: 0a0c534 67c49cc
Author: David Perl <[email protected]>
Date:   Fri Nov 18 11:31:31 2022 +0000

    Merge pull request #371 from DiamondLightSource/353_merge_smargons

commit 67c49cc
Author: Dominic Oram <[email protected]>
Date:   Fri Nov 18 11:23:07 2022 +0000

    (#353) Merged smargons into one

commit 0a0c534
Merge: 8b58b3d 0172183
Author: Dominic Oram <[email protected]>
Date:   Thu Nov 17 15:40:52 2022 +0000

    Merge pull request #362 from DiamondLightSource/361_default_interpreter

    (#361) updating default python interpreter

commit 8b58b3d
Merge: b65f8f0 4f2de21
Author: Dominic Oram <[email protected]>
Date:   Thu Nov 17 15:17:35 2022 +0000

    Merge pull request #347 from DiamondLightSource/231_adjust_zocalo_coords

commit 0172183
Author: Neil.Smith <[email protected]>
Date:   Thu Nov 17 14:56:51 2022 +0000

    (#361) updating default python interpreter

commit 4f2de21
Author: David Perl <[email protected]>
Date:   Thu Nov 17 14:44:58 2022 +0000

commit b65f8f0
Merge: 2bb56e8 9c2d58d
Author: Dominic Oram <[email protected]>
Date:   Thu Nov 17 13:54:07 2022 +0000

    Merge pull request #360 from DiamondLightSource/344_update_nexgen

    344 update nexgen

commit 9c2d58d
Author: David Perl <[email protected]>
Date:   Thu Nov 17 11:58:02 2022 +0000

commit 0baf4f4
Author: David Perl <[email protected]>
Date:   Thu Nov 17 11:53:33 2022 +0000

commit 0e27def
Author: David Perl <[email protected]>
Date:   Thu Nov 17 11:51:59 2022 +0000

commit 2c8d12e
Author: David Perl <[email protected]>
Date:   Thu Nov 17 09:59:01 2022 +0000

commit a7f94b7
Author: David Perl <[email protected]>
Date:   Fri Nov 11 14:44:37 2022 +0000

commit a5896ab
Author: David Perl <[email protected]>
Date:   Fri Nov 11 14:40:37 2022 +0000

    and update tests to match
Copy link
Collaborator

@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.

This is a lot cleaner, thank you. Mostly minor comments:

  • Can you fix the merge conflicts?
  • I think it makes sense for the callbacks to be next to the thing they are handling e.g. the zocalo callback in zocalo_interaction
  • I really like the external_interaction folder, I think zocalo_interaction should live in it and it would be nice to have a description in the __init__ of what it contains
  • testdata.py looks like an empty file, is this required?

datacollection_ids = self.ispyb.ispyb_ids[0]
for id in datacollection_ids:
run_end(id)
self.processing_start_time
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should: remove line doing nothing

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops, was meant to be =time.time()

def __init__(self, parameters: FullParameters, ispyb_handler: ISPyBHandlerCallback):
self.params = parameters
self.processing_start_time = 0.0
self.processing_time = 0.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: This doesn't have to be an instance variable, we only use it in one method

Comment on lines 48 to 59
dc_ids = [1, 2]
dcg_id = 4

mock_ispyb_store_grid_scan.return_value = [dc_ids, None, dcg_id]
mock_ispyb_get_time.return_value = td.DUMMY_TIME_STRING
mock_ispyb_update_time_and_status.return_value = None

params = FullParameters()
ispyb_handler = ISPyBHandlerCallback(params)
ispyb_handler.start(td.test_start_document)
ispyb_handler.descriptor(td.test_descriptor_document)
ispyb_handler.event(td.test_event_document)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I would pull the common bit of these two tests out into a function/fixture


from artemis.external_interaction.communicator_callbacks import ISPyBHandlerCallback
from artemis.parameters import FullParameters

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I think we could test:

  • The exception on a stop w/o ids
  • That ispyb only gets triggered on the correct plan

from artemis.utils import Point3D


def test_run_gridscan_zocalo_calls(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Can we change the name of this test to be a bit more descriptive?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure, I didn't name it :p

from unittest.mock import MagicMock, call

from artemis.external_interaction.communicator_callbacks import FGSCallbackCollection
from artemis.parameters import FullParameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Can we also test that the exceptions are thrown by the zocalo handler if ispyb has not been called correctly yet?

@codecov
Copy link

codecov bot commented Nov 18, 2022

Codecov Report

Merging #357 (f3c1fdf) into main (59739c2) will increase coverage by 0.66%.
The diff coverage is 98.13%.

@@            Coverage Diff             @@
##             main     #357      +/-   ##
==========================================
+ Coverage   85.94%   86.60%   +0.66%     
==========================================
  Files          43       44       +1     
  Lines        1601     1680      +79     
==========================================
+ Hits         1376     1455      +79     
  Misses        225      225              
Impacted Files Coverage Δ
...emis/external_interaction/ispyb/ispyb_dataclass.py 100.00% <ø> (ø)
src/artemis/fast_grid_scan_plan.py 65.15% <77.77%> (-0.53%) ⬇️
...mis/external_interaction/communicator_callbacks.py 98.95% <98.95%> (ø)
src/artemis/__main__.py 92.12% <100.00%> (ø)
...temis/external_interaction/ispyb/store_in_ispyb.py 96.23% <100.00%> (ø)
.../external_interaction/nexus_writing/write_nexus.py 100.00% <100.00%> (ø)
src/artemis/external_interaction/tests/conftest.py 100.00% <100.00%> (ø)
...artemis/external_interaction/zocalo_interaction.py 97.72% <100.00%> (ø)
src/artemis/parameters.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dperl-dls
Copy link
Collaborator Author

I don't know why it's still saying there are conflicts - I merged main in dcb4316. I figure it's because I squashed 13 commits into one for that - but now when I try to merge again I can't commit it because there are no changes, and the diff shows me a bunch of things which are actually identical. All the conflicts can be safely accepted from this branch into main, all the changes are on this branch already.

@DominicOram
Copy link
Collaborator

I don't know why it's still saying there are conflicts - I merged main in dcb4316. I figure it's because I squashed 13 commits into one for that - but now when I try to merge again I can't commit it because there are no changes, and the diff shows me a bunch of things which are actually identical. All the conflicts can be safely accepted from this branch into main, all the changes are on this branch already.

Not sure what was going on here. I managed to merge fine doing:

git checkout main && git pull
git checkout 315_split_fgs_communicator && git pull
git merge main
... fixed a couple of merge conflicts
git commit && git push

Copy link
Collaborator

@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, code looks good. I think we discussed refactoring to have the dc_id in the plan metadata or in the zocalo constructor. Is there an issue for this?

@dperl-dls
Copy link
Collaborator Author

Thanks, code looks good. I think we discussed refactoring to have the dc_id in the plan metadata or in the zocalo constructor. Is there an issue for this?

yes, #372

@dperl-dls dperl-dls merged commit d8819e7 into main Nov 21, 2022
@dperl-dls dperl-dls deleted the 315_split_fgs_communicator branch November 21, 2022 13:35
@DominicOram
Copy link
Collaborator

Thanks, code looks good. I think we discussed refactoring to have the dc_id in the plan metadata or in the zocalo constructor. Is there an issue for this?

yes, #372

Actually #375

noemifrisina pushed a commit to DiamondLightSource/dodal that referenced this pull request Jan 16, 2023
…ource/315_split_fgs_communicator

315 split fgs communicator
NOTE: Commit originally came from https://github.com/DiamondLightSource/python-artemis
noemifrisina pushed a commit to DiamondLightSource/dodal that referenced this pull request Jan 18, 2023
…ource/315_split_fgs_communicator

315 split fgs communicator
NOTE: Commit originally came from https://github.com/DiamondLightSource/python-artemis
noemifrisina pushed a commit to DiamondLightSource/dodal that referenced this pull request Jan 18, 2023
…ource/315_split_fgs_communicator

315 split fgs communicator
NOTE: Commit originally came from https://github.com/DiamondLightSource/python-artemis
noemifrisina pushed a commit to DiamondLightSource/dodal that referenced this pull request Jan 18, 2023
…ource/315_split_fgs_communicator

315 split fgs communicator
NOTE: Commit originally came from https://github.com/DiamondLightSource/python-artemis
noemifrisina pushed a commit to DiamondLightSource/dodal that referenced this pull request Feb 17, 2023
…ource/315_split_fgs_communicator

315 split fgs communicator
NOTE: Commit originally came from https://github.com/DiamondLightSource/python-artemis
noemifrisina pushed a commit to DiamondLightSource/dodal that referenced this pull request Feb 24, 2023
…ource/315_split_fgs_communicator

315 split fgs communicator
NOTE: Commit originally came from https://github.com/DiamondLightSource/python-artemis
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

split fgs_communicator into separate callback classes
2 participants