Skip to content

[SC 9539] Keep order of the sections while previewing the template#355

Merged
AnilSorathiya merged 1 commit intomainfrom
anilsorathiya/sc-9539/preview-template-not-honouring-custom-order
Apr 23, 2025
Merged

[SC 9539] Keep order of the sections while previewing the template#355
AnilSorathiya merged 1 commit intomainfrom
anilsorathiya/sc-9539/preview-template-not-honouring-custom-order

Conversation

@AnilSorathiya
Copy link
Contributor

@AnilSorathiya AnilSorathiya commented Apr 23, 2025

Internal Notes for Reviewers

When you call preview_template() for model documentation, validation reports, or ongoing monitoring reports, it will spit out the preview with the sections ordered as they are displayed in the YAML instead of honouring the custom order specified. For example:

Custom Template Order Incorrect Preview
image image

This change will sort the section tree by the order of the sections in the template (if provided) and set the order to 9999 for the sections that do not have an order.

@AnilSorathiya AnilSorathiya added bug Something isn't working internal Not to be externalized in the release notes labels Apr 23, 2025
@github-actions
Copy link
Contributor

PR Summary

This pull request enhances the sorting logic of the section tree in the _convert_sections_to_section_tree function within the validmind/template.py file. Previously, sections without an explicit order were sorted with a default order of 0. This PR changes the default order for sections without an explicit order to 9999, ensuring that these sections are placed at the end of the sorted list. This change improves the handling of unordered sections by clearly distinguishing them from those with a specified order.

The modification involves updating the lambda function used in the sorted call to set the default order to 9999 instead of 0.

Test Suggestions

  • Test with a template where all sections have explicit orders to ensure they are sorted correctly.
  • Test with a template where some sections do not have an explicit order to verify they are placed at the end.
  • Test with a template where no sections have an explicit order to confirm they are all sorted with the default order of 9999.
  • Test with an empty template to ensure no errors occur and the function handles it gracefully.

Copy link
Contributor

@johnwalz97 johnwalz97 left a comment

Choose a reason for hiding this comment

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

nice 👌

@AnilSorathiya AnilSorathiya merged commit 40727d8 into main Apr 23, 2025
9 checks passed
@johnwalz97 johnwalz97 deleted the anilsorathiya/sc-9539/preview-template-not-honouring-custom-order branch April 25, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working internal Not to be externalized in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants