Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.2.0-alpha.25 #336

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.2.0-alpha.24"
".": "0.2.0-alpha.25"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.2.0-alpha.25 (2024-08-29)

Full Changelog: [v0.2.0-alpha.24...v0.2.0-alpha.25](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.24...v0.2.0-alpha.25)

### Features

* fix: batch uploads to VMs broken when using filesystem storage ([31e4195](https://github.com/openlayer-ai/openlayer-python/commit/31e4195f6626d0f789ad6d8f9eeee7b371b144fa))


### Chores

* **internal:** codegen related update ([#333](https://github.com/openlayer-ai/openlayer-python/issues/333)) ([ad43d95](https://github.com/openlayer-ai/openlayer-python/commit/ad43d954c6066f0d0a7518054739cb20cf90ac19))

## 0.2.0-alpha.24 (2024-08-29)

Full Changelog: [v0.2.0-alpha.23...v0.2.0-alpha.24](https://github.com/openlayer-ai/openlayer-python/compare/v0.2.0-alpha.23...v0.2.0-alpha.24)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openlayer"
version = "0.2.0-alpha.24"
version = "0.2.0-alpha.25"
description = "The official Python library for the openlayer API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/openlayer/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "openlayer"
__version__ = "0.2.0-alpha.24" # x-release-please-version
__version__ = "0.2.0-alpha.25" # x-release-please-version
48 changes: 35 additions & 13 deletions src/openlayer/lib/data/_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ def upload(
presigned_url_response=presigned_url_response,
)
else:
return self.transfer_blob(
return self.upload_blob_local(
file_path=file_path,
object_name=object_name,
presigned_url_response=presigned_url_response,
)

Expand All @@ -105,7 +106,9 @@ def upload_blob_s3(
fields = presigned_url_response.fields
fields["file"] = (object_name, f, "application/x-tar")
e = MultipartEncoder(fields=fields)
m = MultipartEncoderMonitor(e, lambda monitor: t.update(min(t.total, monitor.bytes_read) - t.n))
m = MultipartEncoderMonitor(
e, lambda monitor: t.update(min(t.total, monitor.bytes_read) - t.n)
)
headers = {"Content-Type": m.content_type}
res = requests.post(
presigned_url_response.url,
Expand All @@ -116,7 +119,9 @@ def upload_blob_s3(
)
return res

def upload_blob_gcs(self, file_path: str, presigned_url_response: PresignedURLCreateResponse):
def upload_blob_gcs(
self, file_path: str, presigned_url_response: PresignedURLCreateResponse
):
"""Generic method to upload data to Google Cloud Storage and create the
appropriate resource in the backend.
"""
Expand All @@ -137,7 +142,9 @@ def upload_blob_gcs(self, file_path: str, presigned_url_response: PresignedURLCr
)
return res

def upload_blob_azure(self, file_path: str, presigned_url_response: PresignedURLCreateResponse):
def upload_blob_azure(
self, file_path: str, presigned_url_response: PresignedURLCreateResponse
):
"""Generic method to upload data to Azure Blob Storage and create the
appropriate resource in the backend.
"""
Expand All @@ -161,19 +168,34 @@ def upload_blob_azure(self, file_path: str, presigned_url_response: PresignedURL
)
return res

def transfer_blob(
def upload_blob_local(
self,
file_path: str,
object_name: str,
presigned_url_response: PresignedURLCreateResponse,
):
"""Generic method to transfer data to the openlayer folder and create the
appropriate resource in the backend when using a local deployment.
"""
blob_path = presigned_url_response.storage_uri.replace("local://", "")
dir_path = os.path.dirname(blob_path)
try:
os.makedirs(dir_path, exist_ok=True)
except OSError as exc:
raise _exceptions.OpenlayerError(f"Directory {dir_path} cannot be created") from exc
shutil.copyfile(file_path, blob_path)
return None
with tqdm(
total=os.stat(file_path).st_size,
unit="B",
unit_scale=True,
unit_divisor=1024,
colour="BLUE",
) as t:
with open(file_path, "rb") as f:
fields = {"file": (object_name, f, "application/x-tar")}
e = MultipartEncoder(fields=fields)
m = MultipartEncoderMonitor(
e, lambda monitor: t.update(min(t.total, monitor.bytes_read) - t.n)
)
headers = {"Content-Type": m.content_type}
res = requests.post(
presigned_url_response.url,
data=m,
headers=headers,
verify=VERIFY_REQUESTS,
timeout=REQUESTS_TIMEOUT,
)
return res