Google Cloud Jupyter Config

0.0.12 · active · verified Thu Apr 16

google-cloud-jupyter-config is a Python library that provides utilities for Jupyter environments to retrieve configuration information directly from the Google Cloud SDK (gcloud CLI) and Google Cloud metadata server. It's designed to be a reusable helper for other Jupyter extensions and applications, enabling seamless access to details like project IDs and authentication tokens. The current version is 0.0.12, with releases being infrequent and often tied to the broader 'jupyter-extensions' project.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to retrieve the Google Cloud project ID and an access token using the library. These functions attempt to read from environment variables (e.g., `GCLOUD_PROJECT`), the `gcloud` CLI configuration, and the Google Cloud metadata server (if running on GCP).

import os
from google_cloud_jupyter_config import project
from google_cloud_jupyter_config import token

# Ensure gcloud CLI is configured, or environment variables are set
# For example, by running 'gcloud auth application-default login' or setting GCLOUD_PROJECT

project_id = project.get_project_id()
if project_id:
    print(f"Google Cloud Project ID: {project_id}")
else:
    print("Could not retrieve Google Cloud Project ID. Is gcloud SDK configured or GCLOUD_PROJECT env var set?")

access_token = token.get_access_token()
if access_token:
    print(f"Google Cloud Access Token (first 10 chars): {access_token[:10]}...")
else:
    print("Could not retrieve Google Cloud Access Token. Is gcloud SDK authenticated?")

view raw JSON →