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

feat: use an external json schema for botconfig #1894

Merged
merged 12 commits into from
Mar 1, 2025

Conversation

isuruf
Copy link
Member

@isuruf isuruf commented Mar 26, 2024

As it says above...

bot schema was moved over here: regro/cf-scripts#3789

cc @ytausch @beckermr

closes #1893

Need to use orjson because pydantic.Url is not json dumpable
@isuruf isuruf requested a review from a team as a code owner March 26, 2024 22:56
@isuruf isuruf marked this pull request as draft March 26, 2024 23:02
Copy link
Member

@beckermr beckermr left a comment

Choose a reason for hiding this comment

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

This is great. I'm fine producing the schema right in this repo and not having to use a gist. I'm guessing we'll have to merge once before that works?

Edit: I thought this was cf-scripts. Now this PR makes more sense to me. 🤦‍♂️

@isuruf
Copy link
Member Author

isuruf commented Mar 26, 2024

We'll move the Pydantic model to regro/cf-scripts and dump the schema to that repo too. Then we can use the URL for that file here.

@ytausch
Copy link
Contributor

ytausch commented Mar 27, 2024

Some thoughts about this:

  • Do we really need Url and orjson here? I think it should be enough to reference the other schema as a string, removing the additional serialization overhead.
  • I suggest not to include the other schema as JSON schema but rather to properly import it as a Pydantic model. Otherwise, it will not be possible to use the Pydantic model to access all fields, as explained here. I don't like seeing Pydantic to be downgraded to a JSON schema generation engine, as it's much more powerful if used correctly.

@jaimergp jaimergp linked an issue Apr 29, 2024 that may be closed by this pull request
@beckermr
Copy link
Member

pre-commit.ci autofix

@beckermr beckermr changed the title Use an external json schema for botconfig feat: use an external json schema for botconfig Mar 1, 2025
@beckermr beckermr marked this pull request as ready for review March 1, 2025 12:12
@beckermr
Copy link
Member

beckermr commented Mar 1, 2025

requires regro/cf-scripts#3789 to pass

@beckermr beckermr merged commit 9e44ffa into conda-forge:main Mar 1, 2025
2 checks passed
@ytausch
Copy link
Contributor

ytausch commented Mar 3, 2025

So, do I understand correctly that you decided to no longer support validating conda-forge.yml with pydantic?

@beckermr
Copy link
Member

beckermr commented Mar 3, 2025

No we did not. We moved the serialized json schema and pydantic model to the bot code base.

The linter uses the json.

However, I'd accept a PR that adds an optional, non-default feature that imports the bot's model and makes a pydantic model at the python level that combines the smithy+bot ones. People can then import that model via python to do validation if they like.

The approach here isn't exclusive, but rather to have optional features for those who want them.

We cannot use the pydantic python code by default since it would create a circular dependency between the bots code base and smithy.

@ytausch
Copy link
Contributor

ytausch commented Mar 3, 2025

However, I'd accept a PR that adds an optional, non-default feature that imports the bot's model and makes a pydantic model at the python level that combines the smithy+bot ones. People can then import that model via python to do validation if they like.

Unfortunately, dynamically generated pydantic models do not allow static type checking, which is a large part of the benefit I see in pydantic. Also, I feel it's problematic that we'd then have two different models describing the same thing.

We cannot use the pydantic python code by default since it would create a circular dependency between the bots code base and smithy.

We could avoid this by moving only the bot's pydantic model to a separate conda package. Both conda-smithy and the bot could depend on that package. WDYT about that?

@beckermr
Copy link
Member

beckermr commented Mar 3, 2025

I'm against extra packages here for the same reasons as discussed for smithy.

It sounds like we can support some of the functionality but not all of it.

As I understand it, this model is mostly used to check yaml/json files, not python code.

So I think we've reached a decent compromise.

@isuruf
Copy link
Member Author

isuruf commented Mar 3, 2025

It's been almost a year and no one is using the pydantic model AFAIK (other than dumping the json schema and validating through that)

@ytausch
Copy link
Contributor

ytausch commented Mar 4, 2025

It's been almost a year and no one is using the pydantic model AFAIK (other than dumping the json schema and validating through that)

cf-scripts uses it here: https://github.com/regro/cf-scripts/blob/main/conda_forge_tick/models/node_attributes.py#L4

@beckermr
Copy link
Member

beckermr commented Mar 4, 2025

Right and the model is now in cf-scripts so this will still work fine.

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.

Move BotConfig to regro/cf-scripts and use it in conda-smithy
3 participants