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)

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, alpha sorted

getKnownSteps()

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

maybeListProjectArgs(args, knownGroups, knownScenarios, knownSteps)

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

static validateXML(doc, raiseError=True)

Validate a parsed project.xml file

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.Scenario(node)

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

class pygcam.project.ScenarioGroup(node)

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

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

pygcam.project.getBaseline(scenarios)

Check that exactly one active baseline is defined, and if so, return it

pygcam.project.getDefaultGroup(groups)

Check that exactly one default scenarioGroup is defined, unless there is only one group, in which case it is obviously the default.