Skip to content

Commit 605fe33

Browse files
RRM123ckadner
authored andcommitted
Update UI developer docs (#323)
Closes #323 Signed-off-by: RRM123 <[email protected]>
1 parent fe965be commit 605fe33

File tree

5 files changed

+93
-119
lines changed

5 files changed

+93
-119
lines changed

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ Allows upload, registration, execution, and deployment of:
1313
- Datasets
1414
- Notebooks
1515

16-
For more details about the project please follow this [announcement blog post](https://lfaidata.foundation/blog/2021/09/28/machine-learning-exchange-mlx/).
17-
18-
19-
<img src="docs/images/mlx.png" height="90%" width="90%">
20-
2116
Additionally it provides:
2217

2318
- Automated sample pipeline code generation to execute registered models, datasets and notebooks
@@ -28,6 +23,12 @@ Additionally it provides:
2823
- Serving engine by [KFServing](https://github.com/kubeflow/kfserving)
2924
- Model Metadata schemas
3025

26+
For more details about the project check out this [announcement blog post](https://lfaidata.foundation/blog/2021/09/28/machine-learning-exchange-mlx/).
27+
28+
29+
<img src="docs/images/mlx.png" height="90%" width="90%">
30+
31+
3132
## 1. Deployment
3233
<img src="docs/images/mlx-architecture-4.png" height="40%" width="40%">
3334

@@ -66,13 +67,19 @@ oc get route -n istio-system
6667

6768
## 3. Import Data and AI Assets in MLX Catalog
6869

69-
[Import data and AI assets using MLX's catalog importer](/docs/import-assets.md)
70+
For information on how to import data and AI assets using MLX's catalog importer, use this [guide](/docs/import-assets.md).
7071

7172
## 4. Use MLX
7273

73-
[MLX Usage Instructions](/docs/usage-steps.md)
74-
75-
## 5. Troubleshooting
74+
For information on how to use MLX and create assets check out this [guide](/docs/usage-steps.md).
75+
76+
## 5. How to Contribute
77+
78+
For information about adding new features, bug fixing, communication
79+
or UI and API setup, refer to this [document](CONTRIBUTING.md).
80+
81+
82+
## 6. Troubleshooting
7683

7784
[MLX Troubleshooting Instructions](/docs/troubleshooting.md)
7885

dashboard/origin-mlx/OLD_README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

dashboard/origin-mlx/README.md

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
# Machine Learning Exchange - Web UI
22

3-
## Setup
3+
This README contains information about the front end of the Machine Learning Exchange project.
44

5-
This repo contains the code for the front end UI of the Machine Learning Exchange project.
5+
## Prerequisites
66

7-
To run this app, you'll need a current version of Node.js installed.
7+
- [Node.js](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
8+
to build and run the MLX UI code locally
9+
- [Docker](https://docs.docker.com/get-docker/) to rebuild the MLX UI image
10+
- [`kubectl`](https://kubernetes.io/docs/tasks/tools/#kubectl) to redeploy
11+
the `mlx-ui` service to Kubernetes
12+
13+
14+
## Starting the MLX UI locally
815

916
1. First, clone this repo:
1017
```Bash
@@ -43,55 +50,80 @@ npm start
4350
http://localhost:3000/settings
4451
```
4552

46-
## Deploy MLX UI to Kubernetes
53+
# Development Setup
54+
55+
## Build a Docker Image for MLX UI
56+
57+
```Bash
58+
cd dashboard/origin-mlx
59+
docker build -t <your docker user-id>/<repo name>:<tag name> -f Dockerfile .
60+
docker push <your docker user-id>/<repo name>:<tag name>
61+
```
62+
63+
## (Re-)Deploy to Kubernetes Cluster
64+
65+
For information on how to deploy MLX on a Kubernetes Cluster or OpenShift on IBM
66+
Cloud, check out the guide [here](/docs/mlx-setup.md).
67+
Once the cluster has been deployed, the new `mlx-ui` container image will need to
68+
be redeployed after changes to the UI code have been made.
69+
70+
Change the container image in the deployment spec
71+
[/manifests/base/mlx-deployments/mlx-ui.yaml](/manifests/base/mlx-deployments/mlx-ui.yaml)
72+
under `spec.template.spec.containers` with `name: mlx-ui`
73+
from `image: mlexchange/mlx-ui:nightly`
74+
to `image: <your_docker_user_id>/<repo_name>:<tag_name>`
75+
and then run:
4776

48-
First deploy the MLX UI.
4977
```Bash
50-
kubectl apply -f ./dashboard/origin-mlx/mlx-ui.yml
78+
# navigate to the MLX root directory
79+
# cd ../..
80+
kubectl delete -f manifests/base/mlx-deployments/mlx-ui.yaml
81+
kubectl apply -f manifests/base/mlx-deployments/mlx-ui.yaml
5182
```
5283

5384
Find the UI Host and Port. It may take some time before the MLX UI becomes available.
85+
5486
```Bash
5587
export UI_HOST=$(kubectl get nodes -o jsonpath='{.items[].status.addresses[?(@.type=="ExternalIP")].address}')
5688
export UI_PORT=$(kubectl get service mlx-ui -n kubeflow -o jsonpath='{.spec.ports[0].nodePort}')
5789
```
90+
5891
Open the webpage in a browser:
5992

6093
```Bash
6194
open "http://${UI_HOST}:${UI_PORT}"
6295
```
6396

64-
# Development Setup
65-
66-
## Build a Docker Image for MLX UI
67-
68-
```Bash
69-
cd dashboard/origin-mlx
70-
docker build -t <your docker user-id>/<repo name>:<tag name> -f Dockerfile .
71-
docker push <your docker user-id>/<repo name>:<tag name>
72-
```
97+
## UI Development with Docker Compose
7398

74-
## (Re-)Deploy to Kubernetes Cluster
99+
For information on how to get started with Docker Compose before making any changes
100+
to the UI code, check out the [Quick Start Guide](/quickstart/README.md) and
101+
take a look at the [docker-compose.yaml](/quickstart/docker-compose.yaml) file
102+
to understand how the individual services like `mysql`, `minio`, `mlx-api`, `mlx-ui`,
103+
etc. are working together.
75104

76-
Change the Docker image tag in the deployment spec server/mlx-ui.yml from image: ibmandrewbutler/open-ui:add-homepage to image: <your_docker_user_id>/<repo name>:<tag name> and then run:
105+
The Docker Compose stack can be brought up and taken down by running the following
106+
commands. The `--project-name` tag keeps the docker compose network and the volumes
107+
(stored assets) separate from the quickstart for development. Each docker compose
108+
project has separate network and volumes which can be viewed using
109+
[Docker Desktop](https://www.docker.com/products/docker-desktop/):
77110

78111
```Bash
79-
kubectl delete -f ./dashboard/origin-mlx/mlx-ui.yml
80-
kubectl apply -f ./dashboard/origin-mlx/mlx-ui.yml
112+
docker compose --project-name mlx up
113+
docker compose --project-name mlx down
81114
```
82115

83-
## UI Development with Docker Compose
84-
85116
You can test most code changes without a Kubernetes cluster. A K8s cluster is only
86117
required to `run` the generated sample pipeline code. Running the Quickstart with
87118
Docker Compose is sufficient to test any `katalog` related API endpoints.
88119

89120
A development setup that works very well requires to 2 shell terminals:
90121

91-
### Terminal 1 - Quickstart without `mlx-ui` service
122+
### Terminal 1 - Quickstart without the `mlx-ui` service
92123

93124
Bring up the Quickstart without the `mlx-ui` service, since we will run the MLX UI
94-
from our local source code, instead of using the pre-built Docker image `mlexchange/mlx-ui:nightly-origin-main`.
125+
from our local source code, instead of using the pre-built Docker image
126+
`mlexchange/mlx-ui:nightly-origin-main`.
95127

96128
```Bash
97129
# cd <mlx_root_directory>
@@ -116,7 +148,7 @@ docker compose rm -v -f
116148
docker volume prune -f
117149
```
118150

119-
### Terminal 2 - Start the UI server
151+
### Terminal 2 - Start the MLX UI locally
120152

121153
Navigate to the UI source folder:
122154

@@ -185,6 +217,10 @@ which matches a previous request and the difference of the time between the two
185217

186218
To invalidate or hard reset the cache, navigate to the settings page (clicking the three dots at the bottom of the sidebar) and click on the `Reset Cache` button.
187219

220+
# Development Guidelines:
221+
222+
For information on UI code structure, design principles, etc. check out the [MLX UI Developer Guide](developer-guide.md).
223+
188224
# Project Overview:
189225

190226
![MLX Overview](src/images/image1.png)
Lines changed: 14 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# MLX UI (w/ React)
22

33
## React Design Principles
4+
45
The key feature of React is composition of components. React works by having pages use components to add functionality which themselves use components to add functionality.
56

67
![LandingPage](/docs/images/LandingPage.png)
@@ -11,107 +12,45 @@ Image 1: The Landing Page divided into some of its components.
1112

1213
Image 2: MLX UI structure
1314

14-
15-
React Props vs. State:
15+
### React Props vs. State:
1616

1717
A components props and state are variables which dictate the changeable content of a component. For example, take a parent component that is a webpage and take a child component which represents a Button. The parent could ask for two Buttons with the text="Press" on one and text="Click" on the other. "Press" and "Click" would be the value of the variable props.text and should not be changed inside of the Button component. The state of these Buttons could be something like "clickNum" which defines how many times the button has been clicked. 
1818
Props - Parameters passed from the parent component. Props should not be changed inside the child component. If a prop is changed in a parent component then the child component will be recreated.
1919
State - Variables that dictate the current condition of the component. State can be changed inside the component. If a state variable is changed in a component then the component will be recreated.
2020

21-
22-
Lifecycle Methods:
21+
### Lifecycle Methods:
2322

2423
Each component has several “lifecycle methods” that you can override to run code at particular times in the process. Putting functions in different lifecycle methods will cause the function to be run at a specific point in a component's lifecycle. An example of this is running a function after a component is being unmounted (removed or refreshed).
2524

26-
## Startup
27-
28-
General Startup Instructions: https://github.com/machine-learning-exchange/mlx/tree/main/dashboard/origin-mlx
29-
30-
### Starting the MLX UI locally
31-
32-
To run this app, you'll need a current version of Node.js installed.
33-
34-
1. First, clone this repo:
35-
```Bash
36-
git clone https://github.com/machine-learning-exchange/mlx.git
37-
```
38-
39-
2. Next, install the dependencies by running this command from within the newly created directory:
40-
```Bash
41-
npm install
42-
```
43-
44-
3. Start the app with the following command:
45-
```Bash
46-
npm start
47-
```
48-
49-
4. The app should now be accessible in your web browser at:
50-
```
51-
http://localhost:3000
52-
```
53-
54-
### Starting the MLX UI locally with Docker API
55-
```
56-
git clone https://github.com/machine-learning-exchange/mlx.git
57-
cd mlx/
58-
cd dashboard/origin-mlx/
59-
rm -rf package-lock.json 
60-
npm install
61-
export REACT_APP_API="localhost:8080"
62-
export REACT_APP_RUN="false"
63-
export REACT_APP_UPLOAD="true"
64-
export REACT_APP_DISABLE_LOGIN="true"
65-
npm start
66-
```
67-
68-
### Building an MLX UI Image
69-
70-
```
71-
cd dashboard/origin-mlx
72-
docker build -t <your docker user-id>/<repo name>:<tag name> -f Dockerfile .
73-
docker push <your docker user-id>/<repo name>:<tag name>
74-
```
75-
76-
### Change the UI image on a cluster deployment
77-
Change the image in /manifests/base/mlx-deployments/mlx-ui.yaml under the container with the name mlx-ui at spec.template.spec.containers
78-
```
79-
kubectl delete -f /manifests/base/mlx-deployments/mlx-ui.yaml
80-
kubectl apply -f /manifests/base/mlx-deployments/mlx-ui.yaml
81-
```
8225

8326
## UI File Structure
8427

8528
The folders which contain the pieces of the MLX UI:
8629

8730
![LandingPage](/docs/images/ui-folder-tree.png)
8831

89-
90-
91-
- **components/** - Small items which get used inside of pages. For example, the sidebar is used in all the pages, but is not a page itself. The major components are listed below.
32+
- **components/** - Small items which get used inside of pages. For example, the sidebar is used in all the pages, but is not a page itself. The major components are listed below.
9233
- **Button/**
9334
- **Detail/** - The Detail folder contains the specific implementations of each asset type for the MetaDetailPage. The ComponentDetail, for example, has a MetadataView, RunView, and two SourceCodeDisplays. The ComponentDetail file represents the content of the MetaDetailPage for the Component assets.
9435
- **RunView/** - Contains the displays which dictate what parameters the user must fill out when attempting to run any of the assets
9536
- **Sidebar/**
9637
- **Tooltip/**
9738

98-
9939
- There are other components other than those which make up their own folder. Some of the important ones are listed below.
10040
- Hero - The “Hero Bar” is the bar at the top of the page with mostly navigational items.
10141
- MarkdownViewer - A display which shows the contents of a markdown file
10242
- PageFooter - The content that gets displayed at the bottom of every page
10343
- SecretMenu - The menu which is only available for admins that provides admin’s with extra functionality
10444

10545
- **icons/**
106-
Icons are typically an .svg wrapped in a react component.
46+
Icons are typically an `.svg` wrapped in a React component.
10747

10848
- **images/**
109-
.png files used in UI
49+
`.png` files used in UI
11050

111-
- **lib/**
112-
lib/ is divided into two folders api/ and stores/
113-
api/ - Contains all the functions which calls to the MLX API.
114-
stores/ - Contains all the functions which add to and view the MLX UI data store 
51+
- **lib/** `lib/` is divided into two folders `api/` and `stores/`
52+
- `api/` - Contains all the functions which calls to the MLX API
53+
- `stores/` - Contains all the functions which add to and view the MLX UI data store
11554

11655
- **mock/**
11756
Some mock assets for each asset type (no longer in use).
@@ -124,12 +63,12 @@ Most (>90%) of styling is contained in css files in styles/
12463

12564
## Developing for the MLX UI
12665

66+
### MLX UI Starting Points
12767

128-
MLX UI Starting Points
129-
src/App.tsx controls all the routing inside the react application. If a new route needs to be added it will be added here. If it is not clear what file represents the page at a given url, trace the routes in App.tsx to find the route associated with that url and that route will show the component that is being used.
130-
68+
- `src/App.tsx`: controls all the routing inside the react application. If a new route needs to be added it will be added here. If it is not clear what file represents the page at a given url, trace the routes in App.tsx to find the route associated with that url and that route will show the component that is being used.
13169

132-
src/styles/ contains most (>90%) of the page styling in css. If the style needs to be changed first check the component file for styling and if the css is not inline then check in src/styles/.
70+
- `src/styles/`: contains most (>90%) of the page styling in css. If the style needs to be changed first check the component file for styling and if the css is not inline then check in src/styles/.
13371

72+
- `src/lib/api/`: contains all the calls to the MLX API. If some API call is going wrong, it will likely be an issue in this folder.
13473

135-
src/lib/api/ contains all of the calls to the MLX API. If some API call is going wrong, it will likely be an issue in this folder.
74+
For more information on UI Setup and Deployment go [here](README.md)

dashboard/origin-mlx/mlx-ui.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2021 The MLX Contributors
2-
#
2+
#
33
# SPDX-License-Identifier: Apache-2.0
44
apiVersion: v1
55
kind: ServiceAccount
@@ -28,11 +28,11 @@ spec:
2828
containers:
2929
- name: mlx-ui
3030
# You can use your own webapp image below
31-
image: aipipeline/mlx-ui:nightly-origin-master
31+
image: mlexchange/mlx-ui:nightly-origin-main
3232
imagePullPolicy: Always
3333
env:
3434
- name: REACT_APP_BRAND
35-
value: MLX
35+
value: "Machine Learning eXchange"
3636
- name: REACT_APP_RUN
3737
value: "true"
3838
- name: REACT_APP_UPLOAD

0 commit comments

Comments
 (0)