Skip to main content
Every command in the project, in the order you would use them. Run them from the repository’s root folder, inside the project’s Python environment (source .venv/bin/activate). Spark 4 needs Java 17 or 21, not a newer default such as 26:
  • run_everything.sh and scripts/demo_live.sh find Java 21 by themselves;
  • before any other command that starts Spark (job.py, train.py), set it in that terminal:

1. Set up a computer (once)

2. Reproduce the results

About 20 minutes for all 38 retailers, on the clean data committed in clean/. In order, it:
  1. rebuilds the master table;
  2. replays it through the streaming job;
  3. checks the stream against a direct computation;
  4. runs the batch event study (the answer key) and compares the two;
  5. trains the big-move model.
It stops with an error if any check fails. Model scores in the stream. The model is trained last, so this run’s stream has no model scores. The dashboard’s recording needs them. Either:
  • download the trained model before run_everything.sh:
  • or stream once more after it:
Careful: job.py --fresh with its default folders deletes data/stream/, the full run that the results and the recording come from. For anything else, use other folders (--out, --checkpoint), or scripts/demo_live.sh, which uses data/demo/. The steps one at a time (local files):
To download and clean the raw data by hand, in order: etl/prices_download.py, etl/prices_clean.py, etl/pageviews_download.py, etl/pageviews_clean.py, etl/retail_clean.py, then etl/join_master.py. Retail sales need the FRED files in raw/census/ (see docs/etl-guide.md).

3. Refresh what is published (after a full run)

In this order:
  1. The dashboard’s recording:
    It writes hosting/snapshot/, the Replay and Event history views, from data/stream/, the batch results and the model.
  2. The results pack:
    It writes docs/results/, the tables, charts and checks behind the report. Add --cluster-stream DIR to include a cluster run copied back.
  3. Commit, then git push. The pre-commit hook rebuilds docs-site/. The post-commit hook pushes:
    • the docs site, which Mintlify redeploys;
    • the hosted dashboard, which Streamlit Community Cloud redeploys;
    • the cloud streamer’s copy.
  4. Hugging Face:
    Without --upload it only builds the folders in data/publish/ for you to check. Add --only dataset (or model, space) to upload just one.

4. Watch and demo

The dashboard: calendar-effects.streamlit.app, always on (if nobody has opened it for 12 hours, one click wakes it). The same app on your computer:
Its views:
  • Replay: plays back a recording of a full run, made earlier: pick the years, pause, jump, change the speed. Nothing else needs to run.
  • Live stream: a streaming job running right now, each micro-batch about 15 seconds after it is processed. Start one of these two ways.
  • Event history & forecast and About.
A live run on GitHub’s servers (the cloud streamer, no computer needed): on github.com, Calendar-Effects/live-stream > Actions > Live stream > Run workflow. The same from a terminal:
Every run plays on to the end of the data and then stops by itself: about 15 minutes from 2023-06-01, about an hour from 2016-01-04. It needs the repository secret HF_TOKEN (hosting/live-stream/README.md). A live run from your computer:
Ctrl-C stops it cleanly. It needs hf auth login to publish. Only one run shows on the hosted dashboard at a time: whichever started first. Another run keeps uploading and appears once the first ends. “Live” means the processing is live; the data is a replay of 2016–2025, not today’s market. A run’s last day is 17 December 2025, not the data’s last day, 31 December: the job releases a day only once its 7-day watermark has passed it, and at the end of a replay nothing newer arrives to move the watermark. The batch study covers those days.

5. On the SFU cluster

On the SFU VPN: ssh cluster.cs.sfu.ca, and run long jobs inside tmux. The cluster’s python3 has no pyspark, so the job goes through spark-submit with the Kafka connector:
  • The two paths: --out and --checkpoint are HDFS paths. Clear them with hdfs dfs -rm -r before a rerun.
  • Topics: the team topic is calendar-effects-master; use your own topic for experiments.
  • Late data: add --late-fraction 0.02 to the producer to send some rows late.
  • Checking a topic: python3 scripts/peek_topic.py --topic <topic> prints its first messages.
  • Reports: to put a cluster run in the reports, copy its output folder back to your computer, then run scripts/export_results.py --cluster-stream DIR.

6. Upkeep

7. Submit

When the report and the video are done, tag the commit they describe: