Skip to content
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

logInputs endpoint #17

Merged
merged 10 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Initialize MLflow repo
run: mage repo:init
- name: Install dependencies
run: pip install pytest==8.1.1 psycopg2-binary -e .mlflow.repo
run: pip install pytest==8.1.1 psycopg2-binary==2.9.9 -e .mlflow.repo
- name: Run integration tests
run: mage test:python
# Temporary workaround for failing tests
Expand Down
2 changes: 1 addition & 1 deletion magefiles/generate/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var ServiceInfoMap = map[string]ServiceGenerationInfo{
// "getMetricHistoryBulkInterval",
"logBatch",
// "logModel",
// "logInputs",
"logInputs",
// "startTrace",
// "endTrace",
// "getTraceInfo",
Expand Down
11 changes: 11 additions & 0 deletions magefiles/generate/validations.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,15 @@ var validations = map[string]string{
"SetExperimentTag_ExperimentId": "required",
"SetExperimentTag_Key": "required,max=250,validMetricParamOrTagName",
"SetExperimentTag_Value": "max=5000",
"LogInputs_RunId": "required,runId",
"LogInputs_Datasets": "required",
"DatasetInput_Dataset": "required",
"Dataset_Name": "required,max=500",
"Dataset_Digest": "required,max=36",
"Dataset_SourceType": "required",
"Dataset_Source": "required,max=65535",
"Dataset_Profile": "max:16777215",
"Dataset_Schema": "max:1048575",
"InputTag_Key": "required,max=255",
"InputTag_Value": "required,max=500",
}
1 change: 1 addition & 0 deletions pkg/contract/service/tracking.g.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions pkg/entities/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ func (d *Dataset) ToProto() *protos.Dataset {
Profile: profile,
}
}

func NewDatasetFromProto(proto *protos.Dataset) *Dataset {
return &Dataset{
Name: proto.GetName(),
Digest: proto.GetDigest(),
SourceType: proto.GetSourceType(),
Source: proto.GetSource(),
Schema: proto.GetSchema(),
Profile: proto.GetProfile(),
}
}
12 changes: 12 additions & 0 deletions pkg/entities/dataset_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ func (ds DatasetInput) ToProto() *protos.DatasetInput {
Dataset: ds.Dataset.ToProto(),
}
}

func NewDatasetInputFromProto(proto *protos.DatasetInput) *DatasetInput {
tags := make([]*InputTag, 0, len(proto.GetTags()))
for _, t := range proto.GetTags() {
tags = append(tags, NewInputTagFromProto(t))
}

return &DatasetInput{
Dataset: NewDatasetFromProto(proto.GetDataset()),
Tags: tags,
}
}
7 changes: 7 additions & 0 deletions pkg/entities/input_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ func (i InputTag) ToProto() *protos.InputTag {
Value: &i.Value,
}
}

func NewInputTagFromProto(proto *protos.InputTag) *InputTag {
return &InputTag{
Key: proto.GetKey(),
Value: proto.GetValue(),
}
}
8 changes: 8 additions & 0 deletions pkg/lib/tracking.g.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions pkg/protos/service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions pkg/server/routes/tracking.g.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions pkg/tracking/service/inputs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package service

import (
"context"

"github.com/mlflow/mlflow-go/pkg/contract"
"github.com/mlflow/mlflow-go/pkg/entities"
"github.com/mlflow/mlflow-go/pkg/protos"
)

func (ts TrackingService) LogInputs(
ctx context.Context, input *protos.LogInputs,
) (*protos.LogInputs_Response, *contract.Error) {
if len(input.GetDatasets()) == 0 {
return &protos.LogInputs_Response{}, nil
}

datasets := make([]*entities.DatasetInput, 0, len(input.GetDatasets()))
for _, d := range input.GetDatasets() {
datasets = append(datasets, entities.NewDatasetInputFromProto(d))
}

if err := ts.Store.LogInputs(ctx, input.GetRunId(), datasets); err != nil {
return nil, err
}

return &protos.LogInputs_Response{}, nil
}
50 changes: 50 additions & 0 deletions pkg/tracking/store/mock_tracking_store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading