fs — direct object-store filesystem (S3 / GCS / Azure / HDFS)
The synutils.fs object auto-routes by URI scheme. Schemeless paths (bucket/key/path) are also accepted — the scheme is inferred from synutils.infrastructure.fileSystemPrefix.
Listing methods — output shape at a glance
Same shape across Python and Scala:
Method | What it returns |
|---|---|
| Files → basenames (last |
| Top-level entries as full URIs — files ( |
| All files recursively as full URIs |
| All files recursively as full URIs |
Methods
Method | Purpose |
|---|---|
| Top-level entries as full URIs |
| All files recursively as full URIs |
| Basenames (see table above) |
| Alias for |
| True if file or folder-prefix exists |
| Upload single file |
| Download single file |
| Recursive upload |
| Recursive download |
| Server-side copy |
| Move single file (single-object mode) or copy a directory tree with filtering (tree mode — see below) |
| Rename in place (same bucket/container) |
| Delete file or prefix |
| Create directory marker |
| Read text content |
| Read raw bytes (Python: |
| Read first N bytes as text |
| Write a text file |
| Lazy read stream for large files |
| Upload from a file-like object. Returns the provider-native upload response (boto3 |
| Filesystem URI prefix ( |
| User's base workspace directory: |
| Local temporary directory ( |
move(src, dest, exclude_folders=None, rewrite_subfolders=None) — full signature
Two modes, dispatched automatically:
Single-object move — when
srcdoes not end with/and no filter parameters are given. Performscopy + deleteon the single object (true move semantic).Tree mode (legacy copy-with-filter) — when
srcends with/or either filter parameter is supplied. Lists every object undersrc, applies the filters, and copies each remaining object to the corresponding path underdest. Mirrors the legacy notebookS3FileSystem.move/GCSFileSystem.movesemantics.
Heads-up: Tree mode does not delete the source. The legacy implementation was effectively a filtered tree-copy despite the
movename — this implementation preserves that behaviour for backward compatibility. If you need a true tree-move, follow up withdelete()on the source prefix.
Parameter | Purpose |
|---|---|
| Source URI. Treat as a directory prefix when it ends with |
| Destination URI. |
| Folder names whose objects should be left in place (not copied) during a tree-mode call. Each entry is normalised to |
|
|
# Single-object move (true move: copy + delete)
synutils.fs.move("s3://bucket/a/file.csv", "s3://bucket/b/file.csv")
# Tree copy with exclusions (legacy behaviour — does NOT delete source)
synutils.fs.move(
"s3://bucket/src/", "s3://bucket/dest/",
exclude_folders=["logs", "temp"],
)
# Tree copy with subfolder rename
synutils.fs.move(
"s3://bucket/src/", "s3://bucket/dest/",
rewrite_subfolders={"old_dir": "new_dir"},
)
Legacy aliases (Python only)
These names still work — they delegate to their canonical counterpart. Use the canonical name in new code.
Canonical | Legacy name |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Examples
Python
synutils.fs.upload("local.csv", "gs://my-bucket/remote.csv")
print(synutils.fs.exists("gs://my-bucket/remote.csv"))
# Listing — three shapes
synutils.fs.list("gs://my-bucket/data/") # basenames (legacy AWS shape)
synutils.fs.ls("gs://my-bucket/data/") # full URIs (top level)
synutils.fs.listRecursive("gs://my-bucket/data/") # full URIs (recursive)
# Read raw bytes
data: bytes = synutils.fs.read("gs://my-bucket/config.bin")
# Inspect environment-derived properties
print(synutils.fs.PREFIX) # "gs://"
print(synutils.fs.getBaseDir()) # "/my-bucket/syn-workspace/workspaces/my-ws"
print(synutils.fs.getLocalTempDir()) # "/tmp"
# upload_stream — capture the response (e.g. ETag / VersionId)
with open("/tmp/data.csv", "rb") as f:
resp = synutils.fs.upload_stream(f, "s3://my-bucket/data.csv")
print(resp["ETag"])Scala
synutils.fs.upload("local.csv", "gs://my-bucket/remote.csv")
println(synutils.fs.exists("gs://my-bucket/remote.csv"))
// Listing — three shapes
synutils.fs.list("gs://my-bucket/data/").foreach(println) // basenames
synutils.fs.ls("gs://my-bucket/data/").foreach(println) // full URIs (top level)
synutils.fs.listRecursive("gs://my-bucket/data/").foreach(println) // full URIs (recursive)
// Read raw bytes
val data: Array[Byte] = synutils.fs.read("gs://my-bucket/config.bin")
// Inspect environment-derived properties
println(synutils.fs.PREFIX) // "gs://"
println(synutils.fs.getBaseDir()) // "/my-bucket/syn-workspace/workspaces/my-ws"
println(synutils.fs.getLocalTempDir()) // "/tmp"