I have list of jobs with dependencies and their status. I want to go through each job and map out their dependencies as a tree. The end of the tree will be when both parent dependencies are a status of done - Which means traversal should stop. I'm not sure if I should use recursion or if that's really the only possibility. Is there native mapping tools or data structures that can help me? I'm going to be iterating close to 10K jobs.
Psuedo Code
def map_depends(job_depends):
for job in job_depends:
if job.status = done:
job_tree_map.append(job.name)
else:
map_depends(job.get('dependencies'))
def main():
for job in batch:
if job.get('dependencies'):
map_depends(job.get('dependencies'))
Visual description of what I'm talking about.
-> job_depends1.status = done
main_job -> job_depends3 = running -> job_depends6 = done
-> job_depends2 = running......job_depends2 -> jon_depends4 = done
-> job_depends5 = done