hatchet-dev / hatchet-python

Hatchet Python SDK for Interacting with the Hatchet Engine
10 stars 3 forks source link

Allow circumvention of configuration through default environment variables #65

Open colonelpanic8 opened 6 days ago

colonelpanic8 commented 6 days ago

It's pretty surprising that the configuration that is provided to the main entrypoint to Hatchet (https://github.com/hatchet-dev/hatchet-python/blob/ae00e85ca0417473cb557c49c41755545f35b51e/hatchet_sdk/hatchet.py#L25) is really used more as a collection of defaults than an explicit configuration.

In several different places, surprising defaults take precedence over the configuration values that were explicitly provided in code to the instance:

https://github.com/hatchet-dev/hatchet-python/blob/ae00e85ca0417473cb557c49c41755545f35b51e/hatchet_sdk/loader.py#L67

https://github.com/hatchet-dev/hatchet-python/blob/ae00e85ca0417473cb557c49c41755545f35b51e/hatchet_sdk/loader.py#L83

https://github.com/hatchet-dev/hatchet-python/blob/ae00e85ca0417473cb557c49c41755545f35b51e/hatchet_sdk/loader.py#L101

This actually makes it essentially impossible to use a configuration system other than the one that is built in to hatchet-python.

I think it would be much better if all of this configuration parsing were, for example, moved to an optional classmethod on Hatchet, perhaps with a name like "from_environment_config" that would:

I'm happy to do the work to implement something like this, but would love to have the rough approach signed off on by the maintainers before embarking on doing this work.

colonelpanic8 commented 6 days ago

This may seem like a strange example, but with the status quo, it would actually be impossible, or at least difficult and far from ergonomic, to have a setup where you connect to multiple instances of Hatchet in the same process.

There are conceivable reasons that one might want to do this:

Not saying these are super compelling, but I think that its fair to expect that the configuration system should not make something like this next to impossible.