Where is the right place to set defaults for settings in plugins?

There’s the additional_config.ini file, the job .yaml file and setting self.setting in the .py file. Which is the best place to put them? Does one overwrite the others?

There’s not much of a pattern here, but I’ll give my advice:

  • the job .yaml should probably have null as the default (looking at this, I can’t see why it’s ever not null, and may even be a redundant field…) - so ignore this place.
  • the additional_config.ini is a good place for defaults. This .ini gets merged with the main config.ini on installation, and users can easily edit fields here.
  • Typically I’ll use the values in the config.ini as defaults for jobs, see examples of config.get in the stirring code: pioreactor/pioreactor/background_jobs/stirring.py at master · Pioreactor/pioreactor · GitHub

So I would say additional_config.ini is the best place, but the developer needs to actually use those fields in their Python code.

Does that answer your question?

Thanks, that’s clear. I’ve stopped including the default field in my job .yamls and have started using config.get in the python files to pull from the config.ini