Skip to content

Commit 8ff9862

Browse files
authored
Merge pull request #3 from unboxai/rishab/bento_bug_fix
Fixed model upload tarring issue & updated README
2 parents 7362e3e + ade5764 commit 8ff9862

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ $ pip install -e .
1010

1111
```python
1212
import unboxapi
13-
client = unboxapi.UnboxClient()
13+
client = unboxapi.UnboxClient(email='you@domain.com', password='your_password')
1414

15-
# Package as a bento service and upload to Firebase Storage
16-
client.add(function=predict_function, model=any_model)
15+
# Package a model as a bento service and upload to Firebase
16+
client.add_model(function=predict_function, model=any_model)
17+
18+
# Upload a dataset to Firebase
19+
client.add_dataset(file_path='path/to/dataset.csv', name='dataset_name')
20+
21+
# Upload a pandas data frame to Firebase
22+
client.add_dataframe(df='dataframe_object', name='dataset_name')
1723
```

unboxapi/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import bentoml, getpass, os, pandas as pd, tarfile, tempfile, uuid
1+
import bentoml
2+
import getpass
3+
import os
4+
import pandas as pd
5+
import tarfile
6+
import tempfile
7+
import uuid
28

39
from bentoml.saved_bundle.bundler import _write_bento_content_to_dir
410
from bentoml.utils.tempdir import TempDirectory
@@ -15,7 +21,6 @@ def __init__(self, email: str = None, password: str = None):
1521
self.flask_api = FlaskAPI()
1622
self.firebase_api = FirebaseAPI(email=email, password=password)
1723

18-
1924
def add_model(self, function, model):
2025
bento_service = create_template_model('sklearn', 'text')
2126
bento_service.pack('model', model)
@@ -31,10 +36,9 @@ def add_model(self, function, model):
3136
with tarfile.open(tarfile_path, mode='w:gz') as tar:
3237
tar.add(temp_dir, arcname=bento_service.name)
3338

34-
user_id = self.firebase_api.user['localId']
35-
remote_path = f'users/{user_id}/models/{model_id}'
36-
self.firebase_api.upload(remote_path, tarfile_path)
37-
39+
user_id = self.firebase_api.user['localId']
40+
remote_path = f'users/{user_id}/models/{model_id}'
41+
self.firebase_api.upload(remote_path, tarfile_path)
3842

3943
def add_dataset(self, file_path: str, name: str):
4044
# For now, let's upload straight to Firebase Storage from here
@@ -51,7 +55,6 @@ def add_dataset(self, file_path: str, name: str):
5155
id_token)
5256
return response.json()
5357

54-
5558
def add_dataframe(self, df: pd.DataFrame, name: str):
5659
with tempfile.TemporaryDirectory() as tmp_dir:
5760
dataset_file_path = os.path.join(tmp_dir, str(uuid.uuid1()))

0 commit comments

Comments
 (0)