From bba1d48b1d5904d1afad54b57c0d9649653d9817 Mon Sep 17 00:00:00 2001 From: Matt Kafonek Date: Mon, 23 Oct 2023 10:33:41 -0400 Subject: [PATCH] tweak to catastrophic failure during seed notebook download (#193) * tweak to catastrophic failure during seed notebook download * changelog --- CHANGELOG.md | 4 ++-- origami/clients/rtu.py | 8 +++----- tests/e2e/rtu/test_notebook.py | 8 ++++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcf6a19..49b831f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 For pre-1.0 releases, see [0.0.35 Changelog](https://github.com/noteable-io/origami/blob/0.0.35/CHANGELOG.md) ## [Unreleased] -### Added -- Environ variable `NOTEABLE_RTU_URL` to override RTU websocket, primarily for when apps are running in-cluster with Gate and need to use the http vs websocket service DNS +### Changed +- Removed `RuntimeError` in RTUClient catastrophic failure, top level applications (e.g. PA, Origamist) should define that behavior ### [1.1.2] - 2023-10-12 ### Added diff --git a/origami/clients/rtu.py b/origami/clients/rtu.py index 08bbc49..ca98d12 100644 --- a/origami/clients/rtu.py +++ b/origami/clients/rtu.py @@ -332,9 +332,7 @@ async def catastrophic_failure(self): after inconsistent_state_event and not getting a current_version_id to subscribe by or getting Deltas that cannot be squashed into the builder """ - logger.warning("Catastrophic failure, shutting down RTUClient") - await self.shutdown(now=True) - raise RuntimeError("Catastrophic failure, shutting down RTUClient") + logger.warning("Catastrophic failure, RTU applications can override this hook") @property def cell_ids(self): @@ -439,8 +437,8 @@ async def load_seed_notebook(self): # Current file version id is used in file subscribe request if not file.current_version_id: - logger.warning(f"Gate shows now current version id for File {self.file_id}, aborting.") - await self.catastrophic_failure() + logger.warning(f"Gate shows no current version id for File {self.file_id}, aborting.") + return await self.catastrophic_failure() self.file_version_id = file.current_version_id logger.info("Downloading seed Notebook") diff --git a/tests/e2e/rtu/test_notebook.py b/tests/e2e/rtu/test_notebook.py index e43cf30..5b4cabd 100644 --- a/tests/e2e/rtu/test_notebook.py +++ b/tests/e2e/rtu/test_notebook.py @@ -1,5 +1,7 @@ import asyncio +import uuid +import httpx import pytest from origami.clients.api import APIClient @@ -83,3 +85,9 @@ async def test_replace_cell_content(api_client: APIClient, notebook_maker): assert cell.source == "2 + 2" finally: await rtu_client.shutdown() + + +async def test_connect_bad_file_id(api_client: APIClient): + with pytest.raises(httpx.HTTPStatusError) as e: + await api_client.connect_realtime(file=uuid.uuid4()) + assert e.value.response.status_code == 404