quantlab.core.store_folder.save_component#

quantlab.core.store_folder.save_component(component, folder, readme=None)[source]#

Write component’s config to <folder>/component.json, and readme if given.

The config is checked first: it is written to JSON and rebuilt, and the rebuilt component must equal component. A component that cannot come back from its config (a dataset held in memory has no store to read back) is refused before anything is written. The folder is created as needed; an existing README.md is kept unless readme is given.

Parameters:
componentComponent

The dataset, factor or factor risk model that writes the folder’s store.

folderstr or pathlib.Path

The store’s folder.

readmestr, optional

What the store is, which recipe defines it, what reads it.

Returns:
pathlib.Path

The written component.json.

Raises:
ValueError

If the component does not rebuild equal from its config.

Examples

Needs a built store under the data root, so it is not run here:

save_component(alpha101, "/data/quantlab/factors/us3000/alpha101",
               readme="# alpha101\nAlpha101 on the us3000 roster.")
load_component("/data/quantlab/factors/us3000/alpha101") == alpha101