cascade.repos#
- class cascade.repos.LineFactory[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:
- __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
- 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 Noneline_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:
- Raises:
RuntimeError – If line with the computed name already exists
TypeError – _description_
IOError – _description_
- class cascade.repos.SingleLineRepo(line: Line, *args: Any, meta_prefix: Dict[Any, Any] | None = None, **kwargs: Any)[source]#