Skip to content

Commit

Permalink
fix(WatchJobStatus): use ListJobs to get a job status without full jo…
Browse files Browse the repository at this point in the history
…b arguments.
  • Loading branch information
MingboPeng committed May 2, 2024
1 parent 2deb023 commit 05e6a34
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/PollinationSDK/Wrapper/ScheduledJobInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,18 @@ public async Task<string> WatchJobStatusAsync(Action<string> progressAction = de
var jobId = this.JobID;
LogHelper.LogInfo($"Checking job [{proj.Owner.Name}/{proj.Name}/{jobId}].");

var cloudJob = api.GetJob(proj.Owner.Name, proj.Name, jobId);
// retrieve a slim CloudJob via ListJobs api
var jobIds = new List<string>() { jobId };
var owner = proj.Owner.Name;
var projName = proj.Name;
var getAJobFromJobList = new Func<CloudJob>(() =>
{
var jobList = api.ListJobs(owner, projName, jobIds, page: 1, perPage: 1);
var j = jobList.Resources.FirstOrDefault();
return j;
});

var cloudJob = getAJobFromJobList();
var status = cloudJob.Status;
var startTime = status.StartedAt;
LogHelper.LogInfo($"Init status: {status.ToJson()}");
Expand Down Expand Up @@ -201,7 +212,7 @@ public async Task<string> WatchJobStatusAsync(Action<string> progressAction = de

// update status
await Task.Delay(1000);
cloudJob = api.GetJob(proj.Owner.Name, proj.Name, jobId);
cloudJob = getAJobFromJobList();
status = cloudJob.Status;
//_simulation = new Simulation(proj, simuId);
}
Expand All @@ -213,7 +224,7 @@ public async Task<string> WatchJobStatusAsync(Action<string> progressAction = de

var finishMessage = GetCloudJobDoneMessage(this.CloudJob);
progressAction?.Invoke(finishMessage);
LogHelper.LogInfo($"Finished checking job [{proj.Owner.Name}/{proj.Name}/{jobId}]: [{finishMessage}].");
LogHelper.LogInfo($"Finished checking job [{owner}/{projName}/{jobId}]: [{finishMessage}].");

return finishMessage;
}
Expand Down

0 comments on commit 05e6a34

Please sign in to comment.