> ## 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.

# 2026-11-18 · Mahad · The streaming job runs on the SFU cluster against the course Kafka (task #3)

* **Done:**
  * Copied the repo to the cluster (`~/Calendar-Effects`), created a test topic `calendar-effects-master-mahad-test`, and replayed all 27,654 `clean/master.parquet` messages into the course Kafka with `replay_master.py` (8 s).
  * Ran `src/streaming/job.py --source kafka` on YARN (Spark 3.5.8, Scala 2.13, Java 17), 110 messages per micro-batch, output to HDFS `calendar-effects-test/`. It finished in 252 micro-batches; the watermark dropped 0 rows.
  * The run used its own topic because `calendar-effects-master` is the team's topic: the late-data test (#7) reads it from the start, and 27,654 extra messages would have doubled its input.
  * Fixed the cluster command in `src/streaming/job.py`'s docstring. The earlier one (also in `docs/handoffs/2026-11-17-mahad-kafka-test.md`) failed with "Failed to find data source: kafka".
* **Results** (HDFS output copied back with `hdfs dfs -get`):
  * `scripts/check_streaming.py`: 25,050 daily rows and 600 event CARs match the direct computation (largest difference 1.7e-16).
  * `scripts/compare_stream_batch.py`: 600 of 600 windows match Areej's answer key, and no window is missing.
  * pyarrow 25 on the cluster did not break `applyInPandasWithState` on Spark 3.5; the `<21` pin is only needed for PySpark 4.0 on a laptop.
* **Decisions:** none.
* **Contracts:** no change.
* **How to run it on the cluster** (log in with `ssh cluster.cs.sfu.ca`, port 24 in `~/.ssh/config`; the cluster's `python3` has kafka-python but no pyspark, so the job must go through `spark-submit`):
  ```
  cd Calendar-Effects && export PYTHONPATH=src
  python3 scripts/create_topics.py --topic <topic>
  python3 src/producers/replay_master.py --topic <topic> --seconds-per-day 0
  spark-submit --packages org.apache.spark:spark-sql-kafka-0-10_2.13:3.5.8 src/streaming/job.py \
      --source kafka --topic <topic> --max-per-trigger 110 --once \
      --out calendar-effects/stream --checkpoint calendar-effects/checkpoint
  hdfs dfs -get calendar-effects/stream ~/stream-out
  ```
  * `spark-submit` starts Spark before the script runs, so the Kafka connector must be on its command line.
  * `--out` and `--checkpoint` are HDFS paths. Clear them with `hdfs dfs -rm -r` before a rerun; `--fresh` only clears local folders.
  * Run long jobs inside `tmux` (or with `nohup`), so a dropped VPN or SSH connection doesn't stop them.
* **Next:**
  1. Pick the alerts for the demo video.
  2. Demo video (Nov 23 onward).
* **Blocked on / needs from others:**
  * **Sanchi (#7):** run the late-data test on the cluster with the commands above, using `calendar-effects-master`, and add `--late-fraction 0.02` to the replay. Then check with `check_streaming.py` and `compare_stream_batch.py --stream <copied folder>`.
  * **Anushiya:** `run_everything.sh --kafka` starts the job with `python3`, which works on a laptop but not on the cluster (no pyspark there). Use `spark-submit --packages ...` when it runs on the cluster.
  * **Clean-up:** the test topic `calendar-effects-master-mahad-test` and HDFS `calendar-effects-test/` can be deleted. Kafka's retention will also expire the topic.


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