can we pass environment variable PRODIGY_HOME directly in the prodigy.serve argument

I am trying to run multiple instances of prodigy at the same time on different ports simultaneaously on the same machine. I wanted to know if an argument can be passed, instead of setting environment variable for prodigy home. So that I can have separate settings for all running instances.

Hi! PRODIGY_HOME is currently only an environment variable. I guess you could write to os.environ in between the calls to prodigy.serve, but I'm not sure if this is going to have any side-effects.

Is the main reason you want to change the PRODIGY_HOME location the database file? If so, yo could also just pass different "db_settings" to each call to prodigy.serve via the keyword arguments. The SQLite settings also allow specifying different paths to the .db file. I haven't tested this in detail yet, but something like this should work:

prodigy.serve("...", db_settings={"path": "/custom/path1", "name": "prodigy.db"})
prodigy.serve("...", db_settings={"path": "/custom/path2", "name": "prodigy.db"})

Hello!

I have been trying to use prodigy.serve (1.10.4) like your suggestion here (with textcat.manual recipe) and I wanted to overwrite some configuration settings: port, host, feed_overlap and force_stream_order. For the port and the host, it is fine. Yet, the feed_overlap and the force_stream_order doesn't seem to change accordingly. I want to change the feed_overlap/force_stream_order settings of many instances from this python function. Is there any way to make this work ? Thank you in advance.

Hi! I just had a look and I think the problem here is that prodigy.serve overwrites the config settings after the recipe is loaded and the controller is created, which works fine for settings related to appearance, UI behaviour etc., but won't affect the stream settings because the stream is already created. I'll look into the best way to fix this! In the meantime, the easiest workaround is to just put a prodigy.json in the current working directory (less convenient but should do the job!).

1 Like

Just released v1.10.6, which fixes this – config overrides are now passed in before the controller is created :slightly_smiling_face:

1 Like

Hey guys, it doesn't seem to work in v1.10.8. I try passing "db_settings" when calling prodigy.serve. I have a custom database class, which is being created without the overridden "db_settings". I also tried setting PRODIGY_HOME to a custom prodigy.json in a different place before calling prodigy.serve but then the configuration is empty when the database instance is created.

Did you point the PRODIGY_HOME variable to the to the directory containing the prodigy.json with your custom database settings? And how does your custom database class work? If it's a fully custom class, you'll need to make sure it's available and Prodigy knows where to find it.

One option for this is via entry points. If you're serving Prodigy from Python, you can also register it like this, and then set "db": "custom_db" in your prodigy.json:

from prodigy.util import registry

db = YourCustomDatabase()
registry.databases("custom_db", func=db)
1 Like

Hey, thanks for the quick response!

Yes.

I'm using an adapted version of this solution that was mentioned on a previous thread.

I haven't tried the entry points option, will check that and let you know.