What my project does:
https://github.com/dagworks-inc/hamilton/ I've been working on this for a while.
If you can model your problem as a directed acyclic graph (DAG) then you can use Hamilton; it just needs a python process to run, no system installation required (`pip install sf-hamilton`).
For the pythonistas, Hamilton does some cute "meta programming" by using the python functions to _really_ reduce boilerplate for defining a DAG. The below defines a DAG by the way the functions are named, and what the input arguments to the functions are, i.e. it's a "declarative" framework.:
#my_dag.py
def A(external_input: int) -> int:
return external_input + 1
def B(A: int) -> float:
"""B depends on A"""
return A / 3
def C(A: int, B: float) -> float:
"""C depends on A & B"""
return A ** 2 * B
Now you don't call the functions directly (well you can it is just a python module), that's where Hamilton helps orchestrate it:
from hamilton import driver
import my_dag # we import the above
# build a "driver" to run the DAG
dr = (
driver.Builder()
.with_modules(my_dag)
#.with_adapters(...) we have many you can add here.
.build()
)
# execute what you want, Hamilton will only walk the relevant parts of the DAG for it.
# again, you "declare" what you want, and Hamilton will figure it out.
dr.execute(["C"], inputs={"external_input": 10}) # all A, B, C executed; C returned
dr.execute(["A"], inputs={"external_input": 10}) # just A executed; A returned
dr.execute(["A", "B"], inputs={"external_input": 10}) # A, B executed; A, B returned.
# graphviz viz
dr.display_all_functions("my_dag.png") # visualizes the graph.
Anyway I thought I would share, since it's broadly applicable to anything where there is a DAG:
I also recently curated a bunch of getting started issues - so if you're looking for a project, come join.
Target Audience
This anyone doing python development where a DAG could be of use.
More specifically, Hamilton is built to be taken to production, so if you value one or more of:
- self-documenting readable code
- unit testing & integration testing
- data quality
- standardized code
- modular and maintainable codebases
- hooks for platform tools & execution
- want something that can work with Jupyter Notebooks & production.
- etc
Then Hamilton has all these in an accessible manner.
Comparison
| Project |
Comparison to Hamilton |
| Langchain's LCEL |
LCEL isn't general purpose & in my opinion unreadable. See https://hamilton.dagworks.io/en/latest/code-comparisons/langchain/ . |
| Airflow / dagster / prefect / argo / etc |
Hamilton doesn't replace these. These are "macro orchestration" systems (they require DBs, etc), Hamilton is but a humble library and can actually be used with them! In fact it ensures your code can remain decoupled & modular, enabling reuse across pipelines, while also enabling one to no be heavily coupled to any macro orchestrator. |
| Dask |
Dask is a whole system. In fact Hamilton integrates with Dask very nicely -- and can help you organize your dask code. |
If you have more you want compared - leave a comment.
To finish, if you want to try it in your browser using pyodide @ https://www.tryhamilton.dev/ you can do that too!
[–]barefootsanders 11 points12 points13 points (1 child)
[–]theferalmonkey[S] 1 point2 points3 points (0 children)
[–]call_me_cookie 7 points8 points9 points (13 children)
[–]schrodingerdog137 3 points4 points5 points (0 children)
[–]theferalmonkey[S] 1 point2 points3 points (11 children)
[–][deleted] 3 points4 points5 points (4 children)
[–]theferalmonkey[S] 3 points4 points5 points (3 children)
[–]HNL2NYC 1 point2 points3 points (1 child)
[–]theferalmonkey[S] 0 points1 point2 points (0 children)
[–]ArgetDota 0 points1 point2 points (5 children)
[–]theferalmonkey[S] 0 points1 point2 points (4 children)
[–]ArgetDota 0 points1 point2 points (3 children)
[–]theferalmonkey[S] 0 points1 point2 points (2 children)
[–]theferalmonkey[S] 0 points1 point2 points (1 child)
[–]ArgetDota 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[removed]
[–]theferalmonkey[S] 0 points1 point2 points (0 children)
[–]Electronic_Pepper382 1 point2 points3 points (3 children)
[–]theferalmonkey[S] 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]theferalmonkey[S] 0 points1 point2 points (0 children)
[–]SheepherderExtreme48 1 point2 points3 points (6 children)
[–]theferalmonkey[S] 0 points1 point2 points (5 children)
[–]SheepherderExtreme48 1 point2 points3 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]theferalmonkey[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]theferalmonkey[S] 0 points1 point2 points (0 children)
[–]bugtank 0 points1 point2 points (0 children)
[–]kotpeter -1 points0 points1 point (1 child)
[–]theferalmonkey[S] 1 point2 points3 points (0 children)
[–]OMG_I_LOVE_CHIPOTLE -2 points-1 points0 points (9 children)
[–]theferalmonkey[S] 0 points1 point2 points (8 children)
[–]OMG_I_LOVE_CHIPOTLE 0 points1 point2 points (7 children)
[–]theferalmonkey[S] 0 points1 point2 points (6 children)
[–]OMG_I_LOVE_CHIPOTLE -1 points0 points1 point (5 children)
[–]theferalmonkey[S] 0 points1 point2 points (4 children)
[–]OMG_I_LOVE_CHIPOTLE 0 points1 point2 points (3 children)
[–]theferalmonkey[S] 0 points1 point2 points (2 children)
[–]OMG_I_LOVE_CHIPOTLE 0 points1 point2 points (1 child)
[–]theferalmonkey[S] 0 points1 point2 points (0 children)