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

Use is_plan from bluesky utils #306

Merged
merged 6 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion bluesky_queueserver/manager/profile_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,14 @@ def is_plan(obj):
"""
Returns ``True`` if the object is a plan.
"""
return inspect.isgeneratorfunction(obj)

try:
# If available, use is_plan from bs utils to catch plans with new decorator.
from bluesky.utils import is_plan as bs_utils_is_plan

return bs_utils_is_plan(obj)
except ImportError:
return inspect.isgeneratorfunction(obj)


def is_device(obj):
Expand Down
14 changes: 13 additions & 1 deletion bluesky_queueserver/manager/tests/test_profile_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -3760,7 +3760,7 @@ def test_construct_parameters_1(testmode, success, errmsg):
# ---------------------------------------------------------------------------------


def test_plans_from_nspace():
def test_plans_from_nspace_1():
"""
Function 'plans_from_nspace' is extracting a subset of callable items from the namespace
"""
Expand All @@ -3771,6 +3771,18 @@ def test_plans_from_nspace():
assert callable(plan), f"Plan '{name}' is not callable"


def test_plans_from_nspace_2():
"""
Function 'plans_from_nspace' is extracting a subset of callable items from the namespace
"""
pc_path = get_default_startup_dir()
nspace = load_profile_collection(pc_path)
plans = plans_from_nspace(nspace)
assert "mv" in plans
assert "mvr" in plans
assert "null" in plans


def test_devices_from_nspace():
"""
Function 'plans_from_nspace' is extracting a subset of callable items from the namespace
Expand Down
2 changes: 2 additions & 0 deletions bluesky_queueserver/profile_collection_sim/00-ophyd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# flake8: noqa
print(f"Loading file {__file__!r}")

# Import some built-in plans
from bluesky.plan_stubs import mv, mvr, null
from ophyd.sim import hw

# Import ALL simulated Ophyd objects in global namespace (borrowed from ophyd.sim)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2049,6 +2049,60 @@ existing_plans:
step: '0.01'
properties:
is_generator: true
mv:
description: Move one or more devices to a setpoint. Wait for all to complete.
module: bluesky.plan_stubs
name: mv
parameters:
- description: device1, value1, device2, value2, ...
kind:
name: VAR_POSITIONAL
value: 2
name: args
- default: None
description: Used to mark these as a unit to be waited on.
kind:
name: KEYWORD_ONLY
value: 3
name: group
- description: passed to obj.set()
kind:
name: VAR_KEYWORD
value: 4
name: kwargs
properties:
is_generator: true
mvr:
description: Move one or more devices to a relative setpoint. Wait for all to
complete.
module: bluesky.plan_stubs
name: mvr
parameters:
- description: device1, value1, device2, value2, ...
kind:
name: VAR_POSITIONAL
value: 2
name: args
- default: None
description: Used to mark these as a unit to be waited on.
kind:
name: KEYWORD_ONLY
value: 3
name: group
- description: passed to obj.set()
kind:
name: VAR_KEYWORD
value: 4
name: kwargs
properties:
is_generator: true
'null':
description: Yield a no-op Message. (Primarily for debugging and testing.)
module: bluesky.plan_stubs
name: 'null'
parameters: []
properties:
is_generator: true
plan_test_progress_bars:
description: Test visualization of progress bars.
module: __main__
Expand Down
Loading