File size: 3,195 Bytes
13fc29d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ש# Deploy Streamlit app (free – Streamlit Community Cloud)

## 1. Prerequisites

- App code in a **public** GitHub repo (e.g. `solarwine-ai/Baseline`).
- A [Streamlit Community Cloud](https://share.streamlit.io) account (sign in with GitHub).
- `sensors_wide_sample.csv` committed under `Data/Seymour/` (already in the repo).

## 2. Deploy steps

1. Go to **https://share.streamlit.io** and sign in with GitHub.
2. Click **"New app"**.
3. Set:
   - **Repository:** `solarwine-ai/Baseline` (or your fork).
   - **Branch:** `main`.
   - **Main file path:** `app.py`.
4. Click **"Advanced settings"** and set:
   - **Python version:** 3.11 (or match your local).
   - Leave **Requirements file** as `requirements.txt` (repo root).
5. Under **Secrets**, add your IMS API token so the app can fetch IMS data:

   ```toml
   IMS_API_TOKEN = "your-ims-api-token-here"
   ```

   Streamlit Cloud injects secrets as environment variables; the app reads `IMS_API_TOKEN` from the environment via `os.environ`.

6. Click **"Deploy"**. The first build may take a few minutes.

## 3. How data works on Community Cloud

- **Sensor data (Stage 1):**
  The full `sensors_wide.csv` (982 MB) is gitignored. Instead, a trimmed
  `sensors_wide_sample.csv` (~2.7 MB, Stage 1 columns only, growing season May-Sep)
  is committed. The app automatically falls back to the sample when the full file
  is absent — no code changes needed.

- **IMS data (Stage 2):**
  Click **Download IMS 2024–2025** in the sidebar (requires `IMS_API_TOKEN` in
  Secrets), then **Run Stage 2**. IMS data is fetched at runtime; free-tier memory
  and CPU limits apply to very large or long-running fetches.

- **Secrets:**
  Never commit `.env` or real tokens. Use only the **Secrets** field in the
  Streamlit Cloud app settings.

## 4. Regenerating the sample CSV locally

If you update the full sensor data and need to refresh the sample:

```bash
python -m scripts.create_sample_data
```

This reads `sensors_wide.csv`, extracts Stage 1 columns for May-Sep, and writes
`sensors_wide_sample.csv`. Commit the updated sample.

## 5. Configuration files

- `.streamlit/config.toml` — sets `headless = true` and light theme for Cloud.
- `requirements.txt` — Python dependencies (already in repo root).
- No `packages.txt` needed (no OS-level dependencies).

## 6. Chronos-2 long training (local)

To run LoRA fine-tuning with a large context window until results converge (single run, tuned for 32 GB RAM / 10 CPU cores):

```bash
cd /path/to/Baseline
PYTHONPATH=. conda run -n solarwine python scripts/run_chronos_long_training.py \
  --device cpu \
  --context-days 28 \
  --num-steps 4000 \
  --batch-size 16
```

- **Output:** Checkpoints in `outputs/chronos_finetuned_long/`; benchmark row `lora / all` appended to `outputs/chronos_benchmark.csv`; sample plot `outputs/chronos_forecast_sample.png`.
- **Convergence:** Chronos does not support resuming LoRA across multiple `fit()` calls; use one large `--num-steps` (e.g. 4000–6000). Training uses built-in validation; adjust `--learning-rate` (default `1e-5`) if needed.
- **Resources:** Script sets `OMP_NUM_THREADS` from CPU count; use `--batch-size 8` on lower memory.