New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add link to github diff on JobRequest detail page #4130
Conversation
d26b00f
to
036e34f
Compare
Excited to see this. From the original ticket:
Did you consider this? IMO this would deliver the most value. OR a feature that allows you to diff two arbitrary jobrequests rather than just sequential ones. |
Job detail screenshot new screenshots below |
Yes, I did think about it but I thought I'd try the most basic implementation first just to get my head around django and job server. I think having both "Compare to last run" and "Compare to last successful run" links wouldn't be too hard to do and could provide good value. The arbitrary commit comparison would require more extensive UI changes. |
Yes. I think ideally we would add the "compare to last successful run" as part of this work, while we're thinking about it. If you choose not to, we should capture it in a new issue, as I don't want to lose it as a feature request. I can see it being super useful for tech support, and also gradually educating users that they can do the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm requesting changes because of JobRequestManager.previous
, but please do consider my other comments.
dd3f08d
to
c988022
Compare
Latest screenshots JobRequest Detail pageNo previous JobRequests for this workspace on this backendPrevious JobRequests for this workspace on this backend but none succeededPrevious JobRequests for this workspace on this backend some of which succeededJob DetailNo previous runs of this action in this workspace on this backendPrevious runs of this action in this workspace on this backend but none succeededPrevious runs of this action in this workspace on this backend some of which succeeded |
The wording of these feels clunky (esp the Job detail page) but I'm struggling to make it better. @iaindillingham and @sebbacon raised very good points that it needs to be clear on the Job detail page that this is compare the code for the whole workspace, not just the action in question. |
I suspect we can help the user understand what will happen when they click partly with a little bit of UX tinkering of the sort @tomodwyer excels at? Just spitballing but something like: "View all repo changes since last execution on this backend" |
c988022
to
a61e56b
Compare
1aed2ae
to
eb7f985
Compare
Co-authored-by: Tom O'Dwyer <tom.odwyer@thedatalab.org>
Co-authored-by: Tom O'Dwyer <tom.odwyer@thedatalab.org>
Co-authored-by: Tom O'Dwyer <tom.odwyer@thedatalab.org>
eb7f985
to
fa904eb
Compare
Co-authored-by: Tom O'Dwyer <tom.odwyer@thedatalab.org>
fa904eb
to
7a01711
Compare
With thanks to @tomodwyer I think most of the bikeshedding re wording is resolved. Latest screenshots updated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reworking this PR. I've made several comments that I'd like you to consider; the most important relate to the use of Min
and succeeded=False
. I'm going to approve, because requesting changes feels heavy-handed (and I've requested changes once already). If you'd like me to spend a bit of time on JobRequestManager.previous
, then please ask.
jobserver/models/job_request.py
Outdated
.filter( | ||
workspace=job_request.workspace, | ||
backend=job_request.backend, | ||
id__lt=job_request.id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a good idea to rely on JobRequest.id
being monotonic. We want a temporal ordering, and JobRequest.created_at
is a required field that defaults to timezone.now
. Is there a reason for not using it instead?
id__lt=job_request.id, | |
created_at__lt=job_request.created_at, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's defined as an integer AutoField
-
job-server/jobserver/migrations/0001_initial.py
Lines 811 to 817 in b5b1a9d
"id", | |
models.AutoField( | |
auto_created=True, | |
primary_key=True, | |
serialize=False, | |
verbose_name="ID", | |
), |
created_at
|
||
a = JobRequestFactory(workspace=workspace, backend=backend, sha="abc1234") | ||
b = JobRequestFactory(workspace=workspace, backend=backend, sha="def5678") | ||
comp_url = workspace.repo.get_compare_url(b.sha, a.sha) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small brain snag: Why from b
to a
? (i.e. Why looking back in time?) Wouldn't the diff show everything that was added in a
to get b
in red? Clearly, this is a test: nobody will see. But this is giving me the feeling that I've missed something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparing latter to previous is how my brain works for this, but clearly that's not universal?
jobserver/models/job_request.py
Outdated
workspace_backend_job_requests = workspace_backend_job_requests.annotate( | ||
min_status=Min("jobs__status") | ||
).filter(min_status="succeeded") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're going to have to explain to me what you're doing with Min
here, because I've read it, run it in the shell, and I can't shake the feeling that it's a hack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the values for job.status
are ("failed", "pending", "running", "succeeded"). An efficient way of answering the question: "are all of the status values for all of this JobRequest
's Job
s equal to 'succeeded'?" is to take the minimum (by alphabetical sort) of the Job
s' status
es. Which is to say: min("failed", "pending", "running", "succeeded") == "succeeded"
This could be made more robust by adding a CheckConstraint
to that field to enforce the fact those are indeed the only permissible values or by
workspace_backend_job_requests = workspace_backend_job_requests.annotate(
min_status=Min("jobs__status"), max_status=Max("jobs__status")
).filter(min_status="succeeded", max_status="succeeded")
such that if "zzz" was added as a status then (min("succeeded","zzz")=="succeeded")&(max("succeeded","zzz")=="succeeded")==False
To use the logic in the @property
of Job.status
involves running the query to get all the JobRequests
prior to this one for this workspace/backend, then filtering in memory for the "succeeded" ones. By using the aggregate(s) above, this filtering can be pushed into the database query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see 35ccbf8
1c2ccb1
to
4bb5be2
Compare
4bb5be2
to
f0121ed
Compare
f0121ed
to
e3d8ae6
Compare
fixes #4034