Skip to content

Commit

Permalink
Merge pull request #331 from nerdalert/cmd-output
Browse files Browse the repository at this point in the history
Add cmd output to job record in redis and UI job display
  • Loading branch information
mergify[bot] authored May 3, 2024
2 parents e196b41 + e4da492 commit c39aa54
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ui/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type JobData struct {
RepoName string `json:"repoName"`
JobType string `json:"jobType"`
InstallationID string `json:"installationID"`
Cmd string `json:"cmd"`
}

func getAllJobs(c *gin.Context) {
Expand Down Expand Up @@ -94,6 +95,7 @@ func fetchJobData(jobID string) (JobData, error) {
jobData.RepoName = rdb.Get(ctx, fmt.Sprintf("jobs:%s:repo_name", jobID)).Val()
jobData.JobType = rdb.Get(ctx, fmt.Sprintf("jobs:%s:job_type", jobID)).Val()
jobData.InstallationID = rdb.Get(ctx, fmt.Sprintf("jobs:%s:installation_id", jobID)).Val()
jobData.Cmd = rdb.Get(ctx, fmt.Sprintf("jobs:%s:cmd", jobID)).Val()

return jobData, nil
}
Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/Jobs/All/All.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ const AllJobs: React.FunctionComponent = () => {
<p><strong>Repository Name:</strong> {job.repoName}</p>
<p><strong>S3 URL:</strong> <a href={job.s3URL} target="_blank" rel="noopener noreferrer">{job.s3URL}</a></p>
<p><strong>Model Name:</strong> {job.modelName}</p>
<p><strong>Command Run:</strong> {job.cmd}</p>

</div>
</ExpandableRowContent>
</Td>
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/Jobs/Running/Running.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const RunningJobs: React.FunctionComponent = () => {
<p><strong>Repository Name:</strong> {job.repoName}</p>
<p><strong>S3 URL:</strong> <a href={job.s3URL} target="_blank" rel="noopener noreferrer">{job.s3URL}</a></p>
<p><strong>Model Name:</strong> {job.modelName}</p>
<p><strong>Command Run:</strong> {job.cmd}</p>
</div>
</ExpandableRowContent>
</Td>
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/Jobs/Success/Success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const SuccessJobs: React.FunctionComponent = () => {
<p><strong>Repository Name:</strong> {job.repoName}</p>
<p><strong>S3 URL:</strong> <a href={job.s3URL} target="_blank" rel="noopener noreferrer">{job.s3URL}</a></p>
<p><strong>Model Name:</strong> {job.modelName}</p>
<p><strong>Command Run:</strong> {job.cmd}</p>
</div>
</ExpandableRowContent>
</Td>
Expand Down
1 change: 1 addition & 0 deletions ui/src/app/common/ModelJobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface JobModel {
installationID: string;
s3URL: string;
modelName: string;
cmd: string;
}
4 changes: 4 additions & 0 deletions worker/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ func (w *Worker) runPrecheck(lab, outputDir, modelName string) error {
}
cmdArgs := strings.Fields(commandStr)
cmd := exec.Command(lab, cmdArgs...)
// Register the command for reporting/logging
w.cmdRun = cmd.String()
w.logger.Infof("Running the precheck command: %s", cmd.String())

Expand Down Expand Up @@ -960,6 +961,9 @@ func (w *Worker) datagenSvc(taxonomyFiles []string, outputDir string, numSamples

w.logger.Infof("SDG Post Details: %v", request)

// Register the body for reporting/logging
w.cmdRun = string(jsonData)

response, err := httpClient.Do(request)
if err != nil {
return nil, fmt.Errorf("failed to execute request: %w", err)
Expand Down

0 comments on commit c39aa54

Please sign in to comment.