Registry /
gcp / runai-model-streamer-gcs
Install & Compatibility
Where this runs
tested against v0.16.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
build_error
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 5.3s · import 0.000s · 149MB
148MB installed
● package 148MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
GCSStreamer
✓ from runai_model_streamer_gcs import GCSStreamer
✗ from runai_model_streamer_gcs import GCSStreamer
This quickstart demonstrates how to use `GCSStreamer` to either stream a model directly from Google Cloud Storage as a file-like object or download it to a temporary local file. Ensure your environment is authenticated with GCP and `GCS_MODEL_PATH` is set to a valid object path (e.g., `gs://my-bucket/models/my_model.pt`). This code includes checks to prevent execution with placeholder paths.
import os
from runai.model_streamer.gcs import GCSStreamer
# --- Setup GCS Path (replace with your actual path) ---
# For a real scenario, ensure your environment is authenticated with GCP.
# E.g., by setting GOOGLE_APPLICATION_CREDENTIALS or using `gcloud auth login`.
# This example uses a placeholder and will not work without a valid GCS path and auth.
gcs_model_path = os.environ.get(
'GCS_MODEL_PATH',
'gs://your-bucket-name/path/to/your/model.pt' # REPLACE THIS
)
# --- Example 1: Stream a file-like object ---
# Useful for frameworks that can load directly from file-like objects (e.g., PyTorch torch.load)
try:
if not gcs_model_path.startswith('gs://your-bucket-name'): # Check if placeholder is still there
print(f"Attempting to stream from: {gcs_model_path}")
with GCSStreamer.open(gcs_model_path, 'rb') as f:
# In a real scenario, you'd load your model here, e.g., model = torch.load(f)
print(f"Successfully opened GCS object for streaming: {gcs_model_path}")
else:
print("Skipping streaming example: GCS_MODEL_PATH not set or is placeholder.\nSet GCS_MODEL_PATH environment variable or modify the script.")
except Exception as e:
print(f"Error during streaming: {e}")
# --- Example 2: Download to a local temporary file ---
# Useful for frameworks that require a local file path (e.g., Hugging Face, TensorFlow)
local_temp_path = '/tmp/my_streamed_model.tmp'
try:
if not gcs_model_path.startswith('gs://your-bucket-name'): # Check if placeholder is still there
print(f"Attempting to download from: {gcs_model_path} to {local_temp_path}")
GCSStreamer.download_file(gcs_model_path, local_temp_path)
# In a real scenario, you'd load your model here, e.g., model = MyFramework.load(local_temp_path)
print(f"Successfully downloaded GCS object to: {local_temp_path}")
else:
print("Skipping download example: GCS_MODEL_PATH not set or is placeholder.\nSet GCS_MODEL_PATH environment variable or modify the script.")
except Exception as e:
print(f"Error during download: {e}")
finally:
if os.path.exists(local_temp_path):
os.remove(local_temp_path) # Clean up temporary file
print(f"Cleaned up temporary file: {local_temp_path}")
Debug
Known issues
gotchaGCP Authentication is required for accessing Google Cloud Storage. Ensure your environment variables (`GOOGLE_APPLICATION_CREDENTIALS`) or default GCP project authentication is correctly configured. Without proper authentication, all GCS operations will fail with permission errors.fixRefer to Google Cloud's documentation for authenticating Python applications to GCP services (e.g., `gcloud auth application-default login` or setting `GOOGLE_APPLICATION_CREDENTIALS` to a service account key file).
affects: All versions
gotchaThe `runai-model-streamer-gcs` package strictly depends on the `model-streamer-base` package with the same major and minor version (e.g., `~=0.15.8`). When upgrading, ensure both packages are updated simultaneously to avoid compatibility issues.fixAlways install/upgrade both `runai-model-streamer-gcs` and `model-streamer-base` together, or let `pip` manage the base dependency automatically when installing `runai-model-streamer-gcs`.
affects: All versions
gotchaThe library supports two main patterns: `GCSStreamer.open` for streaming as a file-like object and `GCSStreamer.download_file` for downloading to a local path. Choose the method appropriate for your ML framework, as some require a local file path (e.g., certain Hugging Face model loaders) while others can load from file-like objects (e.g., PyTorch's `torch.load`).fixConsult your ML framework's documentation on model loading. If it supports loading from a file-like object, `GCSStreamer.open` is more efficient. Otherwise, use `GCSStreamer.download_file`.
affects: All versions
deprecatedThe `runai-model-streamer-gcs` package officially requires Python versions between 3.8 and 3.11 (inclusive). While it might function with newer Python versions, compatibility is not guaranteed, and issues may arise. PyPI metadata explicitly states `requires_python: >=3.8,<3.12`.fixEnsure your Python environment is within the supported range (3.8-3.11). Check the project's official `pyproject.toml` or `setup.py` for updated `requires_python` metadata if you encounter compatibility issues with newer Python versions.
affects: 0.15.x and earlier
Upgrade
Version history
0.16.0latest on PyPI · released May 28, 2026
Audit
Dependencies
google-cloud-storagerequiredRequired for interacting with Google Cloud Storage.
model-streamer-baserequiredCore functionality for model streaming.