Skip to content

hotfix: [sdk] Multifile dataset urlsafe #15

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

Merged
merged 3 commits into from
Sep 5, 2024
Merged
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
10 changes: 5 additions & 5 deletions nominal/sdk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import time
from base64 import urlsafe_b64encode
import urllib.parse
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from io import TextIOBase
Expand Down Expand Up @@ -229,8 +229,8 @@ def add_to_dataset_from_io(
raise TypeError(f"dataset {dataset} must be open in binary mode, rather than text mode")

self.poll_until_ingestion_completed()

filename = f"{self.name}{file_extension}"
urlsafe_name = urllib.parse.quote_plus(self.name)
filename = f"{urlsafe_name}{file_extension}"
s3_path = put_multipart_upload(
self._client._auth_header, dataset, filename, "text/csv", self._client._upload_client
)
Expand Down Expand Up @@ -463,7 +463,7 @@ def create_dataset_from_io(

if isinstance(dataset, TextIOBase):
raise TypeError(f"dataset {dataset} must be open in binary mode, rather than text mode")
urlsafe_name = urlsafe_b64encode(name.encode()).decode()
urlsafe_name = urllib.parse.quote_plus(name)
filename = f"{urlsafe_name}{file_extension}"
s3_path = put_multipart_upload(self._auth_header, dataset, filename, "text/csv", self._upload_client)
request = ingest_api.TriggerFileIngest(
Expand Down Expand Up @@ -531,7 +531,7 @@ def create_attachment_from_io(
"""

# TODO(alkasm): create attachment from file/path
urlsafe_name = urlsafe_b64encode(title.encode()).decode()
urlsafe_name = urllib.parse.quote_plus(title)
if isinstance(attachment, TextIOBase):
raise TypeError(f"attachment {attachment} must be open in binary mode, rather than text mode")
s3_path = put_multipart_upload(self._auth_header, attachment, urlsafe_name, mimetype, self._upload_client)
Expand Down