This script scans local checked-out GitHub repositories for MicroSim metadata and updates the combined search index.
Overview
The update-local-microsims.py script provides a fast, offline alternative to the GitHub API-based crawler. It reads metadata.json files directly from local repositories in your workspace directory.
Location
1
src/update-local-microsims.py
Usage
Scan All Repositories
1
pythonsrc/update-local-microsims.py
This scans all repositories in ~/Documents/ws that have a docs/sims directory.
Scan Specific Repositories
12345
# Single repository
pythonsrc/update-local-microsims.pygeometry-course
# Multiple repositories
pythonsrc/update-local-microsims.pyalgebra-1circuitsgeometry-course
List Available Repositories
1
pythonsrc/update-local-microsims.py--list
Output:
123456789
Available repositories in /Users/dan/Documents/ws:
algebra-1 (11 sims)
circuits (18 sims)
geometry-course (27 sims)
microsims (113 sims)
...
Total: 39 repositories with docs/sims
Same repo/sim: Updates the existing entry with new metadata
New repo/sim: Adds as a new entry
Entries without _source: Preserved but may create duplicates
When the same MicroSim exists in the data:
- Running the script again will update the entry (not create a duplicate)
- The updated counter in the summary shows how many were updated
Log Format
Logs are written in JSON Lines format for easy parsing:
Ensure your workspace contains repositories with docs/sims directories:
1
ls~/Documents/ws/*/docs/sims2>/dev/null|head-5
JSON parse errors
Check the metadata.json file for syntax errors:
1
python-mjson.toolpath/to/metadata.json
Missing entries after update
The script only includes entries with valid _source data. Check the log file for errors:
1
grep'"event": "error"'logs/local-update-*.jsonl
Example Workflow
1 2 3 4 5 6 7 8 91011121314
# 1. Check which repos are available
pythonsrc/update-local-microsims.py--list
# 2. Update metadata from a specific repo you just modified
pythonsrc/update-local-microsims.pygeometry-course
# 3. Or update everything
pythonsrc/update-local-microsims.py
# 4. Verify the output
python-c"import json; d=json.load(open('docs/search/microsims-data.json')); print(f'{len(d)} entries')"# 5. Check for any issues in the log
tail-1logs/local-update-$(date+%Y-%m-%d).jsonl|python-mjson.tool
Configuration
Default values are set at the top of the script:
12
WORKSPACE_DIR=Path(os.environ.get("HOME"))/"Documents"/"ws"GITHUB_OWNER="dmccreary"# Used for URL generation
To change defaults, either:
- Use the --workspace flag
- Modify the script constants