Skip to content

Move GEN_KW template feature into RUN_TEMPLATE functionality #10549

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 1 commit into
base: main
Choose a base branch
from

Conversation

xjules
Copy link
Contributor

@xjules xjules commented Apr 3, 2025

This PR does a few things to prevent several storage migrations:

  • make use of existing to10.py storage migration
  • moves GEN_KW template feature into RUN_TEMPLATE functionality
  • removes forward_init_file from GEN_KW

Issue
Resolves #10180
Resolves #10596

Approach

  • Move gen_kw template into run_template
  • remove forward_init_file (-> forward_init = False) from gen_kw

(Screenshot of new behavior in GUI if applicable)

  • PR title captures the intent of the changes, and is fitting for release notes.
  • Added appropriate release note label
  • Commit history is consistent and clean, in line with the contribution guidelines.
  • Make sure unit tests pass locally after every commit (git rebase -i main --exec 'just rapid-tests')

When applicable

  • When there are user facing changes: Updated documentation
  • New behavior or changes to existing untested code: Ensured that unit tests are added (See Ground Rules).
  • Large PR: Prepare changes in small commits for more convenient review
  • Bug fix: Add regression test for the bug
  • Bug fix: Add backport label to latest release (format: 'backport release-branch-name')

@xjules xjules self-assigned this Apr 3, 2025
@xjules xjules marked this pull request as ready for review April 4, 2025 10:50
Copy link

codspeed-hq bot commented Apr 4, 2025

CodSpeed Performance Report

Merging #10549 will not alter performance

Comparing xjules:genkw_template (3338e50) with main (ed0a7cf)

Summary

✅ 25 untouched benchmarks

@xjules xjules force-pushed the genkw_template branch 2 times, most recently from d4f4549 to 6f7dea0 Compare April 10, 2025 07:12
@@ -103,6 +103,16 @@ def _check_for_forward_init_in_gen_kw(gen_kw_list: list[GenKwConfig]) -> None:
if gen_kw.forward_init_file is not None:
logger.info(f"GEN_KW uses FORWARD_INIT: {gen_kw}")

@no_type_check
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it risky to use this decorator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've used it since it was used in from_config_list from before. But I can try without.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It needs to be there due to config_dict handling (ie. config_dict.get(...))

gen_kw_key = cast(str, gen_kw[0])
positional_args = cast(list[str], gen_kw[:-1])

if len(positional_args) == 4:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to if len(positional_args) != 4: return None to avoid some of the indentation?

)
return None

elif version < _LOCAL_STORAGE_VERSION:
migrations = list(
enumerate([to2, to3, to4, to5, to6, to7, to8, to9], start=1)
enumerate([to2, to3, to4, to5, to6, to7, to8, to9, to10], start=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this? Would it be the same to do [to2,to3,to4,to5,to6...][1:] instead of list(enumerate(inner_list))?

Copy link
Contributor Author

@xjules xjules Apr 11, 2025

Choose a reason for hiding this comment

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

This one does the migrations starting from version-1 up to version-10. I guess nobody really wanted to change it since the early days. For the sake of least number of changes, I've just added the necessary migration.

Copy link
Contributor

@jonathan-eq jonathan-eq left a comment

Choose a reason for hiding this comment

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

I have some questions, and some nitpicking 🥇

@xjules xjules force-pushed the genkw_template branch 2 times, most recently from 8b36e57 to 2e9ce24 Compare April 10, 2025 13:40
@jonathan-eq
Copy link
Contributor

I think you can drop the Remove forward_init from gen_kw commit if you rebase on main

@@ -315,6 +313,7 @@ def read_templates(config_dict) -> list[tuple[str, str]]:
"it is synced with your DATA file."
)
templates.append(template)
templates.extend(EnsembleConfig.get_gen_kw_templates(config_dict))
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we testing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no as it is a very temporal change, I was not planning to 😁 But maybe we should 🤷

This includes adding parameter substition feature into substitute
class. GenKwConfig.templates_from_config is reponsible for extracting tmpl
and output files. In case an absolute path is provided as an output file
it raises ConfigValidationError.

To prevent multiple storage migrations this also remove forward_init
from gen_kw.
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.

Remove forward_init from GEN_KW Migrate GenKW template feature into global template option (substitutions)
2 participants