make_path#

scikitplot.utils._path.make_path(root=PosixPath('scikitplot-artifacts'), prefix='file', ext='', *, by_day=False, add_secret=False, private=False, mkdir=True, subdir=None, now=None)[source]#

Make Convenience wrapper to build a unique path (callable with zero args).

Parameters:
rootstr or pathlib.Path, default=Path(“output”)

Base output directory.

prefixstr, default=”file”

Filename prefix.

extstr, default=””

File extension (e.g., "csv").

by_daybool, default=False

If True, nest outputs under YYYY/MM/DD in UTC.

add_secretbool, default=False

If True, append an extra random token for opacity.

privatebool, default=False

If True, append an extra random token for opacity.

mkdirbool, default=True

If True, create the output directory if needed.

subdirstr or None, default=None

Optional subdirectory when by_day=False.

nowdatetime or None, default=None

Timestamp to use. If None, uses current UTC time. Naive datetimes are treated as UTC.

Returns:
pathpathlib.Path

Full path to a unique file location.

Parameters:
Return type:

Path

See also

PathNamer

Configurable generator for repeated use.

Notes

For repeated use with the same configuration, prefer PathNamer to avoid re-specifying parameters.

If private=True, a random token is appended to make names hard to guess. This affects naming only (not OS-level file permissions).

Examples

Zero-argument usage:

>>> from scikitplot.utils._path import make_path
>>> p = make_path()
>>> p.name.startswith("file-")
True

Choose a prefix and extension:

>>> p = make_path(prefix="report", ext="csv")
>>> p.name.endswith(".csv")
True

Disable daily folders and write under a stable subdirectory:

>>> p = make_path(
...     root="output", by_day=False, subdir="runs", prefix="run", ext="json"
... )
>>> "runs" in p.as_posix()
True

Expand “~” and create a private filename:

>>> p = make_path(root="~/artifacts", prefix="run", ext="json", private=True)
>>> p.name.endswith(".json")
True