Skip to content

SOF-8099: add client.files to upload, sign and delete account files - #51

Merged
k0stik merged 3 commits into
mainfrom
chore/SOF-8099-1
Nov 4, 2026
Merged

k0stik merged 3 commits into
mainfrom
chore/SOF-8099-1

Conversation

@k0stik

@k0stik k0stik commented Nov 3, 2026

Copy link
Copy Markdown
Member

What

client.files (FileEndpoints) for the account's object storage folder ("Dropbox"), so notebooks and scripts upload with one call:

records = client.files.upload({"user_script.py": script_text, "model.pt": model_bytes}, account_id=ACCOUNT_ID)
  • upload(files, account_id=None): text is encoded as UTF-8; the platform signs one PUT URL per file for its exact size and guessed content type (POST files/signed-urls, putObject), and each file is PUT to storage with the returned headers. Returns name, key, size, bucket, region, provider per file.
  • get_upload_urls(files), get_download_urls(names), delete(names): the routes themselves. A name ending in / is a folder.

Why

The platform no longer accepts file bodies (mat3ra/web-app#3026): the bytes go straight to storage. The two steps (sign, PUT with the signed headers) lived in api-examples' notebooks_utils; here they sit next to the other endpoints and keep the notebooks simple (mat3ra/api-examples#408).

client.py is reformatted by the black pre-commit hook (it was not black-formatted on main); the only real change there is self.files.

Testing

  • Unit tests: tests/py/unit/test_files.py (signing payload, PUT with signed headers, records, storage refusal, download URLs, delete).
  • Against a local web-app with S3: text and binary upload, download round-trip, folder delete.
  • JupyterLite: the PUT uses requests, like the rest of the client; checked through api-examples#408.

🤖 Generated with Claude Code

k0stik and others added 2 commits November 3, 2026 22:40
The platform no longer takes file bodies: it signs a PUT URL per file (files/signed-urls,
putObject) for the declared size and content type, and the client PUTs the bytes to storage
with the returned headers. FileEndpoints.upload does both steps, so a caller passes names and
content only. get_download_urls and delete cover the other two routes. client.py is
reformatted by the black hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
k0stik added a commit to mat3ra/api-examples that referenced this pull request Nov 3, 2026
The sign-and-PUT steps move to mat3ra-api-client (FileEndpoints, mat3ra/api-client#51), so
the custom calculation notebooks call client.files.upload and notebooks_utils keeps only
to_object_storage_input. Until that PR is released, pyproject.toml pins its commit and
config.yml installs a wheel built from it (packages/); both go back to a released version
before merging.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ubuntu-latest now resolves to Ubuntu 26.04, for which actions/setup-python has no 3.10.13
build, so the test job fails before it runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@k0stik
k0stik merged commit aef2985 into main Nov 4, 2026
3 checks passed
@k0stik
k0stik deleted the chore/SOF-8099-1 branch November 4, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants