Repository navigation
Closed
Description
Currently Numpydoc is marked as a parallel-safe sphinx plugin, but the renaming of duplicate references in rename_references is not parallel-safe because reference_offset will be [0] in each process at the start of the function call.
I'm running into conflicts when building the Astropy docs:
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/stats/biweight.py:docstring of astropy.stats.biweight_midcorrelation:70: WARNING: duplicate citation R11, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/modeling/index.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/stats/biweight.py:docstring of astropy.stats.biweight_midcovariance:138: WARNING: duplicate citation R33, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.coordinates.BaseCoordinateFrame.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/stats/biweight.py:docstring of astropy.stats.biweight_midvariance:101: WARNING: duplicate citation R56, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.coordinates.EarthLocation.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/stats/biweight.py:docstring of astropy.stats.biweight_midvariance:103: WARNING: duplicate citation R66, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.coordinates.EarthLocation.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/stats/bayesian_blocks.py:docstring of astropy.stats.FitnessFunc:7: WARNING: Unknown target name: "scargle2012".
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/stats/bayesian_blocks.py:docstring of astropy.stats.FitnessFunc:26: WARNING: Unknown target name: "scargle2012".
docstring of astropy.stats.LombScargle.false_alarm_probability:62: WARNING: duplicate citation R1313, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.coordinates.SkyCoord.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/modeling/polynomial.py:docstring of astropy.modeling.polynomial.SIP:55: WARNING: duplicate citation R11, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.stats.biweight_midcorrelation.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/modeling/functional_models.py:docstring of astropy.modeling.functional_models.AiryDisk2D:91: WARNING: duplicate citation R11, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.stats.biweight_midcorrelation.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/modeling/functional_models.py:docstring of astropy.modeling.functional_models.Gaussian2D:133: WARNING: duplicate citation R33, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.stats.biweight_midcovariance.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/modeling/optimizers.py:docstring of astropy.modeling.optimizers.SLSQP:19: WARNING: duplicate citation R99, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.coordinates.Galactic.rst
/Users/tom/Dropbox/Code/Astropy/astropy/astropy/modeling/optimizers.py:docstring of astropy.modeling.optimizers.Simplex:18: WARNING: duplicate citation R1111, other instance in /Users/tom/Dropbox/Code/Astropy/astropy/docs/api/astropy.stats.LombScargle.rst
Activity
[-]Reference de-duplication isn't parallel-safe[/-][+]BUG: Reference de-duplication isn't parallel-safe[/+]stefanv commentedon Sep 30, 2017
This is correct: numpydoc reference renumbering is not parallel safe.
jnothman commentedon Oct 23, 2017
Should we consider making the reference renumbering a separate extension, marked unsafe? It would seem to me to be completely separate from the rest of numpydoc.
pv commentedon Oct 23, 2017
stefanv commentedon Oct 23, 2017
At the cost of some nastier looking reference names, we could hash the reference text itself to generate the link IDs.
stefanv commentedon Oct 23, 2017
(This should solve the parallel problem;)
jnothman commentedon Oct 23, 2017
stefanv commentedon Oct 24, 2017
We can probably just generate internal links?
jnothman commentedon Oct 24, 2017
I.e. work around the reST citation mechanism? I suppose we could.
jnothman commentedon Oct 24, 2017
It would be hard to get citation formatting matching the default in both web and PDF using
:ref:links.jnothman commentedon Oct 25, 2017
(I.e. in PDF the bibliography appears as an endnote)
jnothman commentedon Oct 25, 2017
I think this could be acceptable. If the same hash appears multiple times in a doc, the first will be the link target, but maybe we can live with this. Alternatively, we can use numbered refs prefixed by the docstring object name.
There seem to be a number of issues with reference mangling. It appears to be untested. It should be possible to disable, and perhaps should be an extension of its own with
parallel_read_safe=False. Unfortunately, metadata such asparallel_read_safecannot be a function of config, so we are forced to setparallel_read_safe=Falseas long as an unsafe solution is possible within the numpydoc extension.I'm inclined to one of the parallel-safe solutions above, but perhaps still making the mangling possible to disable...
jnothman commentedon Oct 31, 2017
Alternatives for solving this:
:ref:internal links instead. This will mean we no longer get endnotes in TeX builds etc.Opinions?
stefanv commentedon Oct 31, 2017
I don't like (1) and (2) much. Anything that makes the references appear in text as garble seem less than ideal. I'm OK with (6), since we mostly generate HTML, but I suspect we'll get strong resistance.
Does option (3) or (4) allow for reasonable looking links backed by hashes?
jnothman commentedon Oct 31, 2017
I'm not sure what "backed by hashes" means. I'll try to throw together some implementations and screenshots I suppose
stefanv commentedon Oct 31, 2017
I just mean the links can point to anything, they don't need to be legible URIs, but the text that appears on the page should be reasonable.
jnothman commentedon Oct 31, 2017
I don't think that's possible with reST's citation rendering, so that requires (6).
pv commentedon Oct 31, 2017
From a pragmatic point, is avoiding (1) a big issue?
Does parallel reading speed up doc builds noticeably in practice?
jnothman commentedon Oct 31, 2017
There may be a way to do this with a read-doctree hook. Firstly we need a way to mark where numpydoc's processing begins and ends. Fortunately comments are accessible in the doctree, but we can't just bookend the mangled docstring with comments because the beginning of the docstring is processed naively by autosummary to produce a snippet... :\
stefanv commentedon Oct 31, 2017
@pv Good question. Do we rely on users to set parallel processing to false, or can we control that from within the extension?
jnothman commentedon Nov 1, 2017
astrofrog commentedon Nov 1, 2017
From my experiments with astropy, using parallel mode can speed things up by a factor of 2 or more in some cases (saving minutes of build time) so definitely worth it as a developer who wants to check what updated docs look like. It would be a shame to lose that just because of reference de-duplication. So if you wanted to go down the road of 'won't fix', at least please consider making it possible to disable de-duplication as a numpydoc option and then return 'True' for
parallel_read_safein that case.jnothman commentedon Nov 1, 2017
I have a fix for this in #136