Skip to content

SEP-1655: Move the remaining Nomad-specific vocabulary out of app/tasks/models.py - #1226

Open
peter-o-addo wants to merge 4 commits into
mainfrom
SEP-1655
Open

SEP-1655: Move the remaining Nomad-specific vocabulary out of app/tasks/models.py#1226
peter-o-addo wants to merge 4 commits into
mainfrom
SEP-1655

Conversation

@peter-o-addo

@peter-o-addo peter-o-addo commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Move remaining Nomad-specific vocabulary out of the tasks models layer into the Nomad executor package, with executor-neutral log-cursor columns and a regenerated API contract.

  • app/tasks/execution/executors/nomad/__init__.py, app/tasks/logs/log_writer.py: break the Nomad package import cycle via lazy export and deferred config imports
  • app/tasks/execution/executors/nomad/constants.py, app/tasks/models.py, app/tasks/db/seed.py, app/sep/apps/framework/spec.py: relocate Nomad-owned constants and keep internal task names without importing the executor package
  • app/tasks/models.py, app/tasks/crud.py, app/tasks/logs/log_writer.py, app/tasks/execution/executors/nomad/models.py: rename Nomad-named log-cursor columns/accessors to executor-neutral names and neutralize related docs
  • app/tasks/migrations/versions/2026_07_30_1300-c8e4a2b91f70_rename_log_cursor_columns_executor_neutral.py: rename those columns in place with a reversible Alembic migration
  • frontend/packages/api/specs/{tasks,sep}.json, frontend/packages/api/src/generated/{tasks,sep}.ts, changelog.d/SEP-1630.breaking.md: regenerate OpenAPI/TS client for the TaskHistory field rename and record it as breaking
  • Tests: cover the import-cycle fix and column rename migration, and update references for the relocated constants and renamed fields

Tested

Checklist

  • New/modified functions have type hints and rST docstrings
  • New tests added for new features or bug fixes
  • All tests pass locally (make test)
  • Pre-commit hooks pass (make run-pre-commit)
  • Database migrations generated if models changed (make makemigrations)
  • User-facing changes documented (README, inline help, UI text)
  • Configuration changes documented with examples
  • Changelog fragment added under changelog.d/ if the change is user-facing (make changelog-add), or confirmed N/A (internal-only change, or a same-release-cycle fix for an unreleased sibling ticket)

@peter-o-addo
peter-o-addo marked this pull request as ready for review July 30, 2026 15:04
Copilot AI review requested due to automatic review settings July 30, 2026 15:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the executor-neutralization work in the Tasks service by relocating remaining Nomad-specific vocabulary/constants out of the tasks models layer into the Nomad executor package, renaming Nomad-named log cursor columns/accessors to executor-neutral terms, and regenerating the API/TS client contract (with a documented breaking change for the renamed TaskHistory field).

Changes:

  • Break the Nomad executor import cycle by switching app.tasks.execution.executors.nomad to a lazy NomadExecutor export and deferring app.tasks.config imports where needed.
  • Rename Nomad-vocabulary log cursor columns to executor-neutral names (nomad_offsetproducer_fetch_offset, allocation_epochproducer_epoch, log_allocation_epochlog_producer_epoch) with a reversible Alembic migration and updated CRUD/log-writer logic.
  • Regenerate OpenAPI specs + TS clients and add a breaking changelog fragment for the TaskHistory response field rename; update tests accordingly (including new regression tests for the import-cycle and migration rename).

Reviewed changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/app/tasks/test_routes.py Updates test imports to pull RUN_SCRIPT_OUTPUT_FILES_PATH from Nomad constants.
tests/app/tasks/migrations/test_taskhistory_log_nomad_cursor.py Updates existing migration test expectations to use executor-neutral cursor column names.
tests/app/tasks/migrations/test_rename_log_cursor_columns.py Adds coverage for the rename migration upgrade/downgrade preserving values.
tests/app/tasks/logs/test_log_writer.py Updates log-writer tests to use new cursor/epoch parameter and field names.
tests/app/tasks/logs/test_log_eviction.py Updates eviction test to pass the renamed epoch argument.
tests/app/tasks/execution/executors/nomad/test_models.py Updates Nomad executor tests for renamed cursor/epoch fields.
tests/app/tasks/execution/executors/nomad/test_import_cycle.py Adds a subprocess-based regression test ensuring Nomad submodules import without config-first ordering.
tests/app/tasks/db/test_seed.py Updates seed tests to import Nomad-only task name from Nomad constants.
tests/app/sep/apps/framework/test_spec.py Updates framework spec tests to import RUN_SCRIPT_OUTPUT_FILES_PATH from Nomad constants.
frontend/packages/api/src/generated/tasks.ts Regenerates TS types/docs including log_producer_epoch and doc wording adjustments.
frontend/packages/api/src/generated/sep.ts Regenerates shared TS types/docs for the same doc wording adjustments.
frontend/packages/api/specs/tasks.json Regenerates OpenAPI spec reflecting log_producer_epoch and doc wording adjustments.
frontend/packages/api/specs/sep.json Regenerates OpenAPI spec reflecting doc wording adjustments.
changelog.d/SEP-1630.breaking.md Documents the breaking rename from log_allocation_epoch to log_producer_epoch.
app/tasks/models.py Removes RUN_SCRIPT_OUTPUT_FILES_PATH from tasks models; renames cursor/epoch columns and neutralizes related docs; updates internal task-name set.
app/tasks/migrations/versions/2026_07_30_1300-c8e4a2b91f70_rename_log_cursor_columns_executor_neutral.py Adds reversible Alembic column renames for executor-neutral naming.
app/tasks/logs/log_writer.py Renames log-writer cursor/epoch args and guards; defers config import to avoid import cycles.
app/tasks/execution/executors/nomad/models.py Updates Nomad executor log fetching/persisting logic to use executor-neutral cursor/epoch naming.
app/tasks/execution/executors/nomad/constants.py Introduces a dependency-free Nomad constants module for layout and Nomad-only system task names.
app/tasks/execution/executors/nomad/init.py Implements lazy NomadExecutor export via __getattr__ to break import cycles.
app/tasks/db/seed.py Switches seed-time Nomad constants to the new Nomad constants module to avoid heavy imports.
app/tasks/crud.py Renames TaskHistory epoch accessor/mutator methods and updates state-frontier persistence APIs to new field names.
app/sep/apps/framework/spec.py Updates framework spec code to import RUN_SCRIPT_OUTPUT_FILES_PATH from Nomad constants.

Comment on lines 236 to 240
session: AsyncSession,
task_history_id: int,
*,
new_allocation_epoch: int,
new_producer_epoch: int,
) -> None:
Comment on lines +774 to 777
:return: ``(delta_text, new_producer_fetch_offset, new_producer_offset)`` —
the anonymized bytes fetched this cycle, the advanced Nomad-space
offset for the next fetch, and the advanced producer-space offset
that the writer should persist.
Comment thread app/tasks/models.py
Comment on lines +993 to 1002
#: Maintenance / system task names excluded from user-facing task lists.
#: The cert-expiry member is a literal matching
#: :data:`~app.tasks.execution.executors.nomad.constants.CHECK_NOMAD_CERT_EXPIRY_TASK_NAME`
#: so this module does not import the Nomad executor package.
INTERNAL_TASK_NAMES: frozenset[str] = frozenset(
{
INVENTORY_SYNC_TASK_NAME,
SYNC_RUNNING_TASKS_TASK_NAME,
CHECK_NOMAD_CERT_EXPIRY_TASK_NAME,
"tasks__check_nomad_cert_expiry",
}
@peter-o-addo peter-o-addo added the qa in progress Someone is currently testing this PR - do not merge it label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend python qa in progress Someone is currently testing this PR - do not merge it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants