Interactive Mode¶
To enable practical research and development of ForML projects, the framework allows as one of its execution mechanisms to compose and operate its workflows interactively. Generally, this can be utilized within REPL (read-evaluate-print-loop) based terminals or more typically using high-level frontend interfaces like the popular Jupyter notebooks.
Note
ForML still remains grounded in the code-first principle of implementing the ML solution as a software project as opposed to some of the native notebook-first-oriented methodologies. The interactive mode is designed primarily for exploration rather than the implementation of the eventual solution.
This chapter describes the individual tools allowing to use ForML interactively. Please refer to the tutorials for actual examples demonstrating this principle in action.
Project Handle¶
To operate ForML projects interactively, the framework provides the following
programmatic interface allowing one to access the project.Artifact
handle using either the project.open()
function or interactively
binding any project.Source
instance with a custom pipeline using the
.bind()
method.
-
forml.project.open(path: str | Path | None =
None
, package: str | None =None
, **modules: Any) Artifact [source]¶ Getting a programmatic handle to a local ForML project.
-
class forml.project.Artifact(path: str | Path | None =
None
, package: str | None =None
, **modules: Any)[source]¶ Project artifact handle.
- property components : project.Components¶
Tuple of all the individual principal components from this project artifact.
- Returns:
Tuple of the project principal components.
- property launcher : runtime.Virtual¶
A runtime launcher configured with a
volatile registry
preloaded with this artifact.This can be used to interactively execute the particular actions of the project development life cycle. The linked volatile registry is persistent only during the lifetime of this artifact instance.
See also
See the
runtime.Virtual
pseudo runner for more details regarding the launcher API.- Returns:
Virtual launcher instance.
Virtual Launcher¶
The Virtual launcher represents one of the possible execution mechanisms. It is a wrapper around the low-level runner and feed concepts designed specifically for interactive operations (internally it is also used by the testing framework).
- class forml.runtime.Virtual(artifact: project.Artifact)[source]¶
Custom launcher allowing to execute the provided artifact using the default or an explicit runner in combination with a special pipeline sink to capture and return any output produced by the given action.
All states produced while executing the launcher actions are (temporarily) persisted in an internal model registry implemented by the
Volatile provider
.- Parameters:
- artifact: project.Artifact¶
Project artifact to be launched.
The available launcher actions are exposed using the following common triggers:
-
train(lower=
None
, upper=None
) runtime.Virtual.Trained ¶ Trigger the train action.
- Returns:
Accessor of the train-mode features/outcomes outputs.
-
apply(lower=
None
, upper=None
) flow.Features ¶ Trigger the apply action.
- Returns:
The apply-mode output.
-
eval(lower=
None
, upper=None
) float ¶ Trigger the (train-test) eval action.
- Returns:
Evaluation metric value.
Furthermore, these triggers can be accessed using three different approaches:
Directly on the launcher instance:
>>> launcher_instance.eval() 0.83
Using a getitem syntax specifying an explicit runner provider:
>>> launcher_instance['graphviz'].train()
Using a call syntax specifying both an explicit runner and a list of source feeds providers:
>>> launcher_instance('dask', ['openlake']).apply() [0.31, 0.63, 0.16, 0.87]
- class Trained(future: Future)[source]¶
Lazy accessor of the virtual train-mode features/outcomes segment outputs as returned by the
runtime.Virtual.train
method.- property features : flow.Features¶
Get the train-mode features segment values.
- property labels : flow.Labels¶
Get the train-mode labels segment values.