-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Redirect to build detail post manual build #4622
Redirect to build detail post manual build #4622
Conversation
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.
Thanks for your contribution!
|
||
|
||
class BuildList(BuildBase, BuildTriggerMixin, ListView): | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(BuildList, self).get_context_data(**kwargs) | ||
|
||
active_builds = self.get_queryset().exclude(state="finished").values('id') | ||
active_builds = self.get_queryset().exclude(state='finished' | ||
).values('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.
This line is wrapped in a weird way, If this is from pre-commit I think we can just format this manually. /cc @humitos
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.
Yes it was the result of the pre-commit hook.
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.
yup, this is an indenting pattern we don't support.
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.
yapf
sometime fails with weird lines.
I check them manually sometimes in a very fast way and decide to not include them when it happens.
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.
Please, fix this yapf
indent mistake.
readthedocs/builds/views.py
Outdated
return HttpResponseRedirect(reverse('builds_project_list', args=[project.slug])) | ||
build_pk = project.builds.first().pk | ||
return HttpResponseRedirect( | ||
reverse('builds_detail', args=[project.slug, build_pk]) |
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.
We may want a test for this, I'll be testing this manually later
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 think there is a better way to get the pk of the build we just created. project.builds.first()
is not explicit enough i feel. trigger_build
calls prepare_build
, which is where the build object is created. Perhaps we already have access to the build pk on the task signature return somehow?
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 will add a commit. Busy with exams right now.
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.
Looks good, +1 on tests for this. Also if we can get an explicit build id, I think that makes for the most guaranteed UX.
readthedocs/builds/views.py
Outdated
return HttpResponseRedirect(reverse('builds_project_list', args=[project.slug])) | ||
build_pk = project.builds.first().pk | ||
return HttpResponseRedirect( | ||
reverse('builds_detail', args=[project.slug, build_pk]) |
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 think there is a better way to get the pk of the build we just created. project.builds.first()
is not explicit enough i feel. trigger_build
calls prepare_build
, which is where the build object is created. Perhaps we already have access to the build pk on the task signature return somehow?
@agjohnson I am unable to get the result of the task since celery gives a runtime warning when
A related PR at celery tries to change it to a RuntimeWarning |
We don't want signature = prepare_build(proj)
build_pk = signature.get('kwargs', {}).get('build_pk') This might need to be verified, but I don't think we ever use the return from trigger_build. If not, we can either:
Then we can easily get the build_pk from the signature |
@agjohnson I have pushed a commit which returns a tuple now and uses the signature to fetch the build_pk. Should I squash the commits? I am sorry I didn't rebase before commiting. |
There is a problem with the PR since it says that ~1500 files were modified :/ Could you please rebase your changes against master and check that it's correct, please? |
a807a00
to
768779e
Compare
@humitos Sorry. Done now. I still don't know why the tests fail here. |
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.
Thanks for your contribution!
This PR looks good to me.
I'm marking as Request changes because a test case is needed. Once the test is added, I would be ready to merge from my point of view.
Also, I mentioned some small style changes to be considered.
readthedocs/core/utils/__init__.py
Outdated
@@ -172,7 +172,7 @@ def trigger_build(project, version=None, record=True, force=False): | |||
# Current project is skipped | |||
return None | |||
|
|||
return update_docs_task.apply_async() | |||
return (update_docs_task.apply_async(), update_docs_task) |
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 docstring needs to be updated accordingly.
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.
Yeah. Missed it. Also is the AsyncResult
promise necessary? I don't find any use of returning it from the function.
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 not used, I think.
It returns the async result since it's what it creates and could be useful to extend this from outside.
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.
@humitos Should I create a new test or modify the existing tests. Also the existing tests don't actually use any return from trigger_build
, so I am a bit confused.
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.
Modify the test and update the docstring to reflect your changes.
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.
@humitos Sorry but I still can't figure out what to modify in test_core_utils or in other tests since they do not utilize the build_pk
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.
@humitos @agjohnson Ping. Need some help with the tests.
I still can't figure out what to modify in
test_core_utils
or in other tests since they do not utilize thebuild_pk
.
|
||
|
||
class BuildList(BuildBase, BuildTriggerMixin, ListView): | ||
|
||
def get_context_data(self, **kwargs): | ||
context = super(BuildList, self).get_context_data(**kwargs) | ||
|
||
active_builds = self.get_queryset().exclude(state="finished").values('id') | ||
active_builds = self.get_queryset().exclude(state='finished' | ||
).values('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.
Please, fix this yapf
indent mistake.
5729816
to
bdc332b
Compare
94e13af
to
754b60d
Compare
I've added a test here. I think it should be 💯 |
51226ed
to
c972fb2
Compare
Codecov Report
@@ Coverage Diff @@
## master #4622 +/- ##
==========================================
+ Coverage 76.42% 76.47% +0.05%
==========================================
Files 158 158
Lines 9992 9992
Branches 1262 1262
==========================================
+ Hits 7636 7641 +5
+ Misses 2015 2009 -6
- Partials 341 342 +1
|
…redirect-to-build-detail
@invinciblycool THANKS! |
Fixes #4359.
Also sorted imports on running pre-commit hook and some minor modifications to comply with flake8.