Skip to content

Commit

Permalink
Combined download methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bw27492 committed Jan 12, 2024
1 parent 5d77d54 commit 741728b
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions lib/python-beta/src/bailo/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,34 +311,15 @@ def get_download_file(
:param buffer: BytesIO object for bailo to write to
:return: The unique file ID
"""
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 get_download_file_token(
self,
model_id: str,
file_id: str,
buffer: BytesIO,
):
"""
Downloads a specific file, using an API token.
:param model_id: Unique model ID
:param file_id: Unique file ID
:param buffer: BytesIO object for bailo to write to
:return: The unique file ID
..note:: This method requires the TokenAgent agent.
"""
if isinstance(self.agent, TokenAgent):
req = self.agent.get(
f"{self.url}/v2/token/model/{model_id}/file/{file_id}/download", stream=True, timeout=10_000
)
shutil.copyfileobj(req.raw, buffer)
return file_id
else:
raise Exception("get_download_file_token requires the use of TokenAgent")
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

0 comments on commit 741728b

Please sign in to comment.