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

Add multi-file write support to the js and python sdks #451

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b2e80e1
Added multi-file write support
0div Oct 4, 2024
9e6bc17
address PR comments
0div Oct 4, 2024
966f0c7
[WIP] Cleanup
ValentaTomas Oct 5, 2024
eda88d0
address PR comments
0div Oct 7, 2024
a2d4ad7
boyscouting: fix some docstrings
0div Oct 7, 2024
a379a58
Add multi-file write support for python-sdk sync
0div Oct 7, 2024
608ef45
Use `@overload`
0div Oct 8, 2024
68ac038
merge beta
0div Oct 8, 2024
f010211
adapt multi file write tests for nested dirs
0div Oct 8, 2024
fbc4af4
allow passing empty array of files in python-sdk
0div Oct 8, 2024
2afb6d1
allow passing empty array of files in js-sdk
0div Oct 8, 2024
68e5efa
address PR comments
0div Oct 9, 2024
365af43
add extra tests to sandbox_sync write
0div Oct 9, 2024
7767d8f
updated js-sdk tests to check empty path behavior
0div Oct 9, 2024
f5cd1c0
add multifile upload to sanbox_async
0div Oct 9, 2024
834f84c
merge beta
0div Oct 10, 2024
2956a6e
better error messages in python-sdk
0div Oct 10, 2024
c277f9f
better error messages in js-sdk
0div Oct 10, 2024
86262f1
docstring for dataclass
0div Oct 10, 2024
97d0cc1
merge main
0div Dec 12, 2024
cf262ae
fix errors.ts comment
0div Dec 12, 2024
4ca2414
fixed typing syntax and watch tests
0div Dec 12, 2024
93dc1f9
update docs
0div Dec 12, 2024
741b329
add minor changeset
0div Dec 12, 2024
bbeeb04
upadte upload docs and improve read-write-docs
0div Dec 12, 2024
0e2a684
fix indentation in upload docs
0div Dec 13, 2024
b867fe4
Update apps/web/src/app/(docs)/docs/filesystem/read-write/page.mdx
0div Dec 13, 2024
e730810
Update apps/web/src/app/(docs)/docs/filesystem/read-write/page.mdx
0div Dec 13, 2024
d3b99fe
Update apps/web/src/app/(docs)/docs/filesystem/upload/page.mdx
0div Dec 13, 2024
424baec
Update apps/web/src/app/(docs)/docs/filesystem/upload/page.mdx
0div Dec 13, 2024
e73ad23
Update apps/web/src/app/(docs)/docs/filesystem/upload/page.mdx
0div Dec 13, 2024
d0fc09a
Update apps/web/src/app/(docs)/docs/filesystem/upload/page.mdx
0div Dec 13, 2024
1708cc0
Update apps/web/src/app/(docs)/docs/filesystem/upload/page.mdx
0div Dec 13, 2024
502c414
remove WriteData type in js-sdk
0div Dec 13, 2024
724fbc6
remove WriteData type in python-sdk
0div Dec 13, 2024
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
Prev Previous commit
Next Next commit
allow passing empty array of files in python-sdk
  • Loading branch information
0div committed Oct 8, 2024
commit fbc4af4908eaff58f06b7782577a78899e7f11c6
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def write(
When writing to a file that's in a directory that doesn't exist, you'll get an error.
"""

path, write_files, user, request_timeout, = None, [], "user", None
path, write_files, user, request_timeout = None, [], "user", None
if isinstance(path_or_files, str):
if isinstance(data_or_user, list):
raise Exception("Cannot specify path with array of files")
0div marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -165,9 +165,6 @@ def write(
path, write_files, user, request_timeout = \
None, path_or_files, data_or_user, user_or_request_timeout

if len(write_files) == 0:
raise Exception("Need at least one file to write")

# Prepare the files for the multipart/form-data request
httpx_files = []
for file in write_files:
Expand All @@ -178,6 +175,9 @@ def write(
httpx_files.append(('file', (file_path, file_data.read())))
else:
raise ValueError(f"Unsupported data type for file {file_path}")

# Allow passing empty list of files
if len(httpx_files) == 0: return []

params = {"username": user}
if path is not None: params["path"] = path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ def test_write_file(sandbox):

def test_write_multiple_files(sandbox):
# Attempt to write with empty files array
try:
sandbox.files.write([])
except Exception as e:
assert "Need at least one file to write" in str(e)
empty_info = sandbox.files.write([])
assert isinstance(empty_info, list)
assert len(empty_info) == 0

# Attempt to write with path and file array
try:
Expand Down