py2store.access¶
Utils to load stores from store specifications. Includes the logic to allow configurations (and defaults) to be parametrized by external environmental variables and files.
Every data-sourced problem has it’s problem-relevant stores. Once you get your stores right, along with the right access credentials, indexing, serialization, caching, filtering etc. you’d like to be able to name, save and/or share this specification, and easily get access to it later on.
Here are tools to help you out.
There are two main key-value stores: One for configurations the user wants to reuse, and the other for the user’s desired defaults. Both have the same structure:
first level key: Name of the resource (should be a valid python variable name)
The reminder is more or less free form (until the day we lay out some schemas for this)
The system will look for the specification of user_configs and user_defaults in a json file. The filepath to this json file can specified in environment variables
PY2STORE_CONFIGS_JSON_FILEPATH and PY2STORE_DEFAULTS_JSON_FILEPATH
respectively. By default, they are:
~/.py2store_configs.json and ~/.py2store_defaults.json
respectively.
-
py2store.access.
compose
(*functions)[source]¶ Make a function that is the composition of the input functions
-
py2store.access.
dflt_func_loader
(f) → callable[source]¶ Loads and returns the function referenced by f, which could be a callable or a DOTPATH_TO_MODULE.FUNC_NAME dotpath string to one, or a pipeline of these
-
py2store.access.
dotpath_to_func
(f: (<class 'str'>, <built-in function callable>)) → callable[source]¶ Loads and returns the function referenced by f, which could be a callable or a DOTPATH_TO_MODULE.FUNC_NAME dotpath string to one.
-
py2store.access.
dotpath_to_obj
(dotpath)[source]¶ Loads and returns the object referenced by the string DOTPATH_TO_MODULE.OBJ_NAME
-
py2store.access.
fakit
(fak, func_loader=<function dflt_func_loader>)[source]¶ Execute a fak with given f, a, k and function loader.
Essentially returns func_loader(f)(*a, **k)
- Parameters
fak – A (f, a, k) specification. Could be a tuple or a dict (with ‘f’, ‘a’, ‘k’ keys). All but f are optional.
func_loader – A function returning a function. This is where you specify any validation of func specification f, and/or how to get a callable from it.
Returns: A python object.