Skip to content

Commit 276afb1

Browse files
authored
10 ant 1 (#17)
* #10 - Save point * #10 - Save point * #10 - Save point * #10 * #10
1 parent 4853af6 commit 276afb1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1298
-256
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,11 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130-
.history
130+
.history
131+
132+
# VSCode
133+
.vscode/
134+
.history
135+
136+
# Output folder used by examples
137+
resources/output/

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ 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+
### Changed in 0.0.2
9+
10+
- Modify Python imports to use senzing and senzing_core
11+
12+
### Added to 0.0.1
13+
14+
- Couple of new examples
15+
16+
817
### Added to 0.0.1
918

1019
- Initial for V4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ When using a bare metal install, the initialization parameters used by the Senzi
8484
- Python one liner
8585

8686
- ```python
87-
python3 -c $'import configparser; ini_file_name = "<project_path>/etc/G2Module.ini";engine_config_json = {};cfgp = configparser.ConfigParser();cfgp.optionxform = str;cfgp.read(ini_file_name)\nfor section in cfgp.sections(): engine_config_json[section] = dict(cfgp.items(section))\nprint(engine_config_json)'
87+
python3 -c $'import configparser; ini_file_name = "<project_path>/etc/G2Module.ini";settings = {};cfgp = configparser.ConfigParser();cfgp.optionxform = str;cfgp.read(ini_file_name)\nfor section in cfgp.sections(): settings[section] = dict(cfgp.items(section))\nprint(settings)'
8888
```
8989

9090
:pencil2: `<project_path>` in the above example should point to your project.

python/configuration/add_data_sources.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
import sys
55
from pathlib import Path
66

7-
from senzing_core import SzAbstractFactory, SzError
7+
from senzing import SzError
8+
from senzing_core import SzAbstractFactoryCore
89

9-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
1010
INSTANCE_NAME = Path(__file__).stem
11+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
1112

1213

1314
try:
14-
sz_factory = SzAbstractFactory("add_records", ENGINE_CONFIG_JSON, verbose_logging=False)
15+
sz_factory = SzAbstractFactoryCore("add_records", SETTINGS, verbose_logging=False)
1516
sz_config = sz_factory.create_config()
1617
sz_configmanager = sz_factory.create_configmanager()
1718

python/deleting/delete_futures.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
import sys
88
from pathlib import Path
99

10-
from senzing_core import (
11-
SzAbstractFactory,
12-
SzBadInputError,
13-
SzError,
14-
SzRetryableError,
15-
SzUnrecoverableError,
16-
)
10+
from senzing import SzBadInputError, SzError, SzRetryableError, SzUnrecoverableError
11+
from senzing_core import SzAbstractFactoryCore
1712

18-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
1913
INPUT_FILE = Path("../../resources/data/del-500.jsonl").resolve()
2014
INSTANCE_NAME = Path(__file__).stem
15+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
2116

2217

2318
def mock_logger(level, error, error_record=None):
@@ -73,7 +68,7 @@ def futures_del(engine, input_file):
7368

7469

7570
try:
76-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
71+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
7772
sz_engine = sz_factory.create_engine()
7873
futures_del(sz_engine, INPUT_FILE)
7974
except SzError as err:

python/deleting/delete_loop.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@
55
import sys
66
from pathlib import Path
77

8-
from senzing_core import (
9-
SzAbstractFactory,
10-
SzBadInputError,
11-
SzError,
12-
SzRetryableError,
13-
SzUnrecoverableError,
14-
)
15-
16-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
8+
from senzing import SzBadInputError, SzError, SzRetryableError, SzUnrecoverableError
9+
from senzing_core import SzAbstractFactoryCore
10+
1711
INPUT_FILE = Path("../../resources/data/del-500.jsonl").resolve()
1812
INSTANCE_NAME = Path(__file__).stem
13+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
1914

2015

2116
def mock_logger(level, error, error_record=None):
@@ -54,7 +49,7 @@ def del_records_from_file(engine, input_file):
5449

5550

5651
try:
57-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
52+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
5853
sz_engine = sz_factory.create_engine()
5954
del_records_from_file(sz_engine, INPUT_FILE)
6055
except SzError as err:

python/deleting/delete_with_info_futures.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
import sys
88
from pathlib import Path
99

10-
from senzing_core import (
11-
SzAbstractFactory,
10+
from senzing import (
1211
SzBadInputError,
1312
SzEngineFlags,
1413
SzError,
1514
SzRetryableError,
1615
SzUnrecoverableError,
1716
)
17+
from senzing_core import SzAbstractFactoryCore
1818

19-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
2019
INPUT_FILE = Path("../../resources/data/del-500.jsonl").resolve()
2120
INSTANCE_NAME = Path(__file__).stem
2221
OUTPUT_FILE = Path("../../resources/output/delete_file_with_info.jsonl").resolve()
22+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
2323

2424

2525
def mock_logger(level, error, error_record=None):
@@ -79,7 +79,7 @@ def futures_del(engine, input_file, output_file):
7979

8080

8181
try:
82-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
82+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
8383
sz_engine = sz_factory.create_engine()
8484
futures_del(sz_engine, INPUT_FILE, OUTPUT_FILE)
8585
except SzError as err:

python/information/check_datastore_performance.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import os
44
from pathlib import Path
55

6-
from senzing_core import SzAbstractFactory, SzError
6+
from senzing import SzError
7+
from senzing_core import SzAbstractFactoryCore
78

8-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
9+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
910
INSTANCE_NAME = Path(__file__).stem
1011
SECONDS_TO_RUN = 3
1112

1213
try:
13-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
14+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1415
sz_diagnostic = sz_factory.create_diagnostic()
1516
print(sz_diagnostic.check_datastore_performance(SECONDS_TO_RUN))
1617
except SzError as err:

python/information/get_datastore_info.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import os
44
from pathlib import Path
55

6-
from senzing_core import SzAbstractFactory, SzError
6+
from senzing import SzError
7+
from senzing_core import SzAbstractFactoryCore
78

8-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
9+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
910
INSTANCE_NAME = Path(__file__).stem
1011

1112
try:
12-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
13+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1314
sz_diagnostic = sz_factory.create_diagnostic()
1415
print(sz_diagnostic.get_datastore_info())
1516
except SzError as err:

python/information/get_license.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import os
44
from pathlib import Path
55

6-
from senzing_core import SzAbstractFactory, SzError
6+
from senzing import SzError
7+
from senzing_core import SzAbstractFactoryCore
78

8-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
9+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
910
INSTANCE_NAME = Path(__file__).stem
1011

1112
try:
12-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
13+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1314
sz_product = sz_factory.create_product()
1415
print(sz_product.get_license())
1516
except SzError as err:

python/information/get_stats.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@
77
import sys
88
from pathlib import Path
99

10-
from senzing_core import (
11-
SzAbstractFactory,
12-
SzBadInputError,
13-
SzError,
14-
SzRetryableError,
15-
SzUnrecoverableError,
16-
)
17-
18-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
19-
INPUT_FILE = Path("../../resources/data/load-500.json").resolve()
10+
from senzing import SzBadInputError, SzError, SzRetryableError, SzUnrecoverableError
11+
from senzing_core import SzAbstractFactoryCore
12+
13+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
14+
INPUT_FILE = Path("../../resources/data/load-500.jsonl").resolve()
2015
INSTANCE_NAME = Path(__file__).stem
2116

2217

@@ -86,7 +81,7 @@ def futures_add(engine, input_file):
8681

8782

8883
try:
89-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
84+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
9085
sz_engine = sz_factory.create_engine()
9186
futures_add(sz_engine, INPUT_FILE)
9287
except SzError as err:

python/information/get_version.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import os
44
from pathlib import Path
55

6-
from senzing_core import SzAbstractFactory, SzError
6+
from senzing import SzError
7+
from senzing_core import SzAbstractFactoryCore
78

8-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
9+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
910
INSTANCE_NAME = Path(__file__).stem
1011

1112
try:
12-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
13+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1314
sz_product = sz_factory.create_product()
1415
print(sz_product.get_version())
1516
except SzError as err:

python/initialization/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Snippets
44

5+
- **abstract_factory_parameters.py**
6+
- Used to create a dictionary that can be unpacked when creating an SzAbstractFactoryCore, also useful for type annotations
57
- **engine_priming.py**
68
- Priming the Senzing engine before use loads resource intensive assets upfront. Without priming the first SDK call to the engine will appear slower than usual as it causes these assets to be loaded
79
- **factory_and_engines.py**
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+
4+
from senzing import SzError
5+
from senzing_core import SzAbstractFactoryCore, SzAbstractFactoryParametersCore
6+
7+
FACTORY_PARAMETERS: SzAbstractFactoryParametersCore = {
8+
"instance_name": "abstract_factory_parameters",
9+
"settings": {
10+
"PIPELINE": {
11+
"CONFIGPATH": "/etc/opt/senzing",
12+
"RESOURCEPATH": "/opt/senzing/er/resources",
13+
"SUPPORTPATH": "/opt/senzing/data",
14+
},
15+
"SQL": {"CONNECTION": "sqlite3://na:na@/tmp/sqlite/G2C.db"},
16+
},
17+
"verbose_logging": 0,
18+
}
19+
20+
try:
21+
sz_factory = SzAbstractFactoryCore(**FACTORY_PARAMETERS)
22+
sz_config = sz_factory.create_config()
23+
sz_configmgr = sz_factory.create_configmanager()
24+
sz_diagnostic = sz_factory.create_diagnostic()
25+
sz_engine = sz_factory.create_engine()
26+
sz_product = sz_factory.create_product()
27+
# Do work...
28+
except SzError as err:
29+
print(f"\n{err.__class__.__name__} - {err}")

python/initialization/engine_priming.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import os
44
from pathlib import Path
55

6-
from senzing_core import SzAbstractFactory, SzError
6+
from senzing import SzError
7+
from senzing_core import SzAbstractFactoryCore
78

8-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
99
INSTANCE_NAME = Path(__file__).stem
10+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
1011

1112
try:
12-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
13+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1314
sz_engine = sz_factory.create_engine()
1415
print("Priming Senzing engine...")
1516
sz_engine.prime_engine()

python/initialization/factory_and_engines.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
import os
44
from pathlib import Path
55

6-
from senzing_core import SzAbstractFactory, SzError
6+
from senzing import SzError
7+
from senzing_core import SzAbstractFactoryCore
78

8-
ENGINE_CONFIG_JSON = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
99
INSTANCE_NAME = Path(__file__).stem
10+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
1011

1112
try:
12-
sz_factory = SzAbstractFactory(INSTANCE_NAME, ENGINE_CONFIG_JSON, verbose_logging=False)
13+
sz_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=False)
1314
sz_config = sz_factory.create_config()
1415
sz_configmgr = sz_factory.create_configmanager()
1516
sz_diagnostic = sz_factory.create_diagnostic()

python/initialization/g2_module_ini_to_json.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from pathlib import Path
55

66
INI_FILE = Path("../../resources/g2module/G2Module.ini").resolve()
7-
ENGINE_CONFIG_JSON = {}
7+
settings = {}
88

99
cfgp = configparser.ConfigParser()
1010
cfgp.optionxform = str # type: ignore
1111
cfgp.read(INI_FILE)
1212

1313
for section in cfgp.sections():
14-
ENGINE_CONFIG_JSON[section] = dict(cfgp.items(section))
14+
settings[section] = dict(cfgp.items(section))
1515

16-
print(ENGINE_CONFIG_JSON)
16+
print(settings)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
from pathlib import Path
5+
6+
from senzing import SzError
7+
from senzing_core import SzAbstractFactoryCore
8+
9+
# The value of config_id is made up, this example will fail if you run it
10+
CONFIG_ID = 2787481550
11+
INSTANCE_NAME = Path(__file__).stem
12+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
13+
14+
try:
15+
sz_abstract_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, CONFIG_ID)
16+
sz_abstract_factory.create_engine()
17+
except SzError as err:
18+
print(f"\n{err.__class__.__name__} - {err}")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
from pathlib import Path
5+
6+
from senzing import SzError
7+
from senzing_core import SzAbstractFactoryCore
8+
9+
INSTANCE_NAME = Path(__file__).stem
10+
SETTINGS = os.getenv("SENZING_ENGINE_CONFIGURATION_JSON", "{}")
11+
VERBOSE_LOGGING = 1
12+
13+
try:
14+
sz_abstract_factory = SzAbstractFactoryCore(INSTANCE_NAME, SETTINGS, verbose_logging=VERBOSE_LOGGING)
15+
# Create an engine to show debug output
16+
sz_abstract_factory.create_engine()
17+
except SzError as err:
18+
print(f"\n{err.__class__.__name__} - {err}")

0 commit comments

Comments
 (0)