Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Case Insensitivity #118

Merged
merged 6 commits into from
Feb 3, 2025
Merged

Query Case Insensitivity #118

merged 6 commits into from
Feb 3, 2025

Conversation

ndellicarpini
Copy link
Collaborator

  • made Literals in query params case insensitive
  • made layers, layername, and query_layers all aliases of each other
  • made srs and crs aliases of each other
  • added proper filters in additional_coords for selfe and fvcom grid types
  • changed GetLegendInfo.alias to default to False, as it gets set to true anyhow when the request doesn't have a colorscalerange

@ndellicarpini
Copy link
Collaborator Author

not sure how to handle the CI failure except for adding flake8 ignores? those don't seem like valid issues to me

@mpiannucci
Copy link
Collaborator

Yeah this is a typing error because the way those new classes evaluate the type checker can not understand. Which kinda kills the point of the type checker at all. I would rather try to find a solution that is typesafe if possible

@mpiannucci
Copy link
Collaborator

#119

@mpiannucci
Copy link
Collaborator

We can add validators that do the uppercasing and lowercasing to these models instead of messing with the literals

@ndellicarpini
Copy link
Collaborator Author

oh that's an interesting solution, let me see what it looks like once i merge it in

@ndellicarpini
Copy link
Collaborator Author

ndellicarpini commented Feb 3, 2025

actually doesn't this approach make trying a request with getmap fail no matter what? I'm not sure if that matters, just not sure why enforcing the capitalization is important. The only reason i tried to fix this is for layerdetails, which the ncwms documentation refers to as layerDetails, and it doesn't work

@mpiannucci
Copy link
Collaborator

mpiannucci commented Feb 3, 2025

Yeah currently. If its desired, a validator can be added to handle capitalizing GetMap. But i wouldnt worry about it because thats what the spec says it should be.

Ohhhh i see what you are saying now. Yeah that can be fixed by validators

@ndellicarpini
Copy link
Collaborator Author

ndellicarpini commented Feb 3, 2025

Yeah currently. If its desired, a validator can be added to handle capitalizing GetMap. But i wouldnt worry about it because thats what the spec says it should be.

As for layerDetails, that should be fixed by my PR right?

no, your PR lowercases the keys, not the values. idk about lowercasing all of the string values anyhow, could that cause issues down the road?

Edit: I was trying to figure out a way to add a custom validator to all Literal fields, but it looks like the root variable isn't initialized until after validation occurs, so I got hung up trying to get a list of the Literal fields

@mpiannucci
Copy link
Collaborator

I would just change it to be layerDetails in the literal for now

@mpiannucci
Copy link
Collaborator

mpiannucci commented Feb 3, 2025

Or

    @model_validator(mode="before")
    def validate_item(cls, values: Any) -> Any:
        item = values.get("item")
        if item.lower() == "layerdetails":
            values["item"] = "layerDetails"
        return values

@ndellicarpini
Copy link
Collaborator Author

ndellicarpini commented Feb 3, 2025

Well that is what I was trying to avoid, it would be easy enough to add a validator with a manual list of the Literal fields, and then just lowercase the comparison, but that seems annoying to maintain? (granted the requests probably wont change...)

@mpiannucci
Copy link
Collaborator

I would rather be explicit about it since its not going to change often

Copy link
Collaborator

@mpiannucci mpiannucci left a comment

Choose a reason for hiding this comment

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

Thanks for this!!!

@mpiannucci mpiannucci merged commit a01c7dd into main Feb 3, 2025
5 checks passed
@mpiannucci mpiannucci deleted the query-case-fixes branch February 3, 2025 22:04
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