Skip to content

Commit

Permalink
Merge pull request #2 from nojaf/debug-thing
Browse files Browse the repository at this point in the history
  • Loading branch information
jgiannuzzi authored Jul 1, 2024
2 parents bcc1357 + ca70409 commit c5015fb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

In order to increase the performance of the tracking server and the various stores, we propose to rewrite the server and store implementation in Go.

## Temp stuff

```bash
pip install psycopg2-binary
pip install -e .
tar -C /usr/local/python/current/lib/python3.8/site-packages/mlflow -czvf ./ui.tgz ./server/js/build
pip install git+https://github.com/jgiannuzzi/mlflow.git@server-signals
tar -C /usr/local/python/current/lib/python3.8/site-packages/mlflow -xzvf ./ui.tgz
```

## General setup

To ensure we stay compatible with the Python implementation, we aim to generate as much as possible based on the `.proto` files.
Expand Down Expand Up @@ -36,7 +46,7 @@ Any incoming requests the Go server cannot process will be proxied to the existi
Any Go-specific options can be passed with `--go-opts`, which takes a comma-separated list of key-value pairs.

```bash
mlflow-go server --backend-store-uri postgresql://postgres:postgres@localhost:5432/postgres --go-opts LogLevel=debug,ShutdownTimeout=5s
mlflow-go server --backend-store-uri postgresql://postgres:postgres@localhost:5432/postgres --go-opts log_level=debug,ShutdownTimeout=5s
```

## Building the Go binary
Expand Down
4 changes: 4 additions & 0 deletions mlflow_go/go/tracking/service/query/parser/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ type ValidCompareExpr struct {
Value interface{}
}

func (v ValidCompareExpr) String() string {
return fmt.Sprintf("%s.%s %s %v", v.Identifier, v.Key, v.Operator, v.Value)
}

type ValidationError struct {
message string
}
Expand Down
14 changes: 7 additions & 7 deletions mlflow_go/go/tracking/store/sql/runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"regexp"
"strings"

"github.com/gofiber/fiber/v2/log"
"github.com/sirupsen/logrus"
"gorm.io/gorm"
"gorm.io/gorm/clause"

Expand Down Expand Up @@ -118,7 +118,7 @@ func getOffset(pageToken string) (int, *contract.Error) {
}

//nolint:funlen,cyclop,gocognit
func applyFilter(database, transaction *gorm.DB, filter string) *contract.Error {
func applyFilter(logger *logrus.Logger, database, transaction *gorm.DB, filter string) *contract.Error {
filterConditions, err := query.ParseFilter(filter)
if err != nil {
return contract.NewErrorWith(
Expand All @@ -128,7 +128,7 @@ func applyFilter(database, transaction *gorm.DB, filter string) *contract.Error
)
}

log.Debugf("Filter conditions: %#v", filterConditions)
logger.Debugf("Filter conditions: %v", filterConditions)

for index, clause := range filterConditions {
var kind any
Expand Down Expand Up @@ -252,12 +252,12 @@ func applyFilter(database, transaction *gorm.DB, filter string) *contract.Error
}

//nolint:funlen, cyclop
func applyOrderBy(database, transaction *gorm.DB, orderBy []string) *contract.Error {
func applyOrderBy(logger *logrus.Logger, database, transaction *gorm.DB, orderBy []string) *contract.Error {
startTimeOrder := false

for index, orderByClause := range orderBy {
components := runOrder.FindStringSubmatch(orderByClause)
log.Debugf("Components: %#v", components)
logger.Debugf("Components: %#v", components)
//nolint:mnd
if len(components) < 3 {
return contract.NewError(
Expand Down Expand Up @@ -361,13 +361,13 @@ func (s TrackingSQLStore) SearchRuns(
transaction.Offset(offset)

// Filter
contractError = applyFilter(s.db, transaction, filter)
contractError = applyFilter(s.logger, s.db, transaction, filter)
if contractError != nil {
return nil, contractError
}

// OrderBy
contractError = applyOrderBy(s.db, transaction, orderBy)
contractError = applyOrderBy(s.logger, s.db, transaction, orderBy)
if contractError != nil {
return nil, contractError
}
Expand Down
5 changes: 3 additions & 2 deletions mlflow_go/go/tracking/store/sql/runs_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/DATA-DOG/go-sqlmock"
"github.com/ncruces/go-sqlite3/gormlite"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gorm.io/driver/mysql"
Expand Down Expand Up @@ -286,7 +287,7 @@ func assertTestData(

transaction := database.Model(&models.Run{})

contractErr := applyFilter(database, transaction, query)
contractErr := applyFilter(logrus.StandardLogger(), database, transaction, query)
if contractErr != nil {
t.Fatal("contractErr: ", contractErr)
}
Expand Down Expand Up @@ -336,7 +337,7 @@ func TestInvalidSearchRunsQuery(t *testing.T) {

transaction := database.Model(&models.Run{})

contractErr := applyFilter(database, transaction, "⚡✱*@❖$#&")
contractErr := applyFilter(logrus.StandardLogger(), database, transaction, "⚡✱*@❖$#&")
if contractErr == nil {
t.Fatal("expected contract error")
}
Expand Down
3 changes: 2 additions & 1 deletion mlflow_go/go/tracking/store/sql/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

type TrackingSQLStore struct {
logger *logrus.Logger
config *config.Config
db *gorm.DB
}
Expand All @@ -23,5 +24,5 @@ func NewTrackingSQLStore(logger *logrus.Logger, config *config.Config) (*Trackin
return nil, fmt.Errorf("failed to connect to database %q: %w", config.TrackingStoreURI, err)
}

return &TrackingSQLStore{config: config, db: database}, nil
return &TrackingSQLStore{logger: logger, config: config, db: database}, nil
}

0 comments on commit c5015fb

Please sign in to comment.