You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Combine context.plans and context.plan_functions into a single dictionary #180
note: Plan is in core/bluesky_types.py with fields: name, description, model (Pydantic model) PlanModel is in service/model.py under with fields: name, description, parameter_schema (optional dictionary).
The latter also has a classmethod 'from_plan', which serves as alternative constructor.
May be able to make use of TypeAdapter instances to get the JSON schema from.
classPlan(BlueapiBaseModel):
""" A plan that can be run """name: str=Field(description="Referenceable name of the plan")
description: str|None=Field(
description="Description/docstring of the plan", default=None
)
model: type[BaseModel] =Field(
description="Validation model of the parameters for the plan"
)
becomes
classPlan(BlueapiBaseModel):
""" A plan that can be run """name: str=Field(description="Referenceable name of the plan")
description: str|None=Field(
description="Description/docstring of the plan", default=None
)
type_adaptergenerator: PlanGenerator@propertydefschema(self) ->str:
returnself.type_adapter.json_schema()
@DiamondJoseph what if we just convert the plangenerator function to string?
@stan-dot the plan generator was the actual code that was being executed by the RunEngine, but now that it's the opposite side of the _rpc call it's not completely unreasonable. Then
classPlan(BlueapiBaseModel):
ref: tuple[str, str] # module and func name? Require module name if func name not unique?description: str# from the docstringadapterorschema?
So the two dictionaries were originally made so separate the API object, that is passed in and out from external callers, and an internal object with non-serializable data in it to be passed around internally. As @DiamondJoseph says, now we have internal RPC between two processes that makes less sense.
Another option is to try and keep the non-serializable data only in the worker process and never need to pass it around, if that's achievable. We are currently having this discussion because we're thinking about how to get plan information from BlueskyContext to TaskWorker, but I raised #616 to tidy up BlueskyContext anyway, so maybe there's a cleaner way to do all of this?
Activity
callumforrester commentedon May 12, 2023
Also need to integrate the
PlanandPlanModelclassescallumforrester commentedon Feb 7, 2024
I think what's needed is something like
stan-dot commentedon Mar 14, 2024
note:
Planis incore/bluesky_types.pywith fields: name, description, model (Pydantic model)PlanModelis inservice/model.pyunder with fields: name, description, parameter_schema (optional dictionary).The latter also has a classmethod 'from_plan', which serves as alternative constructor.
Both classes extend
BlueepiBaseModelstan-dot commentedon Mar 14, 2024
suggested plan of work:
bluesky_types.py: DataEvent and WatchableStatus. Those could be moved into the Model classcallumforrester commentedon Mar 26, 2024
Need to ensure that there is still a serialisable artefact (i.e. does not hold a function) that can be used as part of the API
stan-dot commentedon Mar 27, 2024
explore avenue to add a field exempt from serialization to the pydantic model. also a pydantic model not a dataclass.
stan-dot commentedon Mar 28, 2024
that's tightly connected with #407 , ideally it's 1 PR for both
callumforrester commentedon Apr 4, 2024
For #407, see #206 (comment)
stan-dot commentedon Apr 4, 2024
discussion output - serialize less, do not except fields, just do composition
DiamondJoseph commentedon Sep 6, 2024
May be able to make use of TypeAdapter instances to get the JSON schema from.
becomes
stan-dot commentedon Sep 9, 2024
@DiamondJoseph what if we just convert the plangenerator function to string?
DiamondJoseph commentedon Sep 9, 2024
@stan-dot the plan generator was the actual code that was being executed by the RunEngine, but now that it's the opposite side of the
_rpccall it's not completely unreasonable. Thencallumforrester commentedon Sep 9, 2024
So the two dictionaries were originally made so separate the API object, that is passed in and out from external callers, and an internal object with non-serializable data in it to be passed around internally. As @DiamondJoseph says, now we have internal RPC between two processes that makes less sense.
Another option is to try and keep the non-serializable data only in the worker process and never need to pass it around, if that's achievable. We are currently having this discussion because we're thinking about how to get plan information from
BlueskyContexttoTaskWorker, but I raised #616 to tidy upBlueskyContextanyway, so maybe there's a cleaner way to do all of this?stan-dot commentedon Sep 9, 2024
BlueskyContextis a god-object because it's too generic a name. TaskWorker will likely have its own contextBlueapiServerwill have its own context.shared state can be held in something like https://github.com/etcd-io/etcd
refactor: Combine plans and plan_functions (#1743)
refactor: Combine plans and plan_functions (DiamondLightSource#1743)