RepoSnowflake (Arctic)Snowflake (Arctic)published Nov 17, 2025seen 5d

Snowflake-Labs/sfguide-getting-started-with-predictive-maintenance

Python

Open original ↗

Captured source

source ↗

Snowflake-Labs/sfguide-getting-started-with-predictive-maintenance

Language: Python

License: MIT

Stars: 0

Forks: 2

Open issues: 0

Created: 2025-11-17T15:19:23Z

Pushed: 2026-03-18T14:52:09Z

Default branch: main

Fork: no

Archived: no

README:

Getting Started with Predictive Maintenance

Learn how to build an end-to-end predictive maintenance solution using Snowflake's Data Cloud. This hands-on tutorial demonstrates how to construct a complete data pipeline in Snowflake—from ingesting raw sensor telemetry and maintenance logs to building analytics-ready tables and deploying an interactive Streamlit application. Finally, you will leverage Snowflake Intelligence to use natural language to discover topics ranging from predicting equipment failures, optimizing maintenance schedules, and reducing operational costs.

What You'll Build

You will build a predictive maintenance solution using Snowflake Intelligence, Streamlit in Snowflake, and an end-to-end Snowflake data pipeline.

🤖 Natural Language Analytics with Snowflake Intelligence

Ask questions about your data in plain English and get AI-powered insights:

  • Natural language queries against your predictive maintenance data
  • Conversational AI assistance for insights and recommendations
  • Automatic SQL generation and data visualization
  • Context-aware follow-up questions and analysis

📊 Interactive Analytics Application

Deploy a multi-page Streamlit dashboard that showcases:

  • Real-time monitoring of 18+ manufacturing assets across 3 facilities
  • AI-powered failure predictions and maintenance recommendations
  • Financial analysis and OEE (Overall Equipment Effectiveness) tracking
  • Interactive visualizations of production line status and asset health

🏗️ Complete Data Pipeline in Snowflake

Build a data pipeline using Snowflake's medallion architecture:

Bronze Layer (Raw Data Ingestion)

  • Ingest raw IoT sensor telemetry (temperature, vibration, pressure)
  • Load maintenance logs and work order data
  • Store equipment master data and specifications

Silver Layer (Curated & Conformed)

  • Transform raw data into dimensional star schema
  • Build fact tables for sensor readings, maintenance events, and production logs
  • Create dimension tables for assets, facilities, technicians, and parts
  • Implement data quality and validation rules

Gold Layer (Analytics-Ready)

  • Aggregate hourly asset health metrics
  • Build ML feature store for predictive models
  • Create semantic views for natural language querying
  • Generate business-ready KPIs and dashboards

Repository Structure

├── README.md # This file
├── LEGAL.md # Legal notice
├── LICENSE # License information
├── scripts/ # SQL setup scripts
│ ├── setup.sql # Database setup
│ └── teardown.sql # Cleanup script
└── streamlit/ # Streamlit application
├── app.py # Main application entry
├── requirements.txt # Python dependencies
├── pages/ # Multi-page dashboard views
│ ├── 1_🏢_Executive_Summary.py # Strategic overview
│ ├── 2_🔧_Fleet_Operations_Center.py # Operations & dispatch
│ ├── 3_📉_OEE_Drill_Down.py # Equipment effectiveness
│ ├── 4_💰_Financial_Risk_Drill_Down.py # Financial analysis
│ ├── 5_🔍_Asset_Detail.py # Asset inspection
│ ├── 6_🗺️_Line_Visualization.py # Production line maps
│ └── line_visualization.html # Visualization for page 6
└── utils/ # Utility modules
├── assistant_ui_components.py # UI components for assistants
├── calculations.py # Business logic
├── conversation_manager.py # Conversation state management
├── cortex_analyst.py # Cortex Analyst REST API integration
├── data_loader.py # Data loading utilities
├── snowflake_intelligence.py # Intelligence Agent integration
└── unified_assistant.py # Unified assistant interface

Prerequisites

Snowflake Requirements

  • Active Snowflake account with appropriate permissions
  • Role with privileges to:
  • Create databases, schemas, tables, and views
  • Create semantic views for Cortex Analyst
  • Create and manage stages
  • Create Streamlit apps
  • Create Intelligence Agents
  • Execute stored procedures
  • Snowflake account in a region with the appropriate Cortex models enabled or cross region inference enabled.

Installation & Setup

Step 1: Set Up Snowflake Database via Snowsight

1. Open Snowsight and log in to your Snowflake account 2. Create a new SQL Worksheet 3. Open the setup script: Navigate to scripts/setup.sql in your local repository 4. Copy the entire contents of setup.sql 5. Paste into the Snowsight worksheet 6. Execute the script: Click "Run All" or press Cmd+Enter (Mac) / Ctrl+Enter (Windows)

What the setup script creates:

  • SNOWCORE_INDUSTRIES database with role and warehouse
  • Three-tier schema structure (Bronze, Silver, Gold layers)
  • Dimension tables: Assets, Plants, Production Lines, OEMs, Sensors, Technicians, Materials, etc.
  • Fact tables: Asset Telemetry, Maintenance Logs, Production Logs, Parts Usage
  • Gold layer aggregations for analytics and ML
  • Semantic view for Cortex Analyst natural language queries
  • Synthetic data spanning from November 1, 2024 to current date (~160,000+ telemetry records, 12+ months)
  • Cortex Agent to be used via Snowflake Intelligence
  • Pre-aggregated OEE and maintenance cost trend tables for 12-month analysis
  • SPCS Infrastructure: Compute pool, network rules, and external access integration (if you have ACCOUNTADMIN privileges)

Step 2: Upload Streamlit Files to Stage

Now we'll upload the Streamlit application files to Snowflake:

1. In Snowsight, create a new SQL Worksheet

2. Upload the main application file:

  • In Snowsight, navigate to Catalog > Database Explorer > SNOWCORE_INDUSTRIES > GOLD > Stages > STREAMLIT_STAGE
  • Click + Files button in the top right
  • Select streamlit/app.py from your local repository
  • Click Upload

3. Upload the pages directory:

  • Still in the STREAMLIT_STAGE view, create a folder called pages
  • Upload all files from streamlit/pages/ into this folder:
  • 1_🏢_Executive_Summary.py
  • 2_🔧_Fleet_Operations_Center.py
  • 3_📉_OEE_Drill_Down.py
  • 4_💰_Financial_Risk_Drill_Down.py
  • 5_🔍_Asset_Detail.py
  • 6_🗺️_Line_Visualization.py
  • line_visualization.html

4. Upload the utils directory:

  • Create a folder called utils in STREAMLIT_STAGE
  • Upload all files from streamlit/utils/

Excerpt shown — open the source for the full document.

Notability

notability 2.0/10

Routine getting started guide, low impact.