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

Give a warning when extensions are explicitly not parallel safe #6812

Merged
merged 2 commits into from Nov 12, 2019

Conversation

astrofrog
Copy link
Contributor

Feature or Bugfix

I would personally treat this as a bug fix since the previous behavior was confusing.

Purpose

Currently, if building a set of docs with a number of extensions in parallel, if one of the extensions explicitly declares itself to be unsafe, the build falls back to a serial build silently, with no way of knowing what extension caused this. Rather than have to dig into the source code for each extension, it's much simpler to just warn the user if the build is falling back to a serial build and what extension caused this. I think it makes sense to include this since if the user is opting in to a parallel build, anything that prevents that from happening should be explicitly stated.

@codecov
Copy link

codecov bot commented Nov 11, 2019

Codecov Report

Merging #6812 into 2.0 will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              2.0    #6812      +/-   ##
==========================================
+ Coverage   83.73%   83.73%   +<.01%     
==========================================
  Files         271      271              
  Lines       41169    41175       +6     
  Branches     6011     6011              
==========================================
+ Hits        34471    34477       +6     
  Misses       5367     5367              
  Partials     1331     1331
Impacted Files Coverage Δ
sphinx/application.py 78.55% <100%> (+0.25%) ⬆️
tests/test_application.py 98.79% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7f53a7...fa1cca1. Read the comment docs.

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

LGTM with nits.

In addition, could you rebase this into 2.0 branch please? Then I'll release this as 2.3.0.

@@ -1126,28 +1126,33 @@ def is_parallel_allowed(self, typ):

``typ`` is a type of processing; ``'read'`` or ``'write'``.
"""

Copy link
Member

Choose a reason for hiding this comment

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

Could you remove this empty line please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

"for parallel reading, assuming it isn't - please "
"ask the extension author to check and make it "
"explicit")
message_false = "the %s extension is not safe for parallel reading"
Copy link
Member

Choose a reason for hiding this comment

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

Please wrap with _() function like above. It is needed for i18n.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

else:
raise ValueError('parallel type %s is not supported' % typ)

for ext in self.extensions.values():
allowed = getattr(ext, attrname, None)
if allowed is None:
logger.warning(message, ext.name)
logger.warning(message_none, ext.name)
Copy link
Member

Choose a reason for hiding this comment

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

I feel message_none and message_false not describe its purpose. I think message_not_declared and message_not_allowed are better. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed - I settled on message_not_declared and message_not_safe - is that ok?

Copy link
Member

Choose a reason for hiding this comment

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

Good point

@@ -98,6 +98,8 @@ def test_add_is_parallel_allowed(app, status, warning):

app.setup_extension('read_serial')
assert app.is_parallel_allowed('read') is False
assert ("the read_serial extension is not safe for parallel reading") in warning.getvalue()
Copy link
Member

Choose a reason for hiding this comment

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

Coudl you remove parenthesis please? They are used only for folding long text to multiple lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@astrofrog astrofrog changed the base branch from master to 2.0 November 12, 2019 14:27
@astrofrog
Copy link
Contributor Author

astrofrog commented Nov 12, 2019

@tk0miya - thanks for the review! I've addressed all your comments and changed this PR to be against 2.0.

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

Great! I'll merge this after CI passed.

@tk0miya tk0miya merged commit e8ef188 into sphinx-doc:2.0 Nov 12, 2019
@tk0miya
Copy link
Member

tk0miya commented Nov 12, 2019

Merged.
Thank you for your contribution!

tk0miya added a commit that referenced this pull request Nov 12, 2019
@astrofrog
Copy link
Contributor Author

Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants