Skip to content

feat: add versioned job objects with syft-migration registry#9432

Merged
koenvanderveen merged 21 commits into
devfrom
koen/init-job-objects
Jul 3, 2026
Merged

feat: add versioned job objects with syft-migration registry#9432
koenvanderveen merged 21 commits into
devfrom
koen/init-job-objects

Conversation

@koenvanderveen

@koenvanderveen koenvanderveen commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Split JobState and JobSubmissionMetadata into versioned JobStateV1 / JobSubmissionMetadataV1 classes built on syft_migration.MigratableObject
  • New folder layout intended as the reference pattern for other packages adopting syft-migration:
    • syft_job/models/<model_name>/ — one folder per versioned object (v1.py + current-version alias in __init__.py)
    • syft_job/migrations/ — migration machinery: registry.py (job_registry), schema.py (pinned PackageProtocolSchema), and future migration functions
  • JobState / JobSubmissionMetadata remain as current-version aliases importable from syft_job.models
  • Old syft_job.models.state / .models.config paths removed; all consumers (syft-job, syft-bg, syft-enclave, root tests) updated
  • Add syft-migration as a syft-job dependency

Test plan

  • New unit tests in packages/syft-job/tests/test_job_migration.py
  • just test-unit-fast (406 passed) and uv run pytest packages/syft-job/tests (9 passed)
  • pre-commit run --all-files passes

Split JobState and JobSubmissionMetadata into versioned V1 MigratableObjects, register them in a package-local migration registry with a pinned protocol schema, and re-export current-version aliases from the models package.
… package

models/ now has one folder per versioned object (job_state/, job_submission_metadata/) with v1.py files and current-version aliases in each folder's __init__. The migration machinery (registry, protocol schema) moves to syft_job/migrations/. Old syft_job.models.state / .config import paths are removed and all consumers updated.
syft-migration: new ProtocolSchema class listing all supported versions per canonical name, computed per protocol by MigrationRegistry.compute_protocol_schemas() and exported via MigrationService.export_protocol_schemas(). syft-job tests: simulate a test-scope V2 of JobState and JobSubmissionMetadata with up/down migrations, loading v1 from disk and upgrading, and downgrading a v2-only object.
… from registry objects

The registry now derives the supported versions directly from its objects dict instead of walking package schemas, returns one ProtocolSchema for the package's protocol, and stamps it with the current package version. MigrationService.export_protocol_schemas is renamed to export_protocol_schema accordingly.
MigrationRegistry now takes protocol_name/package_name/package_version at construction. current_protocol_schema is a computed property pinning the latest registered version of each object, register_protocol_schema becomes register_historic_protocol_schema (history only, usually loaded from release-artifact files), and compute_protocol_schema reads identity from the registry so it no longer raises. syft-job's schema.py registration module is removed since the current schema is now derived.
MigrationError and the _identity/_has_identity helpers move to syft_migration/identity.py, breaking the registry<->schema import cycle so registry.py imports the schema classes at the top instead of inside methods. default_registry is removed: a concrete MigratableObject subclass must now receive registry= (or inherit it); defining one without a registry raises MigrationError.
PackageProtocolSchema now lists all supported versions per canonical name (supported_versions: dict[str, list[str]]) instead of pinning one version via object_versions, sharing a BaseVersionsSchema with ProtocolSchema. Both gain current_schema(canonical_name) returning the latest supported version, and migrate_to_schema targets that.
Replaces the hardcoded __version__ (which had drifted to 0.1.25 while pyproject was at 0.1.39) with importlib.metadata in a dedicated version.py; the job registry now uses the same value.
job_state -> JobState, job_submission_metadata -> JobSubmissionMetadata
…t helpers

test_versioned_objects_registered_and_aliased now checks that a version exists rather than pinning '1'. New test imports every syft_job module, collects all MigratableObject subclasses defined in the package, and asserts each is registered in job_registry. Helpers renamed to create_mock_submission and _mock_submission_config_path.
tests/migrations/ now holds test_objects_registered.py (registry coverage incl. the package scan), test_serialization.py (save/load identity round trips and service loading), test_migrations.py (V2 upgrade/downgrade flows), and mocks.py with the shared mock submission helpers.
MigrationRegistry.has_upgradeable_path_to_latest(canonical_name, from_version) checks a migration path exists to the latest registered version (trivially true for a single version). Tested in syft-migration with mock registries, and syft-job gains test_upgrade_paths.py asserting every registered job object version can upgrade to its latest.
test_migrations.py now runs against job_registry itself: every registered version of JobState and JobSubmissionMetadata is written to disk, loaded, and upgraded to the latest version, and the latest version is downgraded to every registered version and round-tripped through disk. No-ops today with only V1, but automatically exercises real migration paths once newer versions are registered.
tests/migrations/fixtures/<canonical_name>/v<version>.yaml holds a full serialized sample of each registered object version. The real-registry tests load fixtures and upgrade to latest, and downgrade the latest fixture to every version, replacing the _instance_of reference-copy helper. A missing fixture for a registered version fails the test with a pointer to add one.
@koenvanderveen koenvanderveen merged commit 174c77e into dev Jul 3, 2026
19 checks passed
@koenvanderveen koenvanderveen deleted the koen/init-job-objects branch July 3, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant