working on runtime executions
This commit is contained in:
@@ -52,27 +52,22 @@ Attune is an event-driven automation and orchestration platform with built-in mu
|
||||
|
||||
## Runtime Environment
|
||||
|
||||
### `RuntimeType` (Enum)
|
||||
**Values**: `action`, `sensor`
|
||||
|
||||
**Purpose**: Distinguishes between action execution environments and sensor monitoring environments.
|
||||
|
||||
### `Runtime`
|
||||
**Purpose**: Defines an execution environment for actions or sensors.
|
||||
**Purpose**: Defines a unified execution environment for actions and sensors.
|
||||
|
||||
**Key Fields**:
|
||||
- `ref`: Unique reference (format: `pack.(action|sensor).name`)
|
||||
- `runtime_type`: Type of runtime (action or sensor)
|
||||
- `name`: Runtime name (e.g., "python3.11", "nodejs20")
|
||||
- `distributions`: JSON describing available distributions
|
||||
- `ref`: Unique reference (format: `pack.name`, e.g., `core.python`, `core.shell`)
|
||||
- `name`: Runtime name (e.g., "Python", "Shell", "Node.js")
|
||||
- `distributions`: JSON describing available distributions and verification metadata
|
||||
- `installation`: JSON describing installation requirements
|
||||
- `execution_config`: JSON describing how to execute code (interpreter, environment setup, dependencies). Runtimes without an `execution_config` (e.g., `core.builtin`) cannot execute actions — the worker skips them.
|
||||
- `pack`: Parent pack ID
|
||||
|
||||
**Relationships**:
|
||||
- Belongs to: pack
|
||||
- Used by: workers, sensors, actions
|
||||
|
||||
**Purpose**: Defines how to install and execute code (Python, Node.js, containers, etc.).
|
||||
**Purpose**: Defines how to install and execute code (Python, Node.js, containers, etc.). Runtimes are shared between actions and sensors — there is no type distinction.
|
||||
|
||||
### `WorkerType` (Enum)
|
||||
**Values**: `local`, `remote`, `container`
|
||||
@@ -479,7 +474,7 @@ These ensure data consistency and provide audit trails throughout the system.
|
||||
## Common Patterns
|
||||
|
||||
### Reference Format
|
||||
Most components use a `ref` field with format `pack.name` (e.g., `slack.webhook_trigger`). Runtimes use `pack.(action|sensor).name`.
|
||||
All components use a `ref` field with format `pack.name` (e.g., `slack.webhook_trigger`, `core.python`, `core.shell`).
|
||||
|
||||
### Ref vs ID
|
||||
- Foreign key relationships use IDs
|
||||
|
||||
@@ -291,18 +291,10 @@ class Pack(Base):
|
||||
)
|
||||
|
||||
|
||||
class RuntimeType(enum.Enum):
|
||||
action = "action"
|
||||
sensor = "sensor"
|
||||
|
||||
|
||||
class Runtime(Base):
|
||||
__tablename__: str = "runtime"
|
||||
__table_args__: tuple[Constraint, ...] = (
|
||||
CheckConstraint("ref = lower(ref)", name="runtime_ref_lowercase"),
|
||||
CheckConstraint(
|
||||
r"ref ~ '^[^.]+\.(action|sensor)\.[^.]+$'", name="runtime_ref_format"
|
||||
),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
@@ -312,12 +304,10 @@ class Runtime(Base):
|
||||
)
|
||||
pack_ref: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
description: Mapped[str | None] = mapped_column(Text)
|
||||
runtime_type: Mapped[RuntimeType] = mapped_column(
|
||||
Enum(RuntimeType, name="runtime_type_enum", schema=DB_SCHEMA), nullable=False
|
||||
)
|
||||
name: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
distributions: Mapped[JSONDict] = mapped_column(JSONB, nullable=False)
|
||||
installation: Mapped[JSONDict | None] = mapped_column(JSONB)
|
||||
execution_config: Mapped[JSONDict | None] = mapped_column(JSONB)
|
||||
created: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), default=func.now()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user