Skip to content

Commit 78bcd2d

Browse files
Paul Hewletteccles
authored andcommitted
Use jupyter notebooks on local desktop
Problem: Jupyter notebooks must be easily executable by third parties on customer's desktops. Solution: Add section to docs detailing how to load JupyterLab desktop on Linux, Mac or Windows. Add extra special notebook that initialises environment to the users credentials and tailor all notebooks to use the python-dotenv package to load the same environment. Signed-off-by: Paul Hewlett <phewlett76@gmail.com>
1 parent fd8380d commit 78bcd2d

19 files changed

Lines changed: 703 additions & 430 deletions

archivist/notebooks/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
*.env
12
.ipynb_checkpoints/

archivist/notebooks/Check Asset Compliance using CURRENT OUTSTANDING Policy.ipynb

Lines changed: 94 additions & 73 deletions
Large diffs are not rendered by default.

archivist/notebooks/Check Asset Compliance using SINCE Policy.ipynb

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
"from uuid import uuid4\n",
3838
"from warnings import filterwarnings\n",
3939
"\n",
40+
"from dotenv import load_dotenv\n",
41+
"\n",
4042
"from archivist.archivist import Archivist\n",
4143
"from archivist.compliance_policy_requests import (\n",
4244
" CompliancePolicySince,\n",
@@ -49,6 +51,17 @@
4951
{
5052
"cell_type": "code",
5153
"execution_count": 3,
54+
"id": "96987aaf",
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"%reload_ext dotenv\n",
59+
"%dotenv -o notebooks.env"
60+
]
61+
},
62+
{
63+
"cell_type": "code",
64+
"execution_count": 4,
5265
"id": "a877ffed",
5366
"metadata": {},
5467
"outputs": [],
@@ -59,13 +72,13 @@
5972
"# CLIENT = represents the client ID from an Application Registration\n",
6073
"# SECRET = represents the client secret from an Application Registration\n",
6174
"RKVST_URL = getenv(\"RKVST_URL\")\n",
62-
"APPREG_CLIENT = getenv(\"RKVST_APPREG_CLIENT\")\n",
63-
"APPREG_SECRET = getenv(\"RKVST_APPREG_SECRET\")"
75+
"RKVST_APPREG_CLIENT = getenv(\"RKVST_APPREG_CLIENT\")\n",
76+
"RKVST_APPREG_SECRET = getenv(\"RKVST_APPREG_SECRET\")"
6477
]
6578
},
6679
{
6780
"cell_type": "code",
68-
"execution_count": 4,
81+
"execution_count": 5,
6982
"id": "3fdc8e16",
7083
"metadata": {},
7184
"outputs": [
@@ -74,7 +87,7 @@
7487
"output_type": "stream",
7588
"text": [
7689
"Connecting to RKVST\n",
77-
"URL https://app.dev-paul-0.wild.jitsuin.io\n"
90+
"RKVST_URL https://app.rkvst.io\n"
7891
]
7992
}
8093
],
@@ -94,13 +107,13 @@
94107
"\n",
95108
"# Initialize connection to RKVST\n",
96109
"print(\"Connecting to RKVST\")\n",
97-
"print(\"URL\", RKVST_URL)\n",
98-
"arch = Archivist(RKVST_URL, (APPREG_CLIENT, APPREG_SECRET), max_time=300)"
110+
"print(\"RKVST_URL\", RKVST_URL)\n",
111+
"arch = Archivist(RKVST_URL, (RKVST_APPREG_CLIENT, RKVST_APPREG_SECRET), max_time=300)"
99112
]
100113
},
101114
{
102115
"cell_type": "code",
103-
"execution_count": 5,
116+
"execution_count": 6,
104117
"id": "acdf240c",
105118
"metadata": {},
106119
"outputs": [],
@@ -131,7 +144,7 @@
131144
},
132145
{
133146
"cell_type": "code",
134-
"execution_count": 6,
147+
"execution_count": 7,
135148
"id": "8889c68d",
136149
"metadata": {},
137150
"outputs": [],
@@ -157,7 +170,7 @@
157170
},
158171
{
159172
"cell_type": "code",
160-
"execution_count": 7,
173+
"execution_count": 8,
161174
"id": "ba24d143",
162175
"metadata": {},
163176
"outputs": [],
@@ -183,7 +196,7 @@
183196
},
184197
{
185198
"cell_type": "code",
186-
"execution_count": 8,
199+
"execution_count": 9,
187200
"id": "b7482420",
188201
"metadata": {
189202
"scrolled": true
@@ -195,7 +208,7 @@
195208
},
196209
{
197210
"cell_type": "code",
198-
"execution_count": 9,
211+
"execution_count": 10,
199212
"id": "bb5b0651",
200213
"metadata": {},
201214
"outputs": [
@@ -211,7 +224,7 @@
211224
"output_type": "stream",
212225
"text": [
213226
"SINCE_POLICY: {\n",
214-
" \"identity\": \"compliance_policies/e9b458b7-5e08-41ce-bf4c-ff01b7975148\",\n",
227+
" \"identity\": \"compliance_policies/458957bc-4da7-4cc3-b37f-43fa53abe0cc\",\n",
215228
" \"compliance_type\": \"COMPLIANCE_SINCE\",\n",
216229
" \"description\": \"Maintenance should be performed every 10 seconds\",\n",
217230
" \"display_name\": \"Regular Maintenance of Traffic light\",\n",
@@ -222,15 +235,15 @@
222235
" ]\n",
223236
" }\n",
224237
" ],\n",
225-
" \"event_display_type\": \"Maintenance Performed 281b5ac5-764f-446d-84da-17138e18fde0\",\n",
238+
" \"event_display_type\": \"Maintenance Performed a3f86bbf-737a-45d8-bd84-3d6612fb641e\",\n",
226239
" \"closing_event_display_type\": \"\",\n",
227240
" \"time_period_seconds\": \"10\",\n",
228241
" \"dynamic_window\": \"0\",\n",
229242
" \"dynamic_variability\": 0,\n",
230243
" \"richness_assertions\": []\n",
231244
"}\n",
232245
"compliance_policy {\n",
233-
" \"identity\": \"compliance_policies/e9b458b7-5e08-41ce-bf4c-ff01b7975148\",\n",
246+
" \"identity\": \"compliance_policies/458957bc-4da7-4cc3-b37f-43fa53abe0cc\",\n",
234247
" \"compliance_type\": \"COMPLIANCE_SINCE\",\n",
235248
" \"description\": \"Maintenance should be performed every 10 seconds\",\n",
236249
" \"display_name\": \"Regular Maintenance of Traffic light\",\n",
@@ -241,7 +254,7 @@
241254
" ]\n",
242255
" }\n",
243256
" ],\n",
244-
" \"event_display_type\": \"Maintenance Performed 281b5ac5-764f-446d-84da-17138e18fde0\",\n",
257+
" \"event_display_type\": \"Maintenance Performed a3f86bbf-737a-45d8-bd84-3d6612fb641e\",\n",
245258
" \"closing_event_display_type\": \"\",\n",
246259
" \"time_period_seconds\": \"10\",\n",
247260
" \"dynamic_window\": \"0\",\n",
@@ -260,7 +273,7 @@
260273
},
261274
{
262275
"cell_type": "code",
263-
"execution_count": 10,
276+
"execution_count": 11,
264277
"id": "f8ac6dda",
265278
"metadata": {},
266279
"outputs": [
@@ -269,12 +282,12 @@
269282
"output_type": "stream",
270283
"text": [
271284
"TRAFFIC_LIGHT: {\n",
272-
" \"identity\": \"assets/b961c23f-c1db-4bde-9ed3-c997378f2bf2\",\n",
285+
" \"identity\": \"assets/b6f63a6d-24a1-4dd8-a6d7-21e50e603ceb\",\n",
273286
" \"behaviours\": [\n",
287+
" \"RecordEvidence\",\n",
274288
" \"Builtin\",\n",
275289
" \"AssetCreator\",\n",
276-
" \"Attachments\",\n",
277-
" \"RecordEvidence\"\n",
290+
" \"Attachments\"\n",
278291
" ],\n",
279292
" \"attributes\": {\n",
280293
" \"arc_description\": \"Traffic flow control light at A603 North East\",\n",
@@ -283,21 +296,21 @@
283296
" },\n",
284297
" \"confirmation_status\": \"CONFIRMED\",\n",
285298
" \"tracked\": \"TRACKED\",\n",
286-
" \"owner\": \"0x3E06AcBf002E8F67bDe832b3f3E7d2aDA2BE3DC8\",\n",
287-
" \"at_time\": \"2023-01-10T16:20:33Z\",\n",
299+
" \"owner\": \"0xe889E67FdBa658C6f27ccBDa98D9d1B5500Dbbce\",\n",
300+
" \"at_time\": \"2023-01-16T11:52:27Z\",\n",
288301
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
289302
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
290-
" \"chain_id\": \"99\",\n",
303+
" \"chain_id\": \"827586838445807967\",\n",
291304
" \"public\": false,\n",
292-
" \"tenant_identity\": \"tenant/f9040e8b-2afa-48f1-bb00-f055d55ade01\"\n",
305+
" \"tenant_identity\": \"tenant/9bfb80ee-81f6-40dc-b5c7-1c7fb2fb9866\"\n",
293306
"}\n",
294307
"traffic_light {\n",
295-
" \"identity\": \"assets/b961c23f-c1db-4bde-9ed3-c997378f2bf2\",\n",
308+
" \"identity\": \"assets/b6f63a6d-24a1-4dd8-a6d7-21e50e603ceb\",\n",
296309
" \"behaviours\": [\n",
310+
" \"RecordEvidence\",\n",
297311
" \"Builtin\",\n",
298312
" \"AssetCreator\",\n",
299-
" \"Attachments\",\n",
300-
" \"RecordEvidence\"\n",
313+
" \"Attachments\"\n",
301314
" ],\n",
302315
" \"attributes\": {\n",
303316
" \"arc_description\": \"Traffic flow control light at A603 North East\",\n",
@@ -306,13 +319,13 @@
306319
" },\n",
307320
" \"confirmation_status\": \"CONFIRMED\",\n",
308321
" \"tracked\": \"TRACKED\",\n",
309-
" \"owner\": \"0x3E06AcBf002E8F67bDe832b3f3E7d2aDA2BE3DC8\",\n",
310-
" \"at_time\": \"2023-01-10T16:20:33Z\",\n",
322+
" \"owner\": \"0xe889E67FdBa658C6f27ccBDa98D9d1B5500Dbbce\",\n",
323+
" \"at_time\": \"2023-01-16T11:52:27Z\",\n",
311324
" \"storage_integrity\": \"TENANT_STORAGE\",\n",
312325
" \"proof_mechanism\": \"SIMPLE_HASH\",\n",
313-
" \"chain_id\": \"99\",\n",
326+
" \"chain_id\": \"827586838445807967\",\n",
314327
" \"public\": false,\n",
315-
" \"tenant_identity\": \"tenant/f9040e8b-2afa-48f1-bb00-f055d55ade01\"\n",
328+
" \"tenant_identity\": \"tenant/9bfb80ee-81f6-40dc-b5c7-1c7fb2fb9866\"\n",
316329
"}\n"
317330
]
318331
}
@@ -326,7 +339,7 @@
326339
},
327340
{
328341
"cell_type": "code",
329-
"execution_count": 11,
342+
"execution_count": 12,
330343
"id": "d93be01f",
331344
"metadata": {},
332345
"outputs": [
@@ -335,49 +348,49 @@
335348
"output_type": "stream",
336349
"text": [
337350
"MAINTENANCE_PERFORMED: {\n",
338-
" \"identity\": \"assets/b961c23f-c1db-4bde-9ed3-c997378f2bf2/events/433f4c4e-f6e2-43f6-a48c-0f15152a2734\",\n",
339-
" \"asset_identity\": \"assets/b961c23f-c1db-4bde-9ed3-c997378f2bf2\",\n",
351+
" \"identity\": \"assets/b6f63a6d-24a1-4dd8-a6d7-21e50e603ceb/events/eba5bb05-d4ff-4d99-9205-41236560d24d\",\n",
352+
" \"asset_identity\": \"assets/b6f63a6d-24a1-4dd8-a6d7-21e50e603ceb\",\n",
340353
" \"event_attributes\": {\n",
341354
" \"arc_description\": \"Maintenance performed on traffic light\",\n",
342-
" \"arc_display_type\": \"Maintenance Performed 281b5ac5-764f-446d-84da-17138e18fde0\"\n",
355+
" \"arc_display_type\": \"Maintenance Performed a3f86bbf-737a-45d8-bd84-3d6612fb641e\"\n",
343356
" },\n",
344357
" \"asset_attributes\": {},\n",
345358
" \"operation\": \"Record\",\n",
346359
" \"behaviour\": \"RecordEvidence\",\n",
347-
" \"timestamp_declared\": \"2023-01-10T16:20:37Z\",\n",
348-
" \"timestamp_accepted\": \"2023-01-10T16:20:37Z\",\n",
349-
" \"timestamp_committed\": \"2023-01-10T16:20:37.759462037Z\",\n",
360+
" \"timestamp_declared\": \"2023-01-16T11:52:31Z\",\n",
361+
" \"timestamp_accepted\": \"2023-01-16T11:52:31Z\",\n",
362+
" \"timestamp_committed\": \"2023-01-16T11:52:31.599813432Z\",\n",
350363
" \"principal_declared\": {\n",
351-
" \"issuer\": \"https://app.dev-paul-0.wild.jitsuin.io/appidpv1\",\n",
352-
" \"subject\": \"bd3f85d2-9b92-4ef0-82c9-2bcb7b5d25c6\",\n",
353-
" \"display_name\": \"Application display name 05f19055-d2fd-4076-bd02-46a924cbe984\",\n",
364+
" \"issuer\": \"https://app.rkvst.io/appidpv1\",\n",
365+
" \"subject\": \"437bd138-dade-4346-aadd-dfdfee51ddf4\",\n",
366+
" \"display_name\": \"Test Notebooks\",\n",
354367
" \"email\": \"\"\n",
355368
" },\n",
356369
" \"principal_accepted\": {\n",
357-
" \"issuer\": \"https://app.dev-paul-0.wild.jitsuin.io/appidpv1\",\n",
358-
" \"subject\": \"bd3f85d2-9b92-4ef0-82c9-2bcb7b5d25c6\",\n",
359-
" \"display_name\": \"Application display name 05f19055-d2fd-4076-bd02-46a924cbe984\",\n",
370+
" \"issuer\": \"https://app.rkvst.io/appidpv1\",\n",
371+
" \"subject\": \"437bd138-dade-4346-aadd-dfdfee51ddf4\",\n",
372+
" \"display_name\": \"Test Notebooks\",\n",
360373
" \"email\": \"\"\n",
361374
" },\n",
362375
" \"confirmation_status\": \"CONFIRMED\",\n",
363376
" \"transaction_id\": \"\",\n",
364377
" \"block_number\": 0,\n",
365378
" \"transaction_index\": 0,\n",
366-
" \"from\": \"0x3E06AcBf002E8F67bDe832b3f3E7d2aDA2BE3DC8\",\n",
367-
" \"tenant_identity\": \"tenant/f9040e8b-2afa-48f1-bb00-f055d55ade01\"\n",
379+
" \"from\": \"0xe889E67FdBa658C6f27ccBDa98D9d1B5500Dbbce\",\n",
380+
" \"tenant_identity\": \"tenant/9bfb80ee-81f6-40dc-b5c7-1c7fb2fb9866\"\n",
368381
"}\n",
369382
"Sleep 1 second...\n",
370383
"COMPLIANCE (true): {\n",
371384
" \"compliant\": true,\n",
372385
" \"compliance\": [\n",
373386
" {\n",
374-
" \"compliance_policy_identity\": \"compliance_policies/e9b458b7-5e08-41ce-bf4c-ff01b7975148\",\n",
387+
" \"compliance_policy_identity\": \"compliance_policies/458957bc-4da7-4cc3-b37f-43fa53abe0cc\",\n",
375388
" \"compliant\": true,\n",
376389
" \"reason\": \"\"\n",
377390
" }\n",
378391
" ],\n",
379392
" \"next_page_token\": \"\",\n",
380-
" \"compliant_at\": \"2023-01-10T16:20:39Z\"\n",
393+
" \"compliant_at\": \"2023-01-16T11:52:33Z\"\n",
381394
"}\n"
382395
]
383396
}
@@ -397,7 +410,7 @@
397410
},
398411
{
399412
"cell_type": "code",
400-
"execution_count": 12,
413+
"execution_count": 13,
401414
"id": "fe8e2a6e",
402415
"metadata": {},
403416
"outputs": [
@@ -410,13 +423,13 @@
410423
" \"compliant\": false,\n",
411424
" \"compliance\": [\n",
412425
" {\n",
413-
" \"compliance_policy_identity\": \"compliance_policies/e9b458b7-5e08-41ce-bf4c-ff01b7975148\",\n",
426+
" \"compliance_policy_identity\": \"compliance_policies/458957bc-4da7-4cc3-b37f-43fa53abe0cc\",\n",
414427
" \"compliant\": false,\n",
415428
" \"reason\": \"Duration 20s exceeds limit 10s\"\n",
416429
" }\n",
417430
" ],\n",
418431
" \"next_page_token\": \"\",\n",
419-
" \"compliant_at\": \"2023-01-10T16:20:58Z\"\n",
432+
" \"compliant_at\": \"2023-01-16T11:52:52Z\"\n",
420433
"}\n"
421434
]
422435
}
@@ -434,7 +447,7 @@
434447
},
435448
{
436449
"cell_type": "code",
437-
"execution_count": 13,
450+
"execution_count": 14,
438451
"id": "40ffc716",
439452
"metadata": {},
440453
"outputs": [],
@@ -444,6 +457,14 @@
444457
" compliance_policy[\"identity\"],\n",
445458
")"
446459
]
460+
},
461+
{
462+
"cell_type": "code",
463+
"execution_count": null,
464+
"id": "bccec420",
465+
"metadata": {},
466+
"outputs": [],
467+
"source": []
447468
}
448469
],
449470
"metadata": {
@@ -462,7 +483,7 @@
462483
"name": "python",
463484
"nbconvert_exporter": "python",
464485
"pygments_lexer": "ipython3",
465-
"version": "3.10.6"
486+
"version": "3.8.15"
466487
}
467488
},
468489
"nbformat": 4,

0 commit comments

Comments
 (0)