Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
Adds message about discord channel for help
Browse files Browse the repository at this point in the history
Users should not be afraid to ask for help. This is a simple
catch all exceptions, log a message about discord, and raise.

Hopefully people have logging setup to see it, otherwise they
won't...
  • Loading branch information
skrawcz committed Mar 26, 2022
1 parent a87371e commit afd7005
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions hamilton/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

from hamilton import node

DISCORD_ERROR_MESSAGE = (
'Oh no an error! Need help? Join our discord and ask someone for help! https://discord.gg/wCqxqBqn73'
)

if __name__ == '__main__':
import graph
import node
Expand Down Expand Up @@ -45,8 +49,11 @@ def __init__(self, config: Dict[str, Any], *modules: ModuleType, adapter: base.H
"""
if adapter is None:
adapter = base.SimplePythonDataFrameGraphAdapter()

self.graph = graph.FunctionGraph(*modules, config=config, adapter=adapter)
try:
self.graph = graph.FunctionGraph(*modules, config=config, adapter=adapter)
except Exception as e:
logger.error(DISCORD_ERROR_MESSAGE)
raise e
self.adapter = adapter

def _node_is_required_by_anything(self, node_: node.Node) -> bool:
Expand Down Expand Up @@ -108,8 +115,12 @@ def execute(self,
if display_graph:
logger.warning('display_graph=True is deprecated. It will be removed in the 2.0.0 release. '
'Please use visualize_execution().')
outputs = self.raw_execute(final_vars, overrides, display_graph, inputs=inputs)
return self.adapter.build_result(**outputs)
try:
outputs = self.raw_execute(final_vars, overrides, display_graph, inputs=inputs)
return self.adapter.build_result(**outputs)
except Exception as e:
logger.error(DISCORD_ERROR_MESSAGE)
raise e

def raw_execute(self,
final_vars: List[str],
Expand Down

0 comments on commit afd7005

Please sign in to comment.