# FromConfig MlFlow
Project description
FromConfig MlFlow
A fromconfig Launcher
for MlFlow support.
Install
pip install fromconfig_mlflow
Quickstart
Once installed, the launcher is available with the name mlflow
.
Start a local MlFlow server with
mlflow server
You should see
[INFO] Starting gunicorn 20.0.4
[INFO] Listening at: http://127.0.0.1:5000
We will assume that the tracking URI is http://127.0.0.1:5000
from now on.
Given the following module
class Model:
def __init__(self, learning_rate: float):
self.learning_rate = learning_rate
def train(self):
print(f"Training model with learning_rate {self.learning_rate}")
and config files
# config.yaml
model:
_attr_: foo.Model
learning_rate: "@params.learning_rate"
# params.yaml
params:
learning_rate: 0.001
# launcher.yaml
mlflow:
tracking_uri: "http://127.0.0.1:5000"
logging:
level: 20
launcher:
log:
- logging
- mlflow
Run
fromconfig config.yaml params.yaml launcher.yaml - model - train
which prints
INFO:fromconfig.launcher.logger:- launcher.log[0]: logging
INFO:fromconfig.launcher.logger:- launcher.log[1]: mlflow
INFO:fromconfig.launcher.logger:- params.learning_rate: 0.001
INFO:fromconfig.launcher.logger:- mlflow.tracking_uri: http://127.0.0.1:5000
INFO:fromconfig.launcher.logger:- logging.level: 20
INFO:fromconfig.launcher.logger:- model._attr_: foo.Model
INFO:fromconfig.launcher.logger:- model.learning_rate: 0.001
INFO:fromconfig_mlflow.launcher:Started new run: http://127.0.0.1:5000/experiments/0/runs/e5ae42827da041fc989aca024040c725
INFO:fromconfig_mlflow.launcher:Logging artifacts config.json and launch.txt
INFO:fromconfig_mlflow.launcher:Logging parameters
Training model with learning_rate 0.001
If you navigate to http://127.0.0.1:5000/experiments/0/runs/40ea35e951e942bc9f0b9c792c4ce1e7
you should see your parameters and configs.
This example can be found in docs/examples/quickstart
.
Usage Reference
Options
To configure MlFlow, add a mlflow
entry to your config.
You can set the following parameters
run_id
: if you wish to restart an existing runrun_name
: if you wish to give a name to your new runtracking_uri
: to configure the tracking remoteexperiment_name
: to use a different experiment than the custom experimentartifact_location
: the location of the artifacts (config files)
Additionally, if you wish to call the mlflow
launcher multiple times during the launch (for example once before the parser, and once after), you need to configure the different launches with the special launches
key (otherwise only the first launch will actually log artifacts and parameters).
The launches
key should be a list of dictionaries with the following parameters
log_artifacts
: ifTrue
(default), will log the artifacts (the config and command given to the launcher)log_parameters
: ifTrue
(default) will log a flattened view of the parameterspath_config
: if given, will write the config as an artifact with that name (default isconfig.json
)path_command
: if given, will write the command as an artifact with that name (default islaunch.txt
, using the.txt
extension because you can preview it on MlFlow).
See the multi example.
Examples
Multi
Re-using the quickstart code, modify the launcher.yaml
file
mlflow:
tracking_uri: "http://127.0.0.1:5000"
launches:
-
log_artifacts: true
log_parameters: false
path_config: "config.json"
path_command: "launch_config.txt"
-
log_artifacts: true
log_parameters: true
path_config: "parsed.json"
path_command: "launch_parsed.json"
logging:
level: 20
launcher:
parse:
- mlflow
- parser
log:
- logging
- mlflow
and run
fromconfig config.yaml params.yaml launcher.yaml - model - train
If you navigate to the MlFlow run, you should see
- the parameters, a flattened version of the parsed config (
model.learning_rate
is0.001
and not@params.learning_rate
) - the original config, saved as
config.json
- the parsed config, saved as
parsed.json
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.