lazyscribe.prefect package¶
Submodules¶
Prefect experiment tasks.
- class lazyscribe.prefect.experiment.LazyExperiment(project: Path | None = None, author: str | None = 'runner', **kwargs)[source]¶
Bases:
TaskPrefect integration for logging
lazyscribeexperiments.This task is only meant for creating new experiments.
Parameters¶
- projectPath
The path to the project JSON associated with the project.
- authorstr, optional (default
getpass.getuser()) The author of the experiment.
- **kwargs
Keyword arguments for
prefect.Task.
- load_artifact(name: str, validate: bool = True, **kwargs)[source]¶
Add a
load_artifacttask.Parameters¶
- namestr
The name of the artifact to load.
- validatebool, optional (default True)
Whether or not to validate the runtime environment against the artifact metadata.
- **kwargsdict
Keyword arguments for the handler read function.
Returns¶
- object
The artifact.
- log_artifact(name: str, value: Any, handler: str, fname: str | None = None, overwrite: bool = False, **kwargs)[source]¶
Add a
log_artifacttask.Parameters¶
- namestr
The name of the artifact.
- valueAny
The object to persist to the filesystem.
- handlerstr
The name of the handler to use for the object.
- fnamestr, optional (default None)
The filename for the artifact. If not provided, it will be derived from the name of the artifact and the builtin suffix for each handler.
- overwritebool, optional (default False)
Whether or not to overwrite an existing artifact with the same name. If set to
True, the previous artifact will be removed and overwritten with the current artifact.- **kwargsdict
Keyword arguments for the write function of the handler.
- log_metric(name: str, value: float | int)[source]¶
Add a
log_metrictask.Parameters¶
- namestr
Name of the metric.
- valueint or float
Value of the metric.
- log_parameter(name: str, value: Any)[source]¶
Add a
log_parametertask.Parameters¶
- namestr
Name of the parameter.
- valueAny
The parameter itself.
- log_test(name: str, description: str | None = None, flow: Flow | None = None) Iterator[Task][source]¶
Add a
lazyscribe.prefect.LazyTesttask to the flow.On exit from the context handler, an additional task will be added to append the test to the experiment itself.
Parameters¶
- namestr
Name of the test.
- descriptionstr, optional (default None)
A description of the test.
- flowFlow, optional (default None)
A
prefect.Flowobject. If not supplied, this function will retrieve a flow fromprefect.context.
Returns¶
- LazyTest
An instantiated
lazyscribe.prefect.LazyTestobject. This task has already been added to the flow.
- run(name: str | None = None, project: Path | None = None, author: str | None = None) Experiment[source]¶
Instantiate a new experiment.
Parameters¶
- namestr, optional (default None)
The name of the experiment. Defaults to the task name.
- projectPath, optional (default None)
The project JSON path. Defaults to the class attribute.
- authorstr, optional (default None)
The author. Defaults to the class attribute.
Returns¶
- Experiment
The
lazyscribe.Experimentclass.
Prefect project tasks.
- class lazyscribe.prefect.project.LazyProject(fpath: str = 'project.json', mode: Literal['r', 'a', 'w', 'w+'] = 'w', author: str | None = None, storage_options: dict | None = None, **kwargs)[source]¶
Bases:
TaskPrefect integration for logging
lazyscribeprojects.Parameters¶
- fpathstr, optional (default “project.json”)
The location of the project file. If not file exists, this will be the location of the output JSON file.
- mode{“r”, “a”, “w”, “w+”}, optional (default “w”)
The mode for opening the project. See
lazyscribe.Projectfor reference.- authorstr, optional (default None)
The project author.
- storage_optionsdict, optional (default None)
Storage options to pass to the filesystem initialization.
- **kwargs
Keyword arguments for
prefect.Task.
- append(other: Task, **kwargs)[source]¶
Add an
append_experimenttask to the flow.Parameters¶
- otherTask
The new experiment to add.
- **kwargs
Keyword arguments for
prefect.task().
- log(name: str, project: str | Path | Parameter | None = None, author: str | None = None, flow: Flow | None = None) Iterator[Task][source]¶
Add a
lazyscribe.prefect.LazyExperimentto the flow.On exit from the context handler, an additional task will be added to append the experiment to the project itself.
Parameters¶
- namestr
The name of the experiment.
- projectstr, optional (default None)
The location of the project JSON. If you have parameterized the project location, re-supply it here.
- authorstr, optional (default None)
The author of the project. If you have parameterized the author, please re-supply it here.
- flowFlow, optional (default None)
A
prefect.Flowobject. If not supplied, this function will retrieve a flow fromprefect.context.
Returns¶
- LazyExperiment
An instantiated
lazyscribe.prefect.LazyExperimentobject. This task has already been added to the flow.
- merge(other: Project, flow: Flow | None = None)[source]¶
Add a
merge_projectstask to the flow.Parameters¶
- otherProject
The other project.
- flowFlow, optional (default None)
A
prefect.Flowobject. If not supplied, this function will retrieve a flow fromprefect.context.
Returns¶
- Task
The bound
lazyscribe.prefect.merge_projects()task.
- run(fpath: str | None = None, mode: Literal['r', 'a', 'w', 'w+'] | None = None, author: str | None = None, storage_options: dict | None = None) Project[source]¶
Instantiate a
lazyscribe.Project.Parameters¶
- fpathstr, optional (default None)
The location of the project JSON file.
- modestr, optional (default None)
The mode for opening the project.
- authorstr, optional (default None)
The author for the project.
- storage_optionsdict, optional (default None)
Storage options to pass to the filesystem initialization.
Returns¶
- Project
The instantiated project.
Prefect test tasks.
- class lazyscribe.prefect.test.LazyTest(description: str | None = None, **kwargs)[source]¶
Bases:
TaskPrefect integration for logging
lazyscribetests.This task should only be used to instantiate new tests.
Parameters¶
- descriptionstr, optional (default None)
Description of the test.
- **kwargs
Keyword arguments for
prefect.Task.
- log_metric(name: str, value: float | int)[source]¶
Add a
log_metrictask.Parameters¶
- namestr
The name of the metric.
- valuefloat or int
The metric value.
- log_parameter(name: str, value: Any)[source]¶
Add a
log_parametertask.Parameters¶
- namestr
The name of the parameter.
- valueany
The parameter value.
- run(name: str | None = None, description: str | None = None) Test[source]¶
Instantiate a new
lazyscribe.test.Testobject.Parameters¶
- namestr, optional (default None)
The name of the test. Defaults to the task name.
- descriptionstr, optional (default None)
Description of the test.
Returns¶
- Test
Instantiated
lazyscribe.test.Testobject.
Module contents¶
Import the tasks.
- class lazyscribe.prefect.LazyExperiment(project: Path | None = None, author: str | None = 'runner', **kwargs)[source]¶
Bases:
TaskPrefect integration for logging
lazyscribeexperiments.This task is only meant for creating new experiments.
Parameters¶
- projectPath
The path to the project JSON associated with the project.
- authorstr, optional (default
getpass.getuser()) The author of the experiment.
- **kwargs
Keyword arguments for
prefect.Task.
- load_artifact(name: str, validate: bool = True, **kwargs)[source]¶
Add a
load_artifacttask.Parameters¶
- namestr
The name of the artifact to load.
- validatebool, optional (default True)
Whether or not to validate the runtime environment against the artifact metadata.
- **kwargsdict
Keyword arguments for the handler read function.
Returns¶
- object
The artifact.
- log_artifact(name: str, value: Any, handler: str, fname: str | None = None, overwrite: bool = False, **kwargs)[source]¶
Add a
log_artifacttask.Parameters¶
- namestr
The name of the artifact.
- valueAny
The object to persist to the filesystem.
- handlerstr
The name of the handler to use for the object.
- fnamestr, optional (default None)
The filename for the artifact. If not provided, it will be derived from the name of the artifact and the builtin suffix for each handler.
- overwritebool, optional (default False)
Whether or not to overwrite an existing artifact with the same name. If set to
True, the previous artifact will be removed and overwritten with the current artifact.- **kwargsdict
Keyword arguments for the write function of the handler.
- log_metric(name: str, value: float | int)[source]¶
Add a
log_metrictask.Parameters¶
- namestr
Name of the metric.
- valueint or float
Value of the metric.
- log_parameter(name: str, value: Any)[source]¶
Add a
log_parametertask.Parameters¶
- namestr
Name of the parameter.
- valueAny
The parameter itself.
- log_test(name: str, description: str | None = None, flow: Flow | None = None) Iterator[Task][source]¶
Add a
lazyscribe.prefect.LazyTesttask to the flow.On exit from the context handler, an additional task will be added to append the test to the experiment itself.
Parameters¶
- namestr
Name of the test.
- descriptionstr, optional (default None)
A description of the test.
- flowFlow, optional (default None)
A
prefect.Flowobject. If not supplied, this function will retrieve a flow fromprefect.context.
Returns¶
- LazyTest
An instantiated
lazyscribe.prefect.LazyTestobject. This task has already been added to the flow.
- run(name: str | None = None, project: Path | None = None, author: str | None = None) Experiment[source]¶
Instantiate a new experiment.
Parameters¶
- namestr, optional (default None)
The name of the experiment. Defaults to the task name.
- projectPath, optional (default None)
The project JSON path. Defaults to the class attribute.
- authorstr, optional (default None)
The author. Defaults to the class attribute.
Returns¶
- Experiment
The
lazyscribe.Experimentclass.
- class lazyscribe.prefect.LazyProject(fpath: str = 'project.json', mode: Literal['r', 'a', 'w', 'w+'] = 'w', author: str | None = None, storage_options: dict | None = None, **kwargs)[source]¶
Bases:
TaskPrefect integration for logging
lazyscribeprojects.Parameters¶
- fpathstr, optional (default “project.json”)
The location of the project file. If not file exists, this will be the location of the output JSON file.
- mode{“r”, “a”, “w”, “w+”}, optional (default “w”)
The mode for opening the project. See
lazyscribe.Projectfor reference.- authorstr, optional (default None)
The project author.
- storage_optionsdict, optional (default None)
Storage options to pass to the filesystem initialization.
- **kwargs
Keyword arguments for
prefect.Task.
- append(other: Task, **kwargs)[source]¶
Add an
append_experimenttask to the flow.Parameters¶
- otherTask
The new experiment to add.
- **kwargs
Keyword arguments for
prefect.task().
- log(name: str, project: str | Path | Parameter | None = None, author: str | None = None, flow: Flow | None = None) Iterator[Task][source]¶
Add a
lazyscribe.prefect.LazyExperimentto the flow.On exit from the context handler, an additional task will be added to append the experiment to the project itself.
Parameters¶
- namestr
The name of the experiment.
- projectstr, optional (default None)
The location of the project JSON. If you have parameterized the project location, re-supply it here.
- authorstr, optional (default None)
The author of the project. If you have parameterized the author, please re-supply it here.
- flowFlow, optional (default None)
A
prefect.Flowobject. If not supplied, this function will retrieve a flow fromprefect.context.
Returns¶
- LazyExperiment
An instantiated
lazyscribe.prefect.LazyExperimentobject. This task has already been added to the flow.
- merge(other: Project, flow: Flow | None = None)[source]¶
Add a
merge_projectstask to the flow.Parameters¶
- otherProject
The other project.
- flowFlow, optional (default None)
A
prefect.Flowobject. If not supplied, this function will retrieve a flow fromprefect.context.
Returns¶
- Task
The bound
lazyscribe.prefect.merge_projects()task.
- run(fpath: str | None = None, mode: Literal['r', 'a', 'w', 'w+'] | None = None, author: str | None = None, storage_options: dict | None = None) Project[source]¶
Instantiate a
lazyscribe.Project.Parameters¶
- fpathstr, optional (default None)
The location of the project JSON file.
- modestr, optional (default None)
The mode for opening the project.
- authorstr, optional (default None)
The author for the project.
- storage_optionsdict, optional (default None)
Storage options to pass to the filesystem initialization.
Returns¶
- Project
The instantiated project.
- class lazyscribe.prefect.LazyTest(description: str | None = None, **kwargs)[source]¶
Bases:
TaskPrefect integration for logging
lazyscribetests.This task should only be used to instantiate new tests.
Parameters¶
- descriptionstr, optional (default None)
Description of the test.
- **kwargs
Keyword arguments for
prefect.Task.
- log_metric(name: str, value: float | int)[source]¶
Add a
log_metrictask.Parameters¶
- namestr
The name of the metric.
- valuefloat or int
The metric value.
- log_parameter(name: str, value: Any)[source]¶
Add a
log_parametertask.Parameters¶
- namestr
The name of the parameter.
- valueany
The parameter value.
- run(name: str | None = None, description: str | None = None) Test[source]¶
Instantiate a new
lazyscribe.test.Testobject.Parameters¶
- namestr, optional (default None)
The name of the test. Defaults to the task name.
- descriptionstr, optional (default None)
Description of the test.
Returns¶
- Test
Instantiated
lazyscribe.test.Testobject.