Skip to content
Draft
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
44 changes: 25 additions & 19 deletions cdk/launchTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,27 @@ export default (
`export SERVICE=${service}`,
instanceSize ? `export INSTANCE_SIZE=${instanceSize}` : '',
CLOUDWATCH_LOG_GROUP_NAME ? `echo "${CLOUDWATCH_LOG_GROUP_NAME}" | sudo tee ${persistentConfigDir}/log_group_name.txt` : '',

// --- CloudWatch Agent: config + start, on EVERY instance ---
// The agent is installed above for all tiers, but until now only the
// ollama user-data configured and started it, so only the GPU box
// published memory. Memory is the binding resource on the math and delphi
// tiers (all three idle at 0.5-1.3% CPU), so without this there is no
// evidence on which to right-size them.
//
// Guarded with `|| true` because this function runs under `set -e`: a
// metrics agent must never be able to abort an instance boot. The
// nvidia_gpu section of the config collects nothing where there is no
// GPU, so this is a no-op difference for ollama.
'echo "Configuring CloudWatch Agent..."',
`aws s3 cp ${cwAgentConfigAsset.s3ObjectUrl} ${cwAgentTempPath} || echo "CW agent config download failed; continuing"`,
`sudo mkdir -p $(dirname ${cwAgentConfigPath}) || true`,
`sudo mv ${cwAgentTempPath} ${cwAgentConfigPath} || true`,
`sudo chmod 644 ${cwAgentConfigPath} || true`,
`sudo chown root:root ${cwAgentConfigPath} || true`,
'sudo systemctl enable amazon-cloudwatch-agent || true',
'sudo systemctl start amazon-cloudwatch-agent || echo "CW agent failed to start; continuing"',

'exec 1>>/var/log/user-data.log 2>&1',
'echo "Finished User Data Execution at $(date)"',
'sudo mkdir -p /etc/docker',
Expand Down Expand Up @@ -102,26 +123,11 @@ ollamaUsrData.addCommands(

// Start Ollama-specific setup
'echo "Starting Ollama specific setup..."',
'echo "Configuring CloudWatch Agent for GPU metrics..."',

// --- Download CW Agent config from S3 Asset ---
`echo "Downloading CW Agent config from S3..."`,
// Use aws cli to copy from the S3 location provided by the asset object
// The instance needs NAT access (which it has) and S3 permissions (granted above)
`aws s3 cp ${cwAgentConfigAsset.s3ObjectUrl} ${cwAgentTempPath}`,
// Ensure target directory exists and move the file into place
`sudo mkdir -p $(dirname ${cwAgentConfigPath})`,
`sudo mv ${cwAgentTempPath} ${cwAgentConfigPath}`,
`sudo chmod 644 ${cwAgentConfigPath}`,
`sudo chown root:root ${cwAgentConfigPath}`, // Ensure root ownership
'echo "CW Agent config downloaded and placed."',

// --- Enable and Start the CloudWatch Agent Service ---
'echo "Enabling CloudWatch Agent service..."',
'sudo systemctl enable amazon-cloudwatch-agent',
'echo "Starting CloudWatch Agent service..."',
'sudo systemctl start amazon-cloudwatch-agent',
'echo "CloudWatch Agent service started."',
// NOTE: the CloudWatch agent's config download and `systemctl start` used to
// live here. They now run in the shared usrdata() above, for every tier, so
// this block would be a duplicate. The GPU metrics are unaffected: the same
// config file carries the nvidia_gpu section.

// --- Mount EFS using standard NFSv4.1 ---
// Use the manually constructed EFS DNS name
Expand Down
23 changes: 8 additions & 15 deletions delphi/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ this avoids the confusion of having anything called a "cid", the joke was "conve

## helpful background

this was built in two parts, the pca/kmenas/repness and the umap/narrative, and these are combined in the run_delphi.sh script.
this was built in two parts, the pca/kmenas/repness and the umap/narrative, and these are combined in the run_delphi.py script.

## Local Python Environment

Expand Down Expand Up @@ -175,7 +175,7 @@ AWS_SECRET_ACCESS_KEY=dummy
AWS_REGION=us-east-1
```

These are configured in run_delphi.sh for all DynamoDB operations.
These are configured in run_delphi.py for all DynamoDB operations.

### DynamoDB Job Queue System

Expand All @@ -191,13 +191,13 @@ Delphi now includes a distributed job queue system built on DynamoDB:
2. **Processing Jobs**: Start the job poller service:

```bash
./start_poller.sh
python start_poller.py
```

3. **Table Management**: To reset the job queue:

```bash
aws dynamodb delete-table --table-name DelphiJobQueue --endpoint-url http://localhost:8000 && \
aws dynamodb delete-table --table-name Delphi_JobQueue --endpoint-url http://localhost:8000 && \
docker exec -e PYTHONPATH=/app polis-dev-delphi-1 python /app/create_dynamodb_tables.py --endpoint-url http://host.docker.internal:8000
```

Expand All @@ -210,7 +210,7 @@ Delphi now includes a distributed job queue system built on DynamoDB:
### Table Creation

- Primary script: `/create_dynamodb_tables.py` - Creates BOTH Polis math and EVōC tables
- This script is used in `run_delphi.sh` and now integrated into `umap_narrative/run_pipeline.py`
- This script is used in `run_delphi.py` and now integrated into `umap_narrative/run_pipeline.py`

### Schema Definitions

Expand Down Expand Up @@ -242,7 +242,7 @@ Delphi now includes a distributed job queue system built on DynamoDB:
- `Delphi_CollectiveStatement` - Collective statements generated for topics

> **Note:** All table names now use the `Delphi_` prefix for consistency.
> For complete documentation on the table renaming, see `/Users/colinmegill/polis/delphi/docs/DATABASE_NAMING_PROPOSAL.md`
> Table definitions in `create_dynamodb_tables.py` are the canonical reference for names and schemas.

## Reset Single Conversation

Expand Down Expand Up @@ -281,7 +281,7 @@ See [RESET_SINGLE_CONVERSATION.md](docs/RESET_SINGLE_CONVERSATION.md) for detail
After identifying the correct conversation ZID, run the Delphi pipeline directly with:

```bash
./run_delphi.sh --zid=[ZID]
python run_delphi.py --zid [ZID]
```

Additional options include:
Expand All @@ -297,7 +297,7 @@ For production environments, use the job queue system:
1. Start the poller service on your worker machine:

```bash
./start_poller.sh
python start_poller.py
```

2. Submit a job from any machine with access to DynamoDB:
Expand All @@ -323,13 +323,6 @@ For production environments, use the job queue system:
docker exec -e PYTHONPATH=/app polis-dev-delphi-1 python /app/create_dynamodb_tables.py --endpoint-url http://host.docker.internal:8000
```

Or use the reset_database.sh script to recreate all tables:

```bash
# Reset all tables (both Polis math and EVōC tables)
./reset_database.sh
```

2. **Testing specific pipeline stages**:

```bash
Expand Down
Loading
Loading