Skip to content

Commit 59cf704

Browse files
committed
update README and bash script to usable both with uv and with pip
1 parent ade3e63 commit 59cf704

2 files changed

Lines changed: 99 additions & 22 deletions

File tree

README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,56 @@
22

33
A website to display the results of running the sw metadata bot on different organizations
44

5-
## Generating the Dashboard
5+
## Installation
66

7-
The landing page (`index.html`) is generated dynamically from the JSON data report using a Python script and a Mustache template.
7+
### Option 1: Using uv (recommended)
88

9-
### Requirements
9+
```bash
10+
uv sync
11+
```
12+
13+
This creates/updates `.venv` and installs all project dependencies from `pyproject.toml`.
14+
15+
### Option 2: Using pip
16+
17+
```bash
18+
python -m pip install --upgrade pip
19+
python -m pip install "pystache>=0.6.8" "sw-metadata-bot>=0.4.1"
20+
```
21+
22+
If you prefer isolated environments, create and activate a virtual environment first:
1023

11-
You need Python 3 and the `pystache` library to generate the HTML file:
24+
```bash
25+
python -m venv .venv
26+
source .venv/bin/activate
27+
python -m pip install --upgrade pip
28+
python -m pip install "pystache>=0.6.8" "sw-metadata-bot>=0.4.1"
29+
```
30+
31+
## Running Analysis and Updating the Dashboard
32+
33+
Use the helper script to run new analysis, submit issues and update the index.html:
1234

1335
```bash
14-
pip install pystache
36+
bash input/run_analysis.sh
1537
```
1638

17-
### How to Generate
39+
The script now supports two modes automatically:
1840

19-
1. Ensure that the latest JSON report is saved as `created_issues_report.json` in this directory.
20-
2. Run the generation script:
41+
1. `uv` mode when both `uv` and `.venv/` are available
42+
2. `pip` fallback mode when `uv` is not available or `.venv/` does not exist
43+
44+
In fallback mode, it installs required Python dependencies (`sw-metadata-bot`, `pystache`) with `pip` before running.
45+
46+
## Generating Only the Landing Page
47+
48+
If analysis output already exists, regenerate HTML pages with:
2149

2250
```bash
23-
python generate.py
51+
python generate_landing_page.py --config-file input/config.json
2452
```
2553

26-
This script will read the JSON data, parse it, and render it through `template.mustache` to output a the `index.html` file in the same directory.
54+
The generator reads snapshots from `outputs/<run_name>/<snapshot_tag>/run_report.json` and renders:
55+
56+
1. `index.html` for the latest snapshot
57+
2. `history/report_<snapshot_tag>.html` for each available snapshot

input/run_analysis.sh

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,69 @@
11
#!/bin/bash
22

3-
# This script runs the analysis of the bot's performance and generates a report.
3+
# This script runs the analysis workflow and updates the dashboard.
4+
set -euo pipefail
45

56
CONFIG_FILE="input/config.json"
6-
# make sure venv is up to date
7-
uv sync
87

9-
# run analysis using the bot's command line interface
10-
uv run sw-metadata-bot run-analysis --config-file $CONFIG_FILE
8+
USE_UV=false
9+
if command -v uv >/dev/null 2>&1 && [ -d ".venv" ]; then
10+
USE_UV=true
11+
fi
12+
13+
if [ "$USE_UV" = true ]; then
14+
echo "Using uv environment (.venv detected)."
15+
uv sync
16+
else
17+
echo "Using pip fallback (uv missing or .venv not found)."
18+
19+
if [ -x ".venv/bin/python" ]; then
20+
PYTHON_BIN=".venv/bin/python"
21+
elif command -v python3 >/dev/null 2>&1; then
22+
PYTHON_BIN="python3"
23+
elif command -v python >/dev/null 2>&1; then
24+
PYTHON_BIN="python"
25+
else
26+
echo "Error: No Python interpreter found."
27+
exit 1
28+
fi
29+
30+
"$PYTHON_BIN" -m pip install --upgrade pip
31+
"$PYTHON_BIN" -m pip install "pystache>=0.6.8" "sw-metadata-bot>=0.4.1"
32+
fi
33+
34+
if [ "$USE_UV" = true ]; then
35+
uv run sw-metadata-bot run-analysis --config-file "$CONFIG_FILE"
36+
else
37+
"$PYTHON_BIN" -m sw_metadata_bot.main run-analysis --config-file "$CONFIG_FILE"
38+
fi
1139

1240
echo "Analysis completed. Publishing results to respective repositories..."
1341

14-
OUTPUT_DIR=$(uv run python -c "import read_config; config = read_config.read_config('$CONFIG_FILE'); print(read_config.get_output_folder(config))")
15-
# get latest subfolder created from config file
16-
LATEST_SUBFOLDER=$(ls -td $OUTPUT_DIR/*/ | head -1)
42+
if [ "$USE_UV" = true ]; then
43+
OUTPUT_DIR=$(uv run python -c "import read_config; config = read_config.read_config('$CONFIG_FILE'); print(read_config.get_output_folder(config))")
44+
else
45+
OUTPUT_DIR=$(
46+
"$PYTHON_BIN" -c "import read_config; config = read_config.read_config('$CONFIG_FILE'); print(read_config.get_output_folder(config))"
47+
)
48+
fi
49+
50+
# Get latest snapshot folder from output directory.
51+
LATEST_SUBFOLDER=$(ls -td "$OUTPUT_DIR"/*/ | head -1)
52+
if [ -z "${LATEST_SUBFOLDER:-}" ]; then
53+
echo "Error: No snapshot folder found under $OUTPUT_DIR"
54+
exit 1
55+
fi
56+
57+
if [ "$USE_UV" = true ]; then
58+
uv run sw-metadata-bot publish --analysis-root "$LATEST_SUBFOLDER"
59+
else
60+
"$PYTHON_BIN" -m sw_metadata_bot.main publish --analysis-root "$LATEST_SUBFOLDER"
61+
fi
1762

18-
# publish results to github pages
19-
uv run sw-metadata-bot publish --analysis-root $LATEST_SUBFOLDER/
2063
echo "Issues submitted to the repositories"
2164

22-
# generate landing page
23-
uv run python generate_landing_page.py
65+
if [ "$USE_UV" = true ]; then
66+
uv run python generate_landing_page.py --config-file "$CONFIG_FILE"
67+
else
68+
"$PYTHON_BIN" generate_landing_page.py --config-file "$CONFIG_FILE"
69+
fi

0 commit comments

Comments
 (0)