cascade.repos#

class cascade.repos.LineFactory[source]#
classmethod create(path: str, *args: Any, line_type: Literal['model', 'data', None] = None, **kwargs: Any) Line[source]#
classmethod read(path: str, *args: Any, **kwargs: Any) Line[source]#
class cascade.repos.Repo(folder: str, *args: Any, overwrite: bool = False, meta_fmt: Literal['.json', '.yml', '.yaml'] = '.json', **kwargs: Any)[source]#

An interface to manage series of experiments called lines. When created, initializes an empty folder constituting a repository of lines.

Example

>>> from cascade.base import Repo
>>> from cascade.utils.baselines import ConstantBaseline
>>> repo = Repo("repo")
>>> repo.describe("This is a repo with one line for the example.")
>>> line = repo.add_line("const", model_cls=ConstantBaseline)
>>> model = line.add_model()
>>> model.fit()
>>> line.save(model)
__getitem__(key: str | int)[source]#
Returns:

line – existing line of the name passed in key

Return type:

Line

__init__(folder: str, *args: Any, overwrite: bool = False, meta_fmt: Literal['.json', '.yml', '.yaml'] = '.json', **kwargs: Any) None[source]#
Parameters:
  • folder – Path to a folder where Repo needs to be created or already was created if folder does not exist, creates it

  • overwrite (bool) – if True will remove folder that is passed in first argument and start a new repo in that place

  • meta_fmt (Literal['.json', '.yml', '.yaml']) – extension of repo’s metadata files and that will be assigned to the lines by default .json and .yml or .yaml are supported

See also

cascade.base.Line, cascade.data.DataLine, cascade.models.ModelLine

__len__() int[source]#
Returns:

num – a number of lines

Return type:

int

add_line(name: str | None = None, line_type: Literal['data', 'model', None] = 'model', *args: Any, meta_fmt: Literal['.json', '.yml', '.yaml', None] = None, **kwargs: Any) Line[source]#

Adds new line to repo if it doesn’t exist and returns it. If line exists, defines it in repo with parameters provided.

Supports all the parameters of Line using args and kwargs.

Parameters:
  • name (Optional[str], optional) – str, optional

  • meta_fmt (Literal[".json", ".yml", ".yaml", None], by default None) – str, optional

  • name – Name of the line. It is used to name a folder of line. Repo prepends it with self._root before creating. Optional argument. If omitted - names new line automatically using f’{len(self):0>5d}’, by default None

  • line_type (Literal["data", "model"]], by default "model") – The type of model line to create, by default None

  • meta_fmt – Format of meta files. Supported values are the same as for repo. If omitted, inherits format from repo., by default None

Returns:

Created or recreated model line

Return type:

Line

Raises:
  • RuntimeError – If line with the computed name already exists

  • TypeError – _description_

  • IOError – _description_

get_line_names() List[str][source]#

Returns list of line names.

load_obj_meta(obj: str) List[Dict[Any, Any]][source]#

Loads metadata of an object inside repo from disk

Parameters:

obj (str) – obj slug e.g. fair_squid_of_bliss

Returns:

Obj metadata

Return type:

Meta

Raises:

FileNotFoundError – Raises if failed to find the obj with slug specified

reload() None[source]#

Updates internal state

class cascade.repos.SingleLineRepo(line: Line, *args: Any, meta_prefix: Dict[Any, Any] | None = None, **kwargs: Any)[source]#
__init__(line: Line, *args: Any, meta_prefix: Dict[Any, Any] | None = None, **kwargs: Any) None[source]#
Parameters:
  • description – String description of an object

  • tags (Iterable[str], optional) – The list of tags to be added

get_line_names() List[str][source]#
get_root() str[source]#
reload() None[source]#