Skip to content

Commit e621b60

Browse files
committed
Final Commit
1 parent fe6edad commit e621b60

4 files changed

Lines changed: 34 additions & 1 deletion

File tree

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

.streamlit/secrets.toml.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,15 @@
22
# DATA_GOV_SG_API_KEY = "your-key"
33
# Optional: unlock Ops & Admin page in the Streamlit multipage app
44
# SINGAPORE_EDA_ADMIN_TOKEN = "long-random-token"
5+
6+
# Optional deployment hardening for Streamlit Community Cloud:
7+
# Auto-fetch resale CSV when selected file is missing.
8+
# SINGAPORE_EDA_AUTO_DOWNLOAD_ON_MISSING = "1"
9+
# SINGAPORE_EDA_BOOTSTRAP_MAX_ROWS = "20000"
10+
#
11+
# Auto-fetch official median-rent CSV for Rental Yield when missing.
12+
# SINGAPORE_EDA_AUTO_DOWNLOAD_RENT_ON_MISSING = "1"
13+
# SINGAPORE_EDA_RENT_BOOTSTRAP_MAX_ROWS = "200000"
14+
#
15+
# Auto-fetch full planning-area GeoJSON when tiny fixture is selected/missing.
16+
# SINGAPORE_EDA_AUTO_FETCH_GEO_ON_TINY = "1"

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,26 @@ Then: `make test` · `hdb-download -o data/raw/hdb_resale_2017_onwards.csv` (or
8181

8282
9. Add the same Streamlit URL into `quarto/index.qmd` under the "Static site vs interactive app" section so users on Pages can jump to the live app.
8383

84+
### Streamlit deployment notes (lessons learned)
85+
86+
These defaults now reflect issues encountered during deployment and the fixes applied in-repo:
87+
88+
- **Pin Python for Cloud builds:** keep both [`runtime.txt`](runtime.txt) and [`.python-version`](.python-version) set to `3.12`. This avoids unsupported runtime combinations where dependencies (for example `pyarrow`) may fall back to source builds.
89+
- **Dependency files:** Streamlit installs Python deps from [`requirements.txt`](requirements.txt). Keep `packages.txt` for apt/system packages only; do **not** put pip specifiers there.
90+
- **CSV schema guardrails:** the app expects HDB-like resale columns (at least `month`, `resale_price`). If you point the sidebar to a non-HDB CSV, the app now warns clearly and avoids silent bad fallbacks.
91+
- **Fallback order:** when the default raw resale file is missing, the app tries auto-download (if enabled), then safe built-in alternatives, and uses tiny fixtures only as a last resort.
92+
- **Map and rent auto-bootstrap:** optional Cloud toggles can auto-fetch full planning-area GeoJSON and official median-rent CSV so **Map & blocks** and **Rental yield** do not stay on minimal fixtures.
93+
94+
Recommended Streamlit Cloud secrets (copy from [`.streamlit/secrets.toml.example`](.streamlit/secrets.toml.example)):
95+
96+
```toml
97+
SINGAPORE_EDA_AUTO_DOWNLOAD_ON_MISSING = "1"
98+
SINGAPORE_EDA_BOOTSTRAP_MAX_ROWS = "20000"
99+
SINGAPORE_EDA_AUTO_DOWNLOAD_RENT_ON_MISSING = "1"
100+
SINGAPORE_EDA_RENT_BOOTSTRAP_MAX_ROWS = "200000"
101+
SINGAPORE_EDA_AUTO_FETCH_GEO_ON_TINY = "1"
102+
```
103+
84104
## Production: data.gov.sg limits, cache, health API, ops UI
85105

86106
Official **per-10-second** limits (see [`API rate limits`](https://guide.data.gov.sg/developer-guide/api-overview/api-rate-limits)) depend on whether you use an API key and its **tier**:

runtime.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-3.12
1+
3.12

0 commit comments

Comments
 (0)