pyfileconf package¶
py-file-conf is a Python framework for flow-based programming and managing configuration. To use it, you register your main functions and classes, and config files are created automatically for them. It provides a way to run these functions individually, in a list, in sections, or a combination thereof. Configuration can be dynamically updated, enabling powerful scripting.
Subpackages¶
- pyfileconf.assignments package
- pyfileconf.basemodels package
- pyfileconf.config package
- pyfileconf.data package
- pyfileconf.dictfiles package
- pyfileconf.exceptions package
- pyfileconf.imports package
- Subpackages
- pyfileconf.imports.logic package
- pyfileconf.imports.models package
- Subpackages
- pyfileconf.imports.models.statements package
- Submodules
- pyfileconf.imports.models.statements.comment module
- pyfileconf.imports.models.statements.container module
- pyfileconf.imports.models.statements.importbase module
- pyfileconf.imports.models.statements.interfaces module
- pyfileconf.imports.models.statements.module module
- pyfileconf.imports.models.statements.obj module
- pyfileconf.imports.models.statements.rename module
- pyfileconf.imports.models.statements package
- Submodules
- pyfileconf.imports.models.tracker module
- Subpackages
- Subpackages
- pyfileconf.io package
- Subpackages
- pyfileconf.io.file package
- Subpackages
- pyfileconf.io.file.interfaces package
- pyfileconf.io.file.load package
- Subpackages
- pyfileconf.io.file.load.active package
- pyfileconf.io.file.load.lazy package
- pyfileconf.io.file.load.parsers package
- Submodules
- pyfileconf.io.file.load.parsers.assign module
- pyfileconf.io.file.load.parsers.base module
- pyfileconf.io.file.load.parsers.collections module
- pyfileconf.io.file.load.parsers.extname module
- pyfileconf.io.file.load.parsers.fromdict module
- pyfileconf.io.file.load.parsers.funcdef module
- pyfileconf.io.file.load.parsers.imp module
- pyfileconf.io.file.load.parsers.kwargs module
- pyfileconf.io.file.load.parsers.py module
- Subpackages
- pyfileconf.io.file.write package
- Subpackages
- pyfileconf.io.func package
- pyfileconf.io.file package
- Subpackages
- pyfileconf.logger package
- pyfileconf.logic package
- pyfileconf.mixins package
- pyfileconf.opts package
- pyfileconf.pipelines package
- Subpackages
- pyfileconf.pipelines.models package
- Submodules
- pyfileconf.pipelines.models.collection module
- pyfileconf.pipelines.models.config module
- pyfileconf.pipelines.models.dictconfig module
- pyfileconf.pipelines.models.dictfile module
- pyfileconf.pipelines.models.file module
- pyfileconf.pipelines.models.interfaces module
- pyfileconf.pipelines.models.registrar module
- pyfileconf.pipelines.models package
- Subpackages
- pyfileconf.plugin package
- pyfileconf.pmcontext package
- pyfileconf.runner package
- pyfileconf.sectionpath package
- pyfileconf.selector package
- pyfileconf.views package
Submodules¶
pyfileconf.batch module¶
-
class
pyfileconf.batch.
BatchUpdater
(base_section_path_str=None, strip_manager_from_iv=False)[source]¶ Bases:
object
Class that enables config changes across multiple pipeline managers
Update one or multiple registered functions/sections by their full section paths, regardless of in which manager they reside
pyfileconf.debug module¶
pyfileconf.interfaces module¶
pyfileconf.iterate module¶
-
class
pyfileconf.iterate.
IterativeRunner
(section_path_str_or_list, config_updates, base_section_path_str=None, strip_manager_from_iv=False)[source]¶ Bases:
object
Class that enables running functions/sections with different combinations of config updates, even across multiple pipeline managers
Run one or multiple registered functions/sections multiple times, each time updating the config with a combination of the passed config updates.
Aggregates the updates to each config, then takes the itertools product of all the config updates to run the functions with each combination of the configs.
-
__init__
(section_path_str_or_list, config_updates, base_section_path_str=None, strip_manager_from_iv=False)[source]¶ - Parameters
section_path_str_or_list¶ (
Union
[str
,List
[str
],ForwardRef
,List
[ForwardRef
]]) – . separated name of path of function or section, or list thereof. similar to how a function would be imported. e.g. ‘main.data.summarize.summary_func1’ or when running multiple functions/sections, e.g. [‘main.data’, ‘main.analysis.reg.1’]config_updates¶ (
Sequence
[Dict
[str
,Any
]]) – list of kwarg dictionaries which would normally be provided to .updatebase_section_path_str¶ (
Optional
[str
]) – section path str to put at beginning of all passed section pathsstrip_manager_from_iv¶ (
bool
) – whether to remove manager name from any incoming item views
-
cases
: List[Tuple[Dict[str, Any], …]]¶
-
last_case
: Optional[Tuple[Dict[str, Any], …]] = None¶
-
run_items
: List[SectionPath]¶
-
-
pyfileconf.iterate.
get_config_product
(config_dicts)[source]¶ - Parameters
- Return type
- Returns
- Examples
>>> cd = dict( ... section_path_str='abc', ... a=10 ... ) >>> cd2 = dict( ... section_path_str='abc', ... a=20 ... ) >>> cd3 = dict( ... section_path_str='def', ... a=20 ... ) >>> cds = [cd, cd2, cd3] >>> result = get_config_product(cds) >>> result ... [({'section_path_str': 'abc', 'a': 10}, {'section_path_str': 'def', 'a': 20}), ... ({'section_path_str': 'abc', 'a': 20}, {'section_path_str': 'def', 'a': 20})]
pyfileconf.main module¶
-
class
pyfileconf.main.
PipelineManager
(folder, name='project', specific_class_config_dicts=None, auto_pdb=False, force_continue=False, default_config_folder_name='defaults')[source]¶ Bases:
object
Main class for managing flow-based programming and configuration.
-
__init__
(folder, name='project', specific_class_config_dicts=None, auto_pdb=False, force_continue=False, default_config_folder_name='defaults')[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
create
(section_path_str, func_or_class=None)[source]¶ Create a new configuration entry dynamically rather than manually modifying dict file
-
classmethod
get_manager_by_filepath
(filepath)[source]¶ Gets the active pipeline manager which references the passed filepath.
- Parameters
- Return type
- Returns
- Raises
NoPipelineManagerForFilepathException – When no active pipeline manager has a config file matching the file path
-
classmethod
get_manager_by_section_path_str
(section_path_str)[source]¶ Gets the active pipeline manager which references the passed section path.
- Parameters
filepath¶ –
- Return type
- Returns
- Raises
NoPipelineManagerForSectionPathException – When no active pipeline manager has a config file matching the file path
-
load
()[source]¶ Wrapper to track imported modules so that can reimport them upon reloading
- Return type
None
-
refresh
(section_path_str)[source]¶ Reloads from the existing file, then reapplies any config updates. Useful for when this config depends on the attribute of some other config which was updated.
-
reload
()[source]¶ Useful for getting file system changes without having to start a new Python session. Also resets any locally defined configuration.
Reloads functions from pipeline dict, scaffolds config files for any new functions, and updates configuration from files.
Returns: None
- Return type
None
-
reset
(section_path_str_or_view, allow_create=False)[source]¶ Resets a function or section config to default.
To reset all configs, use .reload() instead.
- Parameters
section_path_str_or_view¶ (StrOrView) –
- Returns
-
run
(section_path_str_or_list)[source]¶ Use to run registered pipelines/functions/sections. Pass a single section path or a list of section paths. If a list is passed, the return value will also be a list, with each result item corresponding to the function at the same index.
If a path for a section is passed rather than a path for a function or pipeline, a list of results will be returned for that section as well. Therefore, calling a high-level section will result in a nested list structure of results.
- Args:
- section_path_str_or_list: . separated name of path of function or section, or list thereof.
similar to how a function would be imported. e.g. ‘main.data.summarize.summary_func1’ or when running multiple functions/sections, e.g.
[‘main.data’, ‘main.analysis.reg.1’]
These sections/functions are based on the structure of your pipeline_dict
Returns: result or list of results
-
run_product
(section_path_str_or_list, config_updates, collect_results=True)[source]¶ Run one or multiple registered functions/sections multiple times, each time updating the config with a combination of the passed config updates.
Aggregates the updates to each config, then takes the itertools product of all the config updates to run the functions with each combination of the configs.
- Parameters
section_path_str_or_list¶ (RunnerArgs) – . separated name of path of function or section, or list thereof. similar to how a function would be imported. e.g. ‘main.data.summarize.summary_func1’ or when running multiple functions/sections, e.g. [‘main.data’, ‘main.analysis.reg.1’]
config_updates¶ (
Sequence
[Dict
[str
,Any
]]) – list of kwarg dictionaries which would normally be provided to .updatecollect_results¶ (
bool
) – Whether to aggregate and return results, set to False to save memory if results are stored in some other way
- Return type
IterativeResults
- Returns
-
update
(d_=None, section_path_str=None, pyfileconf_persist=True, **kwargs)[source]¶ Update the configuration for an item by section path.
The main logic is in _update but this also calls the pyfileconf_pre_update and pyfileconf_post_update hooks
-
-
exception
pyfileconf.main.
RunnerException
(*args, section_path_str=None, trace_back=None)[source]¶ Bases:
Exception
-
pyfileconf.main.
create_collections
(specific_class_config_dicts, basepath, pipeline_folder, pipeline_dict_path, manager_name=None)[source]¶
-
pyfileconf.main.
create_project
(path, logs_path, specific_class_config_dicts=None)[source]¶ Creates a new pyfileconf project file structure