aphp / edsnlp

Modular, fast NLP framework, compatible with Pytorch and spaCy, offering tailored support for French clinical notes.
https://aphp.github.io/edsnlp/
BSD 3-Clause "New" or "Revised" License
112 stars 29 forks source link

Isolate edsnlp entry points to prevent auto-import by spacy #235

Closed percevalw closed 9 months ago

percevalw commented 9 months ago

Description

Fixes #234

Since edsnlp 0.10.0, some of our components require optional dependencies (torch, transformers, etc). By default, pip install edsnlp does not install these, so importing one of these components (e.g., eds.transformer) will fail.

It is not an issue when building a pipeline via edsnlp.blank(...) since we only load entry points when required, so a user that does not add these components will face no issue. However, as demonstrated by #234, when using spacy.blank or spacy.load spacy will look into all spacy_factories entry point and try to load them all, and fail when encountering one of the components mentioned previously.

To solve that, we split our components between two namespaces, spacy_factories and a new edsnlp_factories namespace : now spacy will only look in the first namespace, while edsnlp will look in both.

Checklist

codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c918130) 96.58% compared to head (8134c30) 96.59%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #235 +/- ## ======================================= Coverage 96.58% 96.59% ======================================= Files 254 254 Lines 8356 8341 -15 ======================================= - Hits 8071 8057 -14 + Misses 285 284 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.