diff --git a/api/src/opentrons/protocol_engine/commands/command.py b/api/src/opentrons/protocol_engine/commands/command.py index f8f48bba67c..c2314aab579 100644 --- a/api/src/opentrons/protocol_engine/commands/command.py +++ b/api/src/opentrons/protocol_engine/commands/command.py @@ -6,7 +6,15 @@ from abc import ABC, abstractmethod from datetime import datetime from enum import Enum -from typing import TYPE_CHECKING, Generic, Optional, TypeVar, Tuple +from typing import ( + TYPE_CHECKING, + Generic, + Optional, + TypeVar, + Tuple, + Union, + Literal, +) from pydantic import BaseModel, Field from pydantic.generics import GenericModel @@ -27,6 +35,29 @@ CommandPrivateResultT = TypeVar("CommandPrivateResultT") +NoteKind = Union[Literal["warning", "information"], str] + + +class CommandNote(BaseModel): + """A note about a command's execution or dispatch.""" + + noteKind: NoteKind = Field( + ..., + description="The kind of note this is. Only the literal possibilities should be" + " relied upon programmatically.", + ) + shortMessage: str = Field( + ..., + description="The accompanying human-readable short message (suitable for display in a single line)", + ) + longMessage: str = Field( + ..., + description="A longer message that may contain newlines and formatting characters describing the note.", + ) + source: str = Field( + ..., description="An identifier for the party that created the note" + ) + class CommandStatus(str, Enum): """Command execution status.""" diff --git a/shared-data/command/types/index.ts b/shared-data/command/types/index.ts index d3994fc5337..144efa2f46a 100644 --- a/shared-data/command/types/index.ts +++ b/shared-data/command/types/index.ts @@ -31,7 +31,12 @@ export * from './timing' // NOTE: these key/value pairs will only be present on commands at analysis/run time // they pertain only to the actual execution status of a command on hardware, as opposed to // the command's identity and parameters which can be known prior to runtime - +export interface CommandNote { + noteKind: 'warning' | 'information' | string + shortMessage: string + longMessage: string + source: string +} export type CommandStatus = 'queued' | 'running' | 'succeeded' | 'failed' export interface CommonCommandRunTimeInfo { key?: string