Skip to content

Make coref entry points work without PyTorch#23

Merged
adrianeboyd merged 8 commits into
masterfrom
fix/coref-torch-dep
Sep 28, 2022
Merged

Make coref entry points work without PyTorch#23
adrianeboyd merged 8 commits into
masterfrom
fix/coref-torch-dep

Conversation

@polm

@polm polm commented Sep 27, 2022

Copy link
Copy Markdown
Contributor

Before this PR, in environments without PyTorch, using spacy experimental can fail due to attempts to load entry points. This change makes it so the types required for class definitions (torch.nn.Module and torch.Tensor) are stubbed to object when torch is not available.

Before this PR, in environments without PyTorch, using spacy
experimental can fail due to attempts to load entry points. This change
makes it so the types required for class definitions (torch.nn.Module
and torch.Tensor) are stubbed to object when torch is not available.
Without this, it could be unclear why coref didn't work without torch.
This follows the model of the biaffine parser.
@polm

polm commented Sep 27, 2022

Copy link
Copy Markdown
Contributor Author

After thinking about it more, this PR has been updated so that the coref components are structured like the experimental parser implementation. The parts of the code that require PyTorch are put in their own files, and if those classes can't be initialized, then attempting to instantiate them will raise an error instructing the user to install PyTorch. On the other hand, as long as you aren't actually using them, entry points can be initialized without issue.

Comment thread spacy_experimental/coref/span_resolver_model.py Outdated
This is the same as the changes from #24, since they worked.
@adrianeboyd

Copy link
Copy Markdown
Contributor

This seems okay for now. Can you clean up the imports first?

@adrianeboyd adrianeboyd merged commit fb3f24d into master Sep 28, 2022
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.

2 participants