Skip to content

Commit 49d8dd1

Browse files
committed
Initial scaffold
0 parents  commit 49d8dd1

19 files changed

Lines changed: 5270 additions & 0 deletions

.env.example

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copy to .env.local for local overrides. Vite only exposes vars prefixed VITE_.
2+
3+
# Which data source to use: "local" or "hf".
4+
# Defaults: "local" in dev, "hf" in production builds.
5+
VITE_DATA_SOURCE=local
6+
7+
# Path to the local dataset (relative to public/). JSON Lines format.
8+
VITE_LOCAL_DATA_PATH=data/sample.jsonl
9+
10+
# HuggingFace dataset coordinates. Used when VITE_DATA_SOURCE=hf.
11+
VITE_HF_DATASET=username/your-dataset
12+
VITE_HF_CONFIG=default
13+
VITE_HF_SPLIT=train

.github/workflows/deploy.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
# Cancel in-flight runs but always finish the latest one.
14+
concurrency:
15+
group: pages
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
cache: npm
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Build
33+
env:
34+
# GitHub Pages serves the site from /<repo-name>/
35+
BASE_PATH: /${{ github.event.repository.name }}/
36+
# Production build: read from the HuggingFace API.
37+
# Set HF_DATASET as a repository variable (Settings → Variables → Actions).
38+
VITE_DATA_SOURCE: hf
39+
VITE_HF_DATASET: ${{ vars.HF_DATASET }}
40+
VITE_HF_CONFIG: ${{ vars.HF_CONFIG || 'default' }}
41+
VITE_HF_SPLIT: ${{ vars.HF_SPLIT || 'train' }}
42+
run: npm run build
43+
44+
- uses: actions/configure-pages@v4
45+
46+
- uses: actions/upload-pages-artifact@v3
47+
with:
48+
path: dist
49+
50+
deploy:
51+
needs: build
52+
runs-on: ubuntu-latest
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deployment.outputs.page_url }}
56+
steps:
57+
- id: deployment
58+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules
2+
dist
3+
dist-ssr
4+
.vite
5+
*.log
6+
.DS_Store
7+
.env
8+
.env.local
9+
.env.*.local
10+
11+
# Larger exported datasets — keep the small sample committed but
12+
# avoid checking in big exports. Uncomment if needed.
13+
# public/data/*.jsonl
14+
# !public/data/sample.jsonl

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Time Series Explorer
2+
3+
Static web UI for exploring a HuggingFace time-series dataset. Reads from a
4+
local JSONL file during development and from the HuggingFace Datasets Server
5+
API in production. Deploys to GitHub Pages.
6+
7+
This is the **scaffolding phase** — the UI is intentionally a bare placeholder
8+
that just confirms the data pipeline works end to end. Real exploration UI
9+
lands in the design phase.
10+
11+
## Stack
12+
13+
- **Vite + React** — fast dev loop, builds to static files for GitHub Pages.
14+
- **Plotly.js** (via `react-plotly.js` factory + `plotly.js-dist-min`) — zoom,
15+
pan, and rangeslider come built in.
16+
- Plain JavaScript (no TypeScript) — easy to add later if it earns its keep.
17+
18+
## Project layout
19+
20+
```
21+
.
22+
├── index.html # Vite entry
23+
├── vite.config.js # base path is configurable for GH Pages
24+
├── package.json
25+
├── public/
26+
│ └── data/
27+
│ └── sample.jsonl # tiny synthetic dataset for the dev loop
28+
├── src/
29+
│ ├── main.jsx # React mount
30+
│ ├── App.jsx # placeholder UI (loads data, plots row 0)
31+
│ ├── index.css
32+
│ ├── config.js # reads VITE_* env vars, picks data source
33+
│ ├── components/
34+
│ │ └── Plot.jsx # Plotly wrapper (factory + dist-min)
35+
│ └── data/
36+
│ ├── DataSource.js # abstract interface
37+
│ ├── LocalDataSource.js # fetches JSONL from public/
38+
│ ├── HFDataSource.js # hits datasets-server.huggingface.co
39+
│ └── index.js # factory: returns the right one for the env
40+
├── scripts/
41+
│ └── export_to_json.py # HF dataset → JSONL for local dev
42+
└── .github/workflows/
43+
└── deploy.yml # build + deploy to GitHub Pages
44+
```
45+
46+
## Quick start
47+
48+
```bash
49+
npm install
50+
npm run dev
51+
```
52+
53+
Opens at http://localhost:5173 reading `public/data/sample.jsonl` (5 short
54+
synthetic series). You should see metadata up top and a Plotly preview of the
55+
first row.
56+
57+
## Switching data sources
58+
59+
Two modes, controlled by `VITE_DATA_SOURCE`:
60+
61+
| Mode | Reads from | When |
62+
| ------- | ------------------------------------------- | ----------- |
63+
| `local` | `public/<VITE_LOCAL_DATA_PATH>` (JSONL) | dev default |
64+
| `hf` | HuggingFace Datasets Server API (no auth, public datasets) | prod default |
65+
66+
### Use your real dataset locally
67+
68+
Convert the on-disk HF dataset to JSONL once:
69+
70+
```bash
71+
pip install datasets
72+
python scripts/export_to_json.py \
73+
--dataset /path/to/your/saved/dataset \
74+
--output public/data/dataset.jsonl
75+
```
76+
77+
Then in `.env.local`:
78+
79+
```
80+
VITE_LOCAL_DATA_PATH=data/dataset.jsonl
81+
```
82+
83+
For fast iteration while developing, pass `--limit 200` to export a subset.
84+
85+
### Point at the HuggingFace Hub instead
86+
87+
Once your dataset is uploaded:
88+
89+
```
90+
VITE_DATA_SOURCE=hf
91+
VITE_HF_DATASET=your-username/your-dataset
92+
VITE_HF_CONFIG=default
93+
VITE_HF_SPLIT=train
94+
```
95+
96+
The `HFDataSource` paginates the `/rows` endpoint (which caps at 100 rows per
97+
request).
98+
99+
## Deploying to GitHub Pages
100+
101+
1. Push this repo to GitHub.
102+
2. **Settings → Pages**: set source to **GitHub Actions**.
103+
3. **Settings → Secrets and variables → Actions → Variables**: add
104+
`HF_DATASET` (and optionally `HF_CONFIG`, `HF_SPLIT`).
105+
4. Push to `main`. The workflow builds with `BASE_PATH=/<repo-name>/` and
106+
deploys.
107+
108+
The site URL will be `https://<your-username>.github.io/<repo-name>/`.
109+
110+
> Static-site limitation: any HF token shipped with the build is public, so
111+
> the dataset must remain **public** on HuggingFace for this deployment model.
112+
113+
## What's intentionally not here yet
114+
115+
- Schema-aware exploration (filtering, multi-series overlay, search) — design
116+
phase.
117+
- Styling beyond a minimal reset — design phase.
118+
- Tests — once the data layer firms up.
119+
- TypeScript — straightforward to add when the surface is bigger.
120+
121+
## Next step
122+
123+
Share a sample row (or the dataset schema) and we'll lock in the data shape
124+
the rest of the UI will be built around.

index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Time Series Explorer</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/main.jsx"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)