From 5b3cdf206205e1bf0e7cc7a26e88469c60f00a3c Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 10 May 2024 18:10:18 +0200 Subject: [PATCH] Update notebook to match current version of jupyter-events (#98) --- docs/demo/demo-notebook.ipynb | 49 ++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/docs/demo/demo-notebook.ipynb b/docs/demo/demo-notebook.ipynb index cbf8e30..12a109c 100644 --- a/docs/demo/demo-notebook.ipynb +++ b/docs/demo/demo-notebook.ipynb @@ -54,9 +54,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Validator class: Draft7Validator\n", - "Schema: {\n", - " \"$id\": \"myapplication.org/example-event\",\n", + "{\n", + " \"$id\": \"http://myapplication.org/example-event\",\n", " \"version\": 1,\n", " \"title\": \"Example Event\",\n", " \"description\": \"An interesting event to collect\",\n", @@ -125,14 +124,14 @@ "name": "stderr", "output_type": "stream", "text": [ - "{\"__timestamp__\": \"2022-08-11T22:46:22.248281Z\", \"__schema__\": \"myapplication.org/example-event\", \"__schema_version__\": 1, \"__metadata_version__\": 1, \"name\": \"My Event\"}\n" + "{\"__timestamp__\": \"2024-05-04T23:22:40.338884+00:00Z\", \"__schema__\": \"http://myapplication.org/example-event\", \"__schema_version__\": 1, \"__metadata_version__\": 1, \"name\": \"My Event\"}\n" ] }, { "data": { "text/plain": [ - "{'__timestamp__': '2022-08-11T22:46:22.248281Z',\n", - " '__schema__': 'myapplication.org/example-event',\n", + "{'__timestamp__': '2024-05-04T23:22:40.338884+00:00Z',\n", + " '__schema__': 'http://myapplication.org/example-event',\n", " '__schema_version__': 1,\n", " '__metadata_version__': 1,\n", " 'name': 'My Event'}" @@ -144,7 +143,7 @@ } ], "source": [ - "logger.emit(schema_id=\"myapplication.org/example-event\", data={\"name\": \"My Event\"})" + "logger.emit(schema_id=\"http://myapplication.org/example-event\", data={\"name\": \"My Event\"})" ] }, { @@ -160,12 +159,14 @@ "metadata": {}, "outputs": [], "source": [ - "def my_listener(data):\n", - " print(\"hello, from my_listener!\")\n", + "async def my_listener(logger: EventLogger, schema_id: str, data: dict) -> None:\n", + " print(\"hello, from my_listener\")\n", + " print(logger)\n", + " print(schema_id)\n", " print(data)\n", "\n", "\n", - "logger.add_listener(schema_id=\"myapplication.org/example-event\", version=1, listener=my_listener)" + "logger.add_listener(schema_id=\"http://myapplication.org/example-event\", listener=my_listener)" ] }, { @@ -184,24 +185,14 @@ "name": "stderr", "output_type": "stream", "text": [ - "{\"__timestamp__\": \"2022-08-11T22:46:28.947996Z\", \"__schema__\": \"myapplication.org/example-event\", \"__schema_version__\": 1, \"__metadata_version__\": 1, \"name\": \"My Event\"}\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hello world\n", - "EventListenerData(event_logger=, schema_id='myapplication.org/example-event', version=1, data={'name': 'My Event'})\n", - "hello world\n", - "EventListenerData(event_logger=, schema_id='myapplication.org/example-event', version=1, data={'name': 'My Event'})\n" + "{\"__timestamp__\": \"2024-05-04T23:22:40.400243+00:00Z\", \"__schema__\": \"http://myapplication.org/example-event\", \"__schema_version__\": 1, \"__metadata_version__\": 1, \"name\": \"My Event\"}\n" ] }, { "data": { "text/plain": [ - "{'__timestamp__': '2022-08-11T22:46:28.947996Z',\n", - " '__schema__': 'myapplication.org/example-event',\n", + "{'__timestamp__': '2024-05-04T23:22:40.400243+00:00Z',\n", + " '__schema__': 'http://myapplication.org/example-event',\n", " '__schema_version__': 1,\n", " '__metadata_version__': 1,\n", " 'name': 'My Event'}" @@ -210,10 +201,20 @@ "execution_count": 7, "metadata": {}, "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hello, from my_listener\n", + "\n", + "http://myapplication.org/example-event\n", + "{'name': 'My Event'}\n" + ] } ], "source": [ - "logger.emit(schema_id=\"myapplication.org/example-event\", version=1, data={\"name\": \"My Event\"})" + "logger.emit(schema_id=\"http://myapplication.org/example-event\", data={\"name\": \"My Event\"})" ] }, {