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

Create strongly typed PlanCommand class #6

Merged
merged 4 commits into from
Feb 21, 2024

Conversation

mbiannaccone
Copy link
Collaborator

@mbiannaccone mbiannaccone commented Feb 20, 2024

This PR creates the first iteration of our strongly typed command classes, starting with the PlanCommand. There is a _BaseCommand which handles command-agnostic information, like note_id, user_id, command_uuid, etc. The PlanCommand class inherits from _Base and includes anything plan-specific, like narrative.

some notes:

  • I'm using pydantic in strict mode
  • the originate, update, delete, etc methods just return a simple dict right now - i imagine we'll need to refine what exactly needs to be returned here once we've nailed down the specifics of the grpc calls

class PlanCommandAttributes(_BaseCommandAttributes):
"""Attributes speciic to the Plan Command."""

narrative: str | None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's steer right into this question: how do we keep this in sync with the platform? Suppose for example that we decided to add a new field, called timeframe, to the definition of the plan command on the platform, a duration of time within which the plan should be accomplished. How do we protect our customers from being the ones to discover the issues that might be entailed from getting out of sync?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea: integration test? Is there something in home-app exposed via HTTP that returns the command schema? Would it serve our purpose to require that an SDK command class field of a given type exists if and only if it is present in the schema returned in the home-app integration test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there is an endpoint exactly like that in home-app, i'll dig it up and make an integration test. we could also have a test that runs on a cron and checks daily or something. great idea to call this out

Copy link
Collaborator

@aduane aduane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like where this is headed. I think we should decide on what the result of the manipulation of one of these command objects should be. I think we want to return an effect to home-app. Does the effect just present to home-app a command state, which home-app then takes and updates the current state accordingly? Would you manipulate many fields in a here, and then call like plan_command.effect() to get the ModifyCommandEffect with appropriate attributes set?

Note: I don't think we have to make this decision before this can be merged.

return {"command_uuid": self.command_uuid, "user_id": self.user_id, "commit": True}

def enter_in_error(self) -> dict:
"""Enter in error the command."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phrasing suggestion:

Suggested change
"""Enter in error the command."""
"""Mark the command as entered-in-error."""

@mbiannaccone
Copy link
Collaborator Author

@aduane ya i've been bouncing a bunch of ideas like that around too as i'm doing this work. i think we just get this initial version in and then make those decisions once grpc is further along! i kinda just threw those straw-man methods in there as placeholders. i'll leave a comment so that's explicit !

@mbiannaccone mbiannaccone merged commit 1f176ff into main Feb 21, 2024
2 checks passed
@mbiannaccone mbiannaccone deleted the michela/koala-1070-plan-command branch February 21, 2024 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants