Skip to content

Commit

Permalink
chore: fix logging statements (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Oct 30, 2023
1 parent e6aa47c commit 1f95f8d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/dsp_tools/utils/project_create.py
Expand Up @@ -1132,14 +1132,14 @@ def create_project(
if overall_success:
msg = (
f"Successfully created project '{proj_shortname}' ({proj_shortcode}) with all its ontologies. "
f"There were no problems during the creation process.",
f"There were no problems during the creation process."
)
print(f"========================================================\n{msg}")
logger.info(msg)
else:
msg = (
f"The project '{proj_shortname}' ({proj_shortcode}) with its ontologies could be created, "
f"but during the creation process, some problems occurred. Please carefully check the console output.",
f"but during the creation process, some problems occurred. Please carefully check the console output."
)
print(f"========================================================\nWARNING: {msg}")
logger.warning(msg)
Expand Down
12 changes: 6 additions & 6 deletions src/dsp_tools/utils/shared.py
Expand Up @@ -109,7 +109,7 @@ def http_call_with_retry(
raise BaseError(
"This function can only be used with the methods get, post, put, and delete of the Python requests library."
)
action_as_str = f"action='{action}', args='{args}', kwargs='{kwargs}'"
action_as_str = f"{action=}, {args=}, {kwargs=}"
timeout = initial_timeout
for i in range(7):
try:
Expand All @@ -126,7 +126,7 @@ def http_call_with_retry(
timeout += 10
msg = f"Timeout Error: Retry request with timeout {timeout} in {2 ** i} seconds..."
print(f"{datetime.now()}: {msg}")
logger.error(f"{msg} {action_as_str} (retry-counter i={i})", exc_info=True)
logger.error(f"{msg} {action_as_str} (retry-counter {i=:})", exc_info=True)
time.sleep(2**i)
continue

Expand Down Expand Up @@ -158,7 +158,7 @@ def try_network_action(
Returns:
the return value of action
"""
action_as_str = f"action='{action}', args='{args}', kwargs='{kwargs}'"
action_as_str = f"{action=}, {args=}, {kwargs=}"
for i in range(7):
try:
if args and not kwargs:
Expand All @@ -172,13 +172,13 @@ def try_network_action(
except (TimeoutError, ReadTimeout, ReadTimeoutError):
msg = f"Timeout Error: Try reconnecting to DSP server, next attempt in {2 ** i} seconds..."
print(f"{datetime.now()}: {msg}")
logger.error(f"{msg} {action_as_str} (retry-counter i={i})", exc_info=True)
logger.error(f"{msg} {action_as_str} (retry-counter {i=:})", exc_info=True)
time.sleep(2**i)
continue
except (ConnectionError, RequestException):
msg = f"Network Error: Try reconnecting to DSP server, next attempt in {2 ** i} seconds..."
print(f"{datetime.now()}: {msg}")
logger.error(f"{msg} {action_as_str} (retry-counter i={i})", exc_info=True)
logger.error(f"{msg} {action_as_str} (retry-counter {i=:})", exc_info=True)
time.sleep(2**i)
continue
except BaseError as err:
Expand All @@ -189,7 +189,7 @@ def try_network_action(
if try_again_later or in_500_range:
msg = f"Transient Error: Try reconnecting to DSP server, next attempt in {2 ** i} seconds..."
print(f"{datetime.now()}: {msg}")
logger.error(f"{msg} {action_as_str} (retry-counter i={i})", exc_info=True)
logger.error(f"{msg} {action_as_str} (retry-counter {i=:})", exc_info=True)
time.sleep(2**i)
continue
else:
Expand Down
2 changes: 1 addition & 1 deletion src/dsp_tools/utils/xmlupload/read_validate_xml_file.py
Expand Up @@ -39,7 +39,7 @@ def validate_and_parse_xml_file(
check_if_bitstreams_exist(root=root, imgdir=imgdir)
shortcode = root.attrib["shortcode"]
default_ontology = root.attrib["default-ontology"]
logger.info(f"Validated and parsed the XML file. Shortcode='{shortcode}' and default_ontology='{default_ontology}'")
logger.info(f"Validated and parsed the XML file. {shortcode=:} and {default_ontology=:}")
return default_ontology, root, shortcode


Expand Down
2 changes: 1 addition & 1 deletion src/dsp_tools/utils/xmlupload/upload_config.py
Expand Up @@ -65,7 +65,7 @@ def with_server_info(
server_as_foldername = _transform_server_url_to_foldername(server)
save_location = Path.home() / Path(".dsp-tools") / "xmluploads" / server_as_foldername / shortcode / onto_name
save_location.mkdir(parents=True, exist_ok=True)
logger.info(f"save_location='{save_location}'")
logger.info(f"{save_location=:}")
context_iri = f"{server}/ontology/{shortcode}/{onto_name}/v2#"
return dataclasses.replace(
self,
Expand Down
Expand Up @@ -81,7 +81,7 @@ def _upload_stash_item(
except BaseError as err:
_log_unable_to_upload_link_value(err.orig_err_msg_from_api or err.message, stash.res_id, stash.prop_name)
return False
logger.debug(f' Successfully uploaded xml text of "{stash.prop_name}"\n')
logger.debug(f' Successfully uploaded xml text of "{stash.prop_name}"')
return True


Expand Down
2 changes: 1 addition & 1 deletion src/dsp_tools/utils/xmlupload/upload_stashed_xml_texts.py
Expand Up @@ -215,5 +215,5 @@ def _upload_stash_item(
except BaseError as err:
_log_unable_to_upload_xml_resource(err, res_id, stash_item.prop_name)
return False
logger.debug(f' Successfully uploaded xml text of "{stash_item.prop_name}"\n')
logger.debug(f' Successfully uploaded xml text of "{stash_item.prop_name}"')
return True

0 comments on commit 1f95f8d

Please sign in to comment.