quantlab.config.set_data_root#

quantlab.config.set_data_root(path)[source]#

Set the process-level storage root, ahead of the environment variable.

The value is passed through expanduser but not resolve: the QUANTLAB_DATA_DIR value is used unresolved too, so the two behave the same on a symlinked root, and a quoted '~/x' from a shell reaches Python with a literal tilde that would otherwise become a directory named ~. The directory is neither created nor required to exist.

Parameters:
pathstr | os.PathLike | None

The new root. None clears the override so that QUANTLAB_DATA_DIR or the default root applies again.

Returns:
Path | None

The stored Path, or None when the override was cleared.

Raises:
ValueError

If path is an empty or whitespace-only string. An empty environment variable falls through to the default, but a root someone typed explicitly should not silently mean “default”.

Examples

>>> set_data_root("/mnt/quant")
PosixPath('/mnt/quant')
>>> set_data_root(None) is None
True