Skip to content

Commit 4312966

Browse files
refactor: reorganize automation directory structure (#3164)
Reorganize directory structure to better separate concerns: - automation/ → Only workflow-specific scripts used by GitHub Actions - scripts/ → One-time migrations and manual utilities - core/generators/ → Reusable business logic components Changes: - Move one-time migration scripts to scripts/: - backfill_review_metadata.py - fix_library_versions.py - migrate_metadata_format.py - migrate_to_new_structure.py - upgrade_specs.py - upgrade_specs_ai.py - Move reusable generators to core/generators/: - plot_generator.py (from automation/generators/) - Update imports in tests and documentation - Update repository.md with new directory structure - Add sections explaining automation/ vs scripts/ principles All tests pass successfully. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 471167e commit 4312966

File tree

11 files changed

+60
-16
lines changed

11 files changed

+60
-16
lines changed

docs/architecture/repository.md

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,13 @@ pyplots/
7676
├── core/ # Shared business logic
7777
│ ├── __init__.py
7878
│ ├── config.py # Configuration (.env-based)
79-
│ └── database/ # Database layer
80-
│ ├── __init__.py
81-
│ ├── connection.py # Async connection management
82-
│ ├── models.py # SQLAlchemy ORM models
83-
│ └── repositories.py # Repository pattern
79+
│ ├── database/ # Database layer
80+
│ │ ├── __init__.py
81+
│ │ ├── connection.py # Async connection management
82+
│ │ ├── models.py # SQLAlchemy ORM models
83+
│ │ └── repositories.py # Repository pattern
84+
│ └── generators/ # Reusable code generators
85+
│ └── plot_generator.py # Plot code generation utilities
8486
8587
├── api/ # FastAPI backend
8688
│ ├── __init__.py
@@ -95,9 +97,12 @@ pyplots/
9597
│ ├── package.json
9698
│ └── Dockerfile
9799
98-
├── automation/ # Automation scripts
99-
│ └── scripts/
100-
│ └── sync_to_postgres.py # Sync plots/ to database
100+
├── automation/ # Workflow automation
101+
│ └── scripts/ # Workflow-specific utilities
102+
│ ├── sync_to_postgres.py # Sync plots/ to database
103+
│ ├── workflow_utils.py # Utilities for GitHub Actions
104+
│ ├── label_manager.py # Label operations
105+
│ └── workflow_cli.py # CLI for workflows
101106
102107
├── tests/ # Test suite
103108
│ └── unit/
@@ -121,6 +126,15 @@ pyplots/
121126
├── alembic/ # Database migrations
122127
│ └── versions/
123128
129+
├── scripts/ # One-time and manual scripts
130+
│ ├── evaluate-plot.py # Manual plot evaluation
131+
│ ├── regenerate-thumbnails.py # Image processing
132+
│ ├── backfill_review_metadata.py # One-time migration
133+
│ ├── fix_library_versions.py # One-time fix
134+
│ ├── migrate_metadata_format.py # One-time migration
135+
│ ├── migrate_to_new_structure.py # One-time migration
136+
│ └── upgrade_specs*.py # Spec upgrade utilities
137+
124138
├── docs/ # Documentation
125139
│ ├── architecture/
126140
│ ├── workflow.md
@@ -390,12 +404,42 @@ plt.savefig('plot.png', dpi=300)
390404

391405
### `core/`
392406

393-
**Purpose**: Shared business logic used by API
407+
**Purpose**: Shared business logic and reusable components
394408

395409
**Key Components**:
396410
- `database/connection.py` - Async database connection
397411
- `database/models.py` - SQLAlchemy ORM models
398412
- `database/repositories.py` - Repository pattern for data access
413+
- `generators/plot_generator.py` - Reusable plot code generation utilities
414+
415+
---
416+
417+
### `automation/`
418+
419+
**Purpose**: Workflow-specific automation used by GitHub Actions
420+
421+
**Key Components**:
422+
- `scripts/sync_to_postgres.py` - Database sync (used by sync-postgres.yml)
423+
- `scripts/workflow_utils.py` - Parsing and utilities for workflows
424+
- `scripts/label_manager.py` - Label operations and transitions
425+
- `scripts/workflow_cli.py` - CLI interface for workflow steps
426+
427+
**Principle**: Only contains components actively used by workflows. One-time or manual scripts belong in `scripts/`.
428+
429+
---
430+
431+
### `scripts/`
432+
433+
**Purpose**: One-time migrations and manually-run utilities
434+
435+
**Key Components**:
436+
- `evaluate-plot.py` - Manual plot quality evaluation
437+
- `regenerate-thumbnails.py` - Image processing utilities
438+
- `backfill_review_metadata.py` - One-time backfill migration
439+
- `migrate_*.py` - One-time structure migrations
440+
- `upgrade_specs*.py` - Spec upgrade utilities
441+
442+
**Principle**: Scripts that are not part of automated workflows. Used for maintenance, migrations, and manual operations.
399443

400444
---
401445

docs/concepts/claude-skill-plot-generation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ claude-skill plot-generation \
500500
### Example 2: From Python
501501

502502
```python
503-
# automation/generators/claude_generator.py
503+
# core/generators/claude_generator.py
504504
from claude_skills import invoke_skill
505505

506506
result = invoke_skill(

automation/scripts/backfill_review_metadata.py renamed to scripts/backfill_review_metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
always takes the LAST one (the one that led to merge).
1212
1313
Usage:
14-
python automation/scripts/backfill_review_metadata.py --dry-run
15-
python automation/scripts/backfill_review_metadata.py --execute
14+
python scripts/backfill_review_metadata.py --dry-run
15+
python scripts/backfill_review_metadata.py --execute
1616
1717
Requires:
1818
- gh CLI authenticated
File renamed without changes.

automation/scripts/migrate_metadata_format.py renamed to scripts/migrate_metadata_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
2. metadata/{library}.yaml: Flatten current:, remove history, add created/updated/review
88
3. implementations/*.py: Update docstring header to new format
99
10-
Run: uv run python automation/scripts/migrate_metadata_format.py
10+
Run: uv run python scripts/migrate_metadata_format.py
1111
"""
1212

1313
import re

automation/scripts/migrate_to_new_structure.py renamed to scripts/migrate_to_new_structure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
- metadata/{library}.yaml (per-library: preview_url, current, history)
1313
1414
Usage:
15-
python automation/scripts/migrate_to_new_structure.py [--dry-run]
15+
python scripts/migrate_to_new_structure.py [--dry-run]
1616
"""
1717

1818
import argparse

0 commit comments

Comments
 (0)