pygcam.project

This module provides all the functionality that is exposed through the command-line to the gt run sub-command. It is provided in library form so that it can be used from within other programs without having to execute the script.

API

class pygcam.project.Project(xmlFile, projectName, groupName=None)

Represents the <project> element in the projects.xml file.

getKnownGroups()

Return a list of known scenarioGroups for the current project.

getKnownScenarios()

Return a list of known scenarios for the current project and scenarioGroup, baseline first

getKnownSteps(asTuple=False)

Return a list of known steps in seq order, without duplicates.

maybeListProjectArgs(args, knownGroups, knownScenarios, knownStepObjs)

If user asked to list scenarios, steps, or variables, do so and quit.

run(scenarios, skipScenarios, steps, skipSteps, args, tool)

Command templates can include keywords curly braces that are substituted to create the command to execute in the shell. Variables are defined in the <vars> section of the project XML file.

sortScenarios(scenarioSet)

If a baseline is in the scenario set, move it to the front and return the new list

validateProjectArgs(userArgs, knownArgs, argName)

If the user requested steps or scenarios that are not defined, raise an error.

Parameters:
  • userArgs – a list of the elements (projects, groups, scenarios, steps) passed by the user on the command-line.
  • knownArgs – a list of known elements of the given type
  • argName – the tag of the XML element
Returns:

nothing

Raises:

CommandlineError if the elements requested by the user are not defined in the current (project, scenario) context

class pygcam.project.Queries(node)

Represents the <queries> element in the projects.xml file. We don’t process the <queries> element here; we just store it so we can write it to a temp file as needed. Actual reading/processing of contents is handled in queryFile.py.

class pygcam.project.SimpleVariable(name, value, evaluate=False)

Simple variable of name and value to allow loading config file variables alongside variables defined in the project XML file.

class pygcam.project.Variable(node)

Represents the <var> element in the projects.xml file.

classmethod evaluateVars(argDict)

Evaluate vars and store results in argDict