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 d5c487e commit 43c11d3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
1 change: 1 addition & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[pylint]
disable=
duplicate-code,
invalid-name,
line-too-long,
missing-function-docstring,
Expand Down
6 changes: 2 additions & 4 deletions src/senzing_quickstart/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# coding: utf-8

# # Senzing Hello World
#
#
# The following is a quick test of connectivity to Senzing using Python over gRPC.
#
#

# Import python packages.

Expand All @@ -16,7 +16,6 @@
import grpc
from senzing_grpc import SzAbstractFactory


# Create an abstract factory for accessing Senzing via gRPC.

# In[ ]:
Expand All @@ -41,4 +40,3 @@


print(json.dumps(json.loads(sz_product.get_version()), indent=2))

19 changes: 7 additions & 12 deletions src/senzing_quickstart/load_truthsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# coding: utf-8

# # Load Senzing truth-sets
#
#
# These instructions load the [Senzing truth-sets] into the Senzing engine.
#
#
# [Senzing truth-sets]: https://github.com/Senzing/truth-sets

# ## Prepare Python enviroment
Expand All @@ -21,7 +21,6 @@
import requests
from senzing_grpc import SzAbstractFactory, SzEngineFlags, SzError


# Set environment specific variables.

# In[ ]:
Expand Down Expand Up @@ -69,7 +68,6 @@
datasources.append(datasource)

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



# ## Update Senzing configuration
Expand Down Expand Up @@ -102,7 +100,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 @@ -123,10 +121,8 @@


new_json_config = sz_config.export_config(config_handle)
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)
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)


# With the change in Senzing configuration, Senzing objects need to be updated.
Expand All @@ -149,7 +145,7 @@
filepath = home_path + filename
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 @@ -159,7 +155,7 @@
)
print(info)
except SzError as err:
print(err)
print(err)


# ## View results
Expand All @@ -184,4 +180,3 @@
}
search_result = sz_engine.search_by_attributes(json.dumps(search_query))
print(json.dumps(json.loads(search_result), indent=2))

13 changes: 5 additions & 8 deletions src/senzing_quickstart/load_user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# coding: utf-8

# # Load user data
#
#
# These instructions show how to load user data into the Senzing engine.

# ## Upload file of records

# The following instructions show how to upload a file of JSON lines.
# Here is an [example file].
#
#
# 1. In upper-left corner of JuypterLab, click on the
# ![Upload Files](img/upload-icon.png)
# ("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

# ## Prepare Python enviroment
Expand All @@ -25,10 +25,10 @@


import json

import grpc
from senzing_grpc import SzAbstractFactory, SzEngineFlags, SzError


# Set environment specific variables.

# In[ ]:
Expand Down Expand Up @@ -115,9 +115,7 @@


new_json_config = sz_config.export_config(config_handle)
new_config_id = sz_configmanager.add_config(
new_json_config, "Add user datasources"
)
new_config_id = sz_configmanager.add_config(new_json_config, "Add user datasources")
sz_configmanager.replace_default_config_id(old_config_id, new_config_id)


Expand Down Expand Up @@ -150,4 +148,3 @@
print(info)
except SzError as err:
print(err)

0 comments on commit 43c11d3

Please sign in to comment.