|
1 | 1 | # Publishing & Syncing Data (DVC) |
2 | 2 |
|
| 3 | +<style>.md-typeset { font-size: 0.8rem; }</style> |
| 4 | + |
3 | 5 | EPM **code** is public, but the **data** (input CSVs, results) is kept in a **private |
4 | 6 | store** — not in this public repository. The repo only keeps tiny **pointer files** |
5 | 7 | (`*.dvc`); the real data lives in the store and is fetched on demand. |
@@ -27,23 +29,24 @@ and is moved with `dvc push` / `dvc pull`. So git stays light, and the data stay |
27 | 29 |
|
28 | 30 | You work in **your clone of the EPM repo** — the same folder you run EPM from. |
29 | 31 |
|
30 | | -**A. If you already run EPM on this machine** (Python env ready) — just add the data tools: |
| 32 | +=== "Already running EPM here" |
31 | 33 |
|
32 | | -```bash |
33 | | -# in your EPM Python environment (the one you use to run EPM) |
34 | | -pip install -r requirements.txt |
35 | | -``` |
36 | | -This installs **DVC**, `s3fs`, and (on Windows) `pip-system-certs`. |
| 34 | + Your Python environment is ready — just add the data tools: |
| 35 | + ```bash |
| 36 | + pip install -r requirements.txt |
| 37 | + ``` |
| 38 | + Installs **DVC**, `s3fs`, and (on Windows) `pip-system-certs`. |
37 | 39 |
|
38 | | -**B. If it's a fresh machine** — set EPM up first, then the line above: |
| 40 | +=== "Fresh machine" |
39 | 41 |
|
40 | | -```bash |
41 | | -git clone https://github.com/ESMAP-World-Bank-Group/EPM.git |
42 | | -cd EPM |
43 | | -git checkout <your-branch> # e.g. blacksea_2026 |
44 | | -conda activate <your-epm-env> # your EPM Python environment |
45 | | -pip install -r requirements.txt |
46 | | -``` |
| 42 | + Set EPM up first, then install: |
| 43 | + ```bash |
| 44 | + git clone https://github.com/ESMAP-World-Bank-Group/EPM.git |
| 45 | + cd EPM |
| 46 | + git checkout <your-branch> # e.g. blacksea_2026 |
| 47 | + conda activate <your-epm-env> # your EPM Python environment |
| 48 | + pip install -r requirements.txt |
| 49 | + ``` |
47 | 50 |
|
48 | 51 | **Then (both cases) add your store keys — once:** |
49 | 52 |
|
@@ -78,25 +81,32 @@ That's it — the store URL/endpoint is already in the repo (`.dvc/config`). |
78 | 81 | This moves a model's data **out of git** into the store. Do it **once**, by whoever sets the |
79 | 82 | model up; afterwards everyone just uses *setup + publish/sync*. |
80 | 83 |
|
| 84 | +**One command** (from the repo root) — it asks for confirmation, then makes the change locally: |
| 85 | + |
81 | 86 | ```bash |
82 | | -# 1. Initialise DVC for the repo (once per repo) |
83 | | -dvc init |
| 87 | +powershell -File tools/setup_model.ps1 data_<model> # e.g. data_sapp |
| 88 | +``` |
84 | 89 |
|
85 | | -# 2. Point DVC at the store |
86 | | -dvc remote add -d store s3://<bucket>/dvcstore |
87 | | -dvc remote modify store endpointurl <endpoint> |
| 90 | +Then **review** (`git status`) and **publish** (double-click `Publish.bat`). Finally, to make |
| 91 | +**EPM View** show this model, add its branch name to `R2_BRANCHES` in `src/utils/epmFetch.js` |
| 92 | +of the `epm-data-explorer` repo. |
88 | 93 |
|
89 | | -# 3. In .gitignore: remove the line that force-tracks your data folder, |
90 | | -# and add an exception for its pointer: |
91 | | -# !epm/input/data_<model>.dvc |
| 94 | +??? info "What `setup_model.ps1` does under the hood (the manual steps)" |
| 95 | + The script automates exactly these — your files **stay on disk**, and it commits/pushes |
| 96 | + nothing (you review, then publish): |
92 | 97 |
|
93 | | -# 4. Stop tracking the data in git (files stay on your disk), then hand it to DVC |
94 | | -git rm -r --cached epm/input/data_<model> |
95 | | -dvc add epm/input/data_<model> # creates the .dvc pointer |
96 | | -``` |
97 | | - |
98 | | -Then **publish** (step 4). Finally, to make **EPM View** read this model from the store, add |
99 | | -its branch name to `R2_BRANCHES` in `src/utils/epmFetch.js` of the `epm-data-explorer` repo. |
| 98 | + ```bash |
| 99 | + # 1. Initialise DVC for the repo (once per repo) |
| 100 | + dvc init |
| 101 | + # 2. Point DVC at the store (once — already set in this repo's .dvc/config) |
| 102 | + dvc remote add -d store s3://<bucket>/dvcstore |
| 103 | + dvc remote modify store endpointurl <endpoint> |
| 104 | + # 3. .gitignore: drop the whitelist of the data folder, keep its pointer tracked |
| 105 | + # !epm/input/data_<model>.dvc |
| 106 | + # 4. Stop tracking the data in git (files stay), then hand the folder to DVC |
| 107 | + git rm -r --cached epm/input/data_<model> |
| 108 | + dvc add epm/input/data_<model> # creates the .dvc pointer |
| 109 | + ``` |
100 | 110 |
|
101 | 111 | --- |
102 | 112 |
|
@@ -163,5 +173,6 @@ run the model with up-to-date data. |
163 | 173 | |------|------| |
164 | 174 | | `publish.ps1` | engine behind `Publish.bat` | |
165 | 175 | | `sync.ps1` / `sync.sh` | get code + data (Windows / server) | |
| 176 | +| `setup_model.ps1` | onboard a new model's data to the store (one-time, step 3) | |
166 | 177 | | `upload_to_r2.py`, `upload_output_view_to_r2.py` | upload the readable copies | |
167 | 178 | | `.env.example` | keys template (copy to `.env`, git-ignored) | |
0 commit comments