{"library":"ml-goodput-measurement","title":"ML Goodput Measurement","description":"ML Goodput Measurement (ml-goodput-measurement) is a Python library designed to monitor and analyze the efficiency of Machine Learning (ML) workloads. It tracks metrics such as Goodput, Badput, and step time deviation, integrating with Google Cloud Logging, Google Cloud Monitoring, and TensorBoard for data storage, visualization, and alerting. The library is actively maintained, with minor version releases occurring roughly monthly or bi-monthly, and is currently at version 0.0.16.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install ml-goodput-measurement"],"cli":null},"imports":["from goodput import GoodputMonitor","from goodput import GoodputRecorder","from goodput import GoodputCalculator"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport time\nfrom goodput import GoodputMonitor, GoodputRecorder\n\n# --- Configuration Parameters (replace with your actual values) ---\n# IMPORTANT: Use unique run_name and logger_name for each experiment to avoid data corruption.\nJOB_NAME = os.environ.get('GOODPUT_JOB_NAME', 'my-ml-training-job-unique-id')\nLOGGER_NAME = os.environ.get('GOODPUT_LOGGER_NAME', f'goodput_{JOB_NAME}')\nTENSORBOARD_DIR = os.environ.get('GOODPUT_TENSORBOARD_DIR', '/tmp/tensorboard_logs')\n\n# --- Initialize Recorder to log productive steps ---\nrecorder = GoodputRecorder(\n    job_name=JOB_NAME,\n    logger_name=LOGGER_NAME,\n    logging_enabled=True  # Set to True to enable logging to Google Cloud Logging\n)\n\n# --- Simulate a training loop ---\nprint(f\"Starting ML workload: {JOB_NAME}\")\nfor step in range(10):\n    recorder.log_productive_step(step)\n    print(f\"Completed productive step {step}\")\n    time.sleep(1) # Simulate productive work\n    # Simulate some unproductive time or I/O\n    if step % 3 == 0:\n        time.sleep(0.5)\n        recorder.log_unproductive_time(\"data_loading\", 0.5)\n\n# --- Initialize and start GoodputMonitor for asynchronous upload ---\n# The monitor runs in a separate process and uploads to TensorBoard and Google Cloud Monitoring.\nmonitor = GoodputMonitor(\n    job_name=JOB_NAME,\n    logger_name=LOGGER_NAME,\n    tensorboard_dir=TENSORBOARD_DIR,\n    upload_interval=30, # Upload every 30 seconds\n    monitoring_enabled=True, # Set to True to enable monitoring\n    include_badput_breakdown=True\n)\nmonitor.start_goodput_uploader()\n\nprint(\"Goodput Monitor started. Metrics will be uploaded asynchronously.\")\n# Continue with the rest of your training job...\n# For demonstration, let's keep it running for a bit\ntime.sleep(65) \n\n# --- Stop the monitor when the job is done ---\nmonitor.stop_goodput_uploader()\nrecorder.log_job_completion()\nprint(\"ML workload finished. Goodput Monitor stopped.\")","lang":"python","description":"This quickstart demonstrates how to use `GoodputRecorder` to log productive steps and `GoodputMonitor` to asynchronously query and upload Goodput metrics. It simulates a basic ML training loop. Ensure you have a Google Cloud project with billing enabled and appropriate permissions for Cloud Logging, Cloud Monitoring, and GCS (for TensorBoard logs) before running in a real environment. Replace placeholder environment variables with actual unique values for production use.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.0.16","pypi_latest":"0.0.16","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":12.5,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"290.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":12.7,"import_time_s":null,"mem_mb":null,"disk_size":"279M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"310.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":12.6,"import_time_s":null,"mem_mb":null,"disk_size":"296M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"295.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":10.9,"import_time_s":null,"mem_mb":null,"disk_size":"282M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"294.0M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":11.3,"import_time_s":null,"mem_mb":null,"disk_size":"280M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"293.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"ml-goodput-measurement","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":14.8,"import_time_s":null,"mem_mb":null,"disk_size":"287M"}]}}