pymatgen.io.abinit.nodes module¶
This module defines the Node class that is inherited by Task, Work and Flow objects.
-
class
Dependency(node, exts=None)[source]¶ Bases:
objectThis object describes the dependencies among the nodes of a calculation.
A Dependency consists of a Node that produces a list of products (files) that are used by the other nodes (Task or Work) to start the calculation. One usually creates the object by calling work.register
Example
# Register the SCF task in work. scf_task = work.register(scf_strategy)
# Register the NSCF calculation and its dependency on the SCF run via deps. nscf_task = work.register(nscf_strategy, deps={scf_task: “DEN”})
- Parameters
node – The task or the worfklow associated to the dependency or string with a filepath.
exts – Extensions of the output files that are needed for running the other tasks.
-
apply_getters(task)[source]¶ This function is called when we specify the task dependencies with the syntax:
deps={node: “@property”}
In this case the task has to the get property from node before starting the calculation.
At present, the following properties are supported:
@structure
-
connecting_vars()[source]¶ Returns a dictionary with the variables that must be added to the input file in order to connect this
Nodeto its dependencies.
-
get_filepaths_and_exts()[source]¶ Returns the paths of the output files produced by self and its extensions
-
property
info¶
-
class
FileNode(filename)[source]¶ Bases:
pymatgen.io.abinit.nodes.NodeA Node that consists of a file. May be not yet existing
Mainly used to connect
Taskobjects to external files produced in previous runs.-
color_rgb= array([0.4, 0.2, 1. ])¶
-
property
filechildren¶ List with the children (nodes) of this FileNode.
-
property
products¶
-
property
status¶ The status of the Node.
-
-
class
GridFsFile(path, fs_id=None, mode='b')[source]¶ Bases:
monty.collections.AttrDictInformation on a file that will stored in the MongoDb gridfs collection.
-
class
HistoryRecord(level, pathname, lineno, msg, args, exc_info, func=None)[source]¶ Bases:
objectA HistoryRecord instance represents an entry in the
NodeHistory.HistoryRecord instances are created every time something is logged. They contain all the information pertinent to the event being logged. The main information passed in is in msg and args, which are combined using str(msg) % args to create the message field of the record. The record also includes information such as when the record was created, the source line where the logging call was made
-
levelno¶ Numeric logging level for the message (DEBUG, INFO, WARNING, ERROR, CRITICAL)
-
levelname¶ Text logging level for the message (“DEBUG”, “INFO”, “WARNING”, “ERROR”, “CRITICAL”)
-
pathname¶ Full pathname of the source file where the logging call was issued (if available)
-
filename¶ Filename portion of pathname
-
module¶ Module (name portion of filename)
-
lineno¶ Source line number where the logging call was issued (if available)
-
func_name¶ Function name
-
created¶ Time when the HistoryRecord was created (time.time() return value)
-
asctime¶ Textual time when the HistoryRecord was created
-
message¶ -
The result of record.getMessage(), computed just as the record is emitted
Initialize a logging record with interesting information.
-
-
class
Node[source]¶ Bases:
objectAbstract base class defining the interface that must be implemented by the nodes of the calculation.
Nodes are hashable and can be tested for equality
-
ALL_STATUS= [<Status: Initialized, at 120962507016>, <Status: Locked, at 120962509640>, <Status: Ready, at 120962509832>, <Status: Submitted, at 120962510344>, <Status: Running, at 120957670216>, <Status: Done, at 120957671496>, <Status: AbiCritical, at 120957672392>, <Status: QCritical, at 120957671752>, <Status: Unconverged, at 120957669640>, <Status: Error, at 120957673160>, <Status: Completed, at 120957669448>]¶
-
Results¶ alias of
NodeResults
-
S_ABICRITICAL= <Status: AbiCritical, at 120957672392>¶
-
S_DONE= <Status: Done, at 120957671496>¶
-
S_ERROR= <Status: Error, at 120957673160>¶
-
S_INIT= <Status: Initialized, at 120962507016>¶
-
S_LOCKED= <Status: Locked, at 120962509640>¶
-
S_OK= <Status: Completed, at 120957669448>¶
-
S_QCRITICAL= <Status: QCritical, at 120957671752>¶
-
S_READY= <Status: Ready, at 120962509832>¶
-
S_RUN= <Status: Running, at 120957670216>¶
-
S_SUB= <Status: Submitted, at 120962510344>¶
-
S_UNCONVERGED= <Status: Unconverged, at 120957669640>¶
-
SpectatorError¶ alias of
SpectatorNodeError
-
add_deps(deps)[source]¶ Add a list of dependencies to the
Node.- Parameters
deps – List of
Dependencyobjects specifying the dependencies of the node. or dictionary mapping nodes to file extensions e.g. {task: “DEN”}
-
classmethod
as_node(obj)[source]¶ Convert obj into a Node instance.
- Returns
obj if obj is a Node instance, cast obj to
FileNodeinstance of obj is a string. None if obj is None
-
color_hex[source]¶ //en.wikipedia.org/wiki/Web_colors#Hex_triplet
- Type
Node color as Hex Triplet https
-
color_rgb= array([0.41176471, 0.41176471, 0.41176471])¶
-
property
corrections¶ List of dictionaries with infornation on the actions performed to solve AbiCritical Events. Each dictionary contains the AbinitEvent who triggered the correction and a human-readable message with the description of the operation performed.
-
property
deps¶ List of
Dependencyobjects defining the dependencies of this Node. Empty list if thisNodedoes not have dependencies.
-
property
deps_status¶ Returns a list with the status of the dependencies.
-
property
event_handlers¶ The list of handlers registered for this node. If the node is not a Flow and does not have its own list of handlers the handlers registered at the level of the flow are returned.
This trick allows one to registered different handlers at the level of the Task for testing purposes. By default, we have a common list of handlers for all the nodes in the flow. This choice facilitates the automatic installation of the handlers when we use callbacks to generate new Works and Tasks!
-
property
finalized¶ True if the Node has been finalized.
-
property
gc¶ Garbage collector. None if garbage collection is deactivated. Use flow.set_garbage_collector to initialize the object.
-
get_children()[source]¶ Return the list of nodes in the
Flowthat depends on thisNodeNote
This routine assumes the entire flow has been allocated.
-
get_graphviz_dirtree(engine='automatic', **kwargs)[source]¶ Generate directory graph in the DOT language. The graph show the files and directories in the node workdir.
Returns: graphviz.Digraph <https://graphviz.readthedocs.io/en/stable/api.html#digraph>
-
get_vars_dataframe(*varnames)[source]¶ Return pandas DataFrame with the value of the variables specified in varnames. Can be used for task/works/flow. It’s recursive!
-
property
in_spectator_mode¶
-
install_event_handlers(categories=None, handlers=None)[source]¶ Install the EventHandlers for this `Node. If no argument is provided the default list of handlers is installed.
- Parameters
categories – List of categories to install e.g. base + can_change_physics
handlers – explicit list of
EventHandlerinstances. This is the most flexible way to install handlers.
Note
categories and handlers are mutually exclusive.
-
property
is_file¶ True if this node is a file
-
property
is_flow¶ True if this node is a Flow
-
property
is_task¶ True if this node is a Task
-
property
is_work¶ True if this node is a Work
-
isinstance(class_or_string)[source]¶ Check whether the node is a instance of class_or_string. Unlinke the standard isinstance builtin, the method accepts either a class or a string. In the later case, the string is compared with self.__class__.__name__ (case insensitive).
-
log_correction(event, action)[source]¶ This method should be called once we have fixed the problem associated to this event. It adds a new entry in the correction history of the node.
- Parameters
event –
AbinitEventthat triggered the correction.action (str) – Human-readable string with info on the action perfomed to solve the problem.
-
property
name¶ The name of the node (only used for facilitating its identification in the user interface).
-
property
node_id¶ Node identifier.
-
property
num_corrections¶
-
property
relworkdir¶ Return a relative version of the workdir
-
remove_deps(deps)[source]¶ Remove a list of dependencies from the
Node.- Parameters
deps – List of
Dependencyobjects specifying the dependencies of the node.
-
send_signal(signal)[source]¶ Send signal from this node to all connected receivers unless the node is in spectator mode.
signal – (hashable) signal value, see dispatcher connect for details
Return a list of tuple pairs [(receiver, response), … ] or None if the node is in spectator mode.
if any receiver raises an error, the error propagates back through send, terminating the dispatch loop, so it is quite possible to not have all receivers called if a raises an error.
-
show_event_handlers(stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, verbose=0)[source]¶ Print to stream the event handlers installed for this flow.
-
abstract property
status¶ The status of the Node.
-
-
class
NodeCorrections[source]¶ Bases:
listIterable storing the correctios performed by the
EventHandler
-
class
NodeHistory[source]¶ Bases:
collections.dequeLogger-like object
-
class
NodeResults(node, **kwargs)[source]¶ Bases:
dict,monty.json.MSONableDictionary used to store the most important results produced by a
Node.-
JSON_SCHEMA= {'properties': {'exceptions': {'required': True, 'type': 'array'}, 'files': {'required': True, 'type': 'object'}, 'in': {'description': 'dictionary with input parameters', 'required': True, 'type': 'object'}, 'node_class': {'required': True, 'type': 'string'}, 'node_finalized': {'required': True, 'type': 'boolean'}, 'node_history': {'required': True, 'type': 'array'}, 'node_id': {'required': True, 'type': 'integer'}, 'node_name': {'required': True, 'type': 'string'}, 'node_status': {'required': True, 'type': 'string'}, 'out': {'description': 'dictionary with the output results', 'required': True, 'type': 'object'}}, 'type': 'object'}¶
-
property
exceptions¶
-
property
gridfs_files¶ List with the absolute paths of the files to be put in GridFs.
-
register_gridfs_files(**kwargs)[source]¶ This function registers the files that will be saved in GridFS. kwargs is a dictionary mapping the key associated to the file (usually the extension) to the absolute path. By default, files are assumed to be in binary form, for formatted files one should pass a tuple (“filepath”, “t”).
Example:
results.register_gridfs(GSR="path/to/GSR.nc", text_file=("/path/to/txt_file", "t"))
The GSR file is a binary file, whereas text_file is a text file.
-
-
class
Product(ext, path)[source]¶ Bases:
objectA product represents an output file produced by ABINIT instance. This file is needed to start another Task or another Work.
- Parameters
ext – ABINIT file extension
path – (asbolute) filepath
-
connecting_vars()[source]¶ Returns a dictionary with the ABINIT variables that must be used to make the code use this file.
-
property
filepath¶ Absolute path of the file.
-
exception
SpectatorNodeError[source]¶ Bases:
pymatgen.io.abinit.nodes.NodeErrorException raised by
Nodemethods when the node is in spectator mode and we are calling a method with side effects.