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...

Message will look like this in people's output:
-------------------------------------------------------------------
Oh no an error! Need help with Hamilton?
Join our discord and ask for help! https://discord.gg/wCqxqBqn73
-------------------------------------------------------------------
  • Loading branch information
skrawcz committed Mar 27, 2022
1 parent 87663af commit 49f11ed
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions hamilton/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

from hamilton import node

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

if __name__ == '__main__':
import graph
import node
Expand Down Expand Up @@ -45,8 +52,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 +118,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 49f11ed

Please sign in to comment.