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

Add skip-preview-namelist to case.submit and case_run #1471

Merged
merged 8 commits into from
May 9, 2017

Conversation

erichlf
Copy link

@erichlf erichlf commented May 3, 2017

Added '--skip-preview-namelist' to case.build

Added '--skip-preview-namelist' to case.build. This will allow the user
to specify if the namelist should be rebuilt from user_nl_*.

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1276, E3SM-Project/E3SM#1466

User interface changes?: Added --skip-preview-namelist to case.build and
template.case.run

Code review: @jgfouca, @rljacob

@erichlf erichlf requested review from rljacob and jgfouca May 3, 2017 18:58
@erichlf erichlf changed the title Erichlf/case submit/skip pnl Add skip-preview-namelist to case.submit and case_run May 3, 2017
Copy link
Contributor

@jedwards4b jedwards4b left a comment

Choose a reason for hiding this comment

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

The change in template.case.run needs to be made on the cesm side as well.

description=description,
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser = argparse.ArgumentParser(description=description)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this code removed?

parser.add_argument("-a", "--batch-args",
help="Used to pass additional arguments to batch system. ")

args = parser.parse_args(args[1:])
args = parser.parse_args()
Copy link
Contributor

Choose a reason for hiding this comment

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

This is in conflict with master - I recommend that you rebase and update the PR.


CIME.utils.expect(args.prereq is None, "--prereq not currently supported")

CIME.utils.handle_standard_logging_options(args)

return args.caseroot, args.job, args.no_batch, args.resubmit, args.batch_args
return args
Copy link
Contributor

Choose a reason for hiding this comment

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

We prefer the old method of passing the individual fields of args not the args object itself.

Copy link
Member

Choose a reason for hiding this comment

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

"We" is overly broad here. Some of us prefer passing the args object itself :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I am asking for some uniformity across scripts and we have chosen to pass individual fields rather than the args object. Same issue with format - we have standardized around %s and I see no reason to change it here.

Copy link
Member

Choose a reason for hiding this comment

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

@jedwards4b I see your point about uniformity. I think what's going on here (if I can try to speak somewhat for @erichlf and somewhat for myself) is that there are certain coding standards like these that were put in place when the list of cime developers was very small (basically you and Jim F), and now, as there get to be more cime developers, we're not all in agreement about these coding standards.

Could I suggest, @erichlf - for now leave this as it was, but either open an issue for discussion or put this on the agenda of an upcoming Wednesday cime telecon to revisit our coding standards on these points (% vs. format and returning an args object vs. a big list of components).

@@ -43,7 +43,7 @@ def set_value(self, item, value, subgroup=None, ignore_type=False):
elif value.count(":") == 2:
t_spec = "%H:%M:%S"
else:
expect(False, "could not interpret format for wallclock time %s"%value)
expect(False, "could not interpret format for wallclock time {}".format(value))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why these changes from %s to format were made?

Copy link
Author

Choose a reason for hiding this comment

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

It is for python3 compatibility. Yes, we aren't using python3, but it is an easy change that doesn't hurt things and will make any future switch to python3 that much easier.

Copy link
Member

Choose a reason for hiding this comment

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

I personally prefer the new-style format, because I find it more readable. That said, I'm pretty sure that both are supported by python3.

Copy link
Author

Choose a reason for hiding this comment

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

I think you are right that both are currently supported, but if I recall the plan is not to support the old style.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not object to changes that bring us closer to python3 compatibility - however I do object to having a mixture of %s and format and we are about to do a release. I would prefer to wait until after the release and then apply this change uniformly throughout the code.

Copy link
Author

@erichlf erichlf May 5, 2017

Choose a reason for hiding this comment

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

{} and format this is already many instances where this has been implemented throughout the code and not by me.

Copy link
Contributor

Choose a reason for hiding this comment

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

@erichlf , I will approve these changes, and I think @jedwards4b will too, if your next PR is a global update to the new string format.

Copy link
Author

Choose a reason for hiding this comment

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

Absolutely happy to do so.

@erichlf erichlf force-pushed the erichlf/case_submit/skip_pnl branch from 863f30f to bb6fecc Compare May 4, 2017 21:02
@erichlf
Copy link
Author

erichlf commented May 4, 2017

I believe I have addressed all issues, and now things should be working with no conflicts.

Copy link
Contributor

@jedwards4b jedwards4b left a comment

Choose a reason for hiding this comment

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

I'd still like to see these format changes reverted to %s


if args.caseroot is not None:
os.chdir(args.caseroot)

return args.caseroot
if args.skip_preview_namelist is None:
args.skip_preview_namelist = False
Copy link
Contributor

Choose a reason for hiding this comment

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

We use 4-space indents in CIME's python. You should probably configure your editor to do it this way so we stay consistent.

Copy link
Author

Choose a reason for hiding this comment

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

doh!

> %s
""" % ((os.path.basename(args[0]), ) * 4),
> {}
""".format(((os.path.basename(args[0]), ) * 4),
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought one of the benefits of the new-style string formatting is that you don't have to repeat yourself when inserting the same string. Something like {1} {1} {1}.

Copy link
Author

Choose a reason for hiding this comment

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

Will fix. In this case it would be {0} since lists/arrays start at 0 in python.

> %s
""" % ((os.path.basename(args[0]), ) * 4),
> {0}
""".format(os.path.basename(args[0], )),
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the argument to format still need to be a tuple if it's only one thing?

@@ -43,7 +43,7 @@ def set_value(self, item, value, subgroup=None, ignore_type=False):
elif value.count(":") == 2:
t_spec = "%H:%M:%S"
else:
expect(False, "could not interpret format for wallclock time %s"%value)
expect(False, "could not interpret format for wallclock time {}".format(value))
Copy link
Contributor

Choose a reason for hiding this comment

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

@erichlf , I will approve these changes, and I think @jedwards4b will too, if your next PR is a global update to the new string format.

@@ -120,7 +121,7 @@ def _run_model_impl(case, lid):
restore_from_archive(case)

orig_cont = case.get_value("CONTINUE_RUN")
if not orig_cont:
if not (orig_cont or skip_pnl):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe @jedwards4b can help me here. I don't know if skipping create_namelists here is safe if orig_cont is False. run_model can be invoked several times for certain tests and in other situations.

Copy link
Contributor

Choose a reason for hiding this comment

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

You still want to change the CONTINUE_RUN value in either case, so the skip_pnl should be a seperate conditional
if not orig_cont:
case.set_value("CONTINUE_RUN", True)
if not skp_pnl:
create_namelists(case)

Copy link
Author

Choose a reason for hiding this comment

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

Will fix.

@@ -122,6 +123,7 @@ def _run_model_impl(case, lid):
orig_cont = case.get_value("CONTINUE_RUN")
if not orig_cont:
case.set_value("CONTINUE_RUN", True)
if not skip_pnl:
Copy link
Contributor

Choose a reason for hiding this comment

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

This still isn't right. You've changed the original intent which was to re-run create_namelists if CONTINUE_RUN was False. For now, let's not worry about skip_pnl in this code. This code is for recovery from node failures which is a rare corner case and we don't need to worry about how it performs.

Erich L Foster added 8 commits May 9, 2017 10:45
Added the '--skip-preview-namelist' option to case.submit so that we
only build the namelist when needed. The default is false. However, when
running scripts/tests/scripts_regression_tests.py test_save_timings
fails. I am currently debugging this issue.
While converting many of the python2.7 style strings to python3 I made a
mistake in a regex and have fixed those mistakes.
The unpacking of args wasn't working correctly for some strange reason,
so I have now switched to packed args. Additionally, I converted
'--test' to be a proper argument parsed by argparser.

This is still failing
`./scripts/tests/scripts_regression_tests.py L_TestSaveTimings`
Added '--skip-preview-namelist' to case.build. This will allow the user
to specify if the namelist should be rebuilt from user_nl_8.

In this particular commit I added '--skip-preview-namelist' to the call
for case.build in the testing suite, since building namelists during
tests isn't done.

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1276, E3SM-Project/E3SM#1466 (comment)

User interface changes?: Added --skip-preview-namelist to case.build and
template.case.run

Code review: @jgfouca, @rljacob
Added the new skip-preview-namelist option to the cesm version of
template.case.run.

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1276

User interface changes?: Adds --skip-preview-namelist

Code review: @jgfouca, @rljacob
After a rebase from master a few issues reappeared. Most issues were
typos or wrong function handle used. I have fixed these issues.

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1276

User interface changes?: Added skip-preview-namelist option

Code review: @rljacob, @jgfouca
Fixed some indentation inconsistencies, removed the tuple from usage in
parser, fixed logical for skip_pnl and continue_run, and finally fixed
some consistency in strings.

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1276, E3SM-Project/E3SM#1466

User interface changes?:
Added --skip-preview-namelist to case.build and
template.case.run

Code review: @jgfouca, @rljacob
 Removed the logic for skip_pnl in the CONTINUE_RUN portion of the code as
 per @jgfouca

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1276, E3SM-Project/E3SM#1466

User interface changes?: Added --skip-preview-namelist option to
case.submit

Code review: @jgfouca, @rljacob
@erichlf erichlf force-pushed the erichlf/case_submit/skip_pnl branch from f94d6fd to 5a6d393 Compare May 9, 2017 16:48
@erichlf
Copy link
Author

erichlf commented May 9, 2017

This should be ready now.

@jgfouca
Copy link
Contributor

jgfouca commented May 9, 2017

@erichlf why did you assign this to @rljacob ? Usually Jim or I are the integrators.

@erichlf
Copy link
Author

erichlf commented May 9, 2017

@jgfouca Because he was on the origin issue.

@erichlf erichlf assigned jgfouca and unassigned rljacob May 9, 2017
@rljacob
Copy link
Member

rljacob commented May 9, 2017

With the new reviewing system in github, I'm not sure it matters. As long as you or Jim review it. But to get it merged quickly, probably want to re-assign it.

@jgfouca jgfouca merged commit cdcb096 into master May 9, 2017
@jgfouca jgfouca deleted the erichlf/case_submit/skip_pnl branch May 9, 2017 17:06
@ndkeen
Copy link
Contributor

ndkeen commented Jun 7, 2017

When might we see this in ACME?

@rljacob
Copy link
Member

rljacob commented Jun 7, 2017

We are currently a little past alpha.10 we'd need alpha.12 to get this.

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.

6 participants