> ## Documentation Index
> Fetch the complete documentation index at: https://docs.5x.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Development Workflows

> Learn how to develop dbt models, Python applications, Streamlit dashboards, and Metrics project using the IDE with best practices and examples

**Focus:** Master the development workflows for different types of data applications, from dbt transformations to Python scripts and interactive Streamlit dashboards.

The 5X IDE provides specialized development environments for the most common data development tasks. This guide covers practical workflows for building data models, applications, and dashboards with real examples and best practices.

<Note>
  **Development Environment**

  The IDE comes pre-configured with multiple Python versions, dbt environments, and development tools. No additional setup required for basic development tasks.
</Note>

## Python development

### **Python environment overview**

The IDE comes pre-installed with multiple Python versions managed through pyenv, providing flexibility for different project requirements and dependency compatibility.

**Available Python versions:**

* **Python 3.8.20** - Extended legacy support for older projects
* **Python 3.9.23** - Legacy support for older projects
* **Python 3.10.18** - Stable version with good package compatibility
* **Python 3.11.13** - Default version (set by PYENV\_VERSION)
* **Python 3.12.11** - Latest stable with performance improvements
* **Python 3.13.4** - Cutting-edge features and optimizations

**View installed versions:**

```bash theme={null}
ls /root/.pyenv/versions
```

### **Virtual environment management**

Python virtual environments provide isolated dependency management for your projects, preventing conflicts between different project requirements.

**Create a virtual environment:**

```bash theme={null}
# Using Python 3.11.13 (default)
/root/.pyenv/versions/3.11.13/bin/python -m venv my_project_env

# Using specific Python version
/root/.pyenv/versions/3.10.18/bin/python -m venv legacy_project_env
```

**Activate and manage environments:**

```bash theme={null}
# Activate environment
source my_project_env/bin/activate

# Verify active environment (should show your env path)
which python

# Deactivate when finished
deactivate
```

### **Dependency management best practices**

Maintain project dependencies using requirements.txt files for reproducible environments across team members and deployment targets.

**Create requirements.txt:**

```text theme={null}
# Core data processing
pandas==2.0.3
numpy==1.24.3

# API and web requests  
requests==2.31.0
urllib3==2.0.4

# Visualization
matplotlib==3.7.2
seaborn==0.12.2

# Development tools
jupyter==1.0.0
pytest==7.4.0
```

**Install and manage dependencies:**

```bash theme={null}
# Activate environment first
source my_project_env/bin/activate

# Install from requirements file
pip install -r requirements.txt

# Install additional packages and update requirements
pip install scikit-learn==1.3.0
pip freeze > requirements.txt
```

### **Python development examples**

**Data processing script:**

```python theme={null}
import pandas as pd
import numpy as np
from sqlalchemy import create_engine

def process_customer_data(connection_string):
    """Process customer data from warehouse"""
    engine = create_engine(connection_string)
    
    # Load data
    df = pd.read_sql("SELECT * FROM customers", engine)
    
    # Data transformations
    df['full_name'] = df['first_name'] + ' ' + df['last_name']
    df['customer_tier'] = pd.cut(df['total_spent'], 
                                bins=[0, 100, 500, 1000, float('inf')],
                                labels=['Bronze', 'Silver', 'Gold', 'Platinum'])
    
    # Save processed data
    df.to_sql('processed_customers', engine, if_exists='replace', index=False)
    
    return df

if __name__ == "__main__":
    # Your connection string here
    conn_str = "your_connection_string"
    result = process_customer_data(conn_str)
    print(f"Processed {len(result)} customers")
```

**API integration example:**

```python theme={null}
import requests
import json
from datetime import datetime

class DataAPI:
    def __init__(self, base_url, api_key):
        self.base_url = base_url
        self.headers = {'Authorization': f'Bearer {api_key}'}
    
    def fetch_data(self, endpoint, params=None):
        """Fetch data from API endpoint"""
        response = requests.get(
            f"{self.base_url}/{endpoint}",
            headers=self.headers,
            params=params
        )
        response.raise_for_status()
        return response.json()
    
    def process_and_save(self, endpoint, db_connection):
        """Fetch, process, and save data to database"""
        data = self.fetch_data(endpoint)
        
        # Process data
        df = pd.DataFrame(data)
        df['processed_at'] = datetime.now()
        
        # Save to database
        df.to_sql('api_data', db_connection, if_exists='append', index=False)
        
        return df
```

## dbt development

### **dbt Power User extension (recommended approach)**

The dbt Power User extension provides the most integrated development experience, automatically using your configured dbt settings from Settings → Credentials including version selection, database connections, and target configuration.

<img src="https://mintcdn.com/5x/F78wdgJnT4aJ3lPl/images/ide/ide-dbt-extension.png?fit=max&auto=format&n=F78wdgJnT4aJ3lPl&q=85&s=5922e0a3cd58a502f26a5452cd7aaf8d" alt="dbt Power User Extension" style={{borderRadius: '12px', boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)'}} width="2638" height="1560" data-path="images/ide/ide-dbt-extension.png" />

**Key workflows:**

<CardGroup cols={2}>
  <Card title="Model execution" icon="play">
    **Run and test models**

    Execute individual models, selections, or entire dbt projects with integrated test runner
  </Card>

  <Card title="Lineage visualization" icon="project-diagram">
    **Understand dependencies**

    Interactive dependency graphs showing upstream and downstream model relationships
  </Card>

  <Card title="Documentation" icon="book">
    **Generate docs**

    Create and view dbt documentation with integrated preview and automatic refresh
  </Card>

  <Card title="SQL compilation" icon="code">
    **Preview compiled SQL**

    See the actual SQL that will be executed before running models
  </Card>
</CardGroup>

### **Command-line dbt development**

For users preferring terminal-based workflows, the IDE provides pre-configured dbt virtual environments for each supported version.

**Activate dbt environment:**

```bash theme={null}
# List available dbt environments
ls /root/.venv

# Activate specific dbt version
source /root/.venv/dbt-1.8.9/bin/activate

# Verify dbt installation
dbt --version
```

**Available dbt versions:**

* **dbt-1.6.18** (`/root/.venv/dbt-1.6.18/`) - Legacy support
* **dbt-1.7.19** (`/root/.venv/dbt-1.7.19/`) - Stable version
* **dbt-1.8.9** (`/root/.venv/dbt-1.8.9/`) - Current stable
* **dbt-1.9.10** (`/root/.venv/dbt-1.9.10/`) - Latest features

### **dbt development workflow**

**Common dbt commands:**

```bash theme={null}
# Navigate to your dbt project directory
cd /path/to/your/dbt/project

# Run entire project
dbt run

# Run specific models
dbt run --select staging.stg_customers+

# Test your models
dbt test

# Generate documentation
dbt docs generate
dbt docs serve
```

**Model development example:**

```sql theme={null}
-- models/staging/stg_customers.sql
SELECT
    customer_id::int AS customer_id,
    LOWER(TRIM(email)) AS email,
    INITCAP(first_name) AS first_name,
    INITCAP(last_name) AS last_name,
    created_at::timestamp AS created_at,
    CASE 
        WHEN status = 'A' THEN 'active'
        WHEN status = 'I' THEN 'inactive'
        ELSE 'unknown'
    END AS status
FROM {{ source('crm', 'customers') }}
WHERE customer_id IS NOT NULL
```

**Model testing:**

```yaml theme={null}
# models/schema.yml
version: 2

models:
  - name: stg_customers
    description: "Cleaned customer data from CRM system"
    columns:
      - name: customer_id
        description: "Unique customer identifier"
        tests:
          - unique
          - not_null
      - name: email
        description: "Customer email address"
        tests:
          - not_null
          - unique
```

### **Lineage visualization**

The IDE provides powerful lineage visualization capabilities that help you understand data flow and model dependencies throughout your dbt project.

<img src="https://mintcdn.com/5x/F78wdgJnT4aJ3lPl/images/ide/ide-lineage-visualization.png?fit=max&auto=format&n=F78wdgJnT4aJ3lPl&q=85&s=0aacbb484ff6cc750633eca6e538bf44" alt="dbt Model Lineage Visualization" style={{borderRadius: '12px', boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)'}} width="2082" height="1132" data-path="images/ide/ide-lineage-visualization.png" />

**To view lineage:**

1. Open any dbt model file in the editor
2. Navigate to the Lineage tab in the IDE interface
3. Explore interactive dependency graphs showing:
   * Upstream models and sources feeding into current model
   * Downstream models consuming current model output
   * Cross-project dependencies and external table references

**Lineage features:**

* **Interactive navigation** - Click nodes to jump between related models
* **Dependency depth control** - Adjust how many levels of dependencies to display
* **Impact analysis** - Understand which models will be affected by changes
* **Visual debugging** - Identify circular dependencies and optimization opportunities

### **Running dbt commands**

Execute dbt commands directly from the IDE for any valid dbt project without leaving your development workspace.

**To run dbt commands:**

<Steps>
  <Step title="Open dbt project">
    Open a dbt project folder in the IDE
  </Step>

  <Step title="Access dbt command interface">
    Click on the <span style={{display: 'inline-block', verticalAlign: 'middle', width: '24px', height: '24px', margin: '0 4px', color: '#000'}} className="dark:!text-white"><svg width="24" height="24" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><g clipPath="url(#clip0)"><path d="M7.29358 9.00631L6.41358 9.88552C6.27974 9.34717 5.96942 8.86905 5.53206 8.52735C5.09469 8.18564 4.55545 8 4.00024 8C3.44503 8 2.90579 8.18564 2.46843 8.52735C2.03107 8.86905 1.72075 9.34717 1.58691 9.88552L0.706911 9.00631L0.000244141 9.71234L1.14691 10.858L1.00024 11.0045V12.0036H0.000244141V13.0027H1.00024V13.056C1.05124 13.3815 1.14308 13.6993 1.27358 14.0018L0.000244141 15.294L0.706911 16L1.80691 14.901C2.06862 15.2346 2.40103 15.5062 2.78025 15.6962C3.15948 15.8862 3.57612 15.99 4.00024 16C4.42437 15.99 4.84101 15.8862 5.22023 15.6962C5.59946 15.5062 5.93187 15.2346 6.19358 14.901L7.29358 16L8.00024 15.294L6.72691 14.0018C6.85903 13.6929 6.9509 13.3683 7.00024 13.036V12.9694H8.00024V12.0036H7.00024V11.0045L6.85358 10.858L8.00024 9.71234L7.29358 9.00631ZM4.00024 9.00631C4.39807 9.00631 4.7796 9.16421 5.0609 9.44526C5.34221 9.72631 5.50024 10.1075 5.50024 10.505H2.50024C2.50024 10.1075 2.65828 9.72631 2.93958 9.44526C3.22089 9.16421 3.60242 9.00631 4.00024 9.00631ZM6.00024 13.0027C5.9514 13.5161 5.725 13.9965 5.35998 14.3612C4.99496 14.7259 4.51414 14.9521 4.00024 15.0009C3.48634 14.9521 3.00553 14.7259 2.64051 14.3612C2.27549 13.9965 2.04909 13.5161 2.00024 13.0027V11.5041H6.00024V13.0027Z" fill="currentColor" /><path fillRule="evenodd" clipRule="evenodd" d="M6.00024 7V2L14.9149 8.24024L9.00024 12.3805V11.1655L13.1812 8.24024L6.99524 3.91209V7H6.00024Z" fill="currentColor" /></g><defs><clipPath id="clip0"><rect width="16" height="16" fill="white" transform="translate(0.000244141)" /></clipPath></defs></svg></span> icon from the top-right status bar
  </Step>

  <Step title="Go to terminal and activate dbt environment">
    ```bash theme={null}
    # List available dbt environments
    ls /root/.venv

    # Activate specific dbt version
    source /root/.venv/dbt-1.8.9/bin/activate

    # Verify dbt installation
    dbt --version
    ```
  </Step>

  <Step title="Enter command">
    A command input box will appear, allowing you to enter the desired dbt command
  </Step>

  <Step title="Execute command">
    Confirm the command to execute it in the terminal
  </Step>
</Steps>

**Terminal session management:**

If similar commands were executed previously for the same project, the IDE will prompt you to either:

* **Open a new terminal session** - Start a fresh terminal for the command
* **Continue using existing terminal** - Reuse the current terminal session

This integrated feature simplifies the dbt workflow, enabling you to build, test, and manage transformations without leaving your development workspace.

**Example dbt commands:**

```bash theme={null}
# Run all models
dbt run

# Run specific models
dbt run --select staging.stg_customers+

# Test models
dbt test

# Generate documentation
dbt docs generate

# Compile models
dbt compile
```

## Cube development

### **Cube creation**

Create new cubes directly from the IDE without leaving your development environment, providing a seamless and integrated experience for managing cube creation.

**To create a cube:**

<Steps>
  <Step title="Open cubes repository">
    Open any file within the cubes repository
  </Step>

  <Step title="Access cube creation">
    Click on the <Icon icon="add" /> icon located on the top-right corner of the status bar
  </Step>

  <Step title="Automatic server start">
    The Cube Server will automatically start, enabling the cube creation process
  </Step>

  <Step title="Select schema">
    A new file tab will open, displaying a list of available schemas. Select the desired schema
  </Step>

  <Step title="Define and create">
    Proceed to define and create cubes as needed
  </Step>
</Steps>

This workflow provides a seamless and integrated experience for managing cube creation within the IDE, eliminating the need to switch between different tools or environments.

### **Cube server start**

Start the Cube Server for a specific active file tab directly from the IDE toolbar, giving you full control over active Cube Server sessions.

**To start the Cube Server:**

<Steps>
  <Step title="Open cube file">
    Open any file within your cubes repository
  </Step>

  <Step title="Start server">
    Click on the <Icon icon="play" /> icon from the IDE toolbar
  </Step>

  <Step title="Access server">
    Once initiated, the Cube Server will launch and can be accessed locally via `http://localhost:4000`
  </Step>
</Steps>

**Server conflict management:**

If there is an existing Cube Server instance running, a prompt will appear asking you to:

* **Stop the currently active server and start a new one** - Terminate the existing instance and launch a fresh server
* **Cancel to retain the current session** - Keep the existing server running

This ensures that multiple servers do not conflict and that you retain full control over active Cube Server sessions.

## Running Streamlit applications and Python files

### **Running Streamlit applications**

Run Streamlit applications directly from the IDE with automatic environment setup and dependency management.

**To run a Streamlit application:**

<Steps>
  <Step title="Open Streamlit file">
    Open the `streamlit_app.py` file from the Streamlit repository
  </Step>

  <Step title="Run application">
    Click on the <Icon icon="play" /> icon in the IDE toolbar
  </Step>

  <Step title="Select Python version">
    The IDE will prompt you to select the desired Python version for execution
  </Step>

  <Step title="Automatic setup">
    Upon confirmation, a virtual environment will be created automatically
  </Step>

  <Step title="Install dependencies">
    All dependencies listed in the `requirements.txt` file will be installed within the environment
  </Step>

  <Step title="Launch application">
    Once setup is complete, the Streamlit application will launch successfully
  </Step>
</Steps>

### **Running Python files**

Execute standalone Python scripts with the same streamlined workflow as Streamlit applications.

**To run a Python file:**

<Steps>
  <Step title="Open Python file">
    Open any Python file (`.py`) in the IDE
  </Step>

  <Step title="Run script">
    Click on the <span style={{display: 'inline-block', verticalAlign: 'middle', width: '24px', height: '24px', margin: '0 4px', color: '#000'}} className="dark:!text-white"><svg width="24" height="24" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path fillRule="evenodd" clipRule="evenodd" d="M10.9149 8.24024L2.00024 14.4805V2L10.9149 8.24024ZM2.99524 12.5684L9.18117 8.24024L2.99524 3.91209V12.5684ZM5.50024 14.4805V13.2511L12.6812 8.24024L5.50024 3.22935V2L14.4149 8.24024L5.50024 14.4805Z" fill="currentColor" /></svg></span> icon in the IDE toolbar
  </Step>

  <Step title="Select Python version">
    Choose the desired Python version for execution
  </Step>

  <Step title="Environment setup">
    A virtual environment will be created automatically if needed
  </Step>

  <Step title="Install dependencies">
    Dependencies from `requirements.txt` will be installed automatically
  </Step>

  <Step title="Execute script">
    The Python file will run successfully with output displayed in the terminal
  </Step>
</Steps>

**Benefits of integrated execution:**

* **Environment consistency** - Automatic virtual environment creation ensures consistent execution environments
* **Dependency management** - Automatic installation of dependencies from `requirements.txt` reduces manual setup overhead
* **Version selection** - Choose the appropriate Python version for your project requirements
* **Seamless workflow** - Run applications and scripts without leaving the IDE or switching contexts

This process ensures environment consistency and reduces manual setup overhead for Streamlit or Python-based workflows, allowing you to focus on development rather than environment configuration.
