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

# src/common/settings.py

> Where the project's files live, and how to reach Kafka.

`src/common/settings.py` · chapter [Shared rules](https://calendar-effects.mintlify.site/tour/02-shared-rules.md), file 3 · 90 lines · [open in the repository](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py)

## What it does

Where the project's files live, and how to reach Kafka.

Scripts take every path from here, so they work from any folder and a file name is
typed once. What is studied lives in config/ (events, retailers, Wikipedia articles,
retail series) and how it is studied (years, windows, market index) in common.study.

Usage:

```text theme={null}
from common.settings import KAFKA_BOOTSTRAP, RAW_DIR, clean_path

prices = pd.read_parquet(clean_path("prices"))
```

## What is inside

* **`REPO_ROOT`** · [line 17](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L17)
* **`CONFIG_DIR`** · [line 20](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L20): Hand-edited registries, committed. Their columns are contracts (docs/data-contracts.md).
* **`EVENT_TYPES_CSV`** · [line 21](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L21)
* **`EVENT_DATES_CSV`** · [line 22](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L22)
* **`RETAILERS_CSV`** · [line 23](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L23)
* **`WIKI_ARTICLES_CSV`** · [line 24](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L24)
* **`RETAIL_SERIES_CSV`** · [line 25](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L25)
* **`RAW_DIR`** · [line 27](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L27): downloads; gitignored, never edited by hand
* **`CLEAN_DIR`** · [line 28](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L28): cleaned tables; small, committed for the team
* **`DATA_DIR`** · [line 29](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L29): made by runs; gitignored
* **`REPLAY_DIR`** · [line 30](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L30): JSON files for running the streaming job without Kafka
* **`SRC_DIR`** · [line 31](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L31): the project's Python packages
* **`DEMO_STREAM_DIR`** · [line 32](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L32): where scripts/demo\_live.sh writes its run
* **`STREAM_DIR`** · [line 33](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L33): streaming job output, one subfolder per dataset:
* **`STREAM_SUBDIRS`** · [line 34](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L34)
* **`RESULTS_DIR`** · [line 36](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L36): batch event study and model output
* **`MODEL_DIR`** · [line 37](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L37): trained models (src/ml/train.py); remade by a run
* **`BIG_MOVE_MODEL`** · [line 38](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L38): the Spark MLlib PipelineModel the streaming job loads
* **`BIG_MOVE_MODEL_INFO`** · [line 39](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L39): its features, alert cut-off and test scores
* **`CHECKPOINT_DIR`** · [line 40](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L40): Spark streaming checkpoints, one folder per query; gitignored
* **`DOCS_DIR`** · [line 44](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L44): Documentation. docs/ is written by hand; docs-site/ is the Mintlify site that scripts/build\_docs.py builds from the code and docs/ (decision 0011).
* **`DOCS_SITE_DIR`** · [line 45](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L45)
* **`HOSTING_DIR`** · [line 48](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L48): What is published (src/hosting/, decisions 0010 and 0013).
* **`SNAPSHOT_DIR`** · [line 49](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L49): the recorded replay and event history the dashboard shows;
* **`SITE_DIR`** · [line 51](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L51): made by src/hosting/snapshot.py, committed (derived data only)
* **`CARDS_DIR`** · [line 52](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L52): dataset, model and Space card templates
* **`APP_BUNDLE_DIR`** · [line 53](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L53): what the hosted dashboard's repository adds to the code
* **`PUBLISH_DIR`** · [line 54](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L54): the dataset, model and Space folders, staged before upload
* **`HF_OWNER`** · [line 58](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L58): The team's public homes: the Hugging Face organisation (dataset, model, Space, live feed) and the github.com organisation (the docs site's and the hosted dashboard's repositories).
* **`HF_REPOS`** · [line 59](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L59)
* **`GITHUB_ORG`** · [line 60](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L60)
* **`DOCS_URL`** · [line 61](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L61)
* **`DASHBOARD_URL`** · [line 65](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L65): The hosted dashboard (Streamlit Community Cloud) and its live feed: during a demo the streaming job publishes each micro-batch to a public Hugging Face dataset (src/hosting/live.py).
* **`LIVE_REPO`** · [line 66](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L66)
* **`LIVE_CACHE_DIR`** · [line 67](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L67): the dashboard's local copy of the live feed
* **`STREAMER_REPO`** · [line 70](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L70): The cloud streamer (decision 0015): a private github.com repository whose "Live stream" workflow runs scripts/demo\_live.sh on GitHub's servers, so a live run needs no team member's computer.
* **`STREAMER_URL`** · [line 71](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L71)
* **`LINKS`** · [line 72](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L72): where everything is, for pages and cards
* **`clean_path(dataset)`** · [line 84](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L84): The committed Parquet file of a clean dataset, e.g. clean\_path("prices").
* **`KAFKA_BOOTSTRAP`** · [line 90](https://github.sfu.ca/aba395/Calendar-Effects/blob/main/src/common/settings.py#L90): The course cluster's Kafka servers. Set KAFKA\_BOOTSTRAP=localhost:9092 for a local Kafka.

## Connections

**Used by:** [`src/common/contracts.py`](https://calendar-effects.mintlify.site/reference/src/common/contracts), [`etl/prices_download.py`](https://calendar-effects.mintlify.site/reference/etl/prices_download), [`etl/prices_clean.py`](https://calendar-effects.mintlify.site/reference/etl/prices_clean), [`etl/pageviews_download.py`](https://calendar-effects.mintlify.site/reference/etl/pageviews_download), [`etl/pageviews_clean.py`](https://calendar-effects.mintlify.site/reference/etl/pageviews_clean), [`etl/retail_clean.py`](https://calendar-effects.mintlify.site/reference/etl/retail_clean), [`etl/build_events.py`](https://calendar-effects.mintlify.site/reference/etl/build_events), [`etl/join_master.py`](https://calendar-effects.mintlify.site/reference/etl/join_master), [`src/producers/replay_to_files.py`](https://calendar-effects.mintlify.site/reference/src/producers/replay_to_files), [`scripts/create_topics.py`](https://calendar-effects.mintlify.site/reference/scripts/create_topics), [`src/producers/replay_master.py`](https://calendar-effects.mintlify.site/reference/src/producers/replay_master), [`scripts/peek_topic.py`](https://calendar-effects.mintlify.site/reference/scripts/peek_topic), [`src/streaming/job.py`](https://calendar-effects.mintlify.site/reference/src/streaming/job), [`scripts/check_streaming.py`](https://calendar-effects.mintlify.site/reference/scripts/check_streaming), [`src/eventstudy/car.py`](https://calendar-effects.mintlify.site/reference/src/eventstudy/car), [`src/eventstudy/stats.py`](https://calendar-effects.mintlify.site/reference/src/eventstudy/stats), [`src/eventstudy/charts.py`](https://calendar-effects.mintlify.site/reference/src/eventstudy/charts), [`scripts/export_results.py`](https://calendar-effects.mintlify.site/reference/scripts/export_results), [`scripts/compare_stream_batch.py`](https://calendar-effects.mintlify.site/reference/scripts/compare_stream_batch), [`src/ml/train.py`](https://calendar-effects.mintlify.site/reference/src/ml/train), [`src/dashboard/app.py`](https://calendar-effects.mintlify.site/reference/src/dashboard/app), [`src/hosting/snapshot.py`](https://calendar-effects.mintlify.site/reference/src/hosting/snapshot), [`src/hosting/live.py`](https://calendar-effects.mintlify.site/reference/src/hosting/live), [`src/hosting/publish_hf.py`](https://calendar-effects.mintlify.site/reference/src/hosting/publish_hf), [`tests/test_clean_files.py`](https://calendar-effects.mintlify.site/reference/tests/test_clean_files), [`tests/test_dashboard.py`](https://calendar-effects.mintlify.site/reference/tests/test_dashboard), [`tests/test_hosting.py`](https://calendar-effects.mintlify.site/reference/tests/test_hosting), [`tests/test_ai_usage.py`](https://calendar-effects.mintlify.site/reference/tests/test_ai_usage), [`scripts/build_docs.py`](https://calendar-effects.mintlify.site/reference/scripts/build_docs)

## Source

```python title="src/common/settings.py" lines expandable theme={null}
"""Where the project's files live, and how to reach Kafka.

Scripts take every path from here, so they work from any folder and a file name is
typed once. What is studied lives in config/ (events, retailers, Wikipedia articles,
retail series) and how it is studied (years, windows, market index) in common.study.

Usage:
    from common.settings import KAFKA_BOOTSTRAP, RAW_DIR, clean_path

    prices = pd.read_parquet(clean_path("prices"))
"""
from __future__ import annotations

import os
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parents[2]

# Hand-edited registries, committed. Their columns are contracts (docs/data-contracts.md).
CONFIG_DIR = REPO_ROOT / "config"
EVENT_TYPES_CSV = CONFIG_DIR / "event_types.csv"
EVENT_DATES_CSV = CONFIG_DIR / "event_dates.csv"
RETAILERS_CSV = CONFIG_DIR / "retailers.csv"
WIKI_ARTICLES_CSV = CONFIG_DIR / "wiki_articles.csv"
RETAIL_SERIES_CSV = CONFIG_DIR / "retail_series.csv"

RAW_DIR = REPO_ROOT / "raw"                  # downloads; gitignored, never edited by hand
CLEAN_DIR = REPO_ROOT / "clean"              # cleaned tables; small, committed for the team
DATA_DIR = REPO_ROOT / "data"                # made by runs; gitignored
REPLAY_DIR = DATA_DIR / "replay"             # JSON files for running the streaming job without Kafka
SRC_DIR = REPO_ROOT / "src"                  # the project's Python packages
DEMO_STREAM_DIR = DATA_DIR / "demo" / "stream"   # where scripts/demo_live.sh writes its run
STREAM_DIR = DATA_DIR / "stream"             # streaming job output, one subfolder per dataset:
STREAM_SUBDIRS = {"stream_signals": "signals", "stream_event_car": "event_car",
                  "stream_predictions": "predictions"}
RESULTS_DIR = DATA_DIR / "results"           # batch event study and model output
MODEL_DIR = DATA_DIR / "models"              # trained models (src/ml/train.py); remade by a run
BIG_MOVE_MODEL = MODEL_DIR / "big_move"      # the Spark MLlib PipelineModel the streaming job loads
BIG_MOVE_MODEL_INFO = MODEL_DIR / "big_move.json"  # its features, alert cut-off and test scores
CHECKPOINT_DIR = REPO_ROOT / "checkpoints"   # Spark streaming checkpoints, one folder per query; gitignored

# Documentation. docs/ is written by hand; docs-site/ is the Mintlify site that
# scripts/build_docs.py builds from the code and docs/ (decision 0011).
DOCS_DIR = REPO_ROOT / "docs"
DOCS_SITE_DIR = REPO_ROOT / "docs-site"

# What is published (src/hosting/, decisions 0010 and 0013).
HOSTING_DIR = REPO_ROOT / "hosting"
SNAPSHOT_DIR = HOSTING_DIR / "snapshot"      # the recorded replay and event history the dashboard shows;
                                             # made by src/hosting/snapshot.py, committed (derived data only)
SITE_DIR = HOSTING_DIR / "space"             # the Hugging Face Space: a page that embeds the hosted dashboard
CARDS_DIR = HOSTING_DIR / "cards"            # dataset, model and Space card templates
APP_BUNDLE_DIR = HOSTING_DIR / "streamlit"   # what the hosted dashboard's repository adds to the code
PUBLISH_DIR = DATA_DIR / "publish"           # the dataset, model and Space folders, staged before upload

# The team's public homes: the Hugging Face organisation (dataset, model, Space, live feed) and the
# github.com organisation (the docs site's and the hosted dashboard's repositories).
HF_OWNER = "calendar-effects"
HF_REPOS = {"dataset": "calendar-effects", "model": "big-move-model", "space": "dashboard", "live": "live-feed"}
GITHUB_ORG = "Calendar-Effects"
DOCS_URL = "https://calendar-effects.mintlify.app"

# The hosted dashboard (Streamlit Community Cloud) and its live feed: during a demo the streaming
# job publishes each micro-batch to a public Hugging Face dataset (src/hosting/live.py).
DASHBOARD_URL = os.environ.get("CALENDAR_EFFECTS_DASHBOARD_URL", "https://calendar-effects.streamlit.app")
LIVE_REPO = os.environ.get("CALENDAR_EFFECTS_LIVE_REPO", f"{HF_OWNER}/{HF_REPOS['live']}")
LIVE_CACHE_DIR = DATA_DIR / "live"           # the dashboard's local copy of the live feed
# The cloud streamer (decision 0015): a private github.com repository whose "Live stream" workflow
# runs scripts/demo_live.sh on GitHub's servers, so a live run needs no team member's computer.
STREAMER_REPO = f"{GITHUB_ORG}/live-stream"
STREAMER_URL = f"https://github.com/{STREAMER_REPO}/actions/workflows/live-stream.yml"
LINKS = {                                    # where everything is, for pages and cards
    "docs": DOCS_URL,
    "dashboard": DASHBOARD_URL,
    "dataset": f"https://huggingface.co/datasets/{HF_OWNER}/{HF_REPOS['dataset']}",
    "model": f"https://huggingface.co/{HF_OWNER}/{HF_REPOS['model']}",
    "space": f"https://huggingface.co/spaces/{HF_OWNER}/{HF_REPOS['space']}",
    "huggingface": f"https://huggingface.co/{HF_OWNER}",
    "github": f"https://github.com/{GITHUB_ORG}",
    "streamer": STREAMER_URL,
}


def clean_path(dataset: str) -> Path:
    """The committed Parquet file of a clean dataset, e.g. clean_path("prices")."""
    return CLEAN_DIR / f"{dataset}.parquet"


# The course cluster's Kafka servers. Set KAFKA_BOOTSTRAP=localhost:9092 for a local Kafka.
KAFKA_BOOTSTRAP = os.environ.get("KAFKA_BOOTSTRAP", "node1.local:9092,node2.local:9092")
```


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