Skip to content

Commit

Permalink
Route refactoring and UI tweaks (#3)
Browse files Browse the repository at this point in the history
* Remove external resource call in Aim UI

Material Icons are not even actually used.

* Reduce UI built size and memory needed to build

* Refactor routes

- stop using fiber mounts as they were problematic
- make the MLFlow API available directly on / to ease user onboarding
- move health and version to / as well
- fix loading of Aim UI with embedded credentials URL
- use fetch directly to get the version in both UIs
  • Loading branch information
jgiannuzzi authored Apr 4, 2023
1 parent 06db0fa commit 14d0de9
Show file tree
Hide file tree
Showing 24 changed files with 423 additions and 369 deletions.
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
Dockerfile
fasttrack
fasttrack.db*
pkg/ui/*/build*
!pkg/ui/*/build.sh
pkg/ui/*/embed/build*
!pkg/ui/*/embed/build.sh
tests/*/*.src
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:

- name: Mock UI builds
run: |
mkdir pkg/ui/{aim,mlflow}/build
touch pkg/ui/{aim,mlflow}/build/index.html
mkdir pkg/ui/{aim,mlflow}/embed/build
touch pkg/ui/{aim,mlflow}/embed/build/index.html
- name: Check with go vet
run: go vet --tags "${{ steps.tags.outputs.tags }}" ./...
Expand Down Expand Up @@ -74,8 +74,8 @@ jobs:

- name: Mock UI builds
run: |
mkdir pkg/ui/{aim,mlflow}/build
touch pkg/ui/{aim,mlflow}/build/index.html
mkdir pkg/ui/{aim,mlflow}/embed/build
touch pkg/ui/{aim,mlflow}/embed/build/index.html
- name: Run MLFlow integration tests
run: ./tests/mlflow/test.sh
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fasttrack
fasttrack.db*
pkg/ui/*/build*
!pkg/ui/*/build.sh
pkg/ui/*/embed/build*
!pkg/ui/*/embed/build.sh
tests/*/*.src
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Build MLFlow UI
FROM --platform=$BUILDPLATFORM node:16 AS mlflow-build

COPY pkg/ui/mlflow /mlflow
COPY pkg/ui/mlflow/embed /mlflow
RUN /mlflow/build.sh

# Build Aim UI
FROM --platform=$BUILDPLATFORM node:16 AS aim-build

COPY pkg/ui/aim /aim
COPY pkg/ui/aim/embed /aim
RUN /aim/build.sh

# Build fasttrack binary
Expand All @@ -18,8 +18,8 @@ COPY go.mod go.sum ./
RUN go mod download
COPY main.go .
COPY pkg ./pkg
COPY --from=mlflow-build /mlflow/build ./pkg/ui/mlflow/build
COPY --from=aim-build /aim/build ./pkg/ui/aim/build
COPY --from=mlflow-build /mlflow/build ./pkg/ui/mlflow/embed/build
COPY --from=aim-build /aim/build ./pkg/ui/aim/embed/build

ARG TARGETARCH
RUN bash -c "\
Expand Down
138 changes: 0 additions & 138 deletions pkg/api/aim/app.go

This file was deleted.

50 changes: 50 additions & 0 deletions pkg/api/aim/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package aim

import (
"errors"

"github.com/gofiber/fiber/v2"
log "github.com/sirupsen/logrus"
)

func ErrorHandler(c *fiber.Ctx, err error) error {
var e *ErrorResponse
var f *fiber.Error
var d DetailedError

switch {
case errors.As(err, &e):
case errors.As(err, &f):
e = &ErrorResponse{
Code: f.Code,
Message: f.Message,
Detail: "",
}
case errors.As(err, &d):
e = &ErrorResponse{
Code: d.Code(),
Message: d.Message(),
Detail: d.Detail(),
}
default:
e = &ErrorResponse{
Code: fiber.StatusInternalServerError,
Message: err.Error(),
Detail: "",
}
}

fn := log.Errorf

switch e.Code {
case fiber.StatusNotFound:
fn = log.Debugf
case fiber.StatusInternalServerError:
default:
fn = log.Warnf
}

fn("Error encountered in %s %s: %s", c.Method(), c.Path(), err)

return c.Status(e.Code).JSON(e)
}
49 changes: 49 additions & 0 deletions pkg/api/aim/routes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package aim

import (
"github.com/gofiber/fiber/v2"
)

func AddRoutes(r fiber.Router) {
apps := r.Group("apps")
apps.Get("/", GetApps)
apps.Post("/", CreateApp)
apps.Get("/:id/", GetApp)
apps.Put("/:id/", UpdateApp)
apps.Delete("/:id/", DeleteApp)

dashboards := r.Group("/dashboards")
dashboards.Get("/", GetDashboards)
dashboards.Post("/", CreateDashboard)
dashboards.Get("/:id/", GetDashboard)
dashboards.Put("/:id/", UpdateDashboard)
dashboards.Delete("/:id/", DeleteDashboard)

experiments := r.Group("experiments")
experiments.Get("/", GetExperiments)
experiments.Get("/:id/", GetExperiment)
experiments.Get("/:id/activity/", GetExperimentActivity)
experiments.Get("/:id/runs/", GetExperimentRuns)

projects := r.Group("/projects")
projects.Get("/", GetProject)
projects.Get("/activity/", GetProjectActivity)
projects.Get("/pinned-sequences/", GetProjectPinnedSequences)
projects.Post("/pinned-sequences/", UpdateProjectPinnedSequences)
projects.Get("/params/", GetProjectParams)
projects.Get("/status/", GetProjectStatus)

runs := r.Group("/runs")
runs.Get("/active/", GetRunsActive)
runs.Get("/search/run/", GetRunsSearch)
runs.Get("/search/metric/", GetRunsMetricsSearch)
runs.Get("/:id/info/", GetRunInfo)
runs.Post("/:id/metric/get-batch/", GetRunMetricBatch)

tags := r.Group("/tags")
tags.Get("/", GetTags)

r.Use(func(c *fiber.Ctx) error {
return fiber.ErrNotFound
})
}
Loading

0 comments on commit 14d0de9

Please sign in to comment.