Skip to content

Commit

Permalink
Add downloading to notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
GB27247 committed Jan 23, 2024
1 parent 90f0c5b commit ba640a5
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 19 deletions.
115 changes: 97 additions & 18 deletions lib/python-beta/notebooks/models_and_releases_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -92,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -132,9 +132,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.card_from_schema(schema_id='minimal-general-v10-beta')\n",
"\n",
Expand All @@ -155,9 +166,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_card = {\n",
" 'overview': {\n",
Expand Down Expand Up @@ -203,9 +225,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'YOLOv5 model for object detection.'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model = Model.from_id(client=client, model_id=model_id)\n",
"\n",
Expand Down Expand Up @@ -253,7 +286,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -280,9 +313,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"yolov5-wb9i5i\n",
"yolov5-wb9i5i\n"
]
}
],
"source": [
"print(release_one.model_id)\n",
"print(model.model_id)\n",
Expand All @@ -291,6 +333,35 @@
" release_one.upload(\"demo_file.txt\", f)"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Downloading files from release\n",
"\n",
"Similarly you can also download files from release using a response object. Using the same release you can view the contents of **demo_file** as follows."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"b'This is a demo file.\\n'\n"
]
}
],
"source": [
"res = release_one.download(\"demo_file.txt\")\n",
"\n",
"print(res.content)"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand All @@ -309,9 +380,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Successfully retrieved identical releases!\n"
]
}
],
"source": [
"release_latest = model.get_latest_release()\n",
"release_one = model.get_release(version='1.0.0')\n",
Expand Down
2 changes: 1 addition & 1 deletion lib/python-beta/src/bailo/helper/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def from_version(cls, client: Client, model_id: str, version: Version | str) ->
draft,
)

def download(self, filename: str) -> str:
def download(self, filename: str) -> Any:
"""Give returns a Reading object given the file id.
:param filename: The name of the file to retrieve
Expand Down

0 comments on commit ba640a5

Please sign in to comment.