def create_runs():
    exp = create_experiment()
    with mlflow.start_run() as run:
        mlflow.log_metric("m1", 0.1)
    run0 = run
    with mlflow.start_run() as run:
        mlflow.log_metric("m1", 0.2)
    return exp, run0, run
def create_nested_runs():
    exp = create_experiment()
    with mlflow.start_run() as run:
        run0 = run
        mlflow.log_metric("m1", 10.0)
        with mlflow.start_run(nested=True) as run:
            run0_min = run
            mlflow.log_metric("m1", 1.0)
        with mlflow.start_run(nested=True) as run:
            run0_max = run
            mlflow.log_metric("m1", 100.0)
    with mlflow.start_run() as run:
        run1 = run
        mlflow.log_metric("m1", 20.0)
    return exp, run0, run1
Example #3
0
def create_simple_run():
    exp = create_experiment()
    max_depth = 4
    model = create_sklearn_model(max_depth)
    with mlflow.start_run(run_name="my_run") as run:
        mlflow.log_param("max_depth", max_depth)
        mlflow.log_metric("rmse", .789)
        mlflow.set_tag("my_tag", "my_val")
        mlflow.sklearn.log_model(model, "model")
        with open("info.txt", "w") as f:
            f.write("Hi artifact")
        mlflow.log_artifact("info.txt")
        mlflow.log_artifact("info.txt", "dir2")
        mlflow.log_metric("m1", 0.1)
    return exp, run
def create_simple_run():
    exp = create_experiment()
    mlflow.sklearn.autolog()
    X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
    y = np.dot(X, np.array([1, 2])) + 3
    model = LinearRegression()
    with mlflow.start_run(run_name="my_run") as run:
        mlflow.log_param("p1", "0.1")
        mlflow.log_metric("m1", 0.1)
        mlflow.set_tag("my_tag", "my_val")
        with open("info.txt", "w") as f:
            f.write("Hi artifact")
        mlflow.log_artifact("info.txt")
        mlflow.log_artifact("info.txt", "dir2")
        model.fit(X, y)
        mlflow.sklearn.log_model(model, "sklearn-model")
    return exp, run
Example #5
0
def test_no_run_name():
    exp = create_experiment()
    with mlflow.start_run() as run:
        mlflow.log_metric("m1", 0.1)
    run2 = client.get_run(run.info.run_id)
    assert TAG_RUN_NAME not in run2.data.tags
Example #6
0
def create_runs(num_runs):
    exp = create_experiment()
    for _ in range(0, num_runs):
        with mlflow.start_run():
            mlflow.log_metric("m1", 0.1)
    return exp