Skip to content

Commit e37c5b8

Browse files
authored
#56 - Update Python snippets (#58)
1 parent 3a2e9e8 commit e37c5b8

20 files changed

+215
-53
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog], [markdownlint],
66
and this project adheres to [Semantic Versioning].
77

8+
## [0.0.9] - 2025-07-23
9+
10+
### Changed in 0.0.9
11+
12+
- Modify method names changed in SDK
13+
- Additional snippets
14+
815
## [0.0.8] - 2025-06-20
916

1017
### Changed in 0.0.8

python/configuration/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Configuration related examples.
33

44
## Snippets
5-
* **add_data_sources.py**
6-
* Add new data source codes.
5+
* **get_config_registry.py**
6+
* Gets the configuration registry detailing existing configurations.
7+
* **get_data_source_registry.py**
8+
* Gets the data source registry detailing configured data sources in the current default configuration.
9+
* **init_default_config.py**
10+
* Initializes the repository with a default configuration using the default configuration template.
11+
* **register_data_sources.py**
12+
* Retrieves the current default configuration, registers new data source codes in it, registers the new configuration and makes it the current default configuration.
713

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from pathlib import Path
6+
7+
from senzing import SzError
8+
from senzing_core import SzAbstractFactoryCore
9+
10+
INSTANCE_NAME = Path(__file__).stem
11+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
12+
13+
14+
try:
15+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
16+
sz_configmanager = sz_factory.create_configmanager()
17+
response = sz_configmanager.get_config_registry()
18+
print(response)
19+
except SzError as err:
20+
print(f"{err.__class__.__name__} - {err}", file=sys.stderr)

python/configuration/add_data_sources.py renamed to python/configuration/get_data_source_registry.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,12 @@
1212

1313

1414
try:
15-
sz_factory = SzAbstractFactoryCore("add_data_source", SETTINGS, verbose_logging=False)
15+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1616
sz_configmanager = sz_factory.create_configmanager()
1717

1818
config_id = sz_configmanager.get_default_config_id()
1919
sz_config = sz_configmanager.create_config_from_config_id(config_id)
20-
21-
for data_source in ("CUSTOMERS", "REFERENCE", "WATCHLIST"):
22-
_ = sz_config.add_data_source(data_source)
23-
24-
new_config = sz_config.export()
25-
new_config_id = sz_configmanager.set_default_config(new_config, "Add data source CUSTOMERS")
26-
27-
sz_config = sz_configmanager.create_config_from_config_id(new_config_id)
28-
response = sz_config.get_data_sources()
20+
response = sz_config.get_data_source_registry()
2921
print(response)
3022
except SzError as err:
3123
print(f"{err.__class__.__name__} - {err}", file=sys.stderr)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from pathlib import Path
6+
7+
from senzing import SzError
8+
from senzing_core import SzAbstractFactoryCore
9+
10+
EXISTING_CONFIG_MSG = "\nA configuration exists in the repository, replace it with a template configuration? (y/n) "
11+
INSTANCE_NAME = Path(__file__).stem
12+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
13+
14+
15+
try:
16+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
17+
sz_configmanager = sz_factory.create_configmanager()
18+
19+
if current_config_id := sz_configmanager.get_default_config_id():
20+
if not input(EXISTING_CONFIG_MSG).lower() in ("y", "yes"):
21+
sys.exit(1)
22+
23+
sz_config = sz_configmanager.create_config_from_template()
24+
new_default_config = sz_config.export()
25+
new_config_id = sz_configmanager.set_default_config(new_default_config, "Code snippet init_default_config example")
26+
print(f"New default config ID: {new_config_id}")
27+
except SzError as err:
28+
print(f"{err.__class__.__name__} - {err}", file=sys.stderr)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from pathlib import Path
6+
7+
from senzing import SzError
8+
from senzing_core import SzAbstractFactoryCore
9+
10+
INSTANCE_NAME = Path(__file__).stem
11+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
12+
13+
14+
try:
15+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
16+
sz_configmanager = sz_factory.create_configmanager()
17+
18+
current_config_id = sz_configmanager.get_default_config_id()
19+
sz_config = sz_configmanager.create_config_from_config_id(current_config_id)
20+
21+
for data_source in ("CUSTOMERS", "REFERENCE", "WATCHLIST"):
22+
sz_config.register_data_source(data_source)
23+
24+
new_config = sz_config.export()
25+
new_config_id = sz_configmanager.register_config(new_config, "Code snippet register_data_source example")
26+
sz_configmanager.replace_default_config_id(current_config_id, new_config_id)
27+
print(f"New default config ID: {new_config_id}")
28+
except SzError as err:
29+
print(f"{err.__class__.__name__} - {err}", file=sys.stderr)

python/deleting/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Deleting a record only requires the data source code and record ID for the recor
77
## Snippets
88

99
- **delete_futures.py**
10-
- Read and delete source records from a file using multiple threads
10+
- Read and delete source records from a file using multiple threads.
1111
- **delete_loop.py**
12-
- Basic read and delete source records from a file
12+
- Basic read and delete source records from a file.
1313
- **delete_with_info_futures.py**
14-
- Read and delete source records from a file using multiple threads
15-
- Collect the response using the [SZ_WITH_INFO flag](../../README.md#with-info) on the `delete_record()` method and write it to a file
14+
- Read and delete source records from a file using multiple threads.
15+
- Collect the response using the [SZ_WITH_INFO flag](../../README.md#with-info) on the `delete_record()` method and write it to a file.

python/information/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ The information snippets outline the retrieval of different informational aspect
44

55
## Snippets
66

7-
- **check_datastore_performance.py**
8-
- Run an insert test against the Senzing repository to gauge performance
9-
- **get_datastore_info.py**
10-
- Return basic information about the Senzing repository(s)
7+
- **check_repository_performance.py**
8+
- Run an insert test against the Senzing repository to gauge performance.
119
- **get_license.py**
12-
- Return the currently in use license details
10+
- Return the currently in use license details.
11+
- **get_repository_info.py**
12+
- Return basic information about the Senzing repository(s).
1313
- **get_stats.py**
14-
- Return statistical information from the Senzing engine during entity resolution processing
14+
- Return statistical information from the Senzing engine during entity resolution processing.
1515
- **get_version.py**
16-
- Return the current Senzing product version details
16+
- Return the current Senzing product version details.

python/information/check_datastore_performance.py renamed to python/information/check_repository_performance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
try:
1414
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1515
sz_diagnostic = sz_factory.create_diagnostic()
16-
print(sz_diagnostic.check_datastore_performance(SECONDS_TO_RUN))
16+
print(sz_diagnostic.check_repository_performance(SECONDS_TO_RUN))
1717
except SzError as err:
1818
print(f"\n{err.__class__.__name__} - {err}")

python/information/get_datastore_info.py renamed to python/information/get_repository_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
try:
1313
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1414
sz_diagnostic = sz_factory.create_diagnostic()
15-
print(sz_diagnostic.get_datastore_info())
15+
print(sz_diagnostic.get_repository_info())
1616
except SzError as err:
1717
print(f"\n{err.__class__.__name__} - {err}")

0 commit comments

Comments
 (0)