Skip to content

Commit

Permalink
#85 Savepoint; working lint
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Sep 27, 2024
1 parent d55e0c6 commit 9a76ab0
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
relative_files = true
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
extend-ignore =
# E203 and E704 needed for black
E203,
E704,
E501,
W503
max-line-length=88
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ coverage.html
coverage.out

.settings
/.mypy_cache/
/.pytest_cache/
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[settings]
profile=black
src_paths=examples,src,tests
8 changes: 8 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[mypy]

[mypy-grpc.*]
ignore_missing_imports = True


[mypy-requests.*]
ignore_missing_imports = True
44 changes: 22 additions & 22 deletions src/senzing_quickstart/load_truthsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
# In[ ]:


home_path = "/notebooks/"
truth_set_url_prefix = "https://raw.githubusercontent.com/Senzing/truth-sets/refs/heads/main/truthsets/demo/"
truth_set_filenames = [
HOME_PATH = "/notebooks/"
TRUTH_SET_URL_PREFIX = "https://raw.githubusercontent.com/Senzing/truth-sets/refs/heads/main/truthsets/demo/"
TRUTH_SET_FILENAMES = [
"customers.json",
"reference.json",
"watchlist.json",
Expand All @@ -40,9 +40,9 @@
# In[ ]:


for filename in truth_set_filenames:
url = truth_set_url_prefix + filename
response = requests.get(url, stream=True)
for filename in TRUTH_SET_FILENAMES:
URL = TRUTH_SET_URL_PREFIX + filename
response = requests.get(URL, stream=True, timeout=10)
response.raw.decode_content = True
with open(filename, "wb") as file:
shutil.copyfileobj(response.raw, file)
Expand All @@ -57,9 +57,9 @@

datasources = []

for filename in truth_set_filenames:
filepath = home_path + filename
with open(filepath, "r") as file:
for filename in TRUTH_SET_FILENAMES:
FILEPATH = HOME_PATH + filename
with open(FILEPATH, "r", encoding="utf-8") as file:
for line in file:
line_as_dict = json.loads(line)
datasource = line_as_dict.get("DATA_SOURCE")
Expand Down Expand Up @@ -91,8 +91,8 @@


old_config_id = sz_configmanager.get_default_config_id()
old_json_config = sz_configmanager.get_config(old_config_id)
config_handle = sz_config.import_config(old_json_config)
OLD_JSON_CONFIG = sz_configmanager.get_config(old_config_id)
config_handle = sz_config.import_config(OLD_JSON_CONFIG)


# Add DataSources to Senzing configuration.
Expand All @@ -112,8 +112,8 @@
# In[ ]:


new_json_config = sz_config.export_config(config_handle)
new_config_id = sz_configmanager.add_config(new_json_config, "Add TruthSet datasources")
NEW_JSON_CONFIG = sz_config.export_config(config_handle)
new_config_id = sz_configmanager.add_config(NEW_JSON_CONFIG, "Add TruthSet datasources")
sz_configmanager.replace_default_config_id(old_config_id, new_config_id)


Expand All @@ -133,19 +133,19 @@
# In[ ]:


for filename in truth_set_filenames:
filepath = home_path + filename
with open(filepath, "r") as file:
for filename in TRUTH_SET_FILENAMES:
FILEPATH = HOME_PATH + filename
with open(FILEPATH, "r", encoding="utf-8") as file:
for line in file:
try:
line_as_dict = json.loads(line)
info = sz_engine.add_record(
INFO = sz_engine.add_record(
line_as_dict.get("DATA_SOURCE"),
line_as_dict.get("RECORD_ID"),
line,
SzEngineFlags.SZ_WITH_INFO,
)
print(info)
print(INFO)
except SzError as err:
print(err)

Expand All @@ -157,8 +157,8 @@
# In[ ]:


customer_1070_entity = sz_engine.get_entity_by_record_id("CUSTOMERS", "1070")
print(json.dumps(json.loads(customer_1070_entity), indent=2))
CUSTOMER_1070_ENTITY = sz_engine.get_entity_by_record_id("CUSTOMERS", "1070")
print(json.dumps(json.loads(CUSTOMER_1070_ENTITY), indent=2))


# Search for entities by attributes.
Expand All @@ -170,5 +170,5 @@
"name_full": "robert smith",
"date_of_birth": "11/12/1978",
}
search_result = sz_engine.search_by_attributes(json.dumps(search_query))
print(json.dumps(json.loads(search_result), indent=2))
SEARCH_RESULTS = sz_engine.search_by_attributes(json.dumps(search_query))
print(json.dumps(json.loads(SEARCH_RESULTS), indent=2))

0 comments on commit 9a76ab0

Please sign in to comment.