Custom factory component

Hi ,
I created a custom factory component in spacy( 3.1.0 ) , added it to the pipeline, and saved it using to_disk().
I want to package the spacy model with my custom component (using the example )

In the saved model on my machine, I don't see the folder for the custom factory component. I see it added in meta.json in pipelines and in config.cfg.
How do I package it with my custom component ?

Hi! Your custom component factory is just Python code, so it won't be saved out when you export your pipeline to disk (which will only include the meta information, settings and model weights). There's kinda no way for spaCy to know what your component code is, and what needs to be included.

When you load your saved pipeline, you can import or include the factory code before loading the pipeline, and spaCy will be able to detect it.

When you package your model with spacy package in spaCy v3, you'll be able to include the Python file containing your custom component factory or any other registered functions via the --code argument and it will be packaged with the pipeline, so you'll get a self-contained Python package that includes all data and code required.

Btw, we're trying to keep this forum very focused on Prodigy, so for general spaCy usage questions, the discussions board is usually a better place: Discussions · explosion/spaCy · GitHub