Skip to content

Commit

Permalink
Add MLEM model
Browse files Browse the repository at this point in the history
  • Loading branch information
aguschin committed Nov 13, 2022
1 parent e82890c commit db49645
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 36 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/deploy-model-with-mlem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy MLEM model after GTO Stage assignment
on:
push:
tags:
- "*"
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
parse-git-tag:
name: Figure out what was registered/promoted
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "GTO: figure out what was registered/promoted and show the Registry state"
id: gto
uses: iterative/gto-action@v1
with:
show: true
history: true
# we define the Job outputs here to let the next Job use them
outputs:
name: ${{ steps.gto.outputs.name }}
stage: ${{ steps.gto.outputs.stage }}
event: ${{ steps.gto.outputs.event }}
path: ${{ steps.gto.outputs.path }}
deploy-model:
name: Deploy a MLEM model (act on assigning a new stage)
needs: parse-git-tag
if: needs.parse-git-tag.outputs.event == 'assignment'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
- name: Run `mlem deploy``
run: |
mlem deployment run --load deploy/${{ needs.parse-git-tag.outputs.stage }} --model ${{ needs.parse-git-tag.outputs.path }}
35 changes: 0 additions & 35 deletions .github/workflows/gto-act-on-tags.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .mlem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
core:
state:
uri: s3://gto-mlem-example/mlem-deployment-state
3 changes: 3 additions & 0 deletions deploy/dev.mlem
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object_type: deployment
type: heroku
app_name: mlem-dev
3 changes: 3 additions & 0 deletions deploy/prod.mlem
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object_type: deployment
type: heroku
app_name: mlem-prod
3 changes: 3 additions & 0 deletions deploy/staging.mlem
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object_type: deployment
type: heroku
app_name: mlem-staging
Binary file modified models/churn.pkl
Binary file not shown.
37 changes: 37 additions & 0 deletions models/churn.pkl.mlem
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
artifacts:
data.pkl:
hash: 2979af88eef40c69250d61efef3d94a0
size: 319
uri: churn.pkl
model_type:
io:
type: pickle
methods:
__call__:
args:
- name: data
type_:
ptype: str
type: primitive
name: model
returns:
ptype: str
type: primitive
predict:
args:
- name: data
type_:
ptype: str
type: primitive
name: predict
returns:
ptype: str
type: primitive
type: callable
object_type: model
requirements:
- is_package: false
module: __main__
name: __main__
source64zip: eJw1jtEKwyAMRd/9ipCnFoajrwP3I2OEsKadTK2oLezvp5Xdl+SGey6xPm6pQP5mpWzfvRNfzQJEgb0QgTGARJ5tIMKbgqqD3S5gGqg5rcdjekJFnIThfxrhDhOIywIYtk6gOulZFvDbLG6YufDYK5uSlD2Fnu3R9o3maHXmQ4YTugCeM19f75rW8ePwApl9dEKt0GAuyYYVR/UDFWhG0Q==
type: custom
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
gto
gto
mlem[s3,fastapi,heroku]
11 changes: 11 additions & 0 deletions train.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys

import mlem

if __name__ == "__main__":
value = sys.argv[1] if len(sys.argv) > 1 else "no value"

def model(data):
return value

mlem.api.save(model, "models/churn.pkl", sample_data="string")

0 comments on commit db49645

Please sign in to comment.