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

MXDGA-3724: Added the MVP for the fast grid scan motion #2

Merged
merged 7 commits into from
Jan 14, 2022

Conversation

DominicOram
Copy link
Collaborator

See https://jira.diamond.ac.uk/browse/MXDGA-3724

To review:

  • Confirm that the Fast Grid Scan device is doing everything required for https://jira.diamond.ac.uk/browse/MXGDA-3733
  • Confirm unit tests run
  • Note that the system tests will not work against s03 currently as the fast grid scan IOC is not running on it

Copy link
Collaborator

@graeme-winter graeme-winter left a comment

Choose a reason for hiding this comment

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

Made a couple of comments, but these are just opinions on scanning the code.

Do we use black for formatting?

I don't know what the "house style" is for blue sky so I don't know if set_params(1, 2, 3, 4, 5) is good practice or no...

from ophyd.sim import make_fake_device
from src.artemis.devices.fast_grid_scan import FastGridScan, time

from mockito import *
Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally I prefer to import what you use rather than from thing import * - so for example when I wonder what when() is below, I can see where it comes from

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, I wouldn't use import * in the actual production code so I shouldn't in the test code.

# Kickoff timeout in seconds
KICKOFF_TIMEOUT: float = 5.0

def set_program_data(self, nx, ny, width, height, exptime, startx, starty, startz):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kinda feel like more structured API here would help? set_program_data call in the test just looks like pushing a bunch of random numbers

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yh, I left this in as a bit of a placeholder until I had a better feel for how we would actually be using the Device upstream but I'll think about improving it now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I borrowed some of the work of @callumforrester for this, which also included some checking against motor limits.

Choose a reason for hiding this comment

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

Didn't spot this chain, I think this needs updating to reflect this thread: #2 (comment)

@DominicOram
Copy link
Collaborator Author

Made a couple of comments, but these are just opinions on scanning the code.

Do we use black for formatting?

I don't know what the "house style" is for blue sky so I don't know if set_params(1, 2, 3, 4, 5) is good practice or no...

I've been using black, have a mild preference for it as it avoids arguments over specific formatting settings. Not sure if ophyd/bluesky use it. Looks like they use flake8 (https://github.com/bluesky/ophyd/blob/master/.flake8) but they're not necessarily mutually exclusive. Now that this repo is starting to grow I'll add a ticket in for some CI, including format checking against a similar flake8 profile to them.

@graeme-winter
Copy link
Collaborator

Made a couple of comments, but these are just opinions on scanning the code.
Do we use black for formatting?
I don't know what the "house style" is for blue sky so I don't know if set_params(1, 2, 3, 4, 5) is good practice or no...

I've been using black, have a mild preference for it as it avoids arguments over specific formatting settings. Not sure if ophyd/bluesky use it. Looks like they use flake8 (https://github.com/bluesky/ophyd/blob/master/.flake8) but they're not necessarily mutually exclusive. Now that this repo is starting to grow I'll add a ticket in for some CI, including format checking against a similar flake8 profile to them.

We already have black and flake8 set up as pre-commit hooks in most of our analysis code, so we can probably just copypasta the configuration over. Prefer pre-commit to working it out in a CI system as keeps the history cleaner... and makes for easier to read diffs.

Copy link

@callumforrester callumforrester left a comment

Choose a reason for hiding this comment

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

Looks great, Dom. Code is very clear and well-documented. I particularly like the studious use of type annotations! Have added a few minor comments for things I spotted here and there.

src/artemis/devices/fast_grid_scan.py Outdated Show resolved Hide resolved
src/artemis/devices/motors.py Outdated Show resolved Hide resolved
src/artemis/devices/fast_grid_scan.py Outdated Show resolved Hide resolved
except ZeroDivisionError:
fraction = 1
time_remaining = 0
except Exception:

Choose a reason for hiding this comment

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

If there is some unknown exception I think we should pass it upwards with self.set_exception().

src/artemis/devices/system_tests/test_gridscan_system.py Outdated Show resolved Hide resolved
@callumforrester
Copy link

@graeme-winter and @DominicOram

Prefer pre-commit to working it out in a CI system as keeps the history cleaner... and makes for easier to read diffs.

I prefer both because unknown agents can get around pre-commit, but pre-commit covers the 90% case so probably okay. However I suggest making a CI job for the tests regardless.

@thomascobb
Copy link

I'm going to put a plug in for how we do things in Controls, feel free to adopt whatever is useful:

  • Pipenv for version management
  • Pre-commit with black, flake8, isort and mypy for static analysis
  • Pytest for code and coverage
  • Sphinx for tutorials, how-to guides, explanations and reference documentation
  • GitHub Actions for code and docs CI and deployment to PyPI and GitHub Pages
  • VSCode settings using black, flake8, isort and mypy on save

None of this depends on internal DLS infrastructure so will still work if you unset the PYPI mirror.

We've captured this setup in a skeleton module that you can either copy/paste from or git pull changes from:
https://github.com/dls-controls/dls-python3-skeleton

Here's an example of a module that uses it:
https://github.com/dls-controls/sphinx_rtd_theme_github_versions

@DominicOram
Copy link
Collaborator Author

DominicOram commented Jan 11, 2022

Done the rework from both @callumforrester and @graeme-winter, thanks! CI issues will be addressed in https://jira.diamond.ac.uk/browse/MXGDA-3761

@DominicOram
Copy link
Collaborator Author

After discussing with @graeme-winter today I think this is just waiting on review from @bentom08, if you have any thoughts?

Copy link
Contributor

@bentom08 bentom08 left a comment

Choose a reason for hiding this comment

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

Everything looks fine to me, happy for this to be merged in as is.

@DominicOram DominicOram merged commit 586f62d into main Jan 14, 2022
@DominicOram DominicOram deleted the MXGDA_3724 branch January 14, 2022 11:00
DominicOram added a commit to DiamondLightSource/dodal that referenced this pull request Aug 31, 2022
…rce/MXGDA_3724

MXDGA-3724: Added the MVP for the fast grid scan motion
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
…rce/MXGDA_3724

MXDGA-3724: Added the MVP for the fast grid scan motion
NOTE: Commit originally came from https://github.com/DiamondLightSource/python-artemis
rtuck99 pushed a commit that referenced this pull request Dec 14, 2023
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.

5 participants