No topics yet. Start the conversation.

Summary

User supplied summary for the plot

Current weather conditions and forecast for Oslo, Norway.

Description

The below description is supplied in free-text by the user

Hello World Novem Tutorial

A complete guide to building your first Novem job that fetches live weather data and updates a custom visualization.

What You'll Build

A job that:

  • Fetches current Oslo weather from wttr.in API
  • Updates a custom plot with weather description and temperature
  • Runs automatically or on-demand

Prerequisites

  • Novem account
  • Git configured with SSH keys
  • Visual Studio Code with Novem add-in installed

Step 1: Initialize Git Repository

mkdir hello-world
cd hello-world
git init -b main 

Step 2: Create Python Script

Create hello_world.py:

#!/usr/bin/env python3
"""
Hello World Novem Job
Fetches Oslo weather and updates a custom plot
"""
import requests
import pandas as pd
from novem import Plot

def get_oslo_weather():
    """Fetch current weather for Oslo from wttr.in API"""
    url = "https://wttr.in/Oslo?format=j1"
    response = requests.get(url, timeout=10)
    data = response.json()

    # Extract temperature and description
    current = data['current_condition'][0]
    temp = float(current['temp_C'])
    description = current['weatherDesc'][0]['value']

    return temp, description

def update_plot(temp, description):
    """Update the hello_oslo plot"""
    # Create DataFrame
    df = pd.DataFrame({
        'description': [description],
        'temperature': [temp]
    })

    # Update plot data
    plt = Plot('hello_oslo')
    plt.data = df

def main():
    # Fetch weather data
    temp, description = get_oslo_weather()

    # Update Novem plot
    update_plot(temp, description)

if __name__ == "__main__":
    main()

Create requirements.txt:

requests
pandas
novem

Set up environment and execute script locally :

# On Unix/Mac
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python hello_world.py
# On Windows
py -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt
py hello_world.py

Step 3: Create Custom Plot

The Python script references a plot called hello_oslo. Create this using the Visual Studio Code Novem add-in:

  1. Open the Novem add-in in VS Code
  2. Open the plot we created named hello_oslo
  3. Set config/type to custom
  4. Open config/custom/custom.js and paste the code below:
// Extract data (skip header row)
const [description, temp] = info.data[1];

// Set colors
const coldColor = '#3498db';  // Blue
const warmColor = '#e74c3c';  // Red
const descColor = render.dark ? '#bdc3c7' : '#7f8c8d';
const backgroundColor = render.dark ? '#1e1e1e' : '#ffffff';

// Choose temperature color based on 0°C
const tempColor = temp >= 0 ? warmColor : coldColor;

// Style the container
node.innerHTML = '';
node.style.display = 'flex';
node.style.flexDirection = 'column';
node.style.justifyContent = 'center';
node.style.alignItems = 'center';
node.style.background = backgroundColor;
node.style.padding = '40px';
node.style.fontFamily = 'Arial, sans-serif';

// Add description
const desc = document.createElement('div');
desc.textContent = description;
desc.style.fontSize = '28px';
desc.style.color = descColor;
desc.style.marginBottom = '30px';
node.appendChild(desc);

// Add temperature
const tempDiv = document.createElement('div');
tempDiv.textContent = `${temp.toFixed(1)}°C`;
tempDiv.style.fontSize = '72px';
tempDiv.style.fontWeight = 'bold';
tempDiv.style.color = tempColor;
node.appendChild(tempDiv);

Step 4: Push to Novem Repository

Create the repo, which you can do from novem.io.

# Add Novem remote (replace '[username]' with your username, '[repo]' with your repo name 
git remote add origin git@novem.io:[username]/[repo]

# Commit and push
git add hello_world.py requirements.txt
git commit -m "Initial commit: Oslo weather job"
git push -u origin main

Step 5: Create the Job

Create the job using the Visual Studio Code Novem add-in:

  1. Open the Novem add-in in VS Code
  2. Create a new job named hello-world-oslo
  3. Set config/type to data
  4. Set the extract to hello-world
  5. Set config/env/novem_token to your Novem API token that you can generate from your Novem account settings

Step 6: Run the Job

Trigger the job through from novem.io. See the output plot under your plots. There is a log endpoint for the job, here you can see messages to standard out including any error messages. You can see this in VS Code.