Skip to content

Conversation

@ahmadnaufal
Copy link

No description provided.

@ahmadnaufal ahmadnaufal force-pushed the feat/get-upstream-runs-contract branch from 3e910ef to 668b5ba Compare September 26, 2025 08:46
jobWithLineage := queue[0]
queue = queue[1:]

if job, ok := jobsByName[jobWithLineage.JobName]; ok {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if jobsByName generated by traversing the lineage, this check is not required

upstream.JobRuns = make(map[string]*scheduler.JobRunSummary)
}

upstreamJob, exists := jobsByName[upstream.JobName]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this as well

jobRunSummary := &scheduler.JobRunSummary{
ScheduledAt: expectedRunSchedule,
}
upstream.JobRuns[scheduleKey] = jobRunSummary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it mean we compute the job run lineage for each generated runs? if that so, this would be expensive

jobNames = append(jobNames, jobName)
}

jobsByName, err := r.jobRepo.FindByNames(ctx, jobNames)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be called once, instead of recalling it again in 2 function enrichWithJobDetails and getJobsAndProjects

@sravankorumilli
Copy link

@ahmadnaufal
Consider refactoring of the code as per our discussion
GetJobRunLineage([]JobSchedule) []JobRunLineage
GetAllJobUpstreamMap() map[JobName]Job //Input
GetAllPresets() map[ProjectName]Presets

GetJobRunLineage(Job, Schedule, JobUpstreams, PresetMap) JobRunLineage
EnrichJobswithJobDetails(map[JobName]Job, Presets, JobDetails) map[JobName]JobSummary
GetUpsteams(UpstreamSchedule, Window)
GetUpstreamRuns(Job, UpstreamJob) UpstreamJobSchedules
GetAllUpstreamRuns(Job, map[JobName]Job) JobRunLineageSummary

JobRunLineage
{
JobSummary
[]JobRunUpstreams
}

JobSummary
{
Name
Window
Schedule
SLA
Project
}

Copy link

@sravankorumilli sravankorumilli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped a comment based on our discussions

return lineage, nil
}

func (r *LineageResolver) buildLineageStructure(ctx context.Context, jobSchedules []*scheduler.JobSchedule) ([]*scheduler.JobLineageSummary, error) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note:

  1. avoid having function which returns partial information. We can use a different struct which only contain the relation, and use it for our next function, and so on until we get the JobLineageSummary
  2. if possible, improve the naming

@ahmadnaufal
Copy link
Author

closing this to use the new MR instead: #458
cc @deryrahman

@ahmadnaufal ahmadnaufal closed this Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants