Skip to content

feat: models for custom config validation - #186

Merged
uniqueg merged 13 commits into
devfrom
nidhi/issue-164
Aug 18, 2025
Merged

uniqueg merged 13 commits into
devfrom
nidhi/issue-164

Conversation

@Nidhi091999

@Nidhi091999 Nidhi091999 commented Apr 26, 2025 •

Copy link
Copy Markdown
Contributor

Resolves #164

Summary by Sourcery

Implement custom configuration validation using Pydantic models.

New Features:

  • Define Pydantic models for different configuration sections (Controllers, Tes, StoreLogs, Middlewares, ServiceInfo).
  • Enable custom configuration validation within the Foca application setup.

@sourcery-ai

sourcery-ai Bot commented Apr 26, 2025 •

Copy link
Copy Markdown

Reviewer's Guide by Sourcery

This pull request introduces custom configuration validation using Pydantic models. A new file pro_tes/config_models.py is added to define these models, and the application initialization in pro_tes/app.py is updated to use the custom configuration model.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Implement custom application configuration validation using Pydantic models.
  • Create pro_tes/config_models.py to define Pydantic models for application configuration, including models for controllers, TES backend, logging, and middlewares.
  • Define CustomConfig model in pro_tes/config_models.py to represent the overall application configuration structure.
  • Modify pro_tes/app.py to register the CustomConfig model with the Foca application instance using the custom_config_model parameter.
pro_tes/config_models.py
pro_tes/app.py

Assessment against linked issues

Issue Objective Addressed Explanation
#164 Implement the models in file pro_wes/config_models.py. ✅
#164 Pass the models to Foca() constructor in pro_wes/app.py. ✅

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot 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.

Hey @Nidhi091999 - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Hardcoded boolean value for execution trace logs. (link)

Overall Comments:

  • The Pydantic models in config_models.py appear to contain YAML snippets instead of valid field definitions and nested models.
  • Consider using snake_case (e.g., store_logs) for attribute names within the CustomConfig model for consistency with Python conventions.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🔴 Security: 1 blocking issue
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread pro_tes/config_models.py Resolved
Comment thread pro_tes/config_models.py Resolved
Comment thread pro_tes/config_models.py Resolved
Comment thread pro_tes/config_models.py Resolved
Comment thread pro_tes/config_models.py Resolved
@uniqueg uniqueg changed the title Add models for custom config validation feat: models for custom config validation May 2, 2025
@uniqueg
uniqueg self-requested a review May 2, 2025 13:52

@uniqueg uniqueg 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.

Thanks a lot, @Nidhi091999 - as far as I can tell, the models look fine now. However, there are 3 issues remaining:

  1. The app configuration now needs to be updated to include a custom section, which is required to activate the validation. The sections defining the values for custom config params, like controllers, serviceInfo and so on (see https://github.com/elixir-cloud-aai/proTES/blob/f83c3e3cd10eef83829c9f1359830a0d99f4299a/pro_tes/config.yaml#L109C1-L149C84 for all of them) need to children of section custom.
  2. Given that the new custom section changes the paths under which these params can be found when used in the app, all code referencing any params in the custom section need to be updated accordingly, e.g., from current_app.config.foca.tes["service_list"] to current_app.config.foca.custom.tes["service_list"]
  3. The integration tests are currently failing. I am not sure why that is, but possibly it is because currently there is no custom section in pro_tes/config.yaml; so possibly, if you fix point 1 above (which in turns requires addressing point 2), this problem might resolve itself. If not, please try to add some debug statements to see why the tests are failing with the new models.

@uniqueg uniqueg 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.

This looks great - thanks a lot, @Nidhi091999 :)

However, as long as the tests are not fixed, I am a bit hesitant to approve/merge this.

Are you interested in looking at fixing the integration tests? 🙃

@uniqueg
uniqueg merged commit c0d9f37 into dev Aug 18, 2025
@uniqueg
uniqueg deleted the nidhi/issue-164 branch August 18, 2025 14:30
keshxvdayal pushed a commit that referenced this pull request Feb 7, 2026
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.

Write models for custom config validation

2 participants