Hi all, I'm probably trying to misuse your librar...
# hamilton-help
v
Hi all, I'm probably trying to misuse your library but here it goes: I would like to use the framework to run hardware using the DAG approach. The problem that I have and I could not yet see a solution in the docs is: How do i spawn multiple instances of a graph (driver) and sync node execution between instances. Lets say i have a simple A->B->C graph. I want to instantiate 10x copies of the driver but A tasks would finish first between 10 instances then move on to B and after that C. Is it possible to call the executer node by node? I would then write an executor manager but benefit from all the integrated telemetry of the hamilton UI. Thank you, Valery
s
Super interesting question!
So the hamilton driver should be serializable. So you could instantiate one and then distribute it.
Otherwise it sounds like you want each of the parallel drivers to execute in unison? Versus independently?
I have a few more thoughts — but have to go AFK. Will respond in a bit.
So two approaches I can think of if you need them to be in sync: Decentralized 1. Idea is that you run things in parallel, but build a way to “sync” progress between the processes. 2. Approach: need a datastore to sync against that can do atomic updates. 3. Build an adapter that (see lifecycle adapters, blog) that syncs progress to a datastore and only continues if all X processes have completed. E.g. you provide the number of processes & some ID for the run and each will update and then wait for all to complete before continuing… 4. Caveat: order of execution matters here - I think it’s stable, but don’t quote me on that (or it could be something to fix by adding a sort somewhere). 5. The Hamilton UI should be able to work here - it would track each individual driver run. Centralized: 1. So if you need to parameterize over something, I think this is a bit trickier - is that something you need? 2. If you don’t need to parameterize then I think turning on the new execution mode and building your own executor could work — the executor would be in charge of make N copies of the function run somewhere before moving onto the next one; you’d then need to co-ordinate passing in the right data for each one. The Hamilton UI here might need some help in figuring out what to track properly… 3. what you kind of want is what parallelizeable + collect does, but instead of a task being a subgraph, it’s a BFS walk of the graph and parallelizing each node like you want… @Elijah Ben Izzy might have some more thoughts — but yeah if you want to go centralized it’s some amount of code to be augmented to make it work nicely….
e
@Stefan Krawczyk nailed it — one other option, however, is to leverage parallelizable and put it in a single graph. I think. basically: 1. init -> parallelize over A_{0:n} -> collect_1(using parallelizable), then collect 2. collect_1 -> parallelize over B_{0:n” -> collect_2 3. … So basically, each layer/stage is a map-reduce pattern for that stage. So you use splitting/joiner nodes to ensure that each layer gets replicated 10x, and joining afterwards. The nice thing about this is that it gets represented simply and you can use the framework, the bad part is that it couples the fact that you’re running multiple instsances with the structure of the DAG.
v
@Stefan Krawczyk and @Elijah Ben Izzy thank you for the great replies! I will try to test these scenarios a bit more in detail in some time. My use case is using the library to plan work for a robot(6 axis arm) doing tasks. Each DAG would represent the work that needs to be done on a sample and it is convenient for the robot to process multiple samples at once and go through the nodes in batches of the same nodes. The execution is at points not parallelizable at some points. Like: need to process each sample 1 by 1 for this step. Yet some ones will be parallel. Move the whole batch of samples at once. It's a bit outside of your standard use-case for software only OPs but I see as a framework that would be great for handling automation.
s
Cool thanks @Valera K . Curious to see how you get on and where you find friction.