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

Display metatensor-torch torchscript classes correctly in docs #40

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

frostedoyster
Copy link
Collaborator

@frostedoyster frostedoyster commented Jan 26, 2024

Closes #20


📚 Documentation preview 📚: https://metatensor-models--40.org.readthedocs.build/en/40/

@frostedoyster
Copy link
Collaborator Author

@Luthaf something is breaking, seemingly due to the fact that we're compiling slice and join, but I'm not sure. Any ideas?

@Luthaf
Copy link
Member

Luthaf commented Jan 26, 2024

Right =/

When setting METATENSOR_IMPORT_FOR_SPHINX=1, the definition of all classes is changed to something sphinx can parse and understand. But this means TorchScript can no longer parse/understand it! The simplest solution might be to do something like

if os.environ.get("METATENSOR_IMPORT_FOR_SPHINX", "0") == "1":
    compiled_slice = None
else:
    compiled_slice = torch.jit.script(metatensor.torch.slice)

@frostedoyster
Copy link
Collaborator Author

Perfect, thanks. I was also thinking of a similar hack

@frostedoyster frostedoyster merged commit cfa37b2 into main Jan 26, 2024
8 checks passed
@frostedoyster frostedoyster deleted the fix-metatensor-torch-docs branch January 26, 2024 11:54
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.

Fix torch-scripted classes in documentation
2 participants