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

[docs] Remove empty code blocks #13689

Merged
merged 3 commits into from
Jan 12, 2023
Merged

[docs] Remove empty code blocks #13689

merged 3 commits into from
Jan 12, 2023

Conversation

driazati
Copy link
Member

@driazati driazati commented Jan 3, 2023

This removes the linter that checks that each sphinx gallery tutorial begins with the proper boilerplate by extracting it out to sphinx gallery reset functions. This runs automatically so no code in the tutorials nor associated linters are necessary.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 3, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

  • No users to tag found in teams: docs See #10317 for details

Generated by tvm-bot

@driazati driazati marked this pull request as ready for review January 4, 2023 04:19
Copy link
Member

@guberti guberti left a comment

Choose a reason for hiding this comment

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

LGTM - the empty code blocks thing has bugged me for a while.

tests/lint/check_request_hook.py Outdated Show resolved Hide resolved
@guberti
Copy link
Member

guberti commented Jan 10, 2023

For what it's worth, I've never been a fan of how we need to add the following to every tutorial:

# sphinx_gallery_start_ignore
from tvm import testing

testing.utils.install_request_hook(depth=3)
# sphinx_gallery_end_ignore

Instead, we could use reset_modules from sphinx-gallery's configuration to run code before every example. We'd add the following to docs/conf.py:

from tvm import testing
def add_hook(gallery_conf, fname):
    testing.utils.install_request_hook(depth=3)

sphinx_gallery_conf = {
    ...
    'reset_modules': (add_hook),
}

If we needed the hook for pytest as well, we could add a conf.py file to the gallery directory as well. We shouldn't change this here, but it might be worth considering in the future @driazati.

@driazati
Copy link
Member Author

@guberti that makes a lot more sense, I updated the PR to use that and delete the linter which wasn't really correct anyways (some of the preamble was misplaced in a few files).

@guberti
Copy link
Member

guberti commented Jan 11, 2023

I love this PR.

Copy link
Member

@guberti guberti left a comment

Choose a reason for hiding this comment

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

This is a good change, but there's one nuance to highlight - per-file config options like sphinx_gallery_requires_cuda. If we take them out of the ignore block, the flag renders in HTML, which we do not want:

image


I can see two ways to fix this behavior. The easier, uglier way is to continue wrapping all flags in ignore blocks:

# sphinx_gallery_start_ignore
# sphinx_gallery_requires_cuda = True
# sphinx_gallery_end_ignore

This is what's done right now, and changing this may be out of scope for this pull request.

A better alternative would be updating sphinx-gallery to version 4484d35 or beyond, and then setting remove_config_comments=True in the config file. Unfortunately, 4484d35 is not part of any PyPI releases right now, making this a little more annoying.

What do you think @driazati?

@driazati
Copy link
Member Author

I updated the PR to wrap the configs with ignores and made sure they are inside a code block so they don't show up on their own, so now this PR should make everything look fine from the frontend. We could merge this then update the sphinx gallery version (installing from the latest commit isn't a problem with Docker) and remove the _ignore tags.

Copy link
Member

@guberti guberti left a comment

Choose a reason for hiding this comment

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

Sounds good - we'll merge this, and can consider updating sphinx-gallery later. LGTM!

@driazati driazati merged commit 665dd41 into apache:main Jan 12, 2023
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
This removes the linter that checks that each sphinx gallery tutorial begins with the proper boilerplate by extracting it out to sphinx gallery reset functions. This runs automatically so no code in the tutorials nor associated linters are necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants