Skip to content

Upgrade pydantic v2#100

Merged
daniel-thom merged 4 commits into
mainfrom
upgrade-pydantic-v2
Jun 16, 2026
Merged

Upgrade pydantic v2#100
daniel-thom merged 4 commits into
mainfrom
upgrade-pydantic-v2

Conversation

@daniel-thom

Copy link
Copy Markdown
Collaborator

No description provided.

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 pull request migrates JADE’s Pydantic usage from the pydantic.v1 compatibility layer to native Pydantic v2 APIs, updating model configuration, validators, and serialization across the CLI, jobs, and extensions codepaths.

Changes:

  • Replaced v1 imports/usages (pydantic.v1.*, .dict(), .json(), __fields__, root_validator/validator) with v2 equivalents (model_dump*, model_fields, field_validator, model_validator, ConfigDict).
  • Adjusted model field defaults and types for Pydantic v2 semantics (notably Optional[...] fields now explicitly default to None).
  • Updated GitHub workflow Python versions to 3.13.

Reviewed changes

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

Show a summary per file
File Description
tests/test_hpc.py Updates validation error import and model serialization for Pydantic v2.
jade/utils/utils.py Updates BaseModel import and JSON encoding of Pydantic models via model_dump().
jade/models/submitter_params.py Migrates Field import; updates poll_interval type; replaces custom dict() with model_dump().
jade/models/submission_group.py Migrates Field import to Pydantic v2.
jade/models/spark.py Migrates validators from root_validator to model_validator; updates optional typing.
jade/models/singularity.py Migrates validators to field_validator; adds explicit None default for optional container path.
jade/models/pipeline.py Migrates Field import; adds explicit None defaults for Optional fields.
jade/models/jobs.py Migrates Field import; adds v2 field validator for job id coercion.
jade/models/hpc.py Migrates validators to v2 APIs; adds explicit defaults for Optional fields; refactors model validators.
jade/models/cluster_config.py Migrates Field import; adds explicit None default for Optional field.
jade/models/base.py Migrates base model configuration from v1 Config to v2 ConfigDict.
jade/models/init.py Updates schema/default extraction to v2 model_json_schema().
jade/jobs/pipeline_manager.py Migrates pipeline config serialization to model_dump_json().
jade/jobs/job_configuration.py Migrates field introspection from __fields__ to model_fields; updates serialization calls.
jade/jobs/cluster.py Migrates cluster/job status serialization and hashing to model_dump*.
jade/extensions/generic_command/generic_command_parameters.py Migrates validators/introspection/serialization to v2 APIs; adds explicit defaults for Optional fields.
jade/cli/spark.py Migrates spark config serialization to model_dump*.
jade/cli/config.py Migrates JSON generation to model_dump_json() for enum/value conversion.
jade/cli/common.py Migrates model field enumeration to model_fields for click options.
.github/workflows/publish_to_pypi.yml Updates workflow Python version to 3.13.
.github/workflows/gh-pages.yml Updates workflow Python version to 3.13.
.github/workflows/conda_build.yml Updates workflow Python version to 3.13.
.github/workflows/codecov.yml Updates workflow Python version to 3.13.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread jade/jobs/pipeline_manager.py
Comment thread jade/jobs/cluster.py Outdated
Comment thread jade/jobs/cluster.py
Comment thread jade/models/submitter_params.py Outdated
Comment thread jade/extensions/generic_command/generic_command_parameters.py Outdated

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

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

Comment thread jade/models/submitter_params.py
Comment thread jade/models/submitter_params.py Outdated
Comment thread jade/models/submitter_params.py Outdated
Comment thread jade/models/jobs.py Outdated
Comment thread jade/extensions/generic_command/generic_command_parameters.py Outdated
Comment thread jade/models/hpc.py
Comment thread .github/workflows/publish_to_pypi.yml
Comment thread .github/workflows/codecov.yml
Comment thread .github/workflows/gh-pages.yml
Comment thread jade/models/hpc.py Outdated
- Use @model_serializer instead of overriding model_dump() so obsolete/
  default fields are dropped across model_dump_json() and nested
  serialization (SubmitterParams, GenericCommandParametersModel)
- Guard before-validators so a plain string is rejected rather than split
  into characters (blocked_by, hpc_job_ids)
- assign_hpc: use info.data.get("hpc_type") for a structured ValidationError
  instead of a raw KeyError
- Fix misleading gres validation message ('gpu:N', not 'gres=gpu:N')
- Bump actions/setup-python@v2 -> @v5 for reliable Python 3.13 provisioning

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Comment thread jade/models/base.py
from pathlib import Path

from pydantic.v1 import BaseModel
from pydantic import BaseModel, ConfigDict
@daniel-thom daniel-thom merged commit 8f335db into main Jun 16, 2026
3 checks passed
@daniel-thom daniel-thom deleted the upgrade-pydantic-v2 branch June 16, 2026 17:41
github-actions Bot pushed a commit that referenced this pull request Jun 16, 2026
* Use Python 3.13 in actions

* Upgrade to pydantic v2 models
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.

2 participants