Skip to content

Commit 640afec

Browse files
authored
Merge pull request #44 from NOAA-GSL/staging
Staging
2 parents 106eadb + 14ad6e0 commit 640afec

File tree

13 files changed

+617
-129
lines changed

13 files changed

+617
-129
lines changed

.devcontainer/entrypoint.sh

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,12 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# ====== WIKI SYNC SECTION ======
5-
FORCE_UPDATE=0
6-
REFRESH_SECONDS=${DOCS_REFRESH_SECONDS:-3600} # default 1 hour
7-
# Allow skipping wiki sync entirely (useful in restricted-network envs)
8-
SKIP_WIKI=${DATAVIZHUB_SKIP_WIKI_SYNC:-0}
9-
# Hard timeout for git clone so startup never blocks indefinitely
10-
GIT_CLONE_TIMEOUT_SECONDS=${GIT_TIMEOUT_SECONDS:-20}
11-
12-
while [[ ${1:-} ]]; do
13-
case "$1" in
14-
--force) FORCE_UPDATE=1; shift ;;
15-
--refresh-seconds) REFRESH_SECONDS="$2"; shift 2 ;;
16-
*) echo "[entrypoint] Unknown option: "$1"" >&2; exit 2 ;;
17-
esac
18-
done
19-
204
# Copy default .env if missing
215
if [[ ! -f .env && -f .devcontainer/.env ]]; then
226
echo "[entrypoint] Seeding .env from .devcontainer/.env"
237
cp .devcontainer/.env .env
248
fi
259

26-
WIKI_URL="https://github.com/NOAA-GSL/datavizhub.wiki.git"
27-
DOCS_DIR="wiki"
28-
META_FILE="$DOCS_DIR/.mirror_meta"
29-
30-
# Fix stale, non-writable wiki dirs
31-
if [[ -d "$DOCS_DIR" && ! -w "$DOCS_DIR" ]]; then
32-
echo "[entrypoint] Existing $DOCS_DIR not writable — removing"
33-
rm -rf "$DOCS_DIR" || true
34-
fi
35-
36-
now_epoch() { date +%s; }
37-
should_update=0
38-
39-
if [[ ! -d "$DOCS_DIR" ]]; then
40-
should_update=1
41-
elif [[ $FORCE_UPDATE -eq 1 ]]; then
42-
should_update=1
43-
else
44-
last_sync=0
45-
if [[ -f "$META_FILE" ]]; then
46-
# Avoid sourcing untrusted content; parse the expected key instead
47-
last_sync=$(grep -E '^last_sync_epoch=' "$META_FILE" | tail -n1 | cut -d'=' -f2 | tr -d '"' || true)
48-
last_sync=${last_sync:-0}
49-
fi
50-
now=$(now_epoch)
51-
age=$(( now - last_sync ))
52-
if (( age >= REFRESH_SECONDS )); then
53-
should_update=1
54-
fi
55-
fi
56-
57-
if [[ "$SKIP_WIKI" == "1" ]]; then
58-
echo "[entrypoint] Skipping wiki sync (DATAVIZHUB_SKIP_WIKI_SYNC=1)"
59-
else
60-
if [[ $should_update -eq 1 ]]; then
61-
echo "[entrypoint] Cloning wiki (timeout ${GIT_CLONE_TIMEOUT_SECONDS}s)..."
62-
tmp_dir="${DOCS_DIR}.new"
63-
rm -rf "$tmp_dir"
64-
CLONE_CMD=(git clone --depth=1 "$WIKI_URL" "$tmp_dir")
65-
if command -v timeout >/dev/null 2>&1; then
66-
if timeout "${GIT_CLONE_TIMEOUT_SECONDS}s" "${CLONE_CMD[@]}"; then
67-
clone_ok=1
68-
else
69-
clone_ok=0
70-
fi
71-
else
72-
# Fallback: run clone in background and wait up to N seconds
73-
set +e
74-
"${CLONE_CMD[@]}" &
75-
pid=$!
76-
waited=0
77-
while kill -0 "$pid" >/dev/null 2>&1; do
78-
if [[ $waited -ge $GIT_CLONE_TIMEOUT_SECONDS ]]; then
79-
echo "[entrypoint] WARN: git clone exceeded ${GIT_CLONE_TIMEOUT_SECONDS}s; continuing without wiki"
80-
kill "$pid" >/dev/null 2>&1 || true
81-
clone_ok=0
82-
break
83-
fi
84-
sleep 1
85-
waited=$(( waited + 1 ))
86-
done
87-
if [[ ${clone_ok:-1} -ne 0 && ! -d "$tmp_dir" ]]; then
88-
# If the process finished but dir not present, treat as failure
89-
clone_ok=0
90-
fi
91-
set -e
92-
fi
93-
if [[ ${clone_ok:-0} -eq 1 ]]; then
94-
rm -rf "$tmp_dir/.git"
95-
echo "source_url=\"$WIKI_URL\"" > "$tmp_dir/.mirror_meta"
96-
echo "last_sync_epoch=$(now_epoch)" >> "$tmp_dir/.mirror_meta"
97-
rm -rf "$DOCS_DIR" || true
98-
mv "$tmp_dir" "$DOCS_DIR" || cp -R "$tmp_dir"/. "$DOCS_DIR"
99-
rm -rf "$tmp_dir"
100-
echo "[entrypoint] Wiki synced"
101-
else
102-
echo "[entrypoint] WARN: Wiki clone skipped/failed; proceeding without update"
103-
rm -rf "$tmp_dir" || true
104-
fi
105-
else
106-
echo "[entrypoint] Wiki is fresh; skipping sync"
107-
fi
108-
fi
109-
11010
# ====== SERVICE START SECTION ======
11111
AUTOSTART_API=${DATAVIZHUB_AUTOSTART_API:-1}
11212
AUTOSTART_RQ=${DATAVIZHUB_AUTOSTART_RQ:-${DATAVIZHUB_USE_REDIS:-0}}

.github/workflows/sync-wiki.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Sync Wiki to Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- "**" # Run on all branches
7+
pull_request: # Ensure PR builds include wiki
8+
schedule:
9+
- cron: "0 6 * * *" # Daily sync at 6 AM UTC
10+
workflow_dispatch: # Manual trigger
11+
12+
permissions:
13+
contents: write # Allow pushing synced wiki changes
14+
15+
jobs:
16+
sync-wiki:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout main repo
21+
uses: actions/checkout@v4
22+
with:
23+
path: main
24+
25+
- name: Checkout wiki repo
26+
uses: actions/checkout@v4
27+
with:
28+
repository: ${{ github.repository }}.wiki
29+
path: wiki
30+
31+
- name: Sync wiki into docs/source/wiki
32+
run: |
33+
rsync -av --delete wiki/ main/docs/source/wiki/
34+
35+
- name: Commit wiki changes (main only)
36+
run: |
37+
cd main
38+
if [ "${{ github.ref_name }}" = "main" ]; then
39+
git config user.name "github-actions[bot]"
40+
git config user.email "github-actions[bot]@users.noreply.github.com"
41+
git add docs/source/wiki/
42+
if ! git diff --cached --quiet; then
43+
git commit -m "chore(docs): sync wiki into docs/source/wiki"
44+
git push
45+
else
46+
echo "No changes to commit"
47+
fi
48+
else
49+
echo "Skipping commit: branch is ${{ github.ref_name }}"
50+
fi

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ cover/
8282
docs/_build/
8383
docs/build/
8484

85-
# Wiki documentation in dev container (used as context)
86-
wiki/
87-
app/wiki/
8885

8986
# Samples: generated artifacts (keep repo small and clean)
9087
samples/samples/quickstart_outputs/

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ Dev container:
5252

5353
## Documentation Sources
5454
- Wiki: https://github.com/NOAA-GSL/datavizhub/wiki (authoritative documentation for humans and AIs).
55-
- Dev container mirror: `/wiki` contains an auto-cloned snapshot of the wiki for offline/context use. It auto-refreshes at most once per hour on container start. Force refresh with `bash .devcontainer/postStart.sh --force`. This folder lives outside the repo and is not part of the main repository—do not commit its contents.
55+
- CI-synced wiki: A GitHub Action mirrors the GitHub Wiki into `docs/source/wiki/` so it is built with Sphinx. Do not edit `docs/source/wiki/` directly; changes are committed only on `main`.

CONTRIBUTING.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Contributing to DataVizHub
2+
3+
Thanks for your interest in contributing!
4+
This project thrives on community contributions, and we welcome improvements of all kinds.
5+
6+
---
7+
8+
## License and Contributor Terms
9+
10+
- DataVizHub is licensed under the MIT License. See `LICENSE` at the repository root.
11+
- By submitting a pull request, issue suggestion, or any code/documentation/artwork (“Contribution”),
12+
you agree to license your Contribution under the MIT License, and you represent that you have the
13+
right to do so.
14+
- Do not contribute code or assets you don’t have rights to. If you include third‑party code or data,
15+
ensure it is compatible with MIT and include proper attribution as required by the original license.
16+
- No CLA is required at this time; contributions are accepted under the project’s MIT terms.
17+
18+
If you have questions about licensing or attribution, please open an issue before submitting your PR.
19+
20+
---
21+
22+
## Branching Workflow
23+
24+
To keep development organized, we use a two-branch model:
25+
26+
- **`main`** → Stable, production-ready branch.
27+
- Always passes tests and CI/CD.
28+
- Used for tagged releases.
29+
- Do **not** commit directly to `main`.
30+
31+
- **`staging`** → Integration branch.
32+
- Collects feature branches and fixes before merging into `main`.
33+
- Used for testing, docs, and CI validation.
34+
35+
### Rules
36+
1. **Feature Development**
37+
- Branch off `staging`:
38+
```bash
39+
git checkout staging
40+
git pull origin staging
41+
git checkout -b feature/my-feature
42+
```
43+
- Open a Pull Request (PR) into `staging`.
44+
45+
2. **Testing & Integration**
46+
- PRs are merged into `staging`.
47+
- CI/CD runs against `staging`.
48+
- Once stable, `staging` is merged into `main`.
49+
50+
3. **Syncing Main & Staging**
51+
- Occasionally merge `main → staging` to keep hotfixes and metadata aligned.
52+
- Always merge `staging → main` via PR when ready to release.
53+
54+
---
55+
56+
## Code Style
57+
58+
- Python 3.10+ required.
59+
- Follow [PEP8](https://peps.python.org/pep-0008/).
60+
- Run `ruff` and `pytest` locally before opening a PR.
61+
62+
---
63+
64+
## Testing
65+
66+
1. Install dev dependencies:
67+
```bash
68+
poetry install
69+
```
70+
2. Run tests:
71+
```bash
72+
pytest
73+
```
74+
75+
---
76+
77+
## Pull Requests
78+
79+
- Make sure your branch is up-to-date with `staging`.
80+
- Include descriptive commit messages.
81+
- Request a review from at least one maintainer.
82+
83+
---
84+
85+
## Releases
86+
87+
- Releases are tagged from `main`.
88+
- `staging` must be fully merged into `main` before tagging.
89+
90+
---
91+
92+
Thanks again for contributing!

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -689,9 +689,7 @@ with open("/data/out/movie.mp4", "rb") as f:
689689
- API Routers and Endpoints: https://github.com/NOAA-GSL/datavizhub/wiki/DataVizHub-API-Routers-and-Endpoints
690690
- Security Quickstart: https://github.com/NOAA-GSL/datavizhub/wiki/DataVizHub-API-Security-Quickstart
691691
- API docs (GitHub Pages): https://noaa-gsl.github.io/datavizhub/
692-
- Dev container: A read-only mirror of the wiki is auto-cloned into `/wiki` when the dev container starts. It auto-refreshes at most once per hour. This folder is ignored by Git and is not part of the repository on GitHub.
693-
- Force refresh: `bash .devcontainer/postStart.sh --force` (or set `DOCS_REFRESH_SECONDS` to adjust the hourly cadence).
694-
- Note: There is no `docs/` directory in the main repo. If you are not using the dev container, read the wiki directly.
692+
- CI-synced wiki: A GitHub Action mirrors the wiki into `docs/source/wiki/` so Sphinx can build it with the docs. Sync commits occur only on `main`; PRs/branches use the synced copy for builds without committing changes.
695693

696694
## Notes
697695
- Paths: examples use absolute paths (e.g., `/data/...`) for clarity, but the library does not assume a specific root; configure paths via your own settings or env vars if preferred.

docs/source/conf.py

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@
1919
# -- General configuration ---------------------------------------------------
2020

2121
extensions = [
22+
"myst_parser", # Enable Markdown support
2223
"sphinx.ext.autodoc",
2324
"sphinx.ext.autosummary",
2425
"sphinx.ext.napoleon",
2526
"sphinx.ext.viewcode",
2627
]
2728

2829
templates_path = ["_templates"]
29-
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
30+
exclude_patterns = [
31+
"_build",
32+
"Thumbs.db",
33+
".DS_Store",
34+
]
3035

3136
# Napoleon settings for NumPy-style docstrings
3237
napoleon_google_docstring = False
@@ -43,22 +48,42 @@
4348

4449
# -- Options for HTML output -------------------------------------------------
4550

51+
# Default to alabaster; override if RTD theme is available
52+
html_theme = "alabaster"
4653
if _ils.find_spec("sphinx_rtd_theme") is not None: # pragma: no cover - docs build env
4754
html_theme = "sphinx_rtd_theme"
48-
else:
49-
html_theme = "alabaster"
5055
html_static_path = ["_static"]
5156

5257
# Autosummary/napoleon tweaks for cleaner API pages
5358
autosummary_generate = True
5459
autosummary_imported_members = False
55-
html_theme_options = {
56-
"navigation_depth": 3,
57-
"collapse_navigation": False,
58-
"sticky_navigation": True,
60+
if html_theme == "sphinx_rtd_theme":
61+
html_theme_options = {
62+
"navigation_depth": 3,
63+
"collapse_navigation": False,
64+
"sticky_navigation": True,
65+
}
66+
else:
67+
html_theme_options = {}
68+
69+
# Support both .rst and .md sources
70+
source_suffix = {
71+
".rst": "restructuredtext",
72+
".md": "markdown",
5973
}
6074

6175
# Mock optional heavy dependencies to allow building API docs without extras
76+
# Note for maintainers:
77+
# - Importing some API modules executes module-level side effects that are
78+
# incompatible with a docs-build environment (CI or local), for example:
79+
# - Creating or touching filesystem paths (e.g., '/data/uploads') during import
80+
# - Initializing FastAPI app and router wiring (which pulls in optional deps)
81+
# - Triggering background worker wiring (RQ/Redis) or reading env config
82+
# - Potential network or service assumptions when modules import clients
83+
# - To keep the docs build hermetic and fast, we mock these modules so that
84+
# autodoc can still render signatures without executing their import-time code.
85+
# - If you reduce import-time side effects in these modules, feel free to
86+
# remove them from this list.
6287
autodoc_mock_imports = [
6388
"boto3",
6489
"botocore",
@@ -77,4 +102,13 @@
77102
"ffmpeg",
78103
"ffmpeg_python",
79104
"ffmpeg-python",
105+
# Mock API submodules that cause side effects on import during docs build
106+
"datavizhub.api",
107+
"datavizhub.api.server",
108+
"datavizhub.api.routers",
109+
"datavizhub.api.routers.cli",
110+
"datavizhub.api.routers.files",
111+
"datavizhub.api.workers",
112+
"datavizhub.api.workers.executor",
113+
"datavizhub.api.workers.jobs",
80114
]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Wiki Sync Workflow
2+
3+
## Why
4+
- Keeps wiki knowledge versioned with code for branches and PRs.
5+
- Ensures contributors can build docs with up-to-date wiki content.
6+
- Simplifies builds by removing Docker-based wiki mirroring.
7+
8+
## How
9+
- A GitHub Action syncs the GitHub Wiki into `docs/source/wiki/` on pushes, PRs, and a daily schedule.
10+
- Sphinx (with `myst_parser`) builds Markdown wiki pages alongside the docs.
11+
- Commits of wiki changes occur only on `main` to keep history clean.
12+
13+
## Editing Rules
14+
- Edit wiki pages via the GitHub Wiki UI.
15+
- Do not edit `docs/source/wiki/` directly; it is overwritten on sync.

0 commit comments

Comments
 (0)