feat: Implement Autonomys Auto Drive storage integration with comprehensive API supportFeature/autonomys#60
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2c8484add
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| api_key = os.environ.get('AUTONOMYS_AUTO_DRIVE_API_KEY', 'apikey') | ||
| auth_provider = os.environ.get('AUTONOMYS_AUTO_DRIVE_AUTH_PROVIDER', 'apikey') | ||
|
|
||
| if not api_key: |
There was a problem hiding this comment.
Fail fast when AUTONOMYS_AUTO_DRIVE_API_KEY is unset
If the environment variable is missing, get_provider() silently falls back to the literal 'apikey', so the if not api_key guard never triggers. This means a misconfigured environment will attempt API calls with a placeholder key and return confusing auth errors instead of the explicit configuration error promised by the docstring. This only occurs when the env var is unset, but in that case the tools won’t give the intended guidance.
Useful? React with 👍 / 👎.
| async with download_client.stream("GET", endpoint) as response: | ||
| if response.status_code == 200: | ||
| content = b"" | ||
| async for chunk in response.aiter_bytes(): | ||
| content += chunk |
There was a problem hiding this comment.
Avoid buffering whole file in streaming download
The streaming download method builds the full payload in memory by concatenating chunks (content += chunk) and then returns the full bytes object. For large files, this defeats the advertised streaming behavior and can exhaust memory, especially since StreamDownloadTool is intended for large files. This issue only manifests for large downloads, but in that case it will behave the same as a non‑streaming download.
Useful? React with 👍 / 👎.
🔧 Bug Fix AppliedI've identified and fixed an issue with the async download status endpoint: Problem
FixThe fix has been pushed to branch
Test Results (All Passing ✅)@moonpyt Please merge this fix or cherry-pick commit 1fee3f5 into your PR branch. |
…tream_download alias - Remove incorrect /status suffix from async download status endpoint - Add stream_download() as alias for download_object_stream() for backward compatibility - Clarify that download_id must be UUID, not CID - Update docstrings with correct API endpoint information
Summary
This PR implements a complete integration with Autonomys Auto Drive API, providing a comprehensive SDK for file storage, object management, and download operations.
Features Implemented
📤 Upload Functionality
UploadFileSmallToolUploadFileLargeToolUploadFileToolautomatically selects upload method based on file sizeGetUploadStatusToolfor monitoring upload progress📥 Download Functionality
DownloadObjectToolandStreamDownloadToolfor downloading objects by CIDDownloadPublicObjectToolandStreamDownloadPublicObjectToolfor public objectsCreateAsyncDownloadTool: Initiate async downloadsGetAsyncDownloadStatusTool: Check download statusListAsyncDownloadsTool: List all async downloadsDismissAsyncDownloadTool: Dismiss completed downloads📋 Object Management
GetRootObjectsTool: Get root objects with paginationGetSharedRootObjectsTool: Get shared root objectsGetDeletedRootObjectsTool: Get deleted root objectsSearchObjectsToolwith user/global scope supportGetObjectMetadataToolandGetObjectStatusToolfor object informationPublishObjectTool: Publish objectsUnpublishObjectTool: Unpublish objectsDeleteObjectTool: Delete objectsRestoreObjectTool: Restore deleted objectsShareObjectToolfor sharing objects with publicIdGetObjectSummaryToolfor object summaries🔐 Account Management
GetAccountInfoTool(renamed from Subscription to align with API)Technical Details
Architecture
AutoDriveProvideras the core API clientAutoDriveAPIErrorfor API-specific errorsKey Implementation Details
mainnet.auto-drive.autonomys.xyz) and public downloads (public.auto-drive.autonomys.xyz)Content-TypeandAcceptheaders for different endpointsX-Auth-Providerheader is configurable via environment variableFile Structure