Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Switch to using Tox #1459

Merged
merged 9 commits into from
May 19, 2023
Merged

Switch to using Tox #1459

merged 9 commits into from
May 19, 2023

Conversation

Eric-Arellano
Copy link
Collaborator

@Eric-Arellano Eric-Arellano commented May 18, 2023

Summary

Previously, there was no standardized way to build the docs locally. While Tox isn't perfect, it aligns us with the rest of the Qiskit ecosystem.

Switching to Tox is important here because it de-duplicates our requirements, which were specified both in requirements-dev.txt and again in azure-pipelines.yaml.

Details and comments

This also fixes two Sphinx warnings due to bad config in conf.py.

I couldn't actually get NBSphinx to work on my mac due to import errors. But this is still some forward progress, so I put up the PR. CI at least will now use tox, and continue to produce a zip of the docs that CI users can inspect.

Comment on lines -40 to -42
os.environ['QISKIT_DOCS'] = 'TRUE'
if sys.platform == 'darwin':
os.environ['QISKIT_IN_PARALLEL'] = 'TRUE'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These env vars aren't used by anything. Bad copy and paste.

Comment on lines -76 to +48
cell_timeout = int(os.getenv('QISKIT_CELL_TIMEOUT', 180))
nbsphinx_timeout = cell_timeout
nbsphinx_timeout = 300
nbsphinx_execute = 'always'
nbsphinx_execute_arguments = [
"--InlineBackend.figure_formats={'png', 'pdf'}",
"--InlineBackend.rc={'figure.dpi': 96}",
]

nbsphinx_thumbnails = {
}

nbsphinx_widgets_path = ""
html_sourcelink_suffix = ""
nbsphinx_thumbnails = {"**": "_static/no_image.png"}
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 aligned this config with qiskit-metapackage, since that is what actually ends up being used in the final rendered docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! This solve the thumbnail issue in the local build. In general, it's nice to see the same output in local build of the tutorials repo alone as the final rendered docs built by the metapackage.

#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Bad config in Sphinx 6+

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. CI is using Sphinx 7.0 instead of 5.3

envlist = py310,py39,py38

[testenv]
no_package = true
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is because we don't distribute any Python package in this repo. It's solely docs.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@Eric-Arellano Eric-Arellano changed the title [wip] Switch to using Tox (and error on docs errors) Switch to using Tox May 18, 2023
@Eric-Arellano Eric-Arellano marked this pull request as ready for review May 18, 2023 18:10
@Eric-Arellano Eric-Arellano requested review from HuangJunye, mtreinish and 1ucian0 and removed request for HuangJunye May 18, 2023 18:10
Copy link
Contributor

@HuangJunye HuangJunye left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. It's great to reduce the duplication of dependencies in azure-pipelines.yml and making the local build closer to the final build by the metapackage.

Can you also update the instructions about how to build the documentation in readme to reflect the change? After that it should be ready for merging.

Comment on lines -76 to +48
cell_timeout = int(os.getenv('QISKIT_CELL_TIMEOUT', 180))
nbsphinx_timeout = cell_timeout
nbsphinx_timeout = 300
nbsphinx_execute = 'always'
nbsphinx_execute_arguments = [
"--InlineBackend.figure_formats={'png', 'pdf'}",
"--InlineBackend.rc={'figure.dpi': 96}",
]

nbsphinx_thumbnails = {
}

nbsphinx_widgets_path = ""
html_sourcelink_suffix = ""
nbsphinx_thumbnails = {"**": "_static/no_image.png"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Great! This solve the thumbnail issue in the local build. In general, it's nice to see the same output in local build of the tutorials repo alone as the final rendered docs built by the metapackage.

#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. CI is using Sphinx 7.0 instead of 5.3


[testenv:docs]
commands =
sphinx-build -j auto -b html {toxinidir} {toxinidir}/_build/html/
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use -W flag as well or this repo is not ready for that yet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the goal. There is one remaining issue that I plan to fix in a follow up PR -- still a WIP.

@HuangJunye
Copy link
Contributor

You mentioned that nbsphinx is not working on your mac. Does it mean that you can't make a successful local build using tox on your mac?

@Eric-Arellano
Copy link
Collaborator Author

Does it mean that you can't make a successful local build using tox on your mac?

Exactly. But I time-boxed trying to figure this out—there are a few other higher priorities I'm focused on. The main reason I'm cleaning up this repo is to unblock enabling -W in qiskit-metapackage, which is blocked by enabling -W in this repo.

Some forward progress is better than none. While I couldn't get local to work on my mac, CI at least still works.

Copy link
Contributor

@HuangJunye HuangJunye left a comment

Choose a reason for hiding this comment

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

Thanks for updating the readme too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants