Skip to content

Conversation

@atravitz
Copy link
Contributor

resolves OpenFreeEnergy/gufe#585

(new PR because I messed up #1431)

Comment on lines 127 to 133
@validator('protocol_repeats')
def must_be_positive(cls, v):
if v <= 0:
errmsg = f"protocol_repeats must be a positive value, got {v}."
raise ValueError(errmsg)
return v

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't feel strongly about using Annotated[int, Gt(0)] over this.

Copy link
Member

Choose a reason for hiding this comment

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

What error do you get with Annotated[int, Gt(0)]. The advantage I could see of sticking with the validator is to give folks good error messages on why it won't work. That's quite important with settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the error message would be:

   pydantic_core._pydantic_core.ValidationError: 1 validation error for PlainMDProtocolSettings
   protocol_repeats
     Input should be greater than 0 [type=greater_than, input_value=-1, input_type=int] For further information visit https://errors.pydantic.dev/2.11/v/greater_than

I think this is less helpful than the validator, so I'll revert for now. However, this type of pydantic error will be used elsewhere.
We should have a follow-up PR that customizes error messages (maybe something like this), but I consider that out of scope of this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted, and issue opened in gufe: OpenFreeEnergy/gufe#641

@atravitz atravitz requested a review from IAlibay October 10, 2025 19:13
Comment on lines 127 to 133
@validator('protocol_repeats')
def must_be_positive(cls, v):
if v <= 0:
errmsg = f"protocol_repeats must be a positive value, got {v}."
raise ValueError(errmsg)
return v

Copy link
Member

Choose a reason for hiding this comment

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

What error do you get with Annotated[int, Gt(0)]. The advantage I could see of sticking with the validator is to give folks good error messages on why it won't work. That's quite important with settings.

@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.26%. Comparing base (6581c95) to head (a620d9a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1535      +/-   ##
==========================================
- Coverage   95.25%   93.26%   -2.00%     
==========================================
  Files         172      172              
  Lines       14492    14482      -10     
==========================================
- Hits        13805    13506     -299     
- Misses        687      976     +289     
Flag Coverage Δ
fast-tests 93.26% <100.00%> (?)
slow-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

No API break detected ✅

@atravitz atravitz requested a review from IAlibay October 10, 2025 20:28
@atravitz atravitz enabled auto-merge (squash) October 10, 2025 20:59
@atravitz atravitz merged commit b9f7593 into main Oct 10, 2025
13 checks passed
@atravitz atravitz deleted the to_pydantic_v2 branch October 10, 2025 23:02
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.

migrate away from v1 pydantic imports

3 participants