Environment variables¶
This notebook reads its settings from environment variables. Set them before starting Jupyter:
S3_BUCKET: name of an S3 bucket you can access
The cells read ganymede-demo/example.zip from that bucket; upload any zip archive there first.
In [ ]:
Copied!
from fsspec import filesystem
from zipp import Path
from zipfile import ZipFile
from fsspec import filesystem
from zipp import Path
from zipfile import ZipFile
In [ ]:
Copied!
import os
from fsspec import filesystem
# Get the remote archive object and download locally
libarchive_fs = filesystem("libarchive", fo=f"s3://{os.environ['S3_BUCKET']}/ganymede-demo/example.zip")
libarchive_fs.ls("", detail=False)
libarchive_fs.info("")
import os
from fsspec import filesystem
# Get the remote archive object and download locally
libarchive_fs = filesystem("libarchive", fo=f"s3://{os.environ['S3_BUCKET']}/ganymede-demo/example.zip")
libarchive_fs.ls("", detail=False)
libarchive_fs.info("")
In [ ]:
Copied!
import os
s3 = filesystem("s3")
tmp = "/tmp/ganymede_demo"
os.makedirs(tmp, exist_ok=True)
local_fp = f"{tmp}/example.zip"
s3.get(rpath=f"s3://{os.environ['S3_BUCKET']}/ganymede-demo/example.zip", lpath=local_fp)
import os
s3 = filesystem("s3")
tmp = "/tmp/ganymede_demo"
os.makedirs(tmp, exist_ok=True)
local_fp = f"{tmp}/example.zip"
s3.get(rpath=f"s3://{os.environ['S3_BUCKET']}/ganymede-demo/example.zip", lpath=local_fp)
In [ ]:
Copied!
from zipp import Path
p = Path(local_fp)
p.stem
from zipp import Path
p = Path(local_fp)
p.stem