Skip to content
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

Merged
merged 12 commits into from
Mar 20, 2018
Merged

BuildManager #28

merged 12 commits into from
Mar 20, 2018

Conversation

mpacer
Copy link
Collaborator

@mpacer mpacer commented Mar 15, 2018

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.

@@ -10,7 +10,7 @@
import random

from os.path import join as joinp
from glob import glob
from glob import glob, iglob
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glob no longer used

Copy link
Collaborator Author

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


class BuildManager(object):

def __init__(self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd formatting here

Copy link
Collaborator Author

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.

Copy link
Member

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!

Copy link
Collaborator Author

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.

def build_paper(self):
try:
with tempfile.TemporaryDirectory() as build_path:
self.build_path = build_path
Copy link
Member

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.

Copy link
Collaborator Author

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):
Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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).

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)
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

self.master_branch = master_branch
self.build_status = 'Build started...'
self.build_pdf_path = ''
self.master_repo_path = joinp(cache(), 'scipy_proceedings')
Copy link
Member

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?

Copy link
Member

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)

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

@mpacer mpacer changed the title WIP: BuildManager BuildManager Mar 18, 2018
@mpacer
Copy link
Collaborator Author

mpacer commented Mar 18, 2018

@stefanv i made the change you suggested, but it's not actually stopping the other papers from being drawn in… i'm not sure why it required that i first realise that i was already inside the scipy_proceedings directory when deleting the papers.

@mpacer
Copy link
Collaborator Author

mpacer commented Mar 18, 2018

Huzzah, now it works!

Copy link
Member

@stefanv stefanv left a 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!

self.add_output(output)

if errcode:
self.add_output('[X] Error code %d ' % errcode)
Copy link
Member

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?

Copy link
Collaborator Author

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.

self.add_output(output)

if errcode:
self.add_output('[X] Error code %d\n' % errcode)
Copy link
Member

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):
Copy link
Member

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.

Copy link
Member

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?

Copy link
Collaborator Author

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?

Copy link
Collaborator Author

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
Copy link
Member

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?

Copy link
Collaborator Author

@mpacer mpacer Mar 19, 2018

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.

Copy link
Collaborator Author

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.
also update some strings to be f-strings
@stefanv stefanv merged commit c1f1215 into scipy-conference:master Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants