Getting prodigy.util.export_model_data AttributeError: 'str' object has no attribute 'resolve' when running batch_train from python


I am attempting to wrap up a spacy/prodigy model into an MLflow package but I am running into some weird error, when running the batch_train function directly in python:

batch_train(dataset, output_model="/tmp/model/", lang="en", exclusive=True, n_iter=1)

This results in the model training fine, outputting all the metrics then I get the error below. I am using Prodigy 1.8.3 under Conda with Python 3.7.3. Any ideas?

  File "code/", line 111, in <module>
  File "code/", line 83, in train
    exclusive=False, n_iter=1)
  File "/anaconda3/envs/nlp/lib/python3.7/site-packages/prodigy/recipes/", line 271, in batch_train
    msg = export_model_data(output_model, nlp, examples, evals)
  File "cython_src/prodigy/util.pyx", line 353, in prodigy.util.export_model_data
AttributeError: 'str' object has no attribute 'resolve'

Hi! I think what's happening here is that the function expects a Path, not a str. If you call the recipe from the command line, this gets converted automatically by the convert function in the recipe arguments. The following should help:

from pathlib import Path
output_model = Path("/tmp/model/")
1 Like

Thank you Ines! That did the trick!

1 Like