-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial * Initial * Lint issues * Update CHANGELOG.md
- Loading branch information
Showing
142 changed files
with
370,352 additions
and
725 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
ARG BASE_IMAGE=debian:11.5-slim@sha256:e8ad0bc7d0ee6afd46e904780942033ab83b42b446b58efa88d31ecf3adf4678 | ||
ARG BASE_IMAGE=senzing/senzingapi-runtime | ||
FROM ${BASE_IMAGE} | ||
|
||
ENV REFRESHED_AT=2022-10-27 | ||
ENV REFRESHED_AT=2022-12-21 | ||
|
||
LABEL Name="senzing/template-python" \ | ||
LABEL Name="senzing/code-snippets" \ | ||
Maintainer="[email protected]" \ | ||
Version="1.0.0" | ||
|
||
HEALTHCHECK CMD ["/app/healthcheck.sh"] | ||
Version="0.0.1" | ||
|
||
# Run as "root" for system installation. | ||
|
||
|
@@ -17,29 +15,34 @@ USER root | |
|
||
RUN apt-get update \ | ||
&& apt-get -y install \ | ||
vim \ | ||
nano \ | ||
curl \ | ||
less \ | ||
python3 \ | ||
ipython3 \ | ||
python3-pip \ | ||
python3-virtualenv \ | ||
python3-venv \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install packages via PIP. | ||
|
||
COPY requirements.txt ./ | ||
RUN pip3 install --upgrade pip \ | ||
&& pip3 install -r requirements.txt \ | ||
&& rm requirements.txt | ||
|
||
# Install packages via apt. | ||
|
||
# Copy files from repository. | ||
## Copy files from repository. | ||
|
||
COPY ./Python/ /code-snippets/Python | ||
COPY ./Resources/ /code-snippets/Resources | ||
COPY ./rootfs / | ||
|
||
# Make non-root container. | ||
|
||
USER 1001 | ||
|
||
# Runtime execution. | ||
# Runtime environment variables. | ||
|
||
ENV LD_LIBRARY_PATH=/opt/senzing/g2/lib:/opt/senzing/g2/lib/debian | ||
ENV PATH=${PATH}:/opt/senzing/g2/python | ||
ENV PYTHONPATH=/opt/senzing/g2/sdk/python | ||
ENV PYTHONUNBUFFERED=1 | ||
ENV SENZING_DOCKER_LAUNCHED=true | ||
|
||
WORKDIR /app | ||
CMD ["/app/sleep-infinity.sh"] | ||
WORKDIR /code-snippets | ||
ENTRYPOINT ["/bin/bash"] |
41 changes: 41 additions & 0 deletions
41
Python/APIs/G2Config/Data_Source_Management/addDataSource.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2Config, G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
add_response = bytearray() | ||
current_config = bytearray() | ||
current_config_id = bytearray() | ||
new_config = bytearray() | ||
new_config_id = bytearray() | ||
|
||
try: | ||
g2_config = G2Config() | ||
g2_config_mgr = G2ConfigMgr() | ||
|
||
g2_config.init('G2Config', engine_config_json, False) | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
|
||
g2_config_mgr.getDefaultConfigID(current_config_id) | ||
g2_config_mgr.getConfig(current_config_id, current_config) | ||
|
||
config_handle = g2_config.load(current_config) | ||
g2_config.addDataSource(config_handle, '{"DSRC_CODE": "CUSTOMERS"}', add_response) | ||
g2_config.addDataSource(config_handle, '{"DSRC_CODE": "WATCHLIST"}', add_response) | ||
g2_config.addDataSource(config_handle, '{"DSRC_CODE": "REFERENCE"}', add_response) | ||
g2_config.addDataSource(config_handle, '{"DSRC_CODE": "MYTEST"}', add_response) | ||
g2_config.save(config_handle, new_config) | ||
|
||
g2_config_mgr.addConfig(new_config, 'Test data sources added', new_config_id) | ||
g2_config_mgr.setDefaultConfigID(new_config_id) | ||
|
||
g2_config.destroy() | ||
g2_config_mgr.destroy() | ||
|
||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(f'Datasources added, new default config ID: {new_config_id.decode()}') |
40 changes: 40 additions & 0 deletions
40
Python/APIs/G2Config/Data_Source_Management/deleteDataSource.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2Config, G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
add_response = bytearray() | ||
current_config = bytearray() | ||
current_config_id = bytearray() | ||
new_config = bytearray() | ||
new_config_id = bytearray() | ||
|
||
|
||
try: | ||
g2_config = G2Config() | ||
g2_config_mgr = G2ConfigMgr() | ||
|
||
g2_config.init('G2Config', engine_config_json, False) | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
|
||
g2_config_mgr.getDefaultConfigID(current_config_id) | ||
g2_config_mgr.getConfig(current_config_id, current_config) | ||
|
||
config_handle = g2_config.load(current_config) | ||
|
||
g2_config.deleteDataSource(config_handle, '{"DSRC_CODE": "MYTEST"}') | ||
g2_config.save(config_handle, new_config) | ||
g2_config.close(config_handle) | ||
|
||
g2_config_mgr.addConfig(new_config, 'Data source deleted', new_config_id) | ||
g2_config_mgr.setDefaultConfigID(new_config_id) | ||
|
||
g2_config.destroy() | ||
g2_config_mgr.destroy() | ||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(f'Datasource deleted, new default config ID: {new_config_id.decode()}') |
32 changes: 32 additions & 0 deletions
32
Python/APIs/G2Config/Data_Source_Management/listDataSources.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2Config, G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
current_config = bytearray() | ||
current_config_id = bytearray() | ||
data_sources = bytearray() | ||
|
||
try: | ||
g2_config = G2Config() | ||
g2_config_mgr = G2ConfigMgr() | ||
|
||
g2_config.init('G2Config', engine_config_json, False) | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
|
||
g2_config_mgr.getDefaultConfigID(current_config_id) | ||
g2_config_mgr.getConfig(current_config_id, current_config) | ||
config_handle = g2_config.load(current_config) | ||
|
||
g2_config.listDataSources(config_handle, data_sources) | ||
g2_config.close(config_handle) | ||
|
||
g2_config.destroy() | ||
g2_config_mgr.destroy() | ||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(data_sources.decode()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
current_config_id = bytearray() | ||
current_config = bytearray() | ||
new_config_id = bytearray() | ||
|
||
with open('../../../../Resources/Configs/Test_Config.json', 'r') as file: | ||
config = file.read().strip() | ||
|
||
try: | ||
g2_config_mgr = G2ConfigMgr() | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
g2_config_mgr.addConfig(config, 'Testing adding a config.', new_config_id) | ||
g2_config_mgr.setDefaultConfigID(new_config_id.decode()) | ||
g2_config_mgr.destroy() | ||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(f'Configuration added, new configuration ID: {new_config_id.decode()}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
current_config_id = bytearray() | ||
config = bytearray() | ||
|
||
try: | ||
g2_config_mgr = G2ConfigMgr() | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
g2_config_mgr.getDefaultConfigID(current_config_id) | ||
g2_config_mgr.getConfig(current_config_id.decode(), config) | ||
g2_config_mgr.destroy() | ||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(config.decode()) |
19 changes: 19 additions & 0 deletions
19
Python/APIs/G2ConfigMgr/Config_Management/getConfigList.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
config_list = bytearray() | ||
|
||
try: | ||
g2_config_mgr = G2ConfigMgr() | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
g2_config_mgr.getConfigList(config_list) | ||
g2_config_mgr.destroy() | ||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(config_list.decode()) |
19 changes: 19 additions & 0 deletions
19
Python/APIs/G2ConfigMgr/Config_Management/getDefaultConfigID.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
config_id = bytearray() | ||
|
||
try: | ||
g2_config_mgr = G2ConfigMgr() | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
g2_config_mgr.getDefaultConfigID(config_id) | ||
g2_config_mgr.destroy() | ||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(f'Default config ID: {config_id.decode()}') |
20 changes: 20 additions & 0 deletions
20
Python/APIs/G2ConfigMgr/Config_Management/replaceDefaultConfigID.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
CURRENT_CONFIG_ID = 1646704028 | ||
NEW_CONFIG_ID = 1888647012 | ||
|
||
try: | ||
g2_config_mgr = G2ConfigMgr() | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
g2_config_mgr.replaceDefaultConfigID(CURRENT_CONFIG_ID, NEW_CONFIG_ID) | ||
g2_config_mgr.destroy() | ||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(f'Previous config ID {CURRENT_CONFIG_ID} replaced with {NEW_CONFIG_ID}') |
19 changes: 19 additions & 0 deletions
19
Python/APIs/G2ConfigMgr/Config_Management/setDefaultConfigID.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#! /usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException | ||
|
||
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None) | ||
CONFIG_ID = 1646704028 | ||
|
||
try: | ||
g2_config_mgr = G2ConfigMgr() | ||
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False) | ||
g2_config_mgr.setDefaultConfigID(CONFIG_ID) | ||
g2_config_mgr.destroy() | ||
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex: | ||
print(ex) | ||
sys.exit(-1) | ||
|
||
print(f'Default config ID set to: {CONFIG_ID}') |
Oops, something went wrong.