> ## Documentation Index
> Fetch the complete documentation index at: https://calendar-effects.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# How to run it: on a laptop, or on the SFU cluster

> docs/architecture/08-running-it.mmd

```mermaid theme={null}
%% Calendar Effects · 8 · How to run it: on a laptop, or on the SFU cluster. Every command, in order: docs/running.md.
%% Paste into Miro: Creation bar > Diagram > Build with code.
flowchart TB
  subgraph LAPTOP["On a laptop · one command"]
    setup["Setup once<br/>python3 -m venv .venv · source .venv/bin/activate<br/>pip install -r requirements.txt<br/>Spark 4 needs Java 17 or 21, not 26<br/>pyarrow is pinned below 21 for PySpark 4.0"]
    runall["./run_everything.sh --skip-etl<br/>Python and Java · ETL skipped · etl/join_master.py<br/>replay to files + streaming job · check_streaming.py<br/>batch study · compare_stream_batch.py · train the model<br/>about 20 minutes, ends with PASSED"]
    batchrun["Then refresh and publish<br/>python3 src/hosting/snapshot.py · scripts/export_results.py<br/>commit and push: hooks copy to github.com<br/>python3 src/hosting/publish_hf.py --upload"]
    demo["Live demo · diagram 12<br/>scripts/demo_live.sh on a laptop<br/>or the cloud streamer on GitHub Actions"]
    localkafka["Optional: a local Kafka broker<br/>brew install kafka · see the handoff<br/>docs/handoffs/2026-11-17-mahad-kafka-test.md"]
  end

  subgraph CLUSTER["On the SFU cluster · ssh cluster.cs.sfu.ca, port 24 · VPN off campus"]
    gateway["Gateway node · ~/Calendar-Effects<br/>export PYTHONPATH=src<br/>its python3 has kafka-python, not pyspark"]
    prod["python3 scripts/create_topics.py<br/>python3 src/producers/replay_master.py<br/>sends to the course Kafka node1.local, node2.local"]
    submit["spark-submit --packages<br/>org.apache.spark:spark-sql-kafka-0-10_2.13:3.5.8<br/>src/streaming/job.py --source kafka<br/>--out and --checkpoint are HDFS paths"]
    yarn["YARN runs the job on the cluster's workers<br/>Spark 3.5.8, Scala 2.13, Java 17"]
    get["hdfs dfs -get the output<br/>then the same two checks"]
  end

  setup --> runall --> batchrun --> demo
  localkafka -.-> runall
  gateway --> prod --> submit --> yarn --> get
```

## Guide

```mermaid theme={null}
%% Calendar Effects · Guide 8 · How to run it · goes next to diagram 08-running-it.mmd
%% Miro: paste onto a board, or Creation bar > Diagram > Build with code. Read top to bottom.
flowchart TB
  T["GUIDE 8 · RUNNING IT<br/>on a laptop and on the SFU cluster"]

  subgraph S1["1 · LAPTOP · SET UP ONCE"]
    direction LR
    l1["python3 -m venv .venv"] --> l2["source .venv/bin/activate<br/>in every new terminal"] --> l3["pip install -r requirements.txt<br/>-r requirements-dev.txt"] --> l4["Java 21<br/>brew install openjdk@21"]
  end

  subgraph S2["2 · LAPTOP · RUN"]
    direction TB
    r1["./run_everything.sh --skip-etl<br/>ends with PASSED · ≈ 5 min"]
    r2["BATCH STUDY<br/>car.py · stats.py · charts.py"]
    r3["COMPARISON<br/>compare_stream_batch.py"]
    r4["TESTS<br/>python3 -m pytest -q"]
  end

  subgraph S3["3 · SFU CLUSTER · Spark 3.5.8 · Scala 2.13 · Java 17"]
    direction LR
    c1["SFU VPN<br/>if off campus"] --> c2["ssh cluster.cs.sfu.ca<br/>port 24"] --> c3["export PYTHONPATH=src"] --> c4["create_topics.py<br/>replay_master.py"] --> c5["spark-submit --packages<br/>spark-sql-kafka-0-10_2.13:3.5.8<br/>job.py --source kafka"] --> c6["hdfs dfs -get<br/>then run the checks"]
  end

  subgraph S4["4 · TRAPS WE HIT"]
    direction TB
    w1["JAVA 26<br/>Spark 4 needs Java 17 or 21"]
    w2["NO PYARROW ON WORKERS<br/>activate .venv first"]
    w3["NO KAFKA DATA SOURCE<br/>add it with --packages"]
    w4["OLD OUTPUT ON HDFS<br/>--fresh doesn't clear it<br/>use hdfs dfs -rm -r"]
    w5["VPN DROPPED THE JOB<br/>run it in tmux or nohup"]
  end

  T --> S1 --> S2 --> S3 --> S4

  classDef head fill:#2C2C2A,stroke:#2C2C2A,color:#FFFFFF
  classDef step fill:#E1F5EE,stroke:#0F6E56,color:#085041
  classDef file fill:#F1EFE8,stroke:#5F5E5A,color:#444441
  classDef warn fill:#FAECE7,stroke:#993C1D,color:#712B13
  classDef win fill:#EAF3DE,stroke:#3B6D11,color:#27500A
  class T head
  class l1,l2,l3,l4,c1,c2,c3,c4,c5,c6 step
  class r1 win
  class r2,r3,r4 file
  class w1,w2,w3,w4,w5 warn
  style S1 fill:#FFFFFF,stroke:#B4B2A9
  style S2 fill:#FFFFFF,stroke:#B4B2A9
  style S3 fill:#FFFFFF,stroke:#B4B2A9
  style S4 fill:#FFFFFF,stroke:#B4B2A9
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.