Skip to content

Remove lt and gt as cog.Input options - #448

Merged
zeke merged 2 commits into
replicate:futurefrom
dashstander:less-than-bug
Mar 1, 2022
Merged

Remove lt and gt as cog.Input options#448
zeke merged 2 commits into
replicate:futurefrom
dashstander:less-than-bug

Conversation

@dashstander

Copy link
Copy Markdown
Contributor

Due to this pydantic bug, the gt and lt options for cog.Input do not work and cause the schema parsing to fail. This PR removes them and fixes the tests / documentation to not use them.

@dashstander
dashstander changed the base branch from main to future March 1, 2022 01:40
…kes them unusable

Signed-off-by: Dashiell Stander <dstander@protonmail.com>
Signed-off-by: Dashiell Stander <dstander@protonmail.com>

@zeke zeke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ooh tricky. Nice fix.

Looks like the ge and le options are somehow NOT impacted that FastAPI bug uriyyo/fastapi-pagination#148 🤷🏼

def test_gt_lt():
class Predictor(BasePredictor):
def predict(self, num: float = Input(gt=3, lt=10.5)) -> float:
def predict(self, num: float = Input(ge=3.01, le=10.5)) -> float:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could still just be 3, right?

@dashstander dashstander Mar 1, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For some reason I thought it was important to maintain the test's original restrictions on having the value be greater-than-but-not-equal-to 3. But then after I had done all that I noticed that the actual test value that's passed through is 5 so.... yeah, it could just remain 3. Whatever you wanna do

@bfirsh

bfirsh commented Mar 1, 2022

Copy link
Copy Markdown
Contributor

Another IRL conversation that @dashstander and I had briefly: ge and le are such gross non-intuitive options, so maybe this is another place where we break from the Pydantic standards and just call them minimum and maximum, consistent with OpenAPI.

Not essential for this PR if we want to do that -- we can fix in a follow-up one.

@zeke
zeke merged commit d429dab into replicate:future Mar 1, 2022
@zeke

zeke commented Mar 1, 2022

Copy link
Copy Markdown
Member

@all-contributors please add @dashstander for bugs, code, and tests

@allcontributors

Copy link
Copy Markdown
Contributor

@zeke

I've put up a pull request to add @dashstander! 🎉

bfirsh pushed a commit that referenced this pull request Mar 1, 2022
* Removed gt and lt cog.Input options because of a pydantic bug that makes them unusable

Signed-off-by: Dashiell Stander <dstander@protonmail.com>

* Removed references to gt and lt from documentation

Signed-off-by: Dashiell Stander <dstander@protonmail.com>
zeke pushed a commit that referenced this pull request Mar 2, 2022
* Removed gt and lt cog.Input options because of a pydantic bug that makes them unusable

Signed-off-by: Dashiell Stander <dstander@protonmail.com>

* Removed references to gt and lt from documentation

Signed-off-by: Dashiell Stander <dstander@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants