cascade.repos#
Repo is a container for Lines.
- 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.repos 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.create_model(constant=1) >>> model.fit([0], [1]) >>> line.save(model)
- __getitem__(key: Union[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
.jsonand.ymlor.yamlare supported
- add_line(name: Optional[str] = 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._rootbefore 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 model
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 re-created model line
- Return type:
- Raises:
AssertionError – If name is None and line with the computed name already exists
FileNotFoundError – If line was not found even though Repo recorded it at creation time
ValueError – If provided arguments do not match the saved model’s configuration on disk
- class cascade.repos.SingleLineRepo(line: Line, *args: Any, **kwargs: Any)[source]#
Virtual Repo to represent a single line with Repo interface in code