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

CI: Fail doc build on warning #22743

Closed
wants to merge 32 commits into from

Conversation

TomAugspurger
Copy link
Contributor

@TomAugspurger TomAugspurger commented Sep 18, 2018

(continuing a theme)

xref #21564

We print the doc build output to a file and parse that file for errors. This is preferable to Sphinx'x built-in ability to raise on errors, since we will print warnings for all the errors present in a PR, rather than just the first (and immediately exiting the build).

@TomAugspurger TomAugspurger added CI Continuous Integration Docs labels Sep 18, 2018
@pep8speaks
Copy link

pep8speaks commented Sep 18, 2018

Hello @TomAugspurger! Thanks for updating the PR.

Comment last updated on September 20, 2018 at 20:51 Hours UTC

.. toctree::
:hidden:

generated/pandas.api.extensions.ExtensionDtype.na_value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea on this one. Something with numpydoc / sphinx autodoc. I think autodoc detects that na_value has a "docstring" (comments), but numpydoc doesn't. Not super important.

mask = g < 0
g.loc[mask] = g[~mask].mean()
return g
mask = g < 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently the argument passed to func in transform can be either a Series or DataFrame? This implementation should be robust to either.

:func:`read_csv` and :func:`read_table`. They both use the same parsing code to
intelligently convert tabular data into a ``DataFrame`` object. See the
:ref:`cookbook<cookbook.csv>` for some advanced strategies.
The workhorse function for reading text files (a.k.a. flat files) is
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I basically removed all references to read_table not that it's deprecated.

@@ -312,14 +312,15 @@ All one-dimensional list-likes can be combined in a list-like container (includi

s
u
s.str.cat([u.values, ['A', 'B', 'C', 'D'], map(str, u.index)], na_rep='-')
s.str.cat([u.values,
u.index.astype(str).values], na_rep='-')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@h-vetinari the list inside a list was causing issues. I've removed it from the examples. It'd be good to write new ones demonstrating that though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this was an oversight in #22264 where we deprecated lists within lists.

It'd be good to write new ones demonstrating that though.

New examples?

natural and functions similarly to :py:func:`itertools.groupby`:

.. ipython:: python

resampled = df.resample('H')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this point, df is a DataFrame with columns like ['year', 'day', 'hour'...]. This most have been expecting something different.


.. ipython:: python

ts = pd.Timestamp('2014-01-01 09:00')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @jorisvandenbossche @jbrockmendel if you want to take a look at these to ensure I'm doing this properly (#21564)

@@ -9541,14 +9548,16 @@ def to_csv(self, path_or_buf=None, sep=",", na_rep='', float_format=None,
encoding : string, optional
A string representing the encoding to use in the output file,
defaults to 'ascii' on Python 2 and 'utf-8' on Python 3.
compression : {'infer', 'gzip', 'bz2', 'zip', 'xz', None},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't get this line-wrapping to work properly by ending the line with a backslash. Does anyone know the correct syntax? I'm inclided to just get the docs right and # noqa at the end of the line.

@@ -135,6 +136,12 @@ def _process_single_doc(self, single_doc):
try:
obj = pandas # noqa: F821
for name in single_doc.split('.'):
try:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @datapythonista single-page pandas.io.formats.style.Styler wasn't working earlier, since it's not available from the top-level namespace. Do we have tests for this?

@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #22743 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #22743   +/-   ##
=======================================
  Coverage   92.17%   92.17%           
=======================================
  Files         169      169           
  Lines       50739    50739           
=======================================
  Hits        46767    46767           
  Misses       3972     3972
Flag Coverage Δ
#multiple 90.58% <ø> (ø) ⬆️
#single 42.34% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/io/formats/style.py 96.43% <ø> (ø) ⬆️
pandas/core/generic.py 96.67% <ø> (ø) ⬆️
pandas/core/window.py 96.27% <ø> (ø) ⬆️
pandas/core/series.py 93.75% <ø> (ø) ⬆️

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 79f7762...bbcd7bd. Read the comment docs.

@TomAugspurger
Copy link
Contributor Author

https://travis-ci.org/pandas-dev/pandas/jobs/431185566#L5353

I think it's still not failing because Travis is calling run_build_docs.sh which in turn calls build_docs in a subprocess and always exits with 0. I'm going to restructure things a bit.

@TomAugspurger
Copy link
Contributor Author

We'll need to either figure out the rpy2 on travis issue, or figure out a way to "whitelist" errors. Maybe this would be a good reason to move the doc build to azure.

@TomAugspurger
Copy link
Contributor Author

I'm going to split off the changes to the docs to fix the warnings. We can followup later with the infrastructure to fail the build.

@datapythonista
Copy link
Member

That sounds good. Did you see that sphinx-build has an argument -W that should fail the doc build if warnings are found? I'm working on a PR to speed up running doc/make.py with --single, will check also if that option works.

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Dec 17, 2018 via email

@datapythonista
Copy link
Member

Will you continue the work to split off the changes in this PR, or will you open new ones and should we close this?

I'm not sure if there are many warnings left of the ones you were fixing here. I think many have been fixed when linting the code in the docs, and I've been fixing some too.

I agree that ideally we'd like to run the whole doc build and not cancel at the first warning. But given that cancelling is implemented just adding a parameter to the build call, and the complexity needed to run the whole build, I'd prefer to just use -W. In the PRs, we are discarding the generated docs anyway, and if that makes the build fail, we shouldn't have any warnings in master. So, in practice, the difference is that we'll just see the first warning in the CI and not all them. Which I don't think justifies the extra complexity in the build.

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Dec 31, 2018 via email

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Dec 31, 2018 via email

@datapythonista
Copy link
Member

Yes, didn't see the option, but it works as expected. :)

I had to make couple of changes to make our script behave properly when setting this option, but implemented it in #24523.

Do you want to take a look at this PR and see if there is anything you want to commit. Otherwise we can close it.

@datapythonista
Copy link
Member

Closing this, as failing the doc build has been implemented in #24523, and I think all the warnings fixed here have already been fixed somewhere else. Feel free to reopen if there is anything that could be merged from here, and you want to reuse this PR for it.

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Jan 6, 2019

I am not sure #24523 is doing everything that this PR was doing?

Didn't check in detail, but eg here Tom added some regexes for catching ipython directive errors. Are those handled as well in #24523? (or, Tom, what was the reason you needed to do that here?)

@datapythonista
Copy link
Member

I don't see those regex. I implemented a regex to find wrong spaces in the directives in #24650.

I couldn't find anything in this PR that is not fixed already (at least the parts generating warnings). But as said, feel free to reopen if it's still useful.

@jorisvandenbossche
Copy link
Member

I don't see those regex.

The lint_log function here: https://github.com/pandas-dev/pandas/pull/22743/files#diff-884b5131af7960906a35ecd1d041c7c6R347

@datapythonista
Copy link
Member

oh, I see. I thought you meant a regex over the rst files, not the log. I assume sphinx will return with an exit status != 0 if the process raises those (with the -W option). So, I don't think those are useful anymore.

@jorisvandenbossche
Copy link
Member

I assume sphinx will return with an exit status != 0 if the process raises those (with the -W option).

I am not sure that is the case. From a quick test, sphinx doesn't seem to regard an IPython warning as a proper sphinx warning (but that might something that could be fixed in IPython).

(Although that also relates to our use of ipython_warning_is_error = False, so erroring directly is possible (but we choose not to do that, as it stops the build), but letting sphinx turn a warning into an error, not sure about that)

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Jan 7, 2019 via email

@jorisvandenbossche
Copy link
Member

I think you meant error into warning (and then into an error)?

Well, whether IPython directly emits a warning, or we have a way to turn their error in a warning, that doesn't matter too much to me :-) As long as the end result is that there is a warning, that can be turned into an exit code error with sphinx.

I would say that ideally, IPython uses the proper sphinx warning system and issues a sphinx warning instead of printing their warning to stdout, so that the sphinx warning machinery works with them properly?

@TomAugspurger
Copy link
Contributor Author

Yep. I'll raise an issue upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants