-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added databricks_mlflow_model
and databricks_mlflow_experiment
resources
#931
Conversation
MLFlow experiment work
adding test for experiment
Correct case mismatch.
Correct case mismatch.
…orm-provider-databricks into mlflow-experiment-update
Mlflow experiment update
Included artifact_location in experiment and updated docs
* including artifact_location * removing force_new from api struct * Refactor API objects and struct names. * Refactor API objects and struct names. * Improve docs. Fix acceptance test. Co-authored-by: nsoni2 <navin_soni@intuit.com> Co-authored-by: Jeffrey Alvarez <Jeffrey_Alvarez@intuit.com> Co-authored-by: soninavin <soni.navin@gmail.com>
refactoring api function
* Remove toAPIObject. Refactor tests. * Remove toAPIObject. Refactor tests. Co-authored-by: Jeffrey Alvarez <Jeffrey_Alvarez@intuit.com>
removing experiment tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- don't create api package, unless it's reused or big. move api wrapper to resource file instead to keep consistency.
- comments for experiment resource are the same as for model resource.
docs/index.md
Outdated
@@ -48,6 +48,10 @@ Databricks SQL | |||
* Manage [dashboards](resources/sql_dashboard.md) and their [widgets](resources/sql_widget.md). | |||
* Provide [global configuration for all SQL Endpoints](docs/resources/sql_global_config.md) | |||
|
|||
MLFlow | |||
* Create [MLFlow models](resources/mlflow_models.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- rename
mlflow_models.md
tomlflow_model.md
- also add an entry to README.md
docs/index.md
Outdated
@@ -48,6 +48,10 @@ Databricks SQL | |||
* Manage [dashboards](resources/sql_dashboard.md) and their [widgets](resources/sql_widget.md). | |||
* Provide [global configuration for all SQL Endpoints](docs/resources/sql_global_config.md) | |||
|
|||
MLFlow | |||
* Create [MLFlow models](resources/mlflow_models.md). | |||
* Create [MLFlow experiments](resources/mlflow_experiments.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mlflow_experiments.md to mlflow_experiment.md
docs/resources/mlflow_experiments.md
Outdated
|
||
The following arguments are supported: | ||
|
||
* `name` - (Required) Name of MLflow experiment. It must be an absolute path within the Databricks workspace, e.g. `/Users/<some-username>/my-experiment`. For more information about changes to experiment naming conventions, see https://docs.databricks.com/applications/mlflow/experiments.html#experiment-migration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hide url in [..](url)
docs/resources/mlflow_experiments.md
Outdated
The following arguments are supported: | ||
|
||
* `name` - (Required) Name of MLflow experiment. It must be an absolute path within the Databricks workspace, e.g. `/Users/<some-username>/my-experiment`. For more information about changes to experiment naming conventions, see https://docs.databricks.com/applications/mlflow/experiments.html#experiment-migration. | ||
* `artifact_location` - Path to dbfs:/ or s3:// artificate location of the MLflow experiment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: artificate
mlflow/resource_model.go
Outdated
}) | ||
|
||
return common.Resource{ | ||
Create: func(ctx context.Context, data *schema.ResourceData, c *common.DatabricksClient) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make sure that ResourceData is always named d
- d *schema.ResourceData
. it's a convention.
mlflow/api/model.go
Outdated
// MLFlowModelAPI defines the response object from the API | ||
type Model struct { | ||
Name string `json:"name"` | ||
CreationTimestamp int64 `json:"creation_timestamp,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add tf:"computed"
mlflow/api/model.go
Outdated
type Model struct { | ||
Name string `json:"name"` | ||
CreationTimestamp int64 `json:"creation_timestamp,omitempty"` | ||
LastUpdatedTimestamp int64 `json:"last_updated_timestamp,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add tf:"computed"
mlflow/api/model.go
Outdated
Name string `json:"name"` | ||
CreationTimestamp int64 `json:"creation_timestamp,omitempty"` | ||
LastUpdatedTimestamp int64 `json:"last_updated_timestamp,omitempty"` | ||
UserID string `json:"user_id,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add tf:"computed"
mlflow/api/model.go
Outdated
CreationTimestamp int64 `json:"creation_timestamp,omitempty"` | ||
LastUpdatedTimestamp int64 `json:"last_updated_timestamp,omitempty"` | ||
UserID string `json:"user_id,omitempty"` | ||
LatestVersions []string `json:"latest_versions,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add tf:"computed"
mlflow/api/model.go
Outdated
|
||
// Read ... | ||
func (a ModelAPI) Read(modelName string) (*Model, error) { | ||
//var d MLFLowModelAPI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented irrelevant code
Codecov Report
@@ Coverage Diff @@
## master #931 +/- ##
==========================================
+ Coverage 85.30% 85.32% +0.02%
==========================================
Files 93 95 +2
Lines 8582 8663 +81
==========================================
+ Hits 7321 7392 +71
- Misses 773 778 +5
- Partials 488 493 +5
|
…ricks into mlflow
Co-authored-by: Jeffrey Alvarez <Jeffrey_Alvarez@intuit.com>
@nfx Please check our new changes, trying to address all your suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better! :) please see more comments
mlflow/resource_experiment.go
Outdated
} | ||
|
||
// ExperimentAPI ... | ||
type ExperimentAPI struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to ExperimentsAPI
(e.g. almost all APIs are plurals of their entities)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_experiment.go
Outdated
return a.client.Post(a.context, "/mlflow/experiments/delete", d, &d) | ||
} | ||
|
||
///func ResourceMLFlowExperiment() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_experiment.go
Outdated
return err | ||
} | ||
|
||
data.Set("name", ad.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to do d.Set(...)
, because it's already handled by StructToData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_experiment.go
Outdated
data.SetId(ad.ExperimentId) | ||
return nil | ||
}, | ||
Read: func(ctx context.Context, data *schema.ResourceData, c *common.DatabricksClient) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please follow conventions of this software project: replace data *schema.ResourceData
with d *schema.ResourceData
. anyone working on other resources would immediately be confused with this argument naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_experiment.go
Outdated
data.SetId(ad.ExperimentId) | ||
return nil | ||
}, | ||
Update: func(ctx context.Context, data *schema.ResourceData, c *common.DatabricksClient) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data
-> d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_model.go
Outdated
} | ||
|
||
// Update ... | ||
func (a ModelAPI) Update(d *ModelDto) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_model.go
Outdated
|
||
return common.Resource{ | ||
Create: func(ctx context.Context, data *schema.ResourceData, c *common.DatabricksClient) error { | ||
var ad ModelDto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ad
has no semantic meaning, while model
does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_model.go
Outdated
return nil | ||
}, | ||
Read: func(ctx context.Context, data *schema.ResourceData, c *common.DatabricksClient) error { | ||
var d Model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_model.go
Outdated
}, | ||
Read: func(ctx context.Context, data *schema.ResourceData, c *common.DatabricksClient) error { | ||
var d Model | ||
ad, err := NewModelAPI(ctx, c).Read(data.Id()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model, err := ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_model.go
Outdated
return err | ||
} | ||
|
||
if err := common.StructToData(d, s, data); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewrite it with return common.StructToData(model, s, d)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Co-authored-by: Jeffrey Alvarez <Jeffrey_Alvarez@intuit.com>
@nfx Round 2 of suggestions addressed. Please check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuritsu We're almost there! Make Delete() method accept a string argument and remove copy-pasted comment.
And merge in/rebase onto master branch.
And then I'm glad to squash and merge this PR
mlflow/resource_experiment.go
Outdated
}, | ||
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error { | ||
e := Experiment{ExperimentId: d.Id()} | ||
return NewExperimentsAPI(ctx, c).Delete(&e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you refactor Delete method to accept just a string id? E.g. we don't need any other fields than ID to delete an entity. And within that method you'll probably use that struct, but outer interface would be simple and consistent with the rest of resources.
Consistency is key, as eventually we'll try to migrate to go1.17 generics and Delete is one of the most similar methods everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
mlflow/resource_model.go
Outdated
Description string `json:"description,omitempty"` | ||
} | ||
|
||
// ResourceDashboard ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove this copy-pasted comment?...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
databricks_mlflow_model
and databricks_mlflow_experiment
databricks_mlflow_model
and databricks_mlflow_experiment
databricks_mlflow_model
and databricks_mlflow_experiment
resources
…sources (databricks#931) Provides basic support for managing MLflow models and experiments, should hopefully address databricks#861 as well. # databricks_mlflow_experiment ```hcl resource "databricks_mlflow_experiment" "test" { name = "/Users/myuserid/my-experiment" artifact_location = "dbfs:/tmp/my-experiment" description = "My MLflow experiment description" } ``` ## Argument Reference The following arguments are supported: * `name` - (Required) Name of MLflow experiment. It must be an absolute path within the Databricks workspace, e.g. `/Users/<some-username>/my-experiment`. For more information about changes to experiment naming conventions, see [mlflow docs](https://docs.databricks.com/applications/mlflow/experiments.html#experiment-migration). * `artifact_location` - Path to dbfs:/ or s3:// artifact location of the MLflow experiment. * `description` - The description of the MLflow experiment. # databricks_mlflow_model ```hcl resource "databricks_mlflow_model" "test" { name = "My MLflow Model" description = "My MLflow model description" tags { key = "key1" value = "value1" } tags { key = "key2" value = "value2" } } ``` ## Argument Reference The following arguments are supported: * `name` - (Required) Name of MLflow model. * `description` - The description of the MLflow model. * `tags` - Tags for the MLflow model. --- Co-authored-by: nsoni2 <navin_soni@intuit.com> Co-authored-by: Jeffrey Alvarez <Jeffrey_Alvarez@intuit.com> Co-authored-by: Daniel Jensen <daniel_jensen@intuit.com> Co-authored-by: Serge Smertin <259697+nfx@users.noreply.github.com>
Provides basic support for managing MLflow models and experiments, should hopefully address #861 as well.
databricks_mlflow_experiment
Argument Reference
The following arguments are supported:
name
- (Required) Name of MLflow experiment. It must be an absolute path within the Databricks workspace, e.g./Users/<some-username>/my-experiment
. For more information about changes to experiment naming conventions, see mlflow docs.artifact_location
- Path to dbfs:/ or s3:// artifact location of the MLflow experiment.description
- The description of the MLflow experiment.databricks_mlflow_model
Argument Reference
The following arguments are supported:
name
- (Required) Name of MLflow model.description
- The description of the MLflow model.tags
- Tags for the MLflow model.