def log_nodes_cb(node, status):
 import datetime
 import logging
 import json
 if (node.result is not None):
  try:
   runtime = node.result.runtime
   runtime_memory_gb = runtime.runtime_memory_gb
   runtime_threads = runtime.runtime_threads
  except AttributeError:
   runtime_memory_gb = runtime_threads = u'Unknown'
 else:
  runtime_memory_gb = runtime_threads = u'N/A'
 logger = logging.getLogger(u'callback')
 status_dict = {u'name': node.name, u'id': node._id, u'estimated_memory_gb': node._interface.estimated_memory_gb, u'num_threads': node._interface.num_threads}
 if (status == u'start'):
  status_dict[u'start'] = str(datetime.datetime.now())
 elif (status == u'end'):
  status_dict[u'finish'] = str(datetime.datetime.now())
  status_dict[u'runtime_threads'] = runtime_threads
  status_dict[u'runtime_memory_gb'] = runtime_memory_gb
 else:
  status_dict[u'finish'] = str(datetime.datetime.now())
  status_dict[u'error'] = True
 logger.debug(json.dumps(status_dict))

def log_nodes_cb ( node , status ) : import datetime import logging import json if ( node . result is not None ) : try : runtime = node . result . runtime runtime_memory_gb = runtime . runtime_memory_gb runtime_threads = runtime . runtime_threads except AttributeError : runtime_memory_gb = runtime_threads = u'Unknown' else : runtime_memory_gb = runtime_threads = u'N/A' logger = logging . getLogger ( u'callback' ) status_dict = { u'name' : node . name , u'id' : node . _id , u'estimated_memory_gb' : node . _interface . estimated_memory_gb , u'num_threads' : node . _interface . num_threads } if ( status == u'start' ) : status_dict [ u'start' ] = str ( datetime . datetime . now ( ) ) elif ( status == u'end' ) : status_dict [ u'finish' ] = str ( datetime . datetime . now ( ) ) status_dict [ u'runtime_threads' ] = runtime_threads status_dict [ u'runtime_memory_gb' ] = runtime_memory_gb else : status_dict [ u'finish' ] = str ( datetime . datetime . now ( ) ) status_dict [ u'error' ] = True logger . debug ( json . dumps ( status_dict ) )
function to record node run statistics to a log file as json dictionaries parameters node : nipype .