Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into BAI-1086-api-token-su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
bw27492 committed Jan 4, 2024
2 parents f83a77e + a9ca366 commit 79e917e
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 370 deletions.
381 changes: 158 additions & 223 deletions backend/package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"adm-zip": "^0.5.10",
"app-root-path": "^3.1.0",
"archiver": "^6.0.1",
"axios": "^1.6.0",
"axios": "^1.6.3",
"bcryptjs": "^2.4.3",
"body-parser": "^1.20.2",
"bunyan": "^1.8.15",
Expand Down Expand Up @@ -55,9 +55,9 @@
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"multer-s3": "^3.0.1",
"nanoid": "^5.0.2",
"nanoid": "^5.0.4",
"node-fetch": "^3.3.2",
"nodemailer": "^6.9.7",
"nodemailer": "^6.9.8",
"open": "^9.1.0",
"openshift-rest-client": "^8.0.1",
"p-mongo-queue": "^8.4.0",
Expand All @@ -68,17 +68,17 @@
"strip-ansi": "^7.1.0",
"unzipper": "^0.10.14",
"utility-types": "^3.10.0",
"uuid": "^9.0.0",
"uuid": "^9.0.1",
"yargs": "^17.7.1",
"yauzl": "^2.10.0",
"zod": "^3.22.4",
"zod-error": "^1.5.0"
},
"devDependencies": {
"@anatine/zod-mock": "^3.13.2",
"@anatine/zod-mock": "^3.13.3",
"@faker-js/faker": "^8.0.2",
"@swc/core": "^1.3.73",
"@types/adm-zip": "^0.5.3",
"@types/adm-zip": "^0.5.5",
"@types/archiver": "^6.0.2",
"@types/bunyan": "^1.8.10",
"@types/config": "^3.3.2",
Expand All @@ -94,20 +94,20 @@
"@types/multer": "^1.4.7",
"@types/node": "^20.10.1",
"@types/nodemailer": "^6.4.14",
"@types/pako": "^2.0.0",
"@types/shelljs": "^0.8.12",
"@types/supertest": "^2.0.16",
"@types/unzipper": "^0.10.7",
"@types/uuid": "^9.0.1",
"@types/pako": "^2.0.3",
"@types/shelljs": "^0.8.15",
"@types/supertest": "^6.0.2",
"@types/unzipper": "^0.10.9",
"@types/uuid": "^9.0.7",
"@types/yauzl": "^2.10.3",
"@typescript-eslint/eslint-plugin": "^5.59.5",
"@typescript-eslint/parser": "^5.62.0",
"@vitest/coverage-v8": "^0.34.6",
"cross-env": "^7.0.3",
"eslint": "^8.52.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"mongodb-memory-server": "^8.13.0",
"mongodb-memory-server": "^9.1.3",
"nodemon": "^3.0.1",
"prettier": "^3.1.0",
"supertest": "^6.3.3",
Expand Down
7 changes: 2 additions & 5 deletions lib/python-beta/src/bailo/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,8 @@ def get_download_file(
:param buffer: BytesIO object for bailo to write to
:return: The unique file ID
"""
with self.agent.get(
f"{self.url}/v2/model/{model_id}/file/{file_id}/download", stream=True, timeout=10_000
) as req:
with buffer as file:
shutil.copyfileobj(req.raw, file)
req = self.agent.get(f"{self.url}/v2/model/{model_id}/file/{file_id}/download", stream=True, timeout=10_000)
shutil.copyfileobj(req.raw, buffer)
return file_id

def simple_upload(self, model_id: str, name: str, buffer: BytesIO):
Expand Down
2 changes: 1 addition & 1 deletion lib/python-beta/src/bailo/helper/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def update(self) -> None:
)
self.__unpack(res["model"])

def update_model_card(self, model_card: dict[str, Any] = None) -> None:
def update_model_card(self, model_card: dict[str, Any] | None = None) -> None:
"""Uploads and retrieves any changes to the model card on Bailo
:param model_card: Model card dictionary, defaults to None
Expand Down
4 changes: 2 additions & 2 deletions lib/python-beta/src/bailo/helper/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ def upload(self, name: str, file: BytesIO) -> Any:
:param name: The name of the file to upload to bailo
:param f: A BytesIO object
:return: A JSON response object
:return: The unique file ID of the file uploaded
"""
res = self.client.simple_upload(self.model_id, name, file).json()
self.files.append(res["file"]["id"])
self.update()
return res
return res["file"]["id"]

def update(self) -> Any:
"""Updates the any changes to this release on Bailo.
Expand Down
3 changes: 1 addition & 2 deletions lib/python-beta/tests/test_access_request.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

import pytest
from bailo.core.client import Client
from bailo.helper.access_request import AccessRequest
from bailo import AccessRequest, Client


def test_access_request():
Expand Down
24 changes: 24 additions & 0 deletions lib/python-beta/tests/test_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import annotations

from io import BytesIO

import pytest
from bailo import Model


@pytest.mark.integration
def test_file_upload(integration_client, example_model: Model):
byte_obj = b"Test Binary"
file = BytesIO(byte_obj)

example_release = example_model.create_release("0.1.0", "test")

with file as file:
file_id = example_release.upload("test", file)

download_file = BytesIO()
example_release.download(file_id, download_file)

# Check that file uploaded has the same contents as the one downloaded
download_file.seek(0)
assert download_file.read() == byte_obj
Loading

0 comments on commit 79e917e

Please sign in to comment.