Skip to content

Commit

Permalink
#85 Savepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Sep 27, 2024
1 parent 2192252 commit 6474927
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 8 additions & 7 deletions rootfs/notebooks/load_user_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"The following instructions show how to upload a file of JSON lines.\n",
"Here is an [example file].\n",
"\n",
"1. In upper-left corner of Juypter lab, click on the\n",
"1. In upper-left corner of JuypterLab, click on the\n",
" ![Upload Files](img/upload-icon.png)\n",
" \"Upload Files\" icon.\n",
" (\"Upload Files\") icon.\n",
"1. Choose the file of JSON lines to upload.\n",
"\n",
"[example file]: https://raw.githubusercontent.com/senzing-garage/demo-quickstart/refs/heads/main/testdata/example-data-for-senzing.json"
Expand Down Expand Up @@ -130,7 +130,8 @@
" if datasource not in datasources:\n",
" datasources.append(datasource)\n",
"\n",
"print(f\"Found the following DATA_SOURCE values in the data: {datasources}\")"
"print(f\"Found the following DATA_SOURCE values in the data: {datasources}\")\n",
" "
]
},
{
Expand Down Expand Up @@ -202,7 +203,7 @@
"source": [
"old_config_id = sz_configmanager.get_default_config_id()\n",
"old_json_config = sz_configmanager.get_config(old_config_id)\n",
"config_handle = sz_config.import_config(old_json_config)"
"config_handle = sz_config.import_config(old_json_config) "
]
},
{
Expand Down Expand Up @@ -246,7 +247,7 @@
"new_config_id = sz_configmanager.add_config(\n",
" new_json_config, \"Add TruthSet datasources\"\n",
")\n",
"sz_configmanager.replace_default_config_id(old_config_id, new_config_id)"
"sz_configmanager.replace_default_config_id(old_config_id, new_config_id) "
]
},
{
Expand Down Expand Up @@ -293,7 +294,7 @@
"source": [
"with open(filepath, \"r\") as file:\n",
" for line in file:\n",
" try:\n",
" try: \n",
" line_as_dict = json.loads(line)\n",
" info = sz_engine.add_record(\n",
" line_as_dict.get(\"DATA_SOURCE\"),\n",
Expand All @@ -303,7 +304,7 @@
" )\n",
" print(info)\n",
" except SzError as err:\n",
" print(err)"
" print(err) "
]
}
],
Expand Down
13 changes: 7 additions & 6 deletions src/senzing_quickstart/load_user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
# The following instructions show how to upload a file of JSON lines.
# Here is an [example file].
#
# 1. In upper-left corner of Juypter lab, click on the
# 1. In upper-left corner of JuypterLab, click on the
# ![Upload Files](img/upload-icon.png)
# "Upload Files" icon.
# ("Upload Files") icon.
# 1. Choose the file of JSON lines to upload.
#
# [example file]: https://raw.githubusercontent.com/senzing-garage/demo-quickstart/refs/heads/main/testdata/example-data-for-senzing.json
Expand Down Expand Up @@ -62,6 +62,7 @@
datasources.append(datasource)

print(f"Found the following DATA_SOURCE values in the data: {datasources}")



# ## Update Senzing configuration
Expand Down Expand Up @@ -97,7 +98,7 @@

old_config_id = sz_configmanager.get_default_config_id()
old_json_config = sz_configmanager.get_config(old_config_id)
config_handle = sz_config.import_config(old_json_config)
config_handle = sz_config.import_config(old_json_config)


# Add DataSources to Senzing configuration.
Expand All @@ -121,7 +122,7 @@
new_config_id = sz_configmanager.add_config(
new_json_config, "Add TruthSet datasources"
)
sz_configmanager.replace_default_config_id(old_config_id, new_config_id)
sz_configmanager.replace_default_config_id(old_config_id, new_config_id)


# With the change in Senzing configuration, Senzing objects need to be updated.
Expand All @@ -142,7 +143,7 @@

with open(filepath, "r") as file:
for line in file:
try:
try:
line_as_dict = json.loads(line)
info = sz_engine.add_record(
line_as_dict.get("DATA_SOURCE"),
Expand All @@ -152,5 +153,5 @@
)
print(info)
except SzError as err:
print(err)
print(err)

0 comments on commit 6474927

Please sign in to comment.