Skip to content

test_math_pipeline_runs_e2e fails locally: DynamoDB endpoint + RepresentativeComments export #2525

Description

@jucor

Summary

test_math_pipeline_runs_e2e fails locally when DynamoDB, MinIO, and Postgres are all running. Two issues discovered:

1. DYNAMODB_ENDPOINT not loaded from delphi/.env

Neither conftest.py nor run_math_pipeline.py calls load_dotenv(), so env vars from delphi/.env aren't picked up when running tests outside Docker. The test fixture (dynamodb_resource) hardcodes a fallback to http://localhost:8000, but the pipeline code (run_math_pipeline.py:389) uses os.environ.get('DYNAMODB_ENDPOINT') which returns None — causing boto3 to connect to real AWS instead of local DynamoDB.

In CI this works because docker-compose.test.yml injects DYNAMODB_ENDPOINT=http://dynamodb:8000 into the container env.

Fix options:

  • Add load_dotenv(find_dotenv()) to conftest.py
  • Or set DYNAMODB_ENDPOINT in pyproject.toml via [tool.pytest.ini_options] env (requires pytest-env)

2. ~/.aws/credentials overrides dummy defaults

Both the test and pipeline default AWS_ACCESS_KEY_ID to 'dummy' via os.environ.get(...). But when ~/.aws/credentials exists with real AWS creds, boto3's credential chain picks those up before the code's explicit aws_access_key_id='dummy' parameter — but only for clients that don't pass explicit creds (e.g., if DYNAMODB_ENDPOINT is None and boto3 tries real AWS).

3. RepresentativeComments not exported to DynamoDB

Even with correct env vars, the pipeline computes repness but the Delphi_RepresentativeComments table is empty after the e2e test run. PCA and KMeans results are written successfully. This suggests export_to_dynamodb() either skips or fails silently on representative comments.

Reproduction

cd delphi
DYNAMODB_ENDPOINT=http://localhost:8000 \
  AWS_ACCESS_KEY_ID=dummy \
  AWS_SECRET_ACCESS_KEY=dummy \
  uv run pytest tests/test_math_pipeline_runs_e2e.py -v --tb=long

Environment

  • Local dev with Docker services running (DynamoDB, MinIO, Postgres)
  • Tests run outside Docker (via uv run pytest)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions