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

scripts_regression_tests.py does not take command line --machine arguments #2019

Closed
jhkennedy opened this issue Nov 1, 2017 · 3 comments · Fixed by #2023
Closed

scripts_regression_tests.py does not take command line --machine arguments #2019

jhkennedy opened this issue Nov 1, 2017 · 3 comments · Fixed by #2023

Comments

@jhkennedy
Copy link
Contributor

When trying to run the CIME regression tests on my linux desktop, using this command:

./scripts_regression_tests.py --machine linux-generic 2>&1 

I get this error:

ERROR: Could not initialize machine object from $CIME/config/acme/machines/config_machines.xml or $HOME/.cime/config_machines.xml

Note: This occurs in both ACME/cime and ESMCI/cime.

It looks like this error is caused by:

where the Machines() class is initialized upon import, before the _main_func() is run, causing this expect to fail

if machine is None:
if "CIME_MACHINE" in os.environ:
machine = os.environ["CIME_MACHINE"]
else:
machine = self.probe_machine_name()
expect(machine is not None, "Could not initialize machine object from {} or {}".format(infile, local_infile))

and the regression tests to never reach the handling of the command line arguments in _main_func():

if "--machine" in sys.argv:
midx = sys.argv.index("--machine")
mach_name = sys.argv[midx + 1]
MACHINE = Machines(machine=mach_name)
os.environ["CIME_MACHINE"] = mach_name
del sys.argv[midx + 1]
del sys.argv[midx]


Possible Fix:

This could be fixed by deleting the initialization on import:

and changing the --machine option handling in _main_func() to:

    if "--machine" in sys.argv:
        midx = sys.argv.index("--machine")
        mach_name = sys.argv[midx + 1]
        MACHINE = Machines(machine=mach_name)
        os.environ["CIME_MACHINE"] = mach_name
        del sys.argv[midx + 1]
        del sys.argv[midx]
    else:
        MACHINE = Machines()

I don't see any place that ./scripts_regression_tests.py is imported in CIME or ACME, so there is no need as far as I can tell to initialize MACHINE on import.


Note: it might be a good idea to change the options handling here to argparse as well.

@jedwards4b
Copy link
Contributor

Set CIME_MACHINE=yourmachinename before running scripts_regression_tests.py

There were problems with using argparse in scripts_regression_tests.py

@jhkennedy
Copy link
Contributor Author

jhkennedy commented Nov 1, 2017

@jedwards4b That is also a fix, but still requires changes to CIME. That is, if that's the expected use, the machine option should be removed (it is non-functional right now) and the error message or documentation should also tell you to set the CIME_MACHINE environment variable.

Interesting about argparse; do you remember what the problems were?

@jedwards4b
Copy link
Contributor

I think that argparse was incompatible with the unittest argument handling mechanism.
I would encourage you to issue a PR with the changes you suggest.

@jedwards4b jedwards4b self-assigned this Nov 2, 2017
jgfouca added a commit that referenced this issue Nov 2, 2017
fix machines option to srt and unitialzed var

Fix an unitialized variable in prep_ocn_mod.F90, fix the --machine option to scripts_regression_tests.py

Test suite: scripts_regression_tests.py
Test baseline:
Test namelist changes:
Test status: [bit for bit, roundoff, climate changing]

Fixes #1952
Fixes #2019

User interface changes?:

Update gh-pages html (Y/N)?:

Code review:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants