AttributeError: 'WindowsPath' object has no attribute 'startswith'

When I tried to save my model registry, I caught this error. Please help me asap. Thanks

model_registry = project.get_model_registry()

model = model_registry.sklearn.create_model(
    name="model",
    metrics={"test_mae": test_mae},
    description="LightGBM regressor",
    input_example=X_train.sample(),
    model_schema=model_schema
)

model.save(MODELS_DIR / 'model.pkl')

Here is the error

Connected. Call `.close()` to terminate connection gracefully.
Uploading model files (0 dirs, 0 files): 17%
1/6 [00:00<00:02, 2.02it/s]
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[19], line 11
      1 model_registry = project.get_model_registry()
      3 model = model_registry.sklearn.create_model(
      4     name="taxi_demand_predictor_next_hour",
      5     metrics={"test_mae": test_mae},
   (...)
      8     model_schema=model_schema
      9 )
---> 11 model.save(MODELS_DIR / 'model.pkl')

File c:\anaconda3\envs\son-env\lib\site-packages\hsml\model.py:96, in Model.save(self, model_path, await_registration, keep_original_files)
     85 def save(self, model_path, await_registration=480, keep_original_files=False):
     86     """Persist this model including model files and metadata to the model registry.
     87 
     88     # Arguments
   (...)
     94         `Model`: The model metadata object.
     95     """
---> 96     return self._model_engine.save(
     97         self,
     98         model_path,
     99         await_registration=await_registration,
    100         keep_original_files=keep_original_files,
...
    240         update_upload_progress=update_upload_progress,
    241     )
    242 else:

AttributeError: 'WindowsPath' object has no attribute 'startswith'

Had the same issue - instead of using MODELS_DIR / ‘model.pkl’ as an input for model.save, I just used the literal path of the model with an r in front of it and that seemed to do the trick e.g. model.save(r ‘\users\path.…\model.pkl’)