From da1869c09257f69e108a644ae38539806d6d6691 Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 1 Apr 2024 09:25:58 -0500 Subject: [PATCH 1/4] fixing an issue where it was possible to accidentally write to an incorrect workspace if you have archived ones present --- Simple ETL Example/Simple ETL Example.ipynb | 24 +++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Simple ETL Example/Simple ETL Example.ipynb b/Simple ETL Example/Simple ETL Example.ipynb index 227c540..009893c 100644 --- a/Simple ETL Example/Simple ETL Example.ipynb +++ b/Simple ETL Example/Simple ETL Example.ipynb @@ -85,7 +85,7 @@ "systemlink": { "interfaces": [ "ni-files" - ], + ], "outputs": [ { "display_name": "Test Result ID", @@ -178,10 +178,22 @@ "\n", "# Print the list of workspaces you may choose to create the test result and datatable in\n", "workspaces = get_workspaces_resp.json()[\"workspaces\"]\n", - "for workspace in workspaces:\n", - " if workspace[\"enabled\"]: print(workspace[\"name\"])\n", - "\n", - "# Select the desired workspace. As a placeholder, I'm simply selecting the first in the list here\n", + "for idx, workspace in enumerate(workspaces):\n", + " if workspace[\"enabled\"]: \n", + " print(f'{idx} - {workspace[\"name\"]}')\n", + " else:\n", + " workspaces.remove(workspace)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "060092ef", + "metadata": {}, + "outputs": [], + "source": [ + "# Select the desired workspace. \n", + "# As a placeholder, I'm simply selecting the first in the list here\n", "workspace = workspaces[0]" ] }, @@ -382,7 +394,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.4" + "version": "3.8.2" } }, "nbformat": 4, From e60a95a60f5e7b4f5ea50ebde9efbe310776243f Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 1 Apr 2024 09:41:42 -0500 Subject: [PATCH 2/4] Just show archived worspaces too, and let the user know it is archived --- Simple ETL Example/Simple ETL Example.ipynb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Simple ETL Example/Simple ETL Example.ipynb b/Simple ETL Example/Simple ETL Example.ipynb index 009893c..2597f3f 100644 --- a/Simple ETL Example/Simple ETL Example.ipynb +++ b/Simple ETL Example/Simple ETL Example.ipynb @@ -179,10 +179,7 @@ "# Print the list of workspaces you may choose to create the test result and datatable in\n", "workspaces = get_workspaces_resp.json()[\"workspaces\"]\n", "for idx, workspace in enumerate(workspaces):\n", - " if workspace[\"enabled\"]: \n", - " print(f'{idx} - {workspace[\"name\"]}')\n", - " else:\n", - " workspaces.remove(workspace)" + " print(f'{idx} - {workspace[\"name\"]} {\"\" if workspace[\"enabled\"] else \"(Archived)\" }')" ] }, { From 80ac30a583d0a7a909209f661de82693d92c51dc Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 1 Apr 2024 09:49:39 -0500 Subject: [PATCH 3/4] removed an extreneous space --- Simple ETL Example/Simple ETL Example.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simple ETL Example/Simple ETL Example.ipynb b/Simple ETL Example/Simple ETL Example.ipynb index 2597f3f..9d95610 100644 --- a/Simple ETL Example/Simple ETL Example.ipynb +++ b/Simple ETL Example/Simple ETL Example.ipynb @@ -179,7 +179,7 @@ "# Print the list of workspaces you may choose to create the test result and datatable in\n", "workspaces = get_workspaces_resp.json()[\"workspaces\"]\n", "for idx, workspace in enumerate(workspaces):\n", - " print(f'{idx} - {workspace[\"name\"]} {\"\" if workspace[\"enabled\"] else \"(Archived)\" }')" + " print(f'{idx} - {workspace[\"name\"]} {\"\" if workspace[\"enabled\"] else \"(Archived)\"}')" ] }, { From 354d539cb9fbf8c8307e3dd71f8ff37f9dc81ce3 Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 1 Apr 2024 10:53:08 -0500 Subject: [PATCH 4/4] switching to dict to specify the workspace by name instead of index --- Simple ETL Example/Simple ETL Example.ipynb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Simple ETL Example/Simple ETL Example.ipynb b/Simple ETL Example/Simple ETL Example.ipynb index 9d95610..4544b8a 100644 --- a/Simple ETL Example/Simple ETL Example.ipynb +++ b/Simple ETL Example/Simple ETL Example.ipynb @@ -177,9 +177,9 @@ "get_workspaces_resp.raise_for_status()\n", "\n", "# Print the list of workspaces you may choose to create the test result and datatable in\n", - "workspaces = get_workspaces_resp.json()[\"workspaces\"]\n", - "for idx, workspace in enumerate(workspaces):\n", - " print(f'{idx} - {workspace[\"name\"]} {\"\" if workspace[\"enabled\"] else \"(Archived)\"}')" + "workspaces = {w[\"name\"]: w for w in get_workspaces_resp.json()[\"workspaces\"] if w[\"enabled\"]}\n", + "for workspace in workspaces:\n", + " print(workspace)" ] }, { @@ -189,9 +189,10 @@ "metadata": {}, "outputs": [], "source": [ - "# Select the desired workspace. \n", - "# As a placeholder, I'm simply selecting the first in the list here\n", - "workspace = workspaces[0]" + "# Specify the desired workspace by name from the list printed by the cell above.\n", + "# Ensure that you have the Data Maintainer role or equivalent privileges in the workspace.\n", + "# As a placeholder, the Default workspace will be used.\n", + "workspace = workspaces[\"Default\"]" ] }, {