-
Notifications
You must be signed in to change notification settings - Fork 1.5k
docs: add auto-generated API reference for Python, Rust, and K8s #6989
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
Changes from all commits
9c03eff
96a050c
197ee69
425a3dd
11319ce
481e2cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,17 @@ def get_fs(fs_url: str) -> DirFileSystem: | |
| Args: | ||
| fs_url: The URL of the filesystem to initialize. e.g. s3://bucket, gs://bucket, file:///local/path | ||
|
|
||
| Examples: | ||
| >>> from dynamo.common.storage import get_fs | ||
| >>> | ||
| >>> fs = get_fs("file:///data/media") | ||
| >>> protocol = fs.fs.protocol | ||
| >>> protocol if isinstance(protocol, str) else protocol[0] | ||
| 'file' | ||
| >>> fs = get_fs("s3://my-bucket") | ||
| >>> fs.path | ||
| 'my-bucket' | ||
|
Comment on lines
+49
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid
♻️ Proposed doc tweak- >>> fs = get_fs("file:///tmp/media")
+ >>> fs = get_fs("file:///path/to/media")
@@
- >>> fs = get_fs("file:///tmp/media")
+ >>> fs = get_fs("file:///path/to/media")
@@
- 'file:///tmp/media/videos/req-123.mp4'
+ 'file:///path/to/media/videos/req-123.mp4'Based on learnings: hard-coded constants that reduce portability, including temporary paths, should be replaced with portable alternatives such as Python's Also applies to: 94-99 🤖 Prompt for AI Agents |
||
|
|
||
| Returns: | ||
| The initialized DirFileSystem wrapper for the filesystem. | ||
|
|
||
|
|
@@ -81,6 +92,15 @@ def get_media_url( | |
| ``{base_url}/{storage_path}``. When *None*, the URL is constructed | ||
| from the filesystem's protocol and root path. | ||
|
|
||
| Examples: | ||
| >>> from dynamo.common.storage import get_fs, get_media_url | ||
| >>> | ||
| >>> fs = get_fs("file:///data/media") | ||
| >>> get_media_url(fs, "videos/req-123.mp4") | ||
| 'file:///data/media/videos/req-123.mp4' | ||
| >>> get_media_url(fs, "img.png", base_url="https://cdn.example.com/media") | ||
| 'https://cdn.example.com/media/img.png' | ||
|
|
||
| Returns: | ||
| Public URL string for the uploaded file. | ||
| """ | ||
|
|
@@ -110,6 +130,16 @@ async def upload_to_fs( | |
| data: Raw bytes to upload. | ||
| base_url: Optional CDN / proxy base URL for URL rewriting. | ||
|
|
||
| Examples: | ||
| >>> import asyncio | ||
| >>> from dynamo.common.storage import get_fs, upload_to_fs | ||
| >>> | ||
| >>> fs = get_fs("s3://my-media-bucket") | ||
| >>> image_bytes = b"\\x89PNG..." | ||
| >>> url = asyncio.run( | ||
| ... upload_to_fs(fs, "images/req-123/output.png", image_bytes) | ||
| ... ) # doctest: +SKIP | ||
|
|
||
| Returns: | ||
| Public URL string for the uploaded file. | ||
| """ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.