Skip to content

Update cdp_parser.py #52

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: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cdp/cdp_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ def get_orig_parameters(self, check_values=False, argparse_vals_only=True):
"""
self._parse_arguments()

if not self.__args_namespace.parameters:
Copy link
Contributor

@zshaheen zshaheen Aug 13, 2020

Choose a reason for hiding this comment

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

This line checks that the parameters defined in the file, e.g. params.py below, are processed and in this namespace.

e3sm_diags -p path/to/params.py

A namespace was used because when parse_args() is called more than one time, from the second time onwards, it deletes all of the args it read in. This was the case when a user would call view_args(), which would just return the value of parse_args(). Thus, I saved the values of parse_args() into a variable.

if not self.__args_namespace:
return None

parameter = self.__parameter_cls()

# Remove all of the variables.
parameter.__dict__.clear()

# if self.__args_namespace.parameters is not None:
# if self.__args_namespace is not None:
parameter.load_parameter_from_py(
self.__args_namespace.parameters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code for CDPParameter.load_parameter_from_py, a path to the file passed in via -p (see my comment above) must be used. So just passing in a Namespace object will not work.

self.__args_namespace)

if check_values:
parameter.check_values()
Expand Down