Skip to content

Commit

Permalink
unhide create_blob
Browse files Browse the repository at this point in the history
  • Loading branch information
pdevine committed Jan 13, 2025
1 parent f718dab commit a0388b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,12 @@ def _parse_modelfile(self, modelfile: str, base: Optional[Path] = None) -> str:
path = Path(args.strip()).expanduser()
path = path if path.is_absolute() else base / path
if path.exists():
args = f'@{self._create_blob(path)}\n'
args = f'@{self.create_blob(path)}\n'
print(command, args, end='', file=out)

return out.getvalue()

def _create_blob(self, path: Union[str, Path]) -> str:
def create_blob(self, path: Union[str, Path]) -> str:
sha256sum = sha256()
with open(path, 'rb') as r:
while True:
Expand Down Expand Up @@ -1061,12 +1061,12 @@ async def _parse_modelfile(self, modelfile: str, base: Optional[Path] = None) ->
path = Path(args.strip()).expanduser()
path = path if path.is_absolute() else base / path
if path.exists():
args = f'@{await self._create_blob(path)}\n'
args = f'@{await self.create_blob(path)}\n'
print(command, args, end='', file=out)

return out.getvalue()

async def _create_blob(self, path: Union[str, Path]) -> str:
async def create_blob(self, path: Union[str, Path]) -> str:
sha256sum = sha256()
with open(path, 'rb') as r:
while True:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ def test_client_create_blob(httpserver: HTTPServer):
client = Client(httpserver.url_for('/'))

with tempfile.NamedTemporaryFile() as blob:
response = client._create_blob(blob.name)
response = client.create_blob(blob.name)
assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'


Expand All @@ -632,7 +632,7 @@ def test_client_create_blob_exists(httpserver: HTTPServer):
client = Client(httpserver.url_for('/'))

with tempfile.NamedTemporaryFile() as blob:
response = client._create_blob(blob.name)
response = client.create_blob(blob.name)
assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'


Expand Down Expand Up @@ -1098,7 +1098,7 @@ async def test_async_client_create_blob(httpserver: HTTPServer):
client = AsyncClient(httpserver.url_for('/'))

with tempfile.NamedTemporaryFile() as blob:
response = await client._create_blob(blob.name)
response = await client.create_blob(blob.name)
assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'


Expand All @@ -1109,7 +1109,7 @@ async def test_async_client_create_blob_exists(httpserver: HTTPServer):
client = AsyncClient(httpserver.url_for('/'))

with tempfile.NamedTemporaryFile() as blob:
response = await client._create_blob(blob.name)
response = await client.create_blob(blob.name)
assert response == 'sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'


Expand Down

0 comments on commit a0388b2

Please sign in to comment.