CIME.XML.machines.Machines

class CIME.XML.machines.Machines(infile=None, files=None, machine=None, extra_machines_dir=None, read_only=True)[source]

Bases: GenericXML

Methods

__init__

initialize an object if a filename is provided it will be used, otherwise if a files object is provided it will be used otherwise create a files object from default values

add_child

Add element node to self at root

attrib

change_file

check_timestamp

Returns True if timestamp matches what is expected

copy

get

get_child

get_children

This is the critical function, its interface and performance are crucial.

get_default_MPIlib

Get the MPILIB to use from the list of MPILIBS

get_default_compiler

Get the compiler to use from the list of COMPILERS

get_element_text

get_extra_machines_dir

get_field_from_list

Some of the fields have lists of valid values in the xml, parse these lists and return the first value if reqval is not provided and reqval if it is a valid setting for the machine

get_first_child_nodes

Return the names of all the child nodes for the target machine

get_id

get_machine_name

Return the name of the machine

get_machines_dir

Return the directory of the machines file

get_node_names

Return the names of all the child nodes for the target machine

get_optional_child

get_raw_record

get_resolved_value

A value in the xml file may contain references to other xml variables or to environment variables.

get_suffix

get_value

Get Value of fields in the config_machines.xml file

get_values

get_version

has

has_batch_system

Return if this machine has a batch system

invalidate

is_valid_MPIlib

Check the MPILIB is valid for the current machine

is_valid_compiler

Check the compiler is valid for the current machine

list_available_machines

Return a list of machines defined for a given CIME_MODEL

lock

A subclass is doing caching, we need to lock the tree structure in order to avoid invalidating cache.

make_child

make_child_comment

name

pop

print_values

Prints machine values.

probe_machine_name

Find a matching regular expression for hostname in the NODENAME_REGEX field in the file.

read

Read and parse an xml file into the object.

read_fd

remove_child

return_values

return a dictionary of machine info This routine is used by external tools in https://github.com/NCAR/CESM_xml2html

scan_child

Get an xml element matching nodename with optional attributes.

scan_children

scan_optional_child

Get an xml element matching nodename with optional attributes.

set

set_element_text

set_machine

Sets the machine block in the Machines object

set_name

set_text

set_value

ignore_type is not used in this flavor

text

to_string

unlock

validate_timestamp

validate_xml_file

validate an XML file against a provided schema file using pylint

write

Write an xml file from data in self

class CacheEntry(tree, root, modtime)[source]

Bases: tuple

count(value, /)[source]

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)[source]

Return first index of value.

Raises ValueError if the value is not present.

modtime[source]

Alias for field number 2

root[source]

Alias for field number 1

tree[source]

Alias for field number 0

add_child(node, root=None, position=None)[source]

Add element node to self at root

check_timestamp()[source]

Returns True if timestamp matches what is expected

get_children(name=None, attributes=None, root=None)[source]

This is the critical function, its interface and performance are crucial.

You can specify attributes={key:None} if you want to select children with the key attribute but you don’t care what its value is.

get_default_MPIlib(attributes=None)[source]

Get the MPILIB to use from the list of MPILIBS

get_default_compiler()[source]

Get the compiler to use from the list of COMPILERS

get_field_from_list(listname, reqval=None, attributes=None)[source]

Some of the fields have lists of valid values in the xml, parse these lists and return the first value if reqval is not provided and reqval if it is a valid setting for the machine

get_first_child_nodes(nodename)[source]

Return the names of all the child nodes for the target machine

get_machine_name()[source]

Return the name of the machine

get_machines_dir()[source]

Return the directory of the machines file

get_node_names()[source]

Return the names of all the child nodes for the target machine

get_resolved_value(raw_value, allow_unresolved_envvars=False, subgroup=None)[source]

A value in the xml file may contain references to other xml variables or to environment variables. These are refered to in the perl style with $name and $ENV{name}.

>>> obj = GenericXML()
>>> os.environ["FOO"] = "BAR"
>>> os.environ["BAZ"] = "BARF"
>>> obj.get_resolved_value("one $ENV{FOO} two $ENV{BAZ} three")
'one BAR two BARF three'
>>> obj.get_resolved_value("2 + 3 - 1")
'4'
>>> obj.get_resolved_value("0001-01-01")
'0001-01-01'
>>> obj.get_resolved_value("$SHELL{echo hi}") == 'hi'
True
get_value(name, attributes=None, resolved=True, subgroup=None)[source]

Get Value of fields in the config_machines.xml file

has_batch_system()[source]

Return if this machine has a batch system

is_valid_MPIlib(mpilib, attributes=None)[source]

Check the MPILIB is valid for the current machine

is_valid_compiler(compiler)[source]

Check the compiler is valid for the current machine

list_available_machines()[source]

Return a list of machines defined for a given CIME_MODEL

lock()[source]

A subclass is doing caching, we need to lock the tree structure in order to avoid invalidating cache.

print_values(compiler=None)[source]

Prints machine values.

Args:

compiler (str, optional): Name of the compiler to print extra details for. Defaults to None.

probe_machine_name(warn=True)[source]

Find a matching regular expression for hostname in the NODENAME_REGEX field in the file. First match wins.

read(infile, schema=None)[source]

Read and parse an xml file into the object. The schema variable can either be a path to an xsd schema file or a dictionary of paths to files by version.

return_values()[source]

return a dictionary of machine info This routine is used by external tools in https://github.com/NCAR/CESM_xml2html

scan_child(nodename, attributes=None, root=None)[source]

Get an xml element matching nodename with optional attributes.

Error unless exactly one match.

scan_optional_child(nodename, attributes=None, root=None)[source]

Get an xml element matching nodename with optional attributes.

Return None if no match.

set_machine(machine, schema=None)[source]

Sets the machine block in the Machines object

>>> machobj = Machines(machine="melvin")
>>> machobj.get_machine_name()
'melvin'
>>> machobj.set_machine("trump")
Traceback (most recent call last):
...
CIMEError: ERROR: No machine trump found
set_value(vid, value, subgroup=None, ignore_type=True)[source]

ignore_type is not used in this flavor

validate_xml_file(filename, schema)[source]

validate an XML file against a provided schema file using pylint

write(outfile=None, force_write=False)[source]

Write an xml file from data in self