Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning].

## [Unreleased]

## [0.2.8] - 2025-04-21

### Changed in 0.2.8

- Simplify and clean up examples

## [0.2.7] - 2025-04-18

### Changed in 0.2.7
Expand Down
11 changes: 6 additions & 5 deletions examples/misc/add_truthset_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

from . import sz_abstract_factory

record_sets = [
TRUTHSET_CUSTOMER_RECORDS,
TRUTHSET_REFERENCE_RECORDS,
TRUTHSET_WATCHLIST_RECORDS,
]

try:
sz_engine = sz_abstract_factory.create_engine()
record_sets = [
TRUTHSET_CUSTOMER_RECORDS,
TRUTHSET_REFERENCE_RECORDS,
TRUTHSET_WATCHLIST_RECORDS,
]
for record_set in record_sets:
for record in record_set.values():
sz_engine.add_record(
Expand Down
12 changes: 6 additions & 6 deletions examples/misc/add_truthset_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

# Create a new Senzing configuration with additional datasources.

CURRENT_DEFAULT_CONFIG_ID = sz_configmanager.get_default_config_id()
sz_config = sz_configmanager.create_config_from_config_id(CURRENT_DEFAULT_CONFIG_ID)
current_default_config_id = sz_configmanager.get_default_config_id()
sz_config = sz_configmanager.create_config_from_config_id(current_default_config_id)
for data_source_code in TRUTHSET_DATASOURCES:
sz_config.add_data_source(data_source_code)

# Persist new Senzing configuration.

NEW_CONFIG_DEFINITION = sz_config.export()
NEW_DEFAULT_CONFIG_ID = sz_configmanager.register_config(NEW_CONFIG_DEFINITION, "Add TruthSet datasources")
new_config_definition = sz_config.export()
new_default_config_id = sz_configmanager.register_config(new_config_definition, "Add TruthSet datasources")

# Make new Senzing configuration the default and the active configuration.

sz_configmanager.replace_default_config_id(CURRENT_DEFAULT_CONFIG_ID, NEW_DEFAULT_CONFIG_ID)
sz_abstract_factory.reinitialize(NEW_DEFAULT_CONFIG_ID)
sz_configmanager.replace_default_config_id(current_default_config_id, new_default_config_id)
sz_abstract_factory.reinitialize(new_default_config_id)
except SzError as err:
print(f"\nERROR: {err}\n")
4 changes: 2 additions & 2 deletions examples/szabstractfactory/reinitialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
try:
# Using get_active_config_id for demonstrations purposes.
sz_engine = sz_abstract_factory.create_engine()
CONFIG_ID = sz_engine.get_active_config_id()
sz_abstract_factory.reinitialize(CONFIG_ID)
config_id = sz_engine.get_active_config_id()
sz_abstract_factory.reinitialize(config_id)
except SzError as err:
print(f"\nERROR: {err}\n")
5 changes: 3 additions & 2 deletions examples/szconfig/add_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from . import sz_configmanager

data_source_code = "NAME_OF_DATASOURCE"

try:
DATA_SOURCE_CODE = "NAME_OF_DATASOURCE"
sz_config = sz_configmanager.create_config_from_template()
result = sz_config.add_data_source(DATA_SOURCE_CODE)
result = sz_config.add_data_source(data_source_code)
print(f"\n{result}\n")
except SzError as err:
print(f"\nERROR: {err}\n")
5 changes: 3 additions & 2 deletions examples/szconfig/delete_data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from . import sz_configmanager

data_source_code = "TEST"

try:
DATA_SOURCE_CODE = "TEST"
sz_config = sz_configmanager.create_config_from_template()
_ = sz_config.delete_data_source(DATA_SOURCE_CODE)
_ = sz_config.delete_data_source(data_source_code)
except SzError as err:
print(f"\nERROR: {err}\n")
4 changes: 2 additions & 2 deletions examples/szconfig/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

try:
sz_config = sz_configmanager.create_config_from_template()
CONFIG_DEFINITION = sz_config.export()
print(f"\n{CONFIG_DEFINITION}\n")
config_definition = sz_config.export()
print(f"\n{config_definition}\n")
except SzError as err:
print(f"\nERROR: {err}\n")
4 changes: 2 additions & 2 deletions examples/szconfigmanager/create_config_from_config_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from . import sz_configmanager

try:
CONFIG_ID = sz_configmanager.get_default_config_id()
sz_config = sz_configmanager.create_config_from_config_id(CONFIG_ID)
config_id = sz_configmanager.get_default_config_id()
sz_config = sz_configmanager.create_config_from_config_id(config_id)
except SzError as err:
print(f"\nERROR: {err}\n")
4 changes: 2 additions & 2 deletions examples/szconfigmanager/create_config_from_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from . import sz_configmanager

try:
CONFIG_DEFINITION = json.dumps({})
sz_config = sz_configmanager.create_config_from_string(CONFIG_DEFINITION)
config_definition = json.dumps({})
sz_config = sz_configmanager.create_config_from_string(config_definition)
except SzError as err:
print(f"\nERROR: {err}\n")
4 changes: 2 additions & 2 deletions examples/szconfigmanager/get_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from . import sz_configmanager

try:
CONFIG_LIST = sz_configmanager.get_configs()
print(f"\n{CONFIG_LIST}\n")
config_list = sz_configmanager.get_configs()
print(f"\n{config_list}\n")
except SzError as err:
print(f"\nERROR: {err}\n")
4 changes: 2 additions & 2 deletions examples/szconfigmanager/get_default_config_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from . import sz_configmanager

try:
CONFIG_ID = sz_configmanager.get_default_config_id()
print(f"\n{CONFIG_ID}\n")
config_id = sz_configmanager.get_default_config_id()
print(f"\n{config_id}\n")
except SzError as err:
print(f"\nERROR: {err}\n")
6 changes: 3 additions & 3 deletions examples/szconfigmanager/register_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from . import sz_configmanager

try:
CONFIG_COMMENT = "Just an empty example"
config_comment = "Just an empty example"
sz_config = sz_configmanager.create_config_from_template()
CONFIG_DEFINITION = sz_config.export()
CONFIG_ID = sz_configmanager.register_config(CONFIG_DEFINITION, CONFIG_COMMENT)
config_definition = sz_config.export()
config_id = sz_configmanager.register_config(config_definition, config_comment)
except SzError as err:
print(f"\nERROR: {err}\n")
15 changes: 8 additions & 7 deletions examples/szconfigmanager/replace_default_config_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@

from . import sz_configmanager

config_comment = "Just an example"
data_source_code = f"REPLACE_DEFAULT_CONFIG_ID_{time.time()}"

try:
sz_config = sz_configmanager.create_config_from_template()
CURRENT_DEFAULT_CONFIG_ID = sz_configmanager.get_default_config_id()
current_default_config_id = sz_configmanager.get_default_config_id()

# Create a new config.

sz_config = sz_configmanager.create_config_from_config_id(CURRENT_DEFAULT_CONFIG_ID)
data_source_code = f"REPLACE_DEFAULT_CONFIG_ID_{time.time()}"
sz_config = sz_configmanager.create_config_from_config_id(current_default_config_id)
sz_config.add_data_source(data_source_code)

# Persist the new config.

CONFIG_DEFINITION = sz_config.export()
CONFIG_COMMENT = "Just an example"
NEW_DEFAULT_CONFIG_ID = sz_configmanager.register_config(CONFIG_DEFINITION, CONFIG_COMMENT)
config_definition = sz_config.export()
new_default_config_id = sz_configmanager.register_config(config_definition, config_comment)

# Replace default config id.

sz_configmanager.replace_default_config_id(CURRENT_DEFAULT_CONFIG_ID, NEW_DEFAULT_CONFIG_ID)
sz_configmanager.replace_default_config_id(current_default_config_id, new_default_config_id)
except SzError as err:
print(f"\nERROR: {err}\n")
10 changes: 5 additions & 5 deletions examples/szconfigmanager/set_default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

from . import sz_configmanager

config_comment = "Just an example"
data_source_code = f"REPLACE_DEFAULT_CONFIG_ID_{time.time()}"

try:

# Create a new config.

sz_config = sz_configmanager.create_config_from_template()
data_source_code = f"REPLACE_DEFAULT_CONFIG_ID_{time.time()}"
sz_config.add_data_source(data_source_code)

# Persist the new default config.

CONFIG_DEFINITION = sz_config.export()
CONFIG_COMMENT = "Just an example"
CONFIG_ID = sz_configmanager.set_default_config(CONFIG_DEFINITION, CONFIG_COMMENT)

config_definition = sz_config.export()
config_id = sz_configmanager.set_default_config(config_definition, config_comment)
except SzError as err:
print(f"\nERROR: {err}\n")
12 changes: 6 additions & 6 deletions examples/szconfigmanager/set_default_config_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

from . import sz_configmanager

config_comment = "Just an example"
data_source_code = f"REPLACE_DEFAULT_CONFIG_ID_{time.time()}"

try:

# Create a new config.

sz_config = sz_configmanager.create_config_from_template()
data_source_code = f"REPLACE_DEFAULT_CONFIG_ID_{time.time()}"
sz_config.add_data_source(data_source_code)

# Persist the new config.

CONFIG_DEFINITION = sz_config.export()
CONFIG_COMMENT = "Just an example"
NEW_DEFAULT_CONFIG_ID = sz_configmanager.register_config(CONFIG_DEFINITION, CONFIG_COMMENT)
config_definition = sz_config.export()
new_default_config_id = sz_configmanager.register_config(config_definition, config_comment)

# Set default config id.

sz_configmanager.set_default_config_id(NEW_DEFAULT_CONFIG_ID)

sz_configmanager.set_default_config_id(new_default_config_id)
except SzError as err:
print(f"\nERROR: {err}\n")
5 changes: 3 additions & 2 deletions examples/szdiagnostic/check_datastore_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

from . import sz_diagnostic

seconds_to_run = 3

try:
SECONDS_TO_RUN = 3
result = sz_diagnostic.check_datastore_performance(SECONDS_TO_RUN)
result = sz_diagnostic.check_datastore_performance(seconds_to_run)
print(f"\n{result}\n")
except SzError as err:
print(f"\nERROR: {err}\n")
41 changes: 21 additions & 20 deletions examples/szengine/add_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@

from . import sz_engine

data_source_code = "TEST"
flags = SzEngineFlags.SZ_WITH_INFO
record_definition = json.dumps(
{
"RECORD_TYPE": "PERSON",
"PRIMARY_NAME_LAST": "Smith",
"PRIMARY_NAME_FIRST": "Robert",
"DATE_OF_BIRTH": "12/11/1978",
"ADDR_TYPE": "MAILING",
"ADDR_LINE1": "123 Main Street, Las Vegas NV 89132",
"PHONE_TYPE": "HOME",
"PHONE_NUMBER": "702-919-1300",
"EMAIL_ADDRESS": "bsmith@work.com",
"DATE": "1/2/18",
"STATUS": "Active",
"AMOUNT": "100",
}
)
record_id = "1"

try:
DATA_SOURCE_CODE = "TEST"
flags = SzEngineFlags.SZ_WITH_INFO
record_definition = json.dumps(
{
"RECORD_TYPE": "PERSON",
"PRIMARY_NAME_LAST": "Smith",
"PRIMARY_NAME_FIRST": "Robert",
"DATE_OF_BIRTH": "12/11/1978",
"ADDR_TYPE": "MAILING",
"ADDR_LINE1": "123 Main Street, Las Vegas NV 89132",
"PHONE_TYPE": "HOME",
"PHONE_NUMBER": "702-919-1300",
"EMAIL_ADDRESS": "bsmith@work.com",
"DATE": "1/2/18",
"STATUS": "Active",
"AMOUNT": "100",
}
)
RECORD_ID = "1"
result = sz_engine.add_record(DATA_SOURCE_CODE, RECORD_ID, record_definition, flags)
result = sz_engine.add_record(data_source_code, record_id, record_definition, flags)
print(f"\n{result}\n")
except SzError as err:
print(f"\nERROR: {err}\n")
9 changes: 5 additions & 4 deletions examples/szengine/delete_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from . import sz_engine

data_source_code = "TEST"
flags = SzEngineFlags.SZ_WITH_INFO
record_id = "1"

try:
DATA_SOURCE_CODE = "TEST"
flags = SzEngineFlags.SZ_WITH_INFO
RECORD_ID = "1"
result = sz_engine.delete_record(DATA_SOURCE_CODE, RECORD_ID, flags)
result = sz_engine.delete_record(data_source_code, record_id, flags)
print(f"\n{result}\n")
except SzError as err:
print(f"\nERROR: {err}\n")
19 changes: 10 additions & 9 deletions examples/szengine/export_csv_fetch_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

from . import sz_engine

csv_column_list = (
"RESOLVED_ENTITY_ID,RELATED_ENTITY_ID,RESOLVED_ENTITY_NAME,MATCH_LEVEL,MATCH_KEY,DATA_SOURCE,RECORD_ID"
)
flags = SzEngineFlags.SZ_EXPORT_DEFAULT_FLAGS

try:
CSV_COLUMN_LIST = (
"RESOLVED_ENTITY_ID,RELATED_ENTITY_ID,RESOLVED_ENTITY_NAME,MATCH_LEVEL,MATCH_KEY,DATA_SOURCE,RECORD_ID"
)
flags = SzEngineFlags.SZ_EXPORT_DEFAULT_FLAGS
EXPORT_HANDLE = sz_engine.export_csv_entity_report(CSV_COLUMN_LIST, flags)
export_handle = sz_engine.export_csv_entity_report(csv_column_list, flags)
while True:
FRAGMENT = sz_engine.fetch_next(EXPORT_HANDLE)
if not FRAGMENT:
fragment = sz_engine.fetch_next(export_handle)
if not fragment:
break
print(FRAGMENT, end="")
sz_engine.close_export(EXPORT_HANDLE)
print(fragment, end="")
sz_engine.close_export(export_handle)
except SzError as err:
print(f"\nERROR: {err}\n")
13 changes: 7 additions & 6 deletions examples/szengine/export_json_fetch_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from . import sz_engine

flags = SzEngineFlags.SZ_EXPORT_DEFAULT_FLAGS

try:
flags = SzEngineFlags.SZ_EXPORT_DEFAULT_FLAGS
EXPORT_HANDLE = sz_engine.export_json_entity_report(flags)
export_handle = sz_engine.export_json_entity_report(flags)
while True:
FRAGMENT = sz_engine.fetch_next(EXPORT_HANDLE)
if not FRAGMENT:
fragment = sz_engine.fetch_next(export_handle)
if not fragment:
break
print(FRAGMENT, end="")
sz_engine.close_export(EXPORT_HANDLE)
print(fragment, end="")
sz_engine.close_export(export_handle)
except SzError as err:
print(f"\nERROR: {err}\n")
13 changes: 7 additions & 6 deletions examples/szengine/find_network_by_entity_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

from . import sz_engine

build_out_degrees = 1
entity_list = [1, 4]
flags = SzEngineFlags.SZ_FIND_NETWORK_DEFAULT_FLAGS
max_degrees = 2
max_entities = 10

try:
BUILD_OUT_DEGREES = 1
entity_list = [1, 4]
flags = SzEngineFlags.SZ_FIND_NETWORK_DEFAULT_FLAGS
MAX_DEGREES = 2
MAX_ENTITIES = 10
result = sz_engine.find_network_by_entity_id(entity_list, MAX_DEGREES, BUILD_OUT_DEGREES, MAX_ENTITIES, flags)
result = sz_engine.find_network_by_entity_id(entity_list, max_degrees, build_out_degrees, max_entities, flags)
print(f"\n{result}\n")
except SzError as err:
print(f"\nERROR: {err}\n")
Loading
Loading