Skip to content

Fix Python CI classification model preparation and caching - #37424

Merged
IceS2 merged 10 commits into
mainfrom
implement-model-isolation
Nov 11, 2026
Merged

IceS2 merged 10 commits into
mainfrom
implement-model-isolation

Conversation

@IceS2

@IceS2 IceS2 commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fix intermittent Python CI failures caused by classification model downloads during dependency setup. Move the four pinned wheels into an explicit classification-models group, with exact wheel metadata so unrelated uv --locked profiles validate without contacting model hosts. Every ingestion unit/integration entrypoint selects test-classification; static checks, generation, publishing and other tooling remain model-free.

Type of change:

  • Bug fix

High-level design:

  • ingestion/pyproject.toml owns the exact model URLs, SHA256 pins, static wheel metadata, uv pin and supported Python matrix. No model versions or application dependencies are upgraded.
  • One prepare-classification-models composite action processes all models sequentially. It uses the official Actions cache toolkit with locked npm dependencies and the existing Python helper for hash-verified preparation. Consumer jobs retain read-only cache access and upload one uncompressed, one-day classification-models artifact containing separate <cache-key>/model.tar files. Archives are imported before the final classification sync.
  • Only warm-classification-models.yml is added as a workflow. It handles relevant pushes to main, daily warming and manual exact revisions. Requested metadata is read as data with the default-branch helper; distinct model keys across revisions are deduplicated and prepared sequentially. The notifier and both preparation/writer reusable workflows are removed.
  • The warmer has one running and one pending slot (queue: single, cancel-in-progress: false). New requests replace the pending request, including a pending manual revision. Separate model versions retain separate immutable cache entries. Consumers do not share this concurrency group. Both preparation and warming have a 15-minute job timeout.
  • Preserve per-model key identity and the cache transport path model-cache/model.tar. Cache misses use bounded downloads; failed persistent saves fail the warmer. Cache entries remain evictable acceleration rather than durable storage.
  • Discovery selects the numeric maximum of supported-python, currently 3.12. Unit/integration test matrices still cover 3.10/3.11/3.12.
  • Remove venv caching and its dedicated warmer; retain general uv caching and unrelated Playwright warmers. Clean model payloads before general uv post-save. Generic/server setup precedes final model synchronization; later test synchronization retains all four models. The public provisioning CLI remains available, with live downloads explicitly opt-in in its integration test.

Operational warming initially covers main with no retained revisions. Revisions lacking the new metadata layout fail explicitly; release heads must adopt it before being added. No Collate implementation changes.

Tests:

  • Full tooling regression file: 91 passed, exit 0. Includes sequential cold preparation, denied-origin warm reuse, consumer non-writing behavior, hash failures, failed-save propagation, requested uv selection, real shallow Git revision discovery, model-key deduplication and unsupported-layout rejection.
  • Official cache toolkit with a local legacy cache-service fixture and all four real model archives: four saves followed by eight exact restores across two controller runs; zero warm model-origin requests; archive payloads unchanged (229,785,600 bytes). Cold preparation with the model origin denied failed as expected.
  • Returned archives imported into a fresh uv cache, followed by ordinary online --locked model sync and fresh English/Spanish/Italian/Polish model loads: exit 0, unchanged lock and zero model-origin requests.
  • make py_format_check: exit 0; 3,192 files formatted. Node syntax and Prettier checks, current workflow/composite schemas, local references and ADR validation passed. Local actionlint 1.7.12 exits 1 for six unsupported cache-mode/queue diagnostics only; none were suppressed.
  • Earlier hosted MySQL and PostgreSQL runs passed all 21 test jobs across Python 3.10/3.11/3.12. Those runs preceded the sequential action refactor; the updated hosted path remains to be exercised.

Manual test steps:

  1. Dispatch py-tests.yml and py-tests-postgres.yml on this branch. Each run should have one sequential preparation job, one classification-models artifact with four archives, and four successful model loads in every unit/integration job. Consumers must not save persistent model caches.
  2. After the warmer/action reaches main, dispatch warm-classification-models.yml on main with revision set to an exact compatible SHA. Repeat after completion: the second run should have four exact cache hits and no model downloads. Rerun a consumer to verify default-branch cache visibility.
  3. Queue three warmers while one is running. Confirm at most one running and one pending; the latest request replaces the pending request while the running run finishes.
  4. Warm different model metadata revisions. Verify distinct keys coexist and identical keys are deduplicated; unrelated project changes reuse existing keys. Relevant pushes to main should warm their exact SHA directly. Inspect general uv cache post-save contents separately from failure cleanup.

Hosted cache service v2, artifact delivery, persistent cache scope/saves, event delivery and queue replacement remain acceptance gates. No workflows were manually dispatched during this local refactor. Product UI, backend API and schema behavior are outside this change.

UI screen recording:

Not applicable: no UI behavior changes.

@IceS2
IceS2 requested review from a team and akash-jain-10 as code owners November 9, 2026 15:13
@IceS2 IceS2 added the skip-pr-checks Bypass PR metadata validation check label Nov 9, 2026
@IceS2
IceS2 requested review from a team, harshach and tutte as code owners November 9, 2026 15:13
@IceS2
IceS2 requested review from akashverma0786 and a balanced review from Copilot November 9, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Nov 9, 2026
Comment thread ingestion/pyproject.toml Resolved
Copilot AI balanced review requested due to automatic review settings November 9, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Comment thread ingestion/pyproject.toml Resolved
Copilot AI balanced review requested due to automatic review settings November 9, 2026 19:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 9, 2026 22:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 07:03
@sonarqubecloud

Copy link
Copy Markdown

@tutte tutte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you double-check .github/workflows/classification-models-changed.yml?

Copilot AI balanced review requested due to automatic review settings November 10, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 15:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 15:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 10, 2026 20:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 4 closed / 4 findings

🟡 Medium risk · Restructuring Python test dependency setup and model-cache warming could leave CI jobs without classification models or fail preparation if cache behavior differs.

Moves the four classification model wheels into an explicit classification-models group and replaces the notifier and reusable workflows with a single sequential warmer that uses the official cache toolkit, so ingestion test jobs no longer download models during dependency setup. Resolved the ADR gaps covering the model cache key/artifact contract, the single-writer rule, the supported-python CI matrix source, and the cache runtime credentials issue in shell run steps. No open findings remain.

✅ 4 closed
✅ Quality: Model ownership change contradicts an Accepted ADR and doesn't supersede it

📄 ingestion/pyproject.toml:72-77 📄 ingestion/pyproject.toml:165-168 📄 ingestion/noxfile.py:54 📄 ingestion/noxfile.py:70 📄 ingestion/noxfile.py:107 📄 ingestion/noxfile.py:152 📄 ingestion/noxfile.py:321 📄 ingestion/noxfile.py:366 📄 ingestion/Makefile:20 📄 ingestion/Makefile:45
docs/decisions/2026-10-27-local-python-environments-use-locked-profiles.md is cited at noxfile.py:57 and is Accepted. It says: "The test dependency group owns the four release-pinned classification model wheels, with SHA256 hashes … The existing provisioner validates installed versions, spaCy compatibility and model loading without fetching matching models." This PR breaks both parts of that rule:

  • It moves the four wheels out of test into a new classification-models group, used only by the new test-classification profile (pyproject.toml:72-77,165-168).
  • It removes the metadata install-classification-models provisioner call from synchronize (noxfile.py:107,152).
  • It moves validation into scripts/prepare_classification_models.py verify.

No record is added to supersede the old one, so the tree now contradicts its own Accepted decision.

Fix: add a record that supersedes the old one, and set the old record's Status to name it. The new record would say: "Classification model wheels live in the classification-models dependency group and only the test-classification profile, which every ingestion unit/integration entrypoint selects. The general test profile is model-free, and prepare_classification_models.py verify validates installed models instead of the in-package provisioner."

✅ Quality: No ADR records the model cache key/artifact contract or single-writer rule

📄 scripts/prepare_classification_models.py:44-53 📄 scripts/prepare_classification_models.py:56-64 📄 .github/workflows/write-classification-models.yml:51-62 📄 .github/workflows/prepare-classification-models.yml:62-76 📄 .github/actions/setup-openmetadata-test-environment/action.yml:134-147 📄 .github/python-versions.json:1 📄 .github/workflows/py-tests-shared.yml:304-307
The PR adds a contract that several components must agree on, and nothing in docs/decisions/ records it:

  • model_record builds the key classification-model-v1-<uv>-<name>-<sha256>-<sha256(url)>.
  • prepare-classification-models.yml and write-classification-models.yml use that key for both cache entries and artifact names.
  • setup-openmetadata-test-environment downloads artifacts by the classification-model-v1-* pattern and expects */model.tar.
  • .github/python-versions.json becomes the shared interpreter matrix for nox and CI, with discovery on the numeric maximum.

The PR description also states rules in prose that exist nowhere in the tree: "Only the default-branch warmer writes persistent model caches; writer jobs serialize by immutable model key and recheck after acquiring their slot", "Model cleanup runs before the general uv cache post-save", and "Revisions lacking the new metadata layout are unsupported; release heads must adopt it before being added." The repo squash-merges, so these rules would be lost.

Fix: add a record stating: "Classification model caches are keyed classification-model-v1-<uv-version>-<name>-<wheel sha256>-<sha256(url)>, and PR artifacts use the same name. Only the default-branch Warm classification models workflow writes them, serialized per key with a recheck after acquiring the slot. Jobs that install models must run prepare_classification_models.py clean before the general uv cache is saved. The interpreter matrix lives in .github/python-versions.json, and discovery uses its highest version."

✅ Quality: No ADR records pyproject supported-python as the CI matrix source

📄 ingestion/pyproject.toml:135-136 📄 scripts/prepare_classification_models.py:67-75 📄 scripts/prepare_classification_models.py:99 📄 ingestion/noxfile.py:41-44 📄 .github/workflows/py-tests-shared.yml:187-190
This commit moves the shared Python interpreter matrix out of .github/python-versions.json and into a new key, [tool.openmetadata.python-environments] supported-python in ingestion/pyproject.toml. Several components now have to agree on that key: noxfile.py (SUPPORTED_PYTHON_VERSIONS), prepare_classification_models.py matrix/discover, the python-matrix job in py-tests-shared.yml, and the prepare/write classification workflows. Those workflows also pick their setup-python version from the key's numeric maximum. write-classification-models.yml additionally needs every requested revision to carry this key. No record in docs/decisions/ states this rule. ADR:2026-10-27-local-python-environments-use-locked-profiles covers profiles and model locking, not the interpreter matrix. The rule comes from the description: "Discovery uses the numeric maximum of the shared Python matrix (currently 3.12), while test jobs retain 3.10/3.11/3.12." The record should say: "The Python version matrix for CI and Nox is the supported-python list under tool.openmetadata.python-environments in ingestion/pyproject.toml. Model discovery and cache writers run on its numeric maximum. Revisions that lack the key are unsupported for model warming."

✅ Bug: @actions/cache in a shell run step gets no cache runtime credentials

📄 .github/actions/prepare-classification-models/action.yml:41-49 📄 .github/actions/prepare-classification-models/prepare.cjs:26-30 📄 .github/actions/prepare-classification-models/prepare.cjs:60-62 📄 .github/workflows/warm-classification-models.yml:47-50
prepare.cjs calls require("@actions/cache") from a composite run: step (node "$GITHUB_ACTION_PATH/prepare.cjs"). The runner only sets ACTIONS_RUNTIME_TOKEN, ACTIONS_CACHE_URL and ACTIONS_RESULTS_URL for JavaScript and container actions. Shell run: steps don't get them, and that includes run: steps inside composite actions (toolkit#1053, runner#3046). In @actions/cache 4.1.0, a missing service URL is caught and logged: restoreCache returns undefined and saveCache returns -1 (cache.ts).

Hosted CI hits two failures. First, every consumer prepare-spacy-model job treats each model as a cache miss and downloads it from the model host. That brings back the intermittent download failures this PR exists to fix. Second, the default-branch warmer always gets -1 from saveCache and throws Cache save failed, so it fails on every run and never fills the cache. The unit tests swap in a fake cache object, so they can't catch this. Because the test fixture mocks the cache boundary, the suite passes even though the real integration is broken.

Fix: expose the runtime variables to the step. One option is to run crazy-max/ghaction-github-runtime (pinned by SHA) first. Another is to turn prepare.cjs into a real using: node24 JavaScript action, since the runner injects the credentials for those.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@IceS2
IceS2 enabled auto-merge (squash) November 11, 2026 06:23
@IceS2
IceS2 merged commit 388836a into main Nov 11, 2026
66 checks passed
@IceS2
IceS2 deleted the implement-model-isolation branch November 11, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants