Skip to content

Commit

Permalink
Merge pull request #13 from mlops-club/feature/onboarding-instructions
Browse files Browse the repository at this point in the history
Added onboarding instructions
  • Loading branch information
shilongjaycui committed Mar 12, 2024
2 parents bc0fe2e + 5567dcb commit 28de67b
Show file tree
Hide file tree
Showing 58 changed files with 1,171 additions and 1,969 deletions.
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ node_modules
*.vsix
*ipynb*
*venv*
dev-utils/volumes/opt/clearml/agent
dev-utils/volumes/opt/clearml/data
dev-utils/volumes/opt/clearml/logs
dev-utils/volumes/opt/clearml/config/generated_credentials.env
dev-utils/volumes/opt/clearml/config/clearml.conf
dev-utils/volumes/usr
*.log
coverage
coverage
__pycache__/
4 changes: 3 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"amodio.tsl-problem-matcher",
"ms-python.python",
"ms-vscode-remote.remote-ssh",
"GitHub.copilot"
"GitHub.copilot",
"redhat.vscode-yaml",
"ms-vsliveshare.vsliveshare",
]
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
// automatically open the dev VS Code in the clearml-playground-workspace folder
"${workspaceFolder}/dev-utils/clearml-playground-workspace"
"${workspaceFolder}/bentoml-playground-workspace"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
Expand Down
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,15 @@
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
"typescript.tsc.autoDetect": "off",
"json.schemas": [
{
"fileMatch": ["**/*bentofile.json"],
"url": "./src/resources/yamlSchemas/bentofileSchema.json"
}
],
"json.validate.enable": true,
"yaml.schemas": {
"./src/resources/yamlSchemas/bentofileSchema.json": "**/*bentofile.yaml"
}
}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log

All notable changes to the "clearml-session-manager" extension will be documented in this file.
All notable changes to the `vscode-bentoml` extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

Expand Down
269 changes: 37 additions & 232 deletions README.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions bentoml-playground-workspace/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bentoml.bentomlHomeDir": "~/bentoml"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `clearml-playground-workspace`
# `bentoml-playground-workspace`

If you press `F5` to debug this extension, it will open up a development VS Code window
with

- the version of `clearml-session-manager` in this repo, activated
- the version of the `vscode-bentoml` extension in this repo, activated
- this folder as the workspace
3 changes: 3 additions & 0 deletions bentoml-playground-workspace/bentofile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker:
python_version: 3.10
docker_base_image: "python:3.11-slim"
File renamed without changes.
37 changes: 37 additions & 0 deletions bentoml-playground-workspace/linear_regression/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# BentoML Sklearn Example: Linear Regression

0. Install dependencies:

```bash
pip install -r ./requirements.txt
```

1. Train a linear regression model

```bash
python ./train.py
```

2. Run the service:

```bash
bentoml serve service.py:svc
```

3. Send test request

```
curl -X POST -H "content-type: application/json" --data "[[5, 3]]" http://127.0.0.1:3000/predict
```

4. Build Bento

```
bentoml build
```

5. Build docker image

```
bentoml containerize linear_regression:latest
```
5 changes: 5 additions & 0 deletions bentoml-playground-workspace/linear_regression/bentofile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
service: "service.py:svc"
include:
- "service.py"
python:
requirements_txt: "./requirements.txt"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bentoml>=1.0.0
scikit-learn
13 changes: 13 additions & 0 deletions bentoml-playground-workspace/linear_regression/service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import bentoml
from bentoml.io import NumpyNdarray

reg_runner = bentoml.sklearn.get("linear_reg:latest").to_runner()

svc = bentoml.Service("linear_regression", runners=[reg_runner])

input_spec = NumpyNdarray(dtype="int", shape=(-1, 2))


@svc.api(input=input_spec, output=NumpyNdarray())
async def predict(input_arr):
return await reg_runner.predict.async_run(input_arr)
16 changes: 16 additions & 0 deletions bentoml-playground-workspace/linear_regression/train.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from sklearn import linear_model

import bentoml

if __name__ == "__main__":
reg = linear_model.LinearRegression()
reg.fit([[0, 0], [1, 1], [2, 2]], [0, 1, 2])

print("coef: ", reg.coef_)
bento_model = bentoml.sklearn.save_model("linear_reg", reg)
print(f"Model saved: {bento_model}")

# Test running inference with BentoML runner
test_runner = bentoml.sklearn.get("linear_reg:latest").to_runner()
test_runner.init_local()
assert test_runner.predict.run([[1, 1]]) == reg.predict([[1, 1]])
3 changes: 0 additions & 3 deletions dev-utils/clearml-playground-workspace/.vscode/settings.json

This file was deleted.

42 changes: 0 additions & 42 deletions dev-utils/create-clearml-credentials/Dockerfile

This file was deleted.

21 changes: 0 additions & 21 deletions dev-utils/create-clearml-credentials/README.md

This file was deleted.

0 comments on commit 28de67b

Please sign in to comment.