Skip to content

don't copy in versionXX_YY imports #93

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

james-bruten-mo
Copy link
Contributor

@james-bruten-mo james-bruten-mo commented Jun 11, 2025

Description

When a new metadata section with rose app is added, at commit to trunk the app needs to be updated to the latest metadata. This means any imported metadata macros need to be applied to the app and so they need to be copied into the new versions.py by apply_macros. This change adds that functionality.

I've tested this against the new Jules app to ensure it works. I've also checked normal macros work as they currently do. The new functions should get a unit test, but I've not yet added this. I'll open a new issue to add these, and to setup the unit tests to run as CI.

I'm not convinced that the combine_missing_macros function will work perfectly in more complex cases where there are multiple metadata imports. However it is ok for now and will unblock some existing apps tickets.

Checklist

  • I have performed a self-review of my own changes

@james-bruten-mo james-bruten-mo requested a review from a team as a code owner June 11, 2025 12:25
@james-bruten-mo
Copy link
Contributor Author

After discussion with Jenny, we've decided we're missing a feature in apply_macros which is required for new metadata sections. I'll "take" this PR back and do that work here.

@james-bruten-mo
Copy link
Contributor Author

@jennyhickson and @t00sa I think this is ready to be looked at. Cheers

Copy link
Contributor

@jennyhickson jennyhickson left a comment

Choose a reason for hiding this comment

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

Seems generally sound - with further algorithmic improvements in the pipeline as discussed.

for section in meta_imports:
section = self.get_full_import_path(section)
section_missing = []
section_macros = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than having a list of section macros this could just be a len(self.parsed_macros[section] (maybe call it "num_section_macros" to be clearer). If you trigger the after_tag==self.tag condition then just subtract one from the number.

Comment on lines +839 to +843
if after_tag == self.tag:
continue
section_macros.append(after_tag)
if after_tag not in after_tags:
section_missing.append(after_tag)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if after_tag == self.tag:
continue
section_macros.append(after_tag)
if after_tag not in after_tags:
section_missing.append(after_tag)
if after_tag == self.tag:
num_section_macros -= 1
elif after_tag not in after_tags:
section_missing.append(after_tag)

If you go with the above suggestion then this section simplifies

Comment on lines +268 to +269
self.target_macros = {}
self.parsed_macros = defaultdict(list)
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment here to define target vs parsed macros would be handy


def combine_missing_macros(self, meta_imports, missing_macros):
"""
Combine missing macro commands and write them to the relevant versions.py file.
Copy link
Contributor

Choose a reason for hiding this comment

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

writing them doesn't happen in this routine

for meta_import in meta_imports:
for after_tag in missing_macros:
macro = None
for m in self.parsed_macros[meta_import]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Some more comments describing the logic in this routine wouldn't go amiss

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