Skip to content

Commit 715b26f

Browse files
authored
Issue3 ant.1 (#5)
* Initial * Initial * Lint issues * Update CHANGELOG.md
1 parent c0f6515 commit 715b26f

File tree

142 files changed

+370352
-725
lines changed

Some content is hidden

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

142 files changed

+370352
-725
lines changed

Diff for: .pylintrc

+21
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
[pylint]
22
disable=
3+
attribute-defined-outside-init,
34
broad-except,
45
consider-using-f-string,
6+
duplicate-code,
7+
global-statement,
8+
global-variable-undefined,
9+
import-error,
10+
invalid-name,
511
line-too-long,
12+
logging-fstring-interpolation,
13+
missing-class-docstring,
14+
missing-function-docstring,
15+
missing-module-docstring,
16+
protected-access,
17+
redefined-outer-name,
18+
simplifiable-if-statement,
19+
too-few-public-methods,
20+
too-many-arguments,
621
too-many-branches,
22+
too-many-instance-attributes,
23+
too-many-lines,
724
too-many-locals,
25+
too-many-nested-blocks,
26+
too-many-statements,
27+
unspecified-encoding,
28+
unused-argument,
829
good-names=
930
template-python
1031
ignore=

Diff for: CHANGELOG.md

+2-18
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
[markdownlint](https://dlaa.me/markdownlint/),
77
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9-
## [Unreleased]
10-
11-
- Thing 5
12-
- Thing 4
13-
14-
## [1.0.1] - yyyy-mm-dd
15-
16-
### Added to 1.0.1
17-
18-
- Thing 3
19-
20-
### Fixed in 1.0.1
21-
22-
- Thing 2
23-
24-
## [1.0.0] - yyyy-mm-dd
9+
## [1.0.0] - 2022-12-22
2510

2611
### Added to 1.0.0
2712

28-
- Thing 2
29-
- Thing 1
13+
- Initial

Diff for: Dockerfile

+22-19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
ARG BASE_IMAGE=debian:11.5-slim@sha256:e8ad0bc7d0ee6afd46e904780942033ab83b42b446b58efa88d31ecf3adf4678
1+
ARG BASE_IMAGE=senzing/senzingapi-runtime
22
FROM ${BASE_IMAGE}
33

4-
ENV REFRESHED_AT=2022-10-27
4+
ENV REFRESHED_AT=2022-12-21
55

6-
LABEL Name="senzing/template-python" \
6+
LABEL Name="senzing/code-snippets" \
77
Maintainer="[email protected]" \
8-
Version="1.0.0"
9-
10-
HEALTHCHECK CMD ["/app/healthcheck.sh"]
8+
Version="0.0.1"
119

1210
# Run as "root" for system installation.
1311

@@ -17,29 +15,34 @@ USER root
1715

1816
RUN apt-get update \
1917
&& apt-get -y install \
18+
vim \
19+
nano \
20+
curl \
2021
less \
2122
python3 \
23+
ipython3 \
2224
python3-pip \
25+
python3-virtualenv \
26+
python3-venv \
2327
&& rm -rf /var/lib/apt/lists/*
2428

25-
# Install packages via PIP.
26-
27-
COPY requirements.txt ./
28-
RUN pip3 install --upgrade pip \
29-
&& pip3 install -r requirements.txt \
30-
&& rm requirements.txt
31-
32-
# Install packages via apt.
33-
34-
# Copy files from repository.
29+
## Copy files from repository.
3530

31+
COPY ./Python/ /code-snippets/Python
32+
COPY ./Resources/ /code-snippets/Resources
3633
COPY ./rootfs /
3734

3835
# Make non-root container.
3936

4037
USER 1001
4138

42-
# Runtime execution.
39+
# Runtime environment variables.
40+
41+
ENV LD_LIBRARY_PATH=/opt/senzing/g2/lib:/opt/senzing/g2/lib/debian
42+
ENV PATH=${PATH}:/opt/senzing/g2/python
43+
ENV PYTHONPATH=/opt/senzing/g2/sdk/python
44+
ENV PYTHONUNBUFFERED=1
45+
ENV SENZING_DOCKER_LAUNCHED=true
4346

44-
WORKDIR /app
45-
CMD ["/app/sleep-infinity.sh"]
47+
WORKDIR /code-snippets
48+
ENTRYPOINT ["/bin/bash"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from senzing import G2Config, G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
add_response = bytearray()
9+
current_config = bytearray()
10+
current_config_id = bytearray()
11+
new_config = bytearray()
12+
new_config_id = bytearray()
13+
14+
try:
15+
g2_config = G2Config()
16+
g2_config_mgr = G2ConfigMgr()
17+
18+
g2_config.init('G2Config', engine_config_json, False)
19+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
20+
21+
g2_config_mgr.getDefaultConfigID(current_config_id)
22+
g2_config_mgr.getConfig(current_config_id, current_config)
23+
24+
config_handle = g2_config.load(current_config)
25+
g2_config.addDataSource(config_handle, '{"DSRC_CODE": "CUSTOMERS"}', add_response)
26+
g2_config.addDataSource(config_handle, '{"DSRC_CODE": "WATCHLIST"}', add_response)
27+
g2_config.addDataSource(config_handle, '{"DSRC_CODE": "REFERENCE"}', add_response)
28+
g2_config.addDataSource(config_handle, '{"DSRC_CODE": "MYTEST"}', add_response)
29+
g2_config.save(config_handle, new_config)
30+
31+
g2_config_mgr.addConfig(new_config, 'Test data sources added', new_config_id)
32+
g2_config_mgr.setDefaultConfigID(new_config_id)
33+
34+
g2_config.destroy()
35+
g2_config_mgr.destroy()
36+
37+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
38+
print(ex)
39+
sys.exit(-1)
40+
41+
print(f'Datasources added, new default config ID: {new_config_id.decode()}')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from senzing import G2Config, G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
add_response = bytearray()
9+
current_config = bytearray()
10+
current_config_id = bytearray()
11+
new_config = bytearray()
12+
new_config_id = bytearray()
13+
14+
15+
try:
16+
g2_config = G2Config()
17+
g2_config_mgr = G2ConfigMgr()
18+
19+
g2_config.init('G2Config', engine_config_json, False)
20+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
21+
22+
g2_config_mgr.getDefaultConfigID(current_config_id)
23+
g2_config_mgr.getConfig(current_config_id, current_config)
24+
25+
config_handle = g2_config.load(current_config)
26+
27+
g2_config.deleteDataSource(config_handle, '{"DSRC_CODE": "MYTEST"}')
28+
g2_config.save(config_handle, new_config)
29+
g2_config.close(config_handle)
30+
31+
g2_config_mgr.addConfig(new_config, 'Data source deleted', new_config_id)
32+
g2_config_mgr.setDefaultConfigID(new_config_id)
33+
34+
g2_config.destroy()
35+
g2_config_mgr.destroy()
36+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
37+
print(ex)
38+
sys.exit(-1)
39+
40+
print(f'Datasource deleted, new default config ID: {new_config_id.decode()}')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from senzing import G2Config, G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
current_config = bytearray()
9+
current_config_id = bytearray()
10+
data_sources = bytearray()
11+
12+
try:
13+
g2_config = G2Config()
14+
g2_config_mgr = G2ConfigMgr()
15+
16+
g2_config.init('G2Config', engine_config_json, False)
17+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
18+
19+
g2_config_mgr.getDefaultConfigID(current_config_id)
20+
g2_config_mgr.getConfig(current_config_id, current_config)
21+
config_handle = g2_config.load(current_config)
22+
23+
g2_config.listDataSources(config_handle, data_sources)
24+
g2_config.close(config_handle)
25+
26+
g2_config.destroy()
27+
g2_config_mgr.destroy()
28+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
29+
print(ex)
30+
sys.exit(-1)
31+
32+
print(data_sources.decode())
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
current_config_id = bytearray()
9+
current_config = bytearray()
10+
new_config_id = bytearray()
11+
12+
with open('../../../../Resources/Configs/Test_Config.json', 'r') as file:
13+
config = file.read().strip()
14+
15+
try:
16+
g2_config_mgr = G2ConfigMgr()
17+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
18+
g2_config_mgr.addConfig(config, 'Testing adding a config.', new_config_id)
19+
g2_config_mgr.setDefaultConfigID(new_config_id.decode())
20+
g2_config_mgr.destroy()
21+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
22+
print(ex)
23+
sys.exit(-1)
24+
25+
print(f'Configuration added, new configuration ID: {new_config_id.decode()}')
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
current_config_id = bytearray()
9+
config = bytearray()
10+
11+
try:
12+
g2_config_mgr = G2ConfigMgr()
13+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
14+
g2_config_mgr.getDefaultConfigID(current_config_id)
15+
g2_config_mgr.getConfig(current_config_id.decode(), config)
16+
g2_config_mgr.destroy()
17+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
18+
print(ex)
19+
sys.exit(-1)
20+
21+
print(config.decode())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
config_list = bytearray()
9+
10+
try:
11+
g2_config_mgr = G2ConfigMgr()
12+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
13+
g2_config_mgr.getConfigList(config_list)
14+
g2_config_mgr.destroy()
15+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
16+
print(ex)
17+
sys.exit(-1)
18+
19+
print(config_list.decode())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
config_id = bytearray()
9+
10+
try:
11+
g2_config_mgr = G2ConfigMgr()
12+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
13+
g2_config_mgr.getDefaultConfigID(config_id)
14+
g2_config_mgr.destroy()
15+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
16+
print(ex)
17+
sys.exit(-1)
18+
19+
print(f'Default config ID: {config_id.decode()}')
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 senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
CURRENT_CONFIG_ID = 1646704028
9+
NEW_CONFIG_ID = 1888647012
10+
11+
try:
12+
g2_config_mgr = G2ConfigMgr()
13+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
14+
g2_config_mgr.replaceDefaultConfigID(CURRENT_CONFIG_ID, NEW_CONFIG_ID)
15+
g2_config_mgr.destroy()
16+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
17+
print(ex)
18+
sys.exit(-1)
19+
20+
print(f'Previous config ID {CURRENT_CONFIG_ID} replaced with {NEW_CONFIG_ID}')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#! /usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from senzing import G2ConfigMgr, G2BadInputException, G2Exception, G2RetryableException, G2UnrecoverableException
6+
7+
engine_config_json = os.getenv('SENZING_ENGINE_CONFIGURATION_JSON', None)
8+
CONFIG_ID = 1646704028
9+
10+
try:
11+
g2_config_mgr = G2ConfigMgr()
12+
g2_config_mgr.init('G2ConfigMgr', engine_config_json, False)
13+
g2_config_mgr.setDefaultConfigID(CONFIG_ID)
14+
g2_config_mgr.destroy()
15+
except (G2BadInputException, G2RetryableException, G2UnrecoverableException, G2Exception) as ex:
16+
print(ex)
17+
sys.exit(-1)
18+
19+
print(f'Default config ID set to: {CONFIG_ID}')

0 commit comments

Comments
 (0)