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 ff15643 commit 13ad11c
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 28 deletions.
2 changes: 1 addition & 1 deletion rootfs/etc/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0

[program:jupyter-lab]
command = jupyter lab --allow-root
command = jupyter lab --allow-root --NotebookApp.token=''
directory = /notebooks
stderr_logfile = /dev/stderr
stdout_logfile = /dev/stdout
Expand Down
90 changes: 85 additions & 5 deletions rootfs/notebooks/hello_world.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,102 @@
"The following is a quick test of connectivity to Senzing using Python over gRPC.\n"
]
},
{
"cell_type": "markdown",
"id": "06b6ced9-6728-496b-b037-e5740fb5b99c",
"metadata": {},
"source": [
"Import python packages."
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "68ee0170-b9bf-4552-b218-497cc46a3dbd",
"metadata": {},
"outputs": [],
"source": [
"import json\n",
"\n",
"import grpc\n",
"from senzing_grpc import SzAbstractFactory\n",
"\n",
"from senzing_grpc import SzAbstractFactory"
]
},
{
"cell_type": "markdown",
"id": "563342b8-10f2-4eef-a887-21e6471076a5",
"metadata": {},
"source": [
"Create an abstract factory for accessing Senzing via gRPC."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "79b07536-ec75-4288-b5e7-22427f510c5b",
"metadata": {},
"outputs": [],
"source": [
"sz_abstract_factory = SzAbstractFactory(\n",
" grpc_channel=grpc.insecure_channel(\"localhost:8261\")\n",
")\n",
"sz_product = sz_abstract_factory.create_sz_product()\n",
")"
]
},
{
"cell_type": "markdown",
"id": "b1b455d7-7d09-4c64-bdfe-abada6d72d1c",
"metadata": {},
"source": [
"Create a Senzing object."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "be478e8e-a16c-4c05-9f01-7bda4025d953",
"metadata": {},
"outputs": [],
"source": [
"sz_product = sz_abstract_factory.create_sz_product()"
]
},
{
"cell_type": "markdown",
"id": "0b832dd8-02fb-46a7-9556-b42bd7fafb34",
"metadata": {},
"source": [
"Use Senzing object."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "02e3e512-4492-4d52-8bd3-1bc8f08b8a97",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"PRODUCT_NAME\": \"Senzing API\",\n",
" \"VERSION\": \"4.0.0\",\n",
" \"BUILD_VERSION\": \"4.0.0.24237\",\n",
" \"BUILD_DATE\": \"2024-08-24\",\n",
" \"BUILD_NUMBER\": \"2024_08_24__08_53\",\n",
" \"COMPATIBILITY_VERSION\": {\n",
" \"CONFIG_VERSION\": \"11\"\n",
" },\n",
" \"SCHEMA_VERSION\": {\n",
" \"ENGINE_SCHEMA_VERSION\": \"4.0\",\n",
" \"MINIMUM_REQUIRED_SCHEMA_VERSION\": \"4.0\",\n",
" \"MAXIMUM_REQUIRED_SCHEMA_VERSION\": \"4.99\"\n",
" }\n",
"}\n"
]
}
],
"source": [
"print(json.dumps(json.loads(sz_product.get_version()), indent=2))"
]
}
Expand Down
60 changes: 48 additions & 12 deletions rootfs/notebooks/load_truthsets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "de03a1c2-d7b1-40a9-8154-1df47cd49fef",
"metadata": {},
"outputs": [],
Expand All @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "ff9189d1-852d-46b0-9e2e-36f524c9038e",
"metadata": {},
"outputs": [],
Expand All @@ -77,7 +77,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "04555a6e-9c48-4a9b-b8b0-e7285b602fc8",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -109,10 +109,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "7f5cecdf-649a-4a8b-ad64-d2fc3f37166d",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Found the following DATA_SOURCE values in the data: ['CUSTOMERS', 'REFERENCE', 'WATCHLIST']\n"
]
}
],
"source": [
"datasources = []\n",
"\n",
Expand Down Expand Up @@ -142,15 +150,35 @@
"id": "7df1865e-38e5-416a-835b-b326b4eaf7a5",
"metadata": {},
"source": [
"Create Senzing objects."
"Create an abstract factory for accessing Senzing via gRPC."
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "3272f76c-dc95-4ff8-b573-8bddd55fb779",
"metadata": {},
"outputs": [],
"source": [
"sz_abstract_factory = SzAbstractFactory(\n",
" grpc_channel=grpc.insecure_channel(\"localhost:8261\")\n",
")"
]
},
{
"cell_type": "markdown",
"id": "60c3824c-e3ac-4445-ac71-338361890405",
"metadata": {},
"source": [
"Create Senzing objects."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "301ce7eb-9069-4c8d-a1c4-ebe8f78d1bf6",
"metadata": {},
"outputs": [],
"source": [
"sz_abstract_factory = SzAbstractFactory(\n",
" grpc_channel=grpc.insecure_channel(\"localhost:8261\")\n",
Expand All @@ -171,7 +199,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "fbf17cc3-3273-4097-90a2-f0b9a21674a1",
"metadata": {},
"outputs": [],
Expand All @@ -191,7 +219,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "97854ac2-ad01-4663-9f6c-4afd816230f9",
"metadata": {},
"outputs": [],
Expand All @@ -213,7 +241,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "32217742-9e09-4778-b7fe-1e23817251ec",
"metadata": {},
"outputs": [],
Expand All @@ -235,7 +263,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"id": "df805089-7a9a-4e4e-b959-c320819e855b",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -265,7 +293,15 @@
"execution_count": null,
"id": "cb8318ec-cd73-4e43-8349-586c8dd0dbfb",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"DATA_SOURCE\":\"CUSTOMERS\",\"RECORD_ID\":\"1001\",\"AFFECTED_ENTITIES\":[],\"INTERESTING_ENTITIES\":{\"ENTITIES\":[]}}\n"
]
}
],
"source": [
"for filename in truth_set_filenames:\n",
" filepath = home_path + filename\n",
Expand Down
27 changes: 25 additions & 2 deletions src/senzing_quickstart/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# coding: utf-8

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

# Import python packages.

# In[ ]:

Expand All @@ -14,8 +16,29 @@
import grpc
from senzing_grpc import SzAbstractFactory


# Create an abstract factory for accessing Senzing via gRPC.

# In[ ]:


sz_abstract_factory = SzAbstractFactory(
grpc_channel=grpc.insecure_channel("localhost:8261")
)


# Create a Senzing object.

# In[ ]:


sz_product = sz_abstract_factory.create_sz_product()


# Use Senzing object.

# In[ ]:


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

29 changes: 22 additions & 7 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,6 +21,7 @@
import requests
from senzing_grpc import SzAbstractFactory, SzEngineFlags, SzError


# Set environment specific variables.

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

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



# ## Update Senzing configuration

# Create an abstract factory for accessing Senzing via gRPC.

# In[ ]:


sz_abstract_factory = SzAbstractFactory(
grpc_channel=grpc.insecure_channel("localhost:8261")
)


# Create Senzing objects.

# In[ ]:
Expand All @@ -93,7 +105,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 @@ -114,8 +126,10 @@


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 @@ -138,7 +152,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 @@ -148,7 +162,7 @@
)
print(info)
except SzError as err:
print(err)
print(err)


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

Loading

0 comments on commit 13ad11c

Please sign in to comment.