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

[Functorch] Skip docs setup if called in optimize mode #100750

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions test/test_stateless.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,10 @@ def test_stateless_functional_call_warns(self):

class TestPythonOptimizeMode(TestCase):
def test_runs_with_optimize_flag(self):
script = """
import torch
"""
script = "import torch; import torch._functorch.deprecated"
try:
subprocess.check_output(
[sys.executable, '-OO', '-c', script],
[sys.executable, "-OO", "-c", script],
stderr=subprocess.STDOUT,
# On Windows, opening the subprocess with the default CWD makes `import torch`
# fail, so just set CWD to this script's directory
Expand Down
3 changes: 3 additions & 0 deletions torch/_functorch/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def setup_docs(functorch_api, torch_func_api=None, new_api_name=None):
api_name = functorch_api.__name__
if torch_func_api is None:
torch_func_api = getattr(_impl, api_name)
# See https://docs.python.org/3/using/cmdline.html#cmdoption-OO
if torch_func_api.__doc__ is None:
return

warning = get_warning(api_name, new_api_name)
warning_note = "\n.. warning::\n\n" + textwrap.indent(warning, " ")
Expand Down