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

Automatically create a list of cdms2 errors in global_time_series #277

Open
forsyth2 opened this issue Jun 27, 2022 · 2 comments
Open

Automatically create a list of cdms2 errors in global_time_series #277

forsyth2 opened this issue Jun 27, 2022 · 2 comments
Labels
priority: low Low priority task

Comments

@forsyth2
Copy link
Collaborator

Currently, errors in ts.globalAnnual(var) (https://github.com/E3SM-Project/zppy/blob/main/zppy/templates/coupled_global.py#L192) will raise CDMSError("No such variable, " + id) cdms2.error.CDMSError: No such variable. If the variable is added to the glb ts task, the error goes away, but may be replaced by the same error with a new variable.

By catching the exceptions in the loop and creating a list of exceptions, we could catch all of these at once.

@forsyth2 forsyth2 added the priority: low Low priority task label Jun 27, 2022
@forsyth2
Copy link
Collaborator Author

forsyth2 commented Jun 27, 2022

Something like the following, replacing Exception with CDMSError, and printing var rather than v.

    exceptions = []
    for var in vars:
        print(var)
        try:
            v = ts.globalAnnual(var)
            exp["annual"][var] = v
            if "year" not in exp["annual"]:
                time = v.getTime()
                exp["annual"]["year"] = [x.year for x in time.asComponentTime()]
        except Exception:
            exceptions.append(v)
    if exceptions:
        raise Exception(exceptions)

@forsyth2
Copy link
Collaborator Author

Would also need to apply similar logic to the derivations in readTS.py

@forsyth2 forsyth2 added this to the Code maintenance milestone Jun 28, 2022
@forsyth2 forsyth2 removed this from the Code maintenance milestone Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low Low priority task
Projects
None yet
Development

No branches or pull requests

1 participant