Skip to content

chore(pipelines): standardize pytest and testing patterns across Python solution guides - #272

Merged
iht merged 2 commits into
GoogleCloudPlatform:mainfrom
iht:feature/standardize-pytest-testing
Sep 7, 2026
Merged

chore(pipelines): standardize pytest and testing patterns across Python solution guides#272
iht merged 2 commits into
GoogleCloudPlatform:mainfrom
iht:feature/standardize-pytest-testing

Conversation

@iht

@iht iht commented Sep 7, 2026

Copy link
Copy Markdown
Member

Description

Harmonizes the Python testing methodology, developer dependencies, CI test execution, and documentation across all solution guides in the repository.

Key Changes

  1. Requirements Standardization:

    • Standardized requirements-dev.txt across all 5 Python pipelines using non-breaking version ranges:
      • yapf>=0.43,<1.0
      • pylint>=4.0,<5.0
      • pytest>=9.0,<10.0
      • setuptools>=78
    • Updated pipelines/anomaly_detection, pipelines/iot_analytics, and pipelines/ml_ai_python.
    • Added standard requirements-dev.txt to pipelines/cdp and pipelines/marketing_intelligence.
  2. Baseline Unit Tests for ml_ai_python:

    • Added pipelines/ml_ai_python/tests/test_pipeline.py with 7 unit tests covering turn tag prompt formatting, output parsing (PredictionResult), choices formatting, and MyPipelineOptions parsing with default model preset google/gemma-4-E2B-it.
  3. CI Test Execution (pull_request.yml):

    • Updated python-build job to invoke PYTHONPATH=. pipenv run pytest tests/ -v.
    • Preserved lightweight standard library unittest in minimal container compatibility checks (anomaly-training-check and anomaly-serving-check) to keep deployment containers lean.
  4. Renovate Noise Reduction (renovate.json):

    • Added python-dev-tools package group for pytest, pylint, and yapf so that future dependency updates are bundled across all pipelines.
  5. Documentation & Skills:

    • Updated AGENTS.md and .agents/skills/dataflow-pipeline-dev/SKILL.md to document running unit tests with pytest tests/ -v.
    • Standardized testing commands across all Python pipeline README.md files.

Verification

  • Tested unit test execution across pipelines (ml_ai_python: 7/7 passed, anomaly_detection: 28/28 passed, marketing_intelligence: 8/8 passed).
  • Ran yapf --diff -r (0 diffs).
  • Ran pylint (10.00/10 score).
  • Verified python setup.py sdist succeeded in ml_ai_python.
  • Validated renovate.json with jq.

…on solution guides

- Standardize requirements-dev.txt across all 5 Python pipelines with compatible version ranges (pytest>=9.0,<10.0, pylint>=4.0,<5.0, yapf>=0.43,<1.0, setuptools>=78).
- Add baseline unit tests (7 tests) for ml_ai_python covering prompt formatting, output parsing, and pipeline options.
- Update CI workflow (pull_request.yml) to execute tests with PYTHONPATH=. pipenv run pytest tests/ -v.
- Group Python dev tools (pytest, pylint, yapf) in renovate.json under python-dev-tools.
- Align AGENTS.md, dataflow-pipeline-dev skill, and all pipeline READMEs to instruct running tests with pytest tests/ -v.
Comment thread pipelines/anomaly_detection/README.md Outdated
```bash
python -m unittest discover -s tests -v
pytest tests/ -v
python -m unittest discover -s training/tests -v

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not we use also pyttest for the training tests?

@iht iht Sep 7, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, absolutely! Updated pipelines/anomaly_detection/README.md and use_cases/Anomaly_Detection.md to pytest training/tests/ -v for full consistency.

Comment thread pipelines/anomaly_detection/README.md Outdated
python -m unittest discover -s tests -v
pytest tests/ -v
python -m unittest discover -s training/tests -v
python -m unittest discover -s serving/tests -v

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not we use also pyttest for the serving tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Added fastapi>=0.115,<1 and httpx>=0.28,<1 to pipelines/anomaly_detection/requirements-dev.txt so pytest serving/tests/ -v can execute locally without requiring the Docker container, and updated pipelines/anomaly_detection/README.md and use_cases/Anomaly_Detection.md to pytest serving/tests/ -v.

@iht
iht merged commit 62972ac into GoogleCloudPlatform:main Sep 7, 2026
12 checks passed
@iht
iht deleted the feature/standardize-pytest-testing branch September 7, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant