-
Notifications
You must be signed in to change notification settings - Fork 10
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
BuildManager #28
BuildManager #28
Conversation
procbuild/builder.py
Outdated
@@ -10,7 +10,7 @@ | |||
import random | |||
|
|||
from os.path import join as joinp | |||
from glob import glob | |||
from glob import glob, iglob |
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.
glob no longer used
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.
Once i remove the old code, indeed
procbuild/builder.py
Outdated
|
||
class BuildManager(object): | ||
|
||
def __init__(self, |
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.
odd formatting 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.
it makes it easier to change the variables without introducing confusing diffs since I didn't expect these to stay constant. I actually like this format if we end up having a lot of keyword arguments (which I think a lot of these are going to become), for similar reasons.
I'm also thinking that we might want to introduce a "type" system where we create an object first and then can check that everything is well formatted and pass in that instance to the BuildManager.
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 simpler we can keep things the better. The words "type system" fill me with fear!
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 actually was putting quotes only around "type" to distinguish it from "type system". Basically I want one thing that does all the preamble to defining what the builder will need to know, instantiate that object (and make it debugable) and then pass that into the BuildManager
which will do the actual build management. Right now the BuildManager
is playing both roles.
procbuild/builder.py
Outdated
def build_paper(self): | ||
try: | ||
with tempfile.TemporaryDirectory() as build_path: | ||
self.build_path = build_path |
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 section reads very nicely now. Would it make sense to change some of the methods to private members, e.g. self._run_make_paper_script
. My thinking is that we should signal to the user that build_paper
is really what they want to be calling.
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.
that seems reasonable, what I'm hoping is that this will also make it substantially more testable.
@@ -197,6 +197,8 @@ def _build_worker(nr): | |||
|
|||
def build_and_log(*args, **kwargs): |
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.
*args, **kwargs
is such an impenetrable syntax. It would be helpful to document either this method of BuildManager.build_paper
.
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.
Agreed, I actually think this is an unnecessary framework that will go away once we're switching to zmq for messaging.
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 apologise if I was unclear, I was suggesting that we do not change this syntax in this PR. Rather, we wait to change this syntax in a later PR (e.g., #29).
procbuild/builder.py
Outdated
self.build_pdf_path = '' | ||
self.master_repo_path = joinp(cache(), 'scipy_proceedings') | ||
self.build_timestamp = time.strftime('%d/%m %H:%M') | ||
self.target_path = joinp(cache(), '%s.pdf' % target) |
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.
Should this be an input parameter as well?
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
procbuild/builder.py
Outdated
self.master_branch = master_branch | ||
self.build_status = 'Build started...' | ||
self.build_pdf_path = '' | ||
self.master_repo_path = joinp(cache(), 'scipy_proceedings') |
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.
Should this be an input parameter as well?
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.
(my thinking is that the BuildManager should not be dependent on knowledge about the cache)
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.
Agreed on all of these counts. I also have a PRManager PR that i'm working on that changes how the cache works, I should probably make a WIP PR for that too… I just think it'll be easier to get these refactors done one at a time & this one was more isolated.
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.
NB: that comment was relevant because the cache should move into the PRManager since that's what's doing most of the cache management.
@stefanv i made the change you suggested, but |
Huzzah, now it works! |
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.
Some minor questions / comments, but overall looks very good. Thanks @mpacer!
procbuild/builder.py
Outdated
self.add_output(output) | ||
|
||
if errcode: | ||
self.add_output('[X] Error code %d ' % errcode) |
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.
[X] Clean out tools papers directory
or something similar?
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.
Ok — I was trying to directly map it onto what was being done before as a simple fix.
procbuild/builder.py
Outdated
self.add_output(output) | ||
|
||
if errcode: | ||
self.add_output('[X] Error code %d\n' % errcode) |
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.
Same here: try to make the error descriptive.
return joinp(self.build_path, 'papers', self.paper) | ||
|
||
@property | ||
def paper(self): |
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.
What does this method do? Naming doesn't guide the reader, and no docstring.
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 see now how this works. Hrm, wondering if it makes sense to have this at all, or whether it could just be a parameter to the build_paper
method?
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.
Making it a parameter would require that we do the parsing of the PR outside of the Build manager, right now all of that parsing is being done in here. If we were going to switch that, I would want to include that functionality in the PRManager
, which is a bigger refactor. Is this fine for 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.
In the meantime I can add a docstring
return papers[0].split('/')[-1] | ||
|
||
def _run_make_paper_script(self): | ||
"""Runs the scipy_proceedings make_paper.sh script |
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.
Isn't this script just a wrapper around the build manager?
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.
No, this actually builds the paper using the make_paper.sh
script from scipy_proceedings.
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 tried to write that in the docstring for that method… can you suggest how it could be made clearer?
Right now, this is just a WIP because for some reason despite using the same code, it seems to be pulling in the entire upstream repo (including all of its papers) rather than just the proceedings build tools. I don't know why it works for the standard build script but not the main build script.
thx @stefanv for the idea
also update some strings to be f-strings
I want to make the build procedure more isolated chunks that have specific purposes so that they could A: be tested separately and B: understood separately. I think there are also a number of instances where we're issuing shell commands that we could do from within python. (edited)
This is the first step in refactoring the actual builder.
Right now, this is just a WIP because for some reason despite using the
same code, it seems to be pulling in the entire upstream repo (including
all of its papers) rather than just the proceedings build tools. I don't
know why it works for the standard build script but not the main build
script.
I'm stopping for now because I think I overran my github rate limit for the next couple of hours.