-
Notifications
You must be signed in to change notification settings - Fork 5
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
Remove public fields of BlueskyContext and replace with methods #174
Changes from all commits
43a3090
ccd3844
38b8387
f6ea454
a6646e7
b8761c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,15 +41,18 @@ class RunPlan(Task): | |
def do_task(self, ctx: BlueskyContext) -> None: | ||
LOGGER.info(f"Asked to run plan {self.name} with {self.params}") | ||
|
||
plan = ctx.plans[self.name] | ||
func = ctx.plan_functions[self.name] | ||
sanitized_params = _lookup_params(ctx, plan, self.params) | ||
plan_generator = func(**sanitized_params.dict()) | ||
metadata = ctx.find_plan_metadata(self.name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these two functions are only ever called together and both have to be present, it'd be clearer to have a single |
||
func = ctx.find_plan_function(self.name) | ||
if metadata is None or func is None: | ||
raise KeyError(f"No plan named {self.name}") | ||
sanitized_params = _lookup_params(metadata, self.params).dict() | ||
plan_generator = func(**sanitized_params) | ||
ctx.run_engine(plan_generator) | ||
|
||
|
||
def _lookup_params( | ||
ctx: BlueskyContext, plan: Plan, params: Mapping[str, Any] | ||
plan: Plan, | ||
params: Mapping[str, Any], | ||
) -> BaseModel: | ||
""" | ||
Checks plan parameters against context | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth making these two properties as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or not having any properties... I'm always on the fence between the potential for confusion and the nice read-only-ness