Skip to content

Commit

Permalink
Merge pull request #997 from gchq/token-download-method
Browse files Browse the repository at this point in the history
Added get_download_file_token method to client
  • Loading branch information
bw27492 authored Jan 12, 2024
2 parents 8cc441d + b69fa5a commit 5211f3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/python-beta/src/bailo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

# SEMANTIC VERSION
__version__ = "0.3.0"
__version__ = "0.4.0"

from bailo.core.agent import Agent, PkiAgent, TokenAgent
from bailo.core.client import Client
Expand Down
10 changes: 8 additions & 2 deletions lib/python-beta/src/bailo/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from io import BytesIO
from typing import Any

from bailo.core.agent import Agent
from bailo.core.agent import Agent, TokenAgent
from bailo.core.enums import ModelVisibility, SchemaKind
from bailo.core.utils import filter_none

Expand Down Expand Up @@ -311,7 +311,13 @@ 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)
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
)
else:
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

Expand Down

0 comments on commit 5211f3b

Please sign in to comment.