-
Notifications
You must be signed in to change notification settings - Fork 6
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
Combine context.plans and context.plan_functions into a single dictionary #180
Comments
Also need to integrate the |
I think what's needed is something like @dataclass
class Plan:
model: PlanModel
func: PlanGenerator |
note: Both classes extend |
suggested plan of work:
|
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 |
explore avenue to add a field exempt from serialization to the pydantic model. also a pydantic model not a dataclass. |
that's tightly connected with #407 , ideally it's 1 PR for both |
For #407, see #206 (comment) |
discussion output - serialize less, do not except fields, just do composition |
May be able to make use of TypeAdapter instances to get the JSON schema from. class Plan(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 class Plan(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_adapter
generator: PlanGenerator
@property
def schema(self) -> str:
return self.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 class Plan(BlueapiBaseModel):
ref: tuple[str, str] # module and func name? Require module name if func name not unique?
description: str # from the docstring
adapter or schema? |
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 |
shared state can be held in something like https://github.com/etcd-io/etcd |
Making context.plans hold a dataclass e.g.
prevents having to maintain two dictionaries but also means we can easily extract the serialisable parts of the plan to send.
The text was updated successfully, but these errors were encountered: