3 ms·
Can you explain why you chose every function to take in context? https://github.com/hatchet-dev/hatchet/blob/main/python-sdk/examples/dag/worker.py https://git
by krawczstef 3y ago
Can you explain why you chose every function to take in context? https://github.com/hatchet-dev/hatchet/blob/main/python-sdk/examples/dag/worker.py https://github.com/hatchet-dev/hatchet/blob/main/python-sdk/...
This seems like a lot of boiler plate to write functions with to me (context I created http://github.com/DAGWorks-Inc/hamilton http://github.com/DAGWorks-Inc/hamilton).
- abelanger 3y agoWe did it because there are methods that should be accessed which don't map to `args` cleanly. For example, we let users call `context.log`, `context.done` (to determine whether to return on cancellation) or `context.step_output` (to dynamically access a parent's step output). Perhaps there's a more pythonic way to do this? Admittedly this is a pattern we adapted from Go.
- kamikaz1k 3y agoProbably just have it attached to self, like self.context But nbd IMHO
- krawczstef 3y agoyep nbd, but :/
- krawczstef 3y agoyou could just make them optional arguments that you inject if they're declared. Happy to chat more. With Hamilton we could actually build an alternative way to describe your API pretty easily...