polaris.Component.get_or_create_shared_config

Component.get_or_create_shared_config(filepath, create=None)[source]

Get a shared config from the component if it exists, otherwise build and add it.

The companion to get_or_create_shared_step(), and needed for the same reason. A get_*_steps() helper is called once per consumer, so building its config unconditionally hands the second caller a config that the shared steps – created on the first call – are not using. Options set on it reach nothing, and passing it to polaris.Task.set_shared_config() raises, because a different config is already registered at that path.

Parameters:
  • filepath (str) – The path of the config file relative to the base work directory, which is what identifies a shared config

  • create (callable, optional) – Called with no arguments to build the config, and only when it does not already exist – so it must not be relied on for anything a later caller needs. It must return a polaris.config.PolarisConfigParser whose filepath is filepath. A config builder that returns a new parser, as several in Polaris do, can be passed directly. The default builds an empty parser.

Returns:

config (polaris.config.PolarisConfigParser) – The shared config parser