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

RTU modeling #173

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ For pre-1.0 releases, see [0.0.35 Changelog](https://github.com/noteable-io/orig

### Added
- CLI for downloading Notebooks and tailing a Notebook to see all RTU messages
- Modeling for RTU messages that were missing
- `variable_explorer_request` on Kernels channel
- `append_output_event` on Files channel
- `v0_create_widget_mdoel_event` on Files channel

### [1.0.0] - 2023-09-08

Expand Down
8 changes: 4 additions & 4 deletions origami/clients/rtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ async def replay_unapplied_deltas(self):
async def on_kernel_status_update(self, msg: KernelStatusUpdateResponse):
"""Called when we receive a kernel_status_update_event on kernels/ channel"""
self.kernel_state = msg.data.kernel.execution_state
logger.info(f"updating Kernel state to: {self.kernel_state}")
logger.debug(f"updating Kernel state to: {self.kernel_state}")

async def on_bulk_cell_state_update(self, msg: BulkCellStateUpdateResponse):
"""Called when we receive a bulk_cell_state_update_event on kernels/ channel"""
Expand All @@ -695,7 +695,7 @@ async def on_bulk_cell_state_update(self, msg: BulkCellStateUpdateResponse):
# When we see that a cell we're monitoring has finished, resolve the Future to
# be the cell
if item.state in ['finished_with_error', 'finished_with_no_error']:
logger.info(
logger.debug(
"Cell execution for monitored cell finished",
extra={
'cell_id': item.cell_id,
Expand All @@ -722,10 +722,10 @@ async def on_bulk_cell_state_update(self, msg: BulkCellStateUpdateResponse):

async def wait_for_kernel_idle(self):
"""Wait for the kernel to be idle"""
logger.info("Waiting for Kernel to be idle")
logger.debug("Waiting for Kernel to be idle")
while self.kernel_state != 'idle':
await asyncio.sleep(0.05)
logger.info("Kernel is idle")
logger.debug("Kernel is idle")

async def new_delta_request(self, delta=FileDelta) -> FileDelta:
"""
Expand Down
17 changes: 17 additions & 0 deletions origami/models/rtu/channels/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from pydantic import BaseModel, Field, ValidationError, root_validator

from origami.models.api.outputs import KernelOutput
from origami.models.deltas.discriminators import FileDelta
from origami.models.kernels import CellState, KernelStatusUpdate
from origami.models.rtu.base import BaseRTURequest, BaseRTUResponse, BooleanReplyData
Expand Down Expand Up @@ -119,6 +120,13 @@ class UpdateOutputCollectionEvent(FilesResponse):
data: UpdateOutputCollectionEventData


# If Cells are streaming multiple outputs like a pip install or for loop and print, then we'll get
# append to output events
class AppendOutputEvent(FilesResponse):
event: Literal['append_output_event'] = 'append_output_event'
data: KernelOutput


# User cell selection is a collaboration feature, shows which cell each user is currently editing
# Like Deltas, it follows a request -> reply -> event pattern
class UpdateUserCellSelectionRequestData(BaseModel):
Expand Down Expand Up @@ -190,6 +198,13 @@ class TransformViewToCodeReply(FilesResponse):
data: BooleanReplyData


# Widgets, ugh. Not attempting to model the payload, no current plan on doing anything with them
# on the Origami side.
class V0CreateWidgetModelEvent(FilesResponse):
event: Literal['v0_create_widget_model_event'] = 'v0_create_widget_model_event'
data: Any


# When the API squashes Deltas, it will emit a new file versions changed event
class FileVersionsChangedEvent(FilesResponse):
event: Literal['v0_file_versions_changed_event'] = 'v0_file_versions_changed_event'
Expand All @@ -216,9 +231,11 @@ class FileVersionsChangedEvent(FilesResponse):
NewDeltaEvent,
RemoveUserFileSubscriptionEvent,
TransformViewToCodeReply,
V0CreateWidgetModelEvent,
UpdateUserCellSelectionReply,
UpdateUserFileSubscriptionEvent,
UpdateOutputCollectionEvent,
AppendOutputEvent,
UsageMetricsEvent,
],
Field(discriminator='event'),
Expand Down
9 changes: 9 additions & 0 deletions origami/models/rtu/channels/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class VariableExplorerUpdateRequest(KernelsRequest):
event: Literal['variable_explorer_update_request'] = 'variable_explorer_update_request'


# It is confusing but variable_explorer_update_request can either be an RTU client to Gate server
# (RTURequest) or also be propogated out by Gate from another client, meaning it comes in as a
# server-to-client (RTUResponse) so we need to model it just to avoid warning about unmodeled msgs
class VariableExplorerUpdateRequestPropogated(KernelsResponse):
event: Literal['variable_explorer_update_request'] = 'variable_explorer_update_request'
data: dict = Field(default_factory=dict)


class VariableExplorerResponse(KernelsResponse):
event: Literal['variable_explorer_event'] = 'variable_explorer_event'

Expand Down Expand Up @@ -131,6 +139,7 @@ class IntegratedAIResultEvent(KernelsResponse):
KernelSubscribeReply,
KernelStatusUpdateResponse,
BulkCellStateUpdateResponse,
VariableExplorerUpdateRequestPropogated,
VariableExplorerResponse,
IntegratedAIReply,
IntegratedAIResultReply,
Expand Down
2 changes: 1 addition & 1 deletion origami/notebook/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def update_notebook_metadata(self, delta: NBMetadataUpdate):
def update_cell_metadata(self, delta: CellMetadataUpdate):
"""Update cell metadata using a partial update / nested path technique"""
if delta.resource_id in self.deleted_cell_ids:
logger.info(
logger.debug(
f"Skipping update_cell_metadata for deleted cell {delta.resource_id}",
extra={'delta_properties_path': delta.properties.path},
)
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@ def api_base_url():
@pytest.fixture
def test_space_id() -> uuid.UUID:
# TODO: use env var or otherwise make configurable for CI
return uuid.UUID('edc21f3f-fb30-45fb-a30d-668fac0b0e4a')
return uuid.UUID('1ecc737e-0252-49a1-af9b-a0a400db5888')


@pytest.fixture
def test_project_id() -> uuid.UUID:
# TODO: use env var or otherwise make configurable for CI
return uuid.UUID('c34e6a11-cc60-4ab6-9566-10f81a4a46cd')
return uuid.UUID('a752faf4-bbc7-4fe1-9c5f-be92394e48a2')


@pytest.fixture
def test_user_id() -> uuid.UUID:
# TODO: use env var or otherwise make configurable for CI
return uuid.UUID('f9dfb1b5-7ae4-477c-818f-08d0732018d3')
return uuid.UUID('9eb39719-4fc1-44de-9155-3edaeb32ce2c')


class LogWarningTransport(httpx.AsyncHTTPTransport):
Expand Down