Skip to content

Commit

Permalink
python 3.9 compatible traceback
Browse files Browse the repository at this point in the history
  • Loading branch information
YaphetKG committed Jul 28, 2023
1 parent dd4d8f2 commit 13cbf66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions node_normalizer/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def convert_to_kgx(self, outfile_name) -> bool:
continue

except Exception as e:
logger.error(f"Exception thrown in convert_to_KGX(): {''.join(traceback.format_exception(e))}")
logger.error(f"Exception thrown in convert_to_KGX(): {''.join(traceback.format_exc())}")
ret_val = False

# return to the caller
Expand Down Expand Up @@ -280,7 +280,7 @@ async def load(self, block_size) -> bool:
logger.error(f"Error: 1 or more data files were incorrect")
ret_val = False
except Exception as e:
logger.error(f"Exception thrown in load(): {''.join(traceback.format_exception(e))}")
logger.error(f"Exception thrown in load(): {''.join(traceback.format_exc())}")
raise e

# return to the caller
Expand Down
20 changes: 10 additions & 10 deletions node_normalizer/normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def normalize_message(app: FastAPI, message: Message) -> Message:

return ret
except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')


Expand Down Expand Up @@ -130,7 +130,7 @@ async def normalize_results(app,
merged_result['node_bindings'][node_code] = merged_node_bindings

except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')

edge_binding_seen = set()
Expand Down Expand Up @@ -163,7 +163,7 @@ async def normalize_results(app,
hashed_result = json.dumps(merged_result, sort_keys=True)

except Exception as e: # TODO determine exception(s) to catch
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')
hashed_result = False

Expand Down Expand Up @@ -217,7 +217,7 @@ async def normalize_qgraph(app: FastAPI, qgraph: QueryGraph) -> QueryGraph:
merged_nodes[node_code]['ids'] = list(primary_ids)
node_code_map[node_code] = list(primary_ids)
except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')

return QueryGraph.parse_obj({
Expand Down Expand Up @@ -393,7 +393,7 @@ async def normalize_kgraph(
merged_edge['object'] = primary_object
merged_kgraph['edges'][edge_id] = merged_edge
except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')

return KnowledgeGraph.parse_obj(merged_kgraph), node_id_map, edge_id_map
Expand Down Expand Up @@ -429,7 +429,7 @@ async def get_equivalent_curies(
return default_return

except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')
return default_return

Expand Down Expand Up @@ -563,7 +563,7 @@ async def get_normalized_nodes(
}

except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')

return normal_nodes
Expand Down Expand Up @@ -681,7 +681,7 @@ async def get_curie_prefixes(
# set the return data
ret_val[item] = {'curie_prefix': curies}
except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')

return ret_val
Expand Down Expand Up @@ -721,7 +721,7 @@ def _merge_node_attributes(node_a: Dict, node_b, merged_count: int) -> Dict:

node_a['attributes'] = node_a['attributes'] + new_attribute_list
except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')

return node_a
Expand Down Expand Up @@ -771,6 +771,6 @@ def _hash_attributes(attributes: List[Attribute] = None) -> Union[int, bool]:

return hash(frozenset(new_attributes))
except Exception as e:
exception_str = "".join(traceback.format_exception(e))
exception_str = "".join(traceback.format_exc())
logger.error(f'Exception: {exception_str}')
return False

0 comments on commit 13cbf66

Please sign in to comment.