-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Batch ghostscript converter. #9454
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
Conversation
5d8e1e0
to
d235bda
Compare
Could drop the Python 2 bits now. |
done |
lib/matplotlib/testing/compare.py
Outdated
|
||
def _read_until(self, terminator): | ||
"""Read until the prompt is reached.""" | ||
terminator = [six.int2byte(c) for c in six.iterbytes(terminator)] |
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.
If you would like to eliminate the six
import while you are in the neighborhood, you could replace this line with
terminator = [terminator[i:i+1] for i in range(len(terminator))]
or omit that line, so that terminator remains a bytes object, and fix a couple lines lower down to do everything with bytes objects instead of a list of single bytes objects.
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.
done
There is a lot of variability but this does seem to provide a speedup on travis 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.
I haven't tried to understand this in detail, but it looks good and makes sense in general. I think it should be OK subject to passing Appveyor, which is running now.
Actually we never test inkscape/ps on windows right now (all entries in appveyor.yml have TEST_ALL=false)... |
lib/matplotlib/testing/compare.py
Outdated
return (os.fsencode(name) | ||
.replace(b"(", br"\(") | ||
.replace(b")", br"\)") | ||
.replace(b"\\", b"\\\\")) |
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.
Shouldn't the backslash escaping come first to avoid breaking the escaping of parentheses? Might be worth testing with variously strange filenames (unbalanced parens, low-ASCII control characters). Another option is to just raise an exception if the filename contains anything but alphanumerics, because this is only used for baseline and result images, whose filenames are under our control.
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.
fixed
I think the biggest risk here is getting in a deadlock because of how the various buffers interact. E.g. ghostscript is waiting for more input from us but we are waiting for ghostscript's prompt, and one of them is sitting in a buffered pipe. Definitely worth testing carefully on all three operating systems. |
I don't entirely follow this either, but it'll just break our testing if it goes in, and passes existing tests, so I don't see the harm... |
PR Summary
Run a single instance of ghostscript in batch mode for conversion, like #8248 did for inkscape. With some luck this should provide a bit of speedup to the tests... especially in case we decide to restore testing of pdf/ps output on Windows, where spawning processes seem particularly slow (right now it's completely disabled).
PR Checklist