Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ The GitHub Actions user needs these permissions:
- Lambda full access
- DynamoDB full access
- API Gateway full access
- S3 access for SAM artifacts
- S3 access for deployment artifacts (e.g. Lambda bundles, Pulumi state backups as configured)
- Secrets Manager read access

## Deployment Flow
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ security-reports/
vulnerability-reports/
.snyk
.artifacts/*
.artifacts-downloaded/
!.artifacts/security/
.artifacts/security/*
!.artifacts/security/.gitignore
Expand Down
8 changes: 4 additions & 4 deletions coaching/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ dependencies = [
[project.optional-dependencies]
dev = [
# Testing
"pytest>=7.4.0,<9.0.0",
"pytest-asyncio>=0.21.0,<1.0.0",
"pytest>=9.0.3,<10.0.0",
"pytest-asyncio>=1.3.0,<2.0.0",
"pytest-mock>=3.11.1,<4.0.0",
"pytest-cov>=4.1.0,<6.0.0",
"pytest-xdist>=3.3.1,<4.0.0",
Expand Down Expand Up @@ -109,8 +109,8 @@ packages = ["src"]

[tool.uv]
dev-dependencies = [
"pytest>=7.4.0",
"pytest-asyncio>=0.21.0",
"pytest>=9.0.3",
"pytest-asyncio>=1.3.0",
"pytest-mock>=3.11.1",
"black>=23.7.0",
"ruff>=0.1.0",
Expand Down
34 changes: 17 additions & 17 deletions coaching/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
-r requirements.txt

# Additional runtime extras
email-validator==2.1.0.post1
python-multipart==0.0.20

# Development tools
pytest==9.0.3
pytest-asyncio==1.3.0
pytest-mock==3.14.0
pytest-cov==6.0.0
black==23.7.0
ruff==0.8.4
pylint==2.17.4
mypy==1.4.1
types-PyYAML
types-requests
-r requirements.txt
# Additional runtime extras
email-validator==2.1.0.post1
python-multipart==0.0.20
# Development tools
pytest==9.0.3
pytest-asyncio==1.3.0
pytest-mock==3.14.0
pytest-cov==6.0.0
black==23.7.0
ruff==0.8.4
pylint==2.17.4
mypy==1.4.1
types-PyYAML
types-requests
230 changes: 125 additions & 105 deletions coaching/src/scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,105 +1,125 @@
# Coaching Topics Seed Scripts

Scripts for seeding coaching topics to the DynamoDB topics table.

## Overview

These scripts seed coaching topics into the `purposepath-topics-{env}` DynamoDB table.

## Scripts

### `seed_topics.py`
Main seeding script that:
- Creates all coaching topics in DynamoDB from the endpoint registry
- Supports 44 topics total
- Is idempotent (safe to run multiple times)
- Can update existing topics or skip them

## Usage

```bash
# Set environment variables
export AWS_PROFILE=purposepath-dev
export AWS_REGION=us-east-1
export STAGE=dev

# Run seed script
cd coaching
python -m src.scripts.seed_topics

# Run with options
python -m src.scripts.seed_topics --force-update # Update existing
python -m src.scripts.seed_topics --dry-run # Preview changes
python -m src.scripts.seed_topics --validate-only # Validate only
```

## Prerequisites

1. **Infrastructure Deployed**: DynamoDB topics table must exist
2. **AWS Credentials**: Configure AWS profile or credentials
3. **Dependencies**: Install Python dependencies
- Old YAML files remain untouched (cleaned up later)

## Idempotency

The seed script is **idempotent**:
- ✅ Safe to run multiple times
- ✅ Skips existing topics
- ✅ Does not overwrite data
- ✅ Reports what was created vs skipped

## Troubleshooting

### "Topic already exists, skipping"
This is normal if you've run the script before. The script won't overwrite existing topics.

### "No existing prompts found for migration"
This means no old YAML file exists in S3. Admin must create prompts via the API endpoints.

### DynamoDB Access Denied
Ensure your AWS credentials have DynamoDB PutItem permission for the table.

### S3 Access Denied
Ensure your AWS credentials have S3 GetObject and PutObject permissions for the bucket.

## Verification

After seeding, verify with:

```bash
# Check DynamoDB table
aws dynamodb scan \
--table-name purposepath-llm-prompts-dev \
--index-name topic_type-index \
--expression-attribute-values '{":type":{"S":"conversation_coaching"}}' \
--filter-expression "topic_type = :type"

# Check S3 prompts
aws s3 ls s3://purposepath-coaching-prompts-dev/prompts/ --recursive

# Or use verification script
./scripts/verify_topics.sh dev
```

## Next Steps

After seeding:
1. **Verify**: Run verification script
2. **Test**: Test conversation endpoints work with new topics
3. **Create Prompts**: If no prompts were migrated, create them via admin API
4. **Deploy**: Topics are now ready for use

## Related Issues

- #78: Infrastructure setup
- #79: Domain models and repository
- #80: Admin API endpoints
- #81: Service layer migration
- #82: This seed script (final epic task)

## Notes

- Seed script should be run **once per environment** after infrastructure deployment
- The CoachingTopic enum remains for backward compatibility
- Old YAML prompts can be removed in a future cleanup issue
- Prompts can be updated via the admin API after seeding
# Coaching Topics Seed Scripts

Scripts for seeding coaching topics to the DynamoDB topics table.

## Overview

These scripts seed coaching topics into the `purposepath-topics-{env}` DynamoDB table.

## Scripts

### `seed_topics.py`
Main seeding script that:
- Creates all coaching topics in DynamoDB from the endpoint registry
- Seeds every topic defined in the endpoint registry / topic seed data
- Is idempotent (safe to run multiple times)
- Can update existing topics or skip them

## Usage

The script imports `coaching.src.*`. Set **`PYTHONPATH` to the repository root** (the parent folder of the `coaching` package), then run the module as `coaching.src.scripts.seed_topics`.

```bash
# Set environment variables
export AWS_PROFILE=purposepath-dev
export AWS_REGION=us-east-1
export STAGE=dev

# Repository root = PurposePath_AI (folder that contains the `coaching` directory)
export PYTHONPATH="$(pwd)"

# Run seed script (from repo root or from coaching — see below)
cd coaching
uv run python -m coaching.src.scripts.seed_topics

# Run with options
uv run python -m coaching.src.scripts.seed_topics --force-update # Update existing
uv run python -m coaching.src.scripts.seed_topics --dry-run # Preview changes
uv run python -m coaching.src.scripts.seed_topics --validate-only # Validate only

# Seed a single topic (example: strategy_alignment_evaluation, issue #296)
uv run python -m coaching.src.scripts.seed_topics --topic-id strategy_alignment_evaluation --force-update
```

**PowerShell (Windows), from repository root:**

```powershell
$env:AWS_PROFILE = "purposepath-dev"
$env:AWS_REGION = "us-east-1"
$env:STAGE = "dev"
$env:PYTHONPATH = "C:\path\to\PurposePath_AI"
cd coaching
uv run python -m coaching.src.scripts.seed_topics --topic-id strategy_alignment_evaluation --force-update
```

Legacy path `python -m src.scripts.seed_topics` only works if your environment exposes the same import layout as CI (see `pyproject.toml` `pythonpath` for tests).

## Prerequisites

1. **Infrastructure Deployed**: DynamoDB topics table must exist
2. **AWS Credentials**: Configure AWS profile or credentials
3. **Dependencies**: Install Python dependencies (`uv sync` in `coaching/`)

## Idempotency

The seed script is **idempotent**:
- ✅ Safe to run multiple times
- ✅ Skips existing topics
- ✅ Does not overwrite data
- ✅ Reports what was created vs skipped

## Troubleshooting

### "Topic already exists, skipping"
This is normal if you've run the script before. The script won't overwrite existing topics.

### "No existing prompts found for migration"
This means no old YAML file exists in S3. Admin must create prompts via the API endpoints.

### DynamoDB Access Denied
Ensure your AWS credentials have DynamoDB PutItem permission for the table.

### S3 Access Denied
Ensure your AWS credentials have S3 GetObject and PutObject permissions for the bucket.

## Verification

After seeding, verify with:

```bash
# Check DynamoDB table
aws dynamodb scan \
--table-name purposepath-llm-prompts-dev \
--index-name topic_type-index \
--expression-attribute-values '{":type":{"S":"conversation_coaching"}}' \
--filter-expression "topic_type = :type"

# Check S3 prompts
aws s3 ls s3://purposepath-coaching-prompts-dev/prompts/ --recursive

# Or use verification script
./scripts/verify_topics.sh dev
```

## Next Steps

After seeding:
1. **Verify**: Run verification script
2. **Test**: Test conversation endpoints work with new topics
3. **Create Prompts**: If no prompts were migrated, create them via admin API
4. **Deploy**: Topics are now ready for use

## Related Issues

- #78: Infrastructure setup
- #79: Domain models and repository
- #80: Admin API endpoints
- #81: Service layer migration
- #82: This seed script (final epic task)

## Notes

- Seed script should be run **once per environment** after infrastructure deployment
- The CoachingTopic enum remains for backward compatibility
- Old YAML prompts can be removed in a future cleanup issue
- Prompts can be updated via the admin API after seeding
3 changes: 3 additions & 0 deletions coaching/src/scripts/seed_topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
--deactivate-orphans Deactivate topics that no longer have endpoints

Examples:
# Set PYTHONPATH to the repository root (parent of the `coaching` package), then:
# Seed all new topics (skip existing)
python -m coaching.src.scripts.seed_topics

Expand All @@ -32,6 +33,8 @@

# Deactivate orphaned topics
python -m coaching.src.scripts.seed_topics --deactivate-orphans

See coaching/src/scripts/README.md for PowerShell / uv invocations.
"""

import argparse
Expand Down
3 changes: 2 additions & 1 deletion coaching/tests/integration/test_unified_ai_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def test_all_topics_have_required_fields(self):
assert topic_data.topic_name
assert topic_data.topic_type in ["single_shot", "conversation_coaching"]
assert topic_data.category
assert topic_data.model_code
assert topic_data.basic_model_code
assert topic_data.premium_model_code
assert 0.0 <= topic_data.temperature <= 2.0
assert topic_data.max_tokens > 0

Expand Down
Loading
Loading