Skip to content

Commit

Permalink
added the outline of the PR. need to discuss the caching format
Browse files Browse the repository at this point in the history
  • Loading branch information
stan-dot committed Jun 25, 2024
1 parent 2c84311 commit 057367b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/blueapi/core/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class BlueskyContext:
)
plans: dict[str, Plan] = field(default_factory=dict)
devices: dict[str, Device] = field(default_factory=dict)
# todo add some format to keep the lazy vs non-lazy devices
plan_functions: dict[str, PlanGenerator] = field(default_factory=dict)

_reference_cache: dict[type, type] = field(default_factory=dict)
Expand Down Expand Up @@ -104,6 +105,11 @@ def with_device_module(self, module: ModuleType) -> None:

def with_dodal_module(self, module: ModuleType, **kwargs) -> None:
devices, exceptions = make_all_devices(module, **kwargs)
# todo modify here
# factories = get_device_factories(module)

# for non-lazy devices, we instantiate them
# for lazy devices we add to the context to do when the plan is run

for device in devices.values():
self.device(device)
Expand Down
2 changes: 2 additions & 0 deletions src/blueapi/worker/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def prepare_params(self, ctx: BlueskyContext) -> BaseModel:
def do_task(self, ctx: BlueskyContext) -> None:
LOGGER.info(f"Asked to run plan {self.name} with {self.params}")

# todo here call ensure_connected on alpl the devices marked in the context as needing that
# ensure_connected(ctx.lazy_devices.values())
func = ctx.plan_functions[self.name]
prepared_params = self.prepare_params(ctx)
ctx.run_engine(func(**prepared_params.dict()))
Expand Down

0 comments on commit 057367b

Please sign in to comment.