Skip to content

Commit 4f4eb06

Browse files
Add log message when spaCy model is downloaded
1 parent 0adf071 commit 4f4eb06

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/neo4j_graphrag/experimental/components/resolver.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
import abc
16+
import logging
1617
from itertools import combinations
1718
from typing import Any, Optional, List
1819

@@ -27,6 +28,7 @@
2728
from neo4j_graphrag.experimental.pipeline import Component
2829
from neo4j_graphrag.utils import driver_config
2930

31+
logger = logging.getLogger(__name__)
3032

3133
class EntityResolver(Component, abc.ABC):
3234
"""Entity resolution base class
@@ -314,10 +316,9 @@ def _load_or_download_spacy_model(model_name: str) -> Language:
314316
try:
315317
return spacy.load(model_name)
316318
except OSError as e:
317-
# The exact error message can differ slightly depending on spaCy version,
318-
# so you may want to be broader or narrower with handling logic:
319+
# handling cases where the spaCy model is not yet downloaded:
319320
if "doesn't seem to be a Python package or a valid path" in str(e):
320-
print(f"Model '{model_name}' not found. Downloading...")
321+
logger.info(f"Model '{model_name}' not found. Downloading...")
321322
spacy_download(model_name)
322323
return spacy.load(model_name)
323324
else:

0 commit comments

Comments
 (0)