def clearVariableDictionary(self): """ Clear all variables from the 'global' variable dictionary that aren't "built-in" to the current session. """ for key in depends_variables.names(): if key == 'DEPENDS_DIR': continue if key == 'NODE_PATH': continue
def open(self, filename): """ Loads a snapshot, in the form of a json, file off disk and applies the values it pulls to the currently active dependency graph. Cleans up the UI accordingly. """ if not os.path.exists(filename): return False # Load the snapshot off disk with open(filename, 'rb') as fp: snapshot = json.loads(fp.read()) # Apply the data to the in-flight Dag self.dag.restoreSnapshot(snapshot["DAG"]) # Initialize the objects inside the graphWidget & restore the scene self.graphicsScene.restoreSnapshot(snapshot["DAG"]) # Variable substitutions self.clearVariableDictionary() for v in snapshot["DAG"]["VARIABLE_SUBSTITIONS"]: depends_variables.variableSubstitutions[v["NAME"]] = (v["VALUE"], False) # The current session gets a variable representing the location of the current workflow if 'WORKFLOW_DIR' not in depends_variables.names(): depends_variables.add('WORKFLOW_DIR') depends_variables.setx('WORKFLOW_DIR', os.path.dirname(filename), readOnly=True) # Additional meta-data loading if "RELOAD_PLUGINS_FILENAME_TEMP" in snapshot: filename = snapshot["RELOAD_PLUGINS_FILENAME_TEMP"] # UI tidies self.undoStack.clear() self.undoStack.setClean() self.workingFilename = filename self.setWindowTitle("Depends (%s)" % self.workingFilename) self.variableWidget.rebuild(depends_variables.variableSubstitutions) self.addRecentItem(filename) self.rebuildRecentMenu() return True
def dagNodesSanityCheck(self, dagNodes): """ Runs a series of sanity tests on the given dag nodes to make sure they are fit to be executed in their current state. """ # # Full DAG validation # # Insure all $ variables that are used, exist for dagNode in dagNodes: (singleDollarVariables, doubleDollarVariables) = self.dagNodeVariablesUsed(dagNode) for sdVariable in singleDollarVariables: if sdVariable not in depends_variables.names(): raise RuntimeError( "Depends variable $%s used in node '%s' does not exist in current environment." % (sdVariable, dagNode.name)) # Insure all $$ variables that are used, are present in the current environment for dagNode in dagNodes: (singleDollarVariables, doubleDollarVariables) = self.dagNodeVariablesUsed(dagNode) for ddVariable in doubleDollarVariables: if ddVariable not in os.environ: raise RuntimeError( "Environment variable $%s used in node '%s' does not exist in current environment." % (ddVariable, dagNode.name)) # # Individual node validation # for dagNode in dagNodes: # Insure all the inputs are connected if not self.dag.nodeAllInputsConnected(dagNode): raise RuntimeError("Node '%s' is missing a required input." % (dagNode.name)) # Insure the validation function passes for each node. try: dagNode.validate() except Exception, err: raise RuntimeError( "Dag node '%s' did not pass its validation test with the error:\n%s" % (dagNode.name, err))
def dagNodesSanityCheck(self, dagNodes): """ Runs a series of sanity tests on the given dag nodes to make sure they are fit to be executed in their current state. """ # # Full DAG validation # # Insure all $ variables that are used, exist for dagNode in dagNodes: (singleDollarVariables, doubleDollarVariables) = self.dagNodeVariablesUsed(dagNode) for sdVariable in singleDollarVariables: if sdVariable not in depends_variables.names(): raise RuntimeError("Depends variable $%s used in node '%s' does not exist in current environment." % (sdVariable, dagNode.name)) # Insure all $$ variables that are used, are present in the current environment for dagNode in dagNodes: (singleDollarVariables, doubleDollarVariables) = self.dagNodeVariablesUsed(dagNode) for ddVariable in doubleDollarVariables: if ddVariable not in os.environ: raise RuntimeError("Environment variable $%s used in node '%s' does not exist in current environment." % (ddVariable, dagNode.name)) # # Individual node validation # for dagNode in dagNodes: # Insure all the inputs are connected if not self.dag.nodeAllInputsConnected(dagNode): raise RuntimeError("Node '%s' is missing a required input." % (dagNode.name)) # Insure the validation function passes for each node. try: dagNode.validate() except Exception, err: raise RuntimeError("Dag node '%s' did not pass its validation test with the error:\n%s" % (dagNode.name, err))