Skip to content

Allow injection of Devices into plan arguments from the BlueskyContext - #175

Merged
DiamondJoseph merged 15 commits into
DiamondLightSource:mainfrom
DiamondJoseph:context-injection
May 18, 2023
Merged

DiamondJoseph merged 15 commits into
DiamondLightSource:mainfrom
DiamondJoseph:context-injection

Conversation

@DiamondJoseph

@DiamondJoseph DiamondJoseph commented May 11, 2023 •

Copy link
Copy Markdown
Contributor

closes #116

@DiamondJoseph

Copy link
Copy Markdown
Contributor Author

Probably wants some documentation too

Comment thread src/blueapi/core/context.py Resolved
Comment thread src/blueapi/core/context.py Resolved
Comment thread src/blueapi/core/context.py Resolved
@codecov

codecov Bot commented May 12, 2023 •

Copy link
Copy Markdown

Codecov Report

Merging #175 (f80b733) into main (a90b53b) will increase coverage by 0.40%.
The diff coverage is 80.00%.

@@            Coverage Diff             @@
##             main     #175      +/-   ##
==========================================
+ Coverage   87.50%   87.90%   +0.40%     
==========================================
  Files          41       41              
  Lines        1120     1124       +4     
==========================================
+ Hits          980      988       +8     
+ Misses        140      136       -4     
Impacted Files Coverage Δ
src/blueapi/config.py 96.36% <ø> (ø)
src/blueapi/core/context.py 97.11% <0.00%> (+3.84%) ⬆️
src/blueapi/core/__init__.py 100.00% <100.00%> (ø)
src/blueapi/core/device_lookup.py 94.11% <100.00%> (+0.78%) ⬆️
src/blueapi/utils/base_model.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

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

@DiamondJoseph DiamondJoseph changed the title Allow injection of plan arguments from the BlueskyContext Allow injection of Devices into plan arguments from the BlueskyContext May 12, 2023
Comment thread tests/core/test_context.py Resolved
Comment thread src/blueapi/startup/example.py Resolved
Comment thread src/blueapi/core/context.py Outdated
)

no_default = para.default is Parameter.empty
if isinstance(para.default, Component):

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.

Component covers all ophyd devices? If we're checking for that we probably don't need to the default_factory and can revert to just setting the default value.

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

Looks good, only minor nitpicks

Comment thread src/blueapi/startup/example_plans.py Resolved
Comment thread src/blueapi/core/__init__.py Resolved
Comment thread src/blueapi/core/device_lookup.py Outdated
)


def inject(x):

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.

Worth commenting that types are intentionally omitted to bypass type checking? This function doesn't look like it does much otherwise. I think x could be typed as str as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have added some doc string and if the linting fails I can revert the name: str

Comment thread tests/core/test_context.py Resolved
@DiamondJoseph
DiamondJoseph merged commit 6e579fe into DiamondLightSource:main May 18, 2023
@DiamondJoseph
DiamondJoseph deleted the context-injection branch May 18, 2023 07:57
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.

Enable injection of device from context into plans

3 participants