Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
fabricate.Builder Class Reference
Inheritance diagram for fabricate.Builder:
object

Public Member Functions

def __init__ (self, runner=None, dirs=None, dirdepth=100, ignoreprefix='.', ignore=None, hasher=md5_hasher, depsname='.deps', quiet=False, debug=False, inputs_only=False, parallel_ok=False)
 
def echo (self, message)
 
def echo_command (self, command, echo=None)
 
def echo_delete (self, filename, error=None)
 
def echo_debug (self, message)
 
def run (self, args, kwargs)
 
def done (self, command, deps, outputs)
 
def memoize (self, command, kwargs)
 
def outofdate (self, func)
 
def cmdline_outofdate (self, command)
 
def autoclean (self)
 
def deps (self)
 
def read_deps (self)
 
def write_deps (self, depsname=None)
 
def set_runner (self, runner)
 

Public Attributes

 dirs
 
 dirdepth
 
 ignoreprefix
 
 ignore
 
 depsname
 
 hasher
 
 quiet
 
 debug
 
 inputs_only
 
 checking
 
 hash_cache
 
 runner
 
 parallel_ok
 
 outofdate_flag
 
short int type
 
short int number
 
char name [SIZE_OF_OBJ_NAME]
 
cat_entry star
 

Private Member Functions

def _run (self, args, kwargs)
 
def _is_relevant (self, fullname)
 
def _join_results_handler (self)
 

Private Attributes

 _deps
 

Static Private Attributes

dictionary _runner_map
 

Detailed Description

The Builder.

    You may supply a "runner" class to change the way commands are run
    or dependencies are determined. For an example, see:
        https://github.com/SimonAlfie/fabricate/wiki/HowtoMakeYourOwnRunner

    A "runner" must be a subclass of Runner and must have a __call__()
    function that takes a command as a list of args and returns a tuple of
    (deps, outputs), where deps is a list of rel-path'd dependency files
    and outputs is a list of rel-path'd output files. The default runner
    is SmartRunner, which automatically picks one of StraceRunner,
    AtimesRunner, or AlwaysRunner depending on your system.
    A "runner" class may have an __init__() function that takes the
    builder as a parameter.

Definition at line 982 of file fabricate.py.

Constructor & Destructor Documentation

def fabricate.Builder.__init__ (   self,
  runner = None,
  dirs = None,
  dirdepth = 100,
  ignoreprefix = '.',
  ignore = None,
  hasher = md5_hasher,
  depsname = '.deps',
  quiet = False,
  debug = False,
  inputs_only = False,
  parallel_ok = False 
)
Initialise a Builder with the given options.

"runner" specifies how programs should be run.  It is either a
    callable compatible with the Runner class, or a string selecting
    one of the standard runners ("atimes_runner", "strace_runner",
    "always_runner", or "smart_runner").
"dirs" is a list of paths to look for dependencies (or outputs) in
    if using the strace or atimes runners.
"dirdepth" is the depth to recurse into the paths in "dirs" (default
    essentially means infinitely). Set to 1 to just look at the
    immediate paths in "dirs" and not recurse at all. This can be
    useful to speed up the AtimesRunner if you're building in a large
    tree and you don't care about all of the subdirectories.
"ignoreprefix" prevents recursion into directories that start with
    prefix.  It defaults to '.' to ignore svn directories.
    Change it to '_svn' if you use _svn hidden directories.
"ignore" is a regular expression.  Any dependency that contains a
    regex match is ignored and not put into the dependency list.
    Note that the regex may be VERBOSE (spaces are ignored and # line
    comments allowed -- use \ prefix to insert these characters)
"hasher" is a function which returns a string which changes when
    the contents of its filename argument changes, or None on error.
    Default is md5_hasher, but can also be mtime_hasher.
"depsname" is the name of the JSON dependency file to load/save.
"quiet" set to True tells the builder to not display the commands being
    executed (or other non-error output).
"debug" set to True makes the builder print debug output, such as why
    particular commands are being executed
"inputs_only" set to True makes builder only re-build if input hashes
    have changed (ignores output hashes); use with tools that touch
    files that shouldn't cause a rebuild; e.g. g++ collect phase
"parallel_ok" set to True to indicate script is safe for parallel running

Definition at line 1001 of file fabricate.py.

Referenced by PandAna.core.core.spectrum.fill().

1001  quiet=False, debug=False, inputs_only=False, parallel_ok=False):
1002  """ Initialise a Builder with the given options.
1003 
1004  "runner" specifies how programs should be run. It is either a
1005  callable compatible with the Runner class, or a string selecting
1006  one of the standard runners ("atimes_runner", "strace_runner",
1007  "always_runner", or "smart_runner").
1008  "dirs" is a list of paths to look for dependencies (or outputs) in
1009  if using the strace or atimes runners.
1010  "dirdepth" is the depth to recurse into the paths in "dirs" (default
1011  essentially means infinitely). Set to 1 to just look at the
1012  immediate paths in "dirs" and not recurse at all. This can be
1013  useful to speed up the AtimesRunner if you're building in a large
1014  tree and you don't care about all of the subdirectories.
1015  "ignoreprefix" prevents recursion into directories that start with
1016  prefix. It defaults to '.' to ignore svn directories.
1017  Change it to '_svn' if you use _svn hidden directories.
1018  "ignore" is a regular expression. Any dependency that contains a
1019  regex match is ignored and not put into the dependency list.
1020  Note that the regex may be VERBOSE (spaces are ignored and # line
1021  comments allowed -- use \ prefix to insert these characters)
1022  "hasher" is a function which returns a string which changes when
1023  the contents of its filename argument changes, or None on error.
1024  Default is md5_hasher, but can also be mtime_hasher.
1025  "depsname" is the name of the JSON dependency file to load/save.
1026  "quiet" set to True tells the builder to not display the commands being
1027  executed (or other non-error output).
1028  "debug" set to True makes the builder print debug output, such as why
1029  particular commands are being executed
1030  "inputs_only" set to True makes builder only re-build if input hashes
1031  have changed (ignores output hashes); use with tools that touch
1032  files that shouldn't cause a rebuild; e.g. g++ collect phase
1033  "parallel_ok" set to True to indicate script is safe for parallel running
1034  """
1035  if dirs is None:
1036  dirs = ['.']
1037  self.dirs = dirs
1038  self.dirdepth = dirdepth
1039  self.ignoreprefix = ignoreprefix
1040  if ignore is None:
1041  ignore = r'$x^' # something that can't match
1042  self.ignore = re.compile(ignore, re.VERBOSE)
1043  self.depsname = depsname
1044  self.hasher = hasher
1045  self.quiet = quiet
1046  self.debug = debug
1047  self.inputs_only = inputs_only
1048  self.checking = False
1049  self.hash_cache = {}
1050 
1051  # instantiate runner after the above have been set in case it needs them
1052  if runner is not None:
1053  self.set_runner(runner)
1054  elif hasattr(self, 'runner'):
1055  # For backwards compatibility, if a derived class has
1056  # defined a "runner" method then use it:
1057  pass
1058  else:
1059  self.runner = SmartRunner(self)
1060 
1061  is_strace = isinstance(self.runner.actual_runner(), StraceRunner)
1062  self.parallel_ok = parallel_ok and is_strace and _pool is not None
1063  if self.parallel_ok:
1064  global _results
1065  _results = threading.Thread(target=_results_handler,
1066  args=[self])
1067  _results.setDaemon(True)
1068  _results.start()
1069  atexit.register(self._join_results_handler)
1070  StraceRunner.keep_temps = False # unsafe for parallel execution
1071 
def set_runner(self, runner)
Definition: fabricate.py:1337
def _join_results_handler(self)
Definition: fabricate.py:1371

Member Function Documentation

def fabricate.Builder._is_relevant (   self,
  fullname 
)
private
Return True if file is in the dependency search directories. 

Definition at line 1353 of file fabricate.py.

References fabricate.Builder.dirdepth, fabricate.Builder.dirs, and fabricate.Builder.ignoreprefix.

1353  def _is_relevant(self, fullname):
1354  """ Return True if file is in the dependency search directories. """
1355 
1356  # need to abspath to compare rel paths with abs
1357  fullname = os.path.abspath(fullname)
1358  for path in self.dirs:
1359  path = os.path.abspath(path)
1360  if fullname.startswith(path):
1361  rest = fullname[len(path):]
1362  # files in dirs starting with ignoreprefix are not relevant
1363  if os.sep+self.ignoreprefix in os.sep+os.path.dirname(rest):
1364  continue
1365  # files deeper than dirdepth are not relevant
1366  if rest.count(os.sep) > self.dirdepth:
1367  continue
1368  return True
1369  return False
1370 
def _is_relevant(self, fullname)
Definition: fabricate.py:1353
def fabricate.Builder._join_results_handler (   self)
private
Stops then joins the results handler thread

Definition at line 1371 of file fabricate.py.

1372  """Stops then joins the results handler thread"""
1373  _stop_results.set()
1374  _results.join()
1375 
1376 # default Builder instance, used by helper run() and main() helper functions
def _join_results_handler(self)
Definition: fabricate.py:1371
def fabricate.Builder._run (   self,
  args,
  kwargs 
)
private

Definition at line 1099 of file fabricate.py.

References fabricate.args_to_list(), fabricate.Builder.cmdline_outofdate(), and fabricate.Builder.parallel_ok.

Referenced by fabricate.Builder.run().

1099  def _run(self, *args, **kwargs):
1100  after = kwargs.pop('after', None)
1101  group = kwargs.pop('group', True)
1102  echo = kwargs.pop('echo', None)
1103  arglist = args_to_list(args)
1104  if not arglist:
1105  raise TypeError('run() takes at least 1 argument (0 given)')
1106  # we want a command line string for the .deps file key and for display
1107  command = subprocess.list2cmdline(arglist)
1108  if not self.cmdline_outofdate(command):
1109  if self.parallel_ok:
1110  _groups.ensure(group)
1111  return command, None, None
1112 
1113  # if just checking up-to-date-ness, set flag and do nothing more
1114  self.outofdate_flag = True
1115  if self.checking:
1116  if self.parallel_ok:
1117  _groups.ensure(group)
1118  return command, None, None
1119 
1120  # use runner to run command and collect dependencies
1121  self.echo_command(command, echo=echo)
1122  if self.parallel_ok:
1123  arglist.insert(0, self.runner)
1124  if after is not None:
1125  if not isinstance(after, (list, tuple)):
1126  after = [after]
1127  # This command is registered to False group firstly,
1128  # but the actual group of this command should
1129  # count this blocked command as well as usual commands
1130  _groups.inc_count_for_blocked(group)
1131  _groups.add(False,
1132  _after(after, _todo(group, command, arglist,
1133  kwargs)))
1134  else:
1135  async = _pool.apply_async(_call_strace, arglist, kwargs)
1136  _groups.add(group, _running(async, command))
1137  return None
1138  else:
1139  deps, outputs = self.runner(*arglist, **kwargs)
1140  return self.done(command, deps, outputs)
1141 
def echo_command(self, command, echo=None)
Definition: fabricate.py:1077
def done(self, command, deps, outputs)
Definition: fabricate.py:1161
def _run(self, args, kwargs)
Definition: fabricate.py:1099
def cmdline_outofdate(self, command)
Definition: fabricate.py:1218
def args_to_list(args)
Definition: fabricate.py:129
def fabricate.Builder.autoclean (   self)
Automatically delete all outputs of this build as well as the .deps
    file. 

Definition at line 1257 of file fabricate.py.

References fabricate.Builder.depsname.

1257  def autoclean(self):
1258  """ Automatically delete all outputs of this build as well as the .deps
1259  file. """
1260  # first build a list of all the outputs from the .deps file
1261  outputs = []
1262  dirs = []
1263  for command, deps in self.deps.items():
1264  outputs.extend(dep for dep, hashed in deps.items()
1265  if hashed.startswith('output-'))
1266  outputs.append(self.depsname)
1267  self._deps = None
1268  for output in outputs:
1269  try:
1270  os.remove(output)
1271  except OSError as e:
1272  if os.path.isdir(output):
1273  # cache directories to be removed once all other outputs
1274  # have been removed, as they may be content of the dir
1275  dirs.append(output)
1276  else:
1277  self.echo_delete(output, e)
1278  else:
1279  self.echo_delete(output)
1280  # delete the directories in reverse sort order
1281  # this ensures that parents are removed after children
1282  for dir in sorted(dirs, reverse=True):
1283  try:
1284  os.rmdir(dir)
1285  except OSError as e:
1286  self.echo_delete(dir, e)
1287  else:
1288  self.echo_delete(dir)
1289 
1290 
def echo_delete(self, filename, error=None)
Definition: fabricate.py:1085
def autoclean(self)
Definition: fabricate.py:1257
def fabricate.Builder.cmdline_outofdate (   self,
  command 
)
Return True if given command line is out of date. 

Definition at line 1218 of file fabricate.py.

References fabricate.StraceProcess.deps, fabricate.Builder.deps(), fabricate.Builder.depsname, fabricate.Builder.echo_debug(), fabricate.Builder.hash_cache, fabricate.Builder.hasher, and fabricate.Builder.inputs_only.

Referenced by fabricate.Builder._run().

1218  def cmdline_outofdate(self, command):
1219  """ Return True if given command line is out of date. """
1220  if command in self.deps:
1221  # command has been run before, see if deps have changed
1222  for dep, oldhash in self.deps[command].items():
1223  assert oldhash.startswith('input-') or \
1224  oldhash.startswith('output-'), \
1225  "%s file corrupt, do a clean!" % self.depsname
1226  io_type, oldhash = oldhash.split('-', 1)
1227 
1228  # make sure this dependency or output hasn't changed
1229  if dep in self.hash_cache:
1230  # already hashed so don't repeat hashing work
1231  newhash = self.hash_cache[dep]
1232  else:
1233  # not in hash_cache so make sure this dependency or
1234  # output hasn't changed
1235  newhash = self.hasher(dep)
1236  if newhash is not None:
1237  # Add newhash to the hash cache
1238  self.hash_cache[dep] = newhash
1239 
1240  if newhash is None:
1241  self.echo_debug("rebuilding %r, %s %s doesn't exist" %
1242  (command, io_type, dep))
1243  break
1244  if newhash != oldhash and (not self.inputs_only or io_type == 'input'):
1245  self.echo_debug("rebuilding %r, hash for %s %s (%s) != old hash (%s)" %
1246  (command, io_type, dep, newhash, oldhash))
1247  break
1248  else:
1249  # all dependencies are unchanged
1250  return False
1251  else:
1252  self.echo_debug('rebuilding %r, no dependency data' % command)
1253  # command has never been run, or one of the dependencies didn't
1254  # exist or had changed
1255  return True
1256 
def cmdline_outofdate(self, command)
Definition: fabricate.py:1218
def deps(self)
Definition: fabricate.py:1292
def echo_debug(self, message)
Definition: fabricate.py:1094
def fabricate.Builder.deps (   self)
Lazy load .deps file so that instantiating a Builder is "safe". 

Definition at line 1292 of file fabricate.py.

References fabricate.Builder._deps, fabricate.Builder.depsname, fabricate.Builder.read_deps(), and fabricate.Builder.write_deps().

Referenced by fabricate.Builder.cmdline_outofdate(), fabricate.Builder.done(), and fabricate.Builder.write_deps().

1292  def deps(self):
1293  """ Lazy load .deps file so that instantiating a Builder is "safe". """
1294  if not hasattr(self, '_deps') or self._deps is None:
1295  self.read_deps()
1296  atexit.register(self.write_deps, depsname=os.path.abspath(self.depsname))
1297  return self._deps
1298 
def read_deps(self)
Definition: fabricate.py:1299
def deps(self)
Definition: fabricate.py:1292
def write_deps(self, depsname=None)
Definition: fabricate.py:1316
def fabricate.Builder.done (   self,
  command,
  deps,
  outputs 
)
Store the results in the .deps file when they are available 

Definition at line 1161 of file fabricate.py.

References fabricate.StraceProcess.deps, fabricate.Builder.deps(), fabricate.Builder.hash_cache, and fabricate.Builder.hasher.

1161  def done(self, command, deps, outputs):
1162  """ Store the results in the .deps file when they are available """
1163  if deps is not None or outputs is not None:
1164  deps_dict = {}
1165 
1166  # hash the dependency inputs and outputs
1167  for dep in deps:
1168  if dep in self.hash_cache:
1169  # already hashed so don't repeat hashing work
1170  hashed = self.hash_cache[dep]
1171  else:
1172  hashed = self.hasher(dep)
1173  if hashed is not None:
1174  deps_dict[dep] = "input-" + hashed
1175  # store hash in hash cache as it may be a new file
1176  self.hash_cache[dep] = hashed
1177 
1178  for output in outputs:
1179  hashed = self.hasher(output)
1180  if hashed is not None:
1181  deps_dict[output] = "output-" + hashed
1182  # update hash cache as this file should already be in
1183  # there but has probably changed
1184  self.hash_cache[output] = hashed
1185 
1186  self.deps[command] = deps_dict
1187 
1188  return command, deps, outputs
1189 
def done(self, command, deps, outputs)
Definition: fabricate.py:1161
def deps(self)
Definition: fabricate.py:1292
def fabricate.Builder.echo (   self,
  message 
)
Print message, but only if builder is not in quiet mode. 

Definition at line 1072 of file fabricate.py.

References print, and fabricate.Builder.quiet.

Referenced by fabricate.Builder.echo_command(), and fabricate.Builder.echo_delete().

1072  def echo(self, message):
1073  """ Print message, but only if builder is not in quiet mode. """
1074  if not self.quiet:
1075  print(message)
1076 
def echo(self, message)
Definition: fabricate.py:1072
bool print
def fabricate.Builder.echo_command (   self,
  command,
  echo = None 
)
Show a command being executed. Also passed run's "echo" arg
    so you can override what's displayed.

Definition at line 1077 of file fabricate.py.

References fabricate.Builder.echo(), and submit_syst.str.

1077  def echo_command(self, command, echo=None):
1078  """ Show a command being executed. Also passed run's "echo" arg
1079  so you can override what's displayed.
1080  """
1081  if echo is not None:
1082  command = str(echo)
1083  self.echo(command)
1084 
def echo(self, message)
Definition: fabricate.py:1072
def echo_command(self, command, echo=None)
Definition: fabricate.py:1077
def fabricate.Builder.echo_debug (   self,
  message 
)
Print message, but only if builder is in debug mode. 

Definition at line 1094 of file fabricate.py.

References fabricate.Builder.debug, and print.

Referenced by fabricate.Builder.cmdline_outofdate(), and fabricate.Builder.echo_delete().

1094  def echo_debug(self, message):
1095  """ Print message, but only if builder is in debug mode. """
1096  if self.debug:
1097  print('DEBUG: ' + message)
1098 
bool print
def echo_debug(self, message)
Definition: fabricate.py:1094
def fabricate.Builder.echo_delete (   self,
  filename,
  error = None 
)
Show a file being deleted. For subclassing Builder and overriding
    this function, the exception is passed in if an OSError occurs
    while deleting a file. 

Definition at line 1085 of file fabricate.py.

References fabricate.Builder.echo(), and fabricate.Builder.echo_debug().

1085  def echo_delete(self, filename, error=None):
1086  """ Show a file being deleted. For subclassing Builder and overriding
1087  this function, the exception is passed in if an OSError occurs
1088  while deleting a file. """
1089  if error is None:
1090  self.echo('deleting %s' % filename)
1091  else:
1092  self.echo_debug('error deleting %s: %s' % (filename, error.strerror))
1093 
def echo(self, message)
Definition: fabricate.py:1072
def echo_delete(self, filename, error=None)
Definition: fabricate.py:1085
def echo_debug(self, message)
Definition: fabricate.py:1094
def fabricate.Builder.memoize (   self,
  command,
  kwargs 
)
Run the given command, but only if its dependencies have changed --
    like run(), but returns the status code instead of raising an
    exception on error. If "command" is a string (as per memoize.py)
    it's split into args using shlex.split() in a POSIX/bash style,
    otherwise it's a list of args as per run().

    This function is for compatiblity with memoize.py and is
    deprecated. Use run() instead. 

Definition at line 1190 of file fabricate.py.

References fabricate.args_to_list(), CosmicTrackTree.run, Metric.Metric.run, om::RateSummaryNt.run, comi::LeanaNt.run, cvn::ProngSummary.run, bpf::SliceSummary.run, comi::CanaNt.run, EventId.run, hough::HValidateNt.run, sumdata::DataRunNumInMC.run, caf::SRHeader.run, flugg.run, g3numi.run, SubEntry.run, caf::SRSpill.run, g4numi.run, g4lbne.run, g4minerva.run, RunInfo.run, flat::FlatHeader.run, flat::FlatSpill.run, art::detail::RangeSetInfo.run, ana::SpectrumLoaderNuTreeSpillCuts::Key_t.run, readFlux.run, EventFilter.run, BeamlineAna.run, febstat::EventFEBStatus.run, lem::EventSummary.run, State.run, lem::MatchSummary.run, chaninfo::FindSwappedChannels.run, calib::DetRespDrift.run, caldp::DriftResponse.run, validation::NoiseClusterAnalysis.run, tbem::TBRecoAna.run, flat::FlatNeutrino.run, calib::FiberCalibration.run, CalibAnaPlot.run, cmf::EventId.run, calib::TimingCalibration.run, comi::NumiFilteringAna.run, earms::ElasticArmsValidate.run, caf::SRNeutrino.run, bsf::BremShowerFilter.run, fuzz::FuzzyKValidate.run, calib::MuonTrackHits.run, EventID.run, airshower::AirSlicer.run, SelectOutput.run, genie::flux::GNuMIFluxPassThroughInfo.run, fnex::MCEventInfo_struct.run, genie::flux::GSimpleNtpNuMI.run, art::SamplingInput::Config.run, slicer::SlicerAna.run, htk::HoughTrack.run, fuzz::FuzzyKVertex.run, EventInfo.run, caf::Proxy< caf::SRHeader >.run, fnex::DataEventInfo_struct.run, calib::MuondEdxAna.run, fnex::EventInfo_struct_RunSubrunCycle.run, caf::Proxy< caf::SRNeutrino >.run, fnex::EventId.run, fabricate.Builder.run(), and caf::Proxy< caf::SRSpill >.run.

1190  def memoize(self, command, **kwargs):
1191  """ Run the given command, but only if its dependencies have changed --
1192  like run(), but returns the status code instead of raising an
1193  exception on error. If "command" is a string (as per memoize.py)
1194  it's split into args using shlex.split() in a POSIX/bash style,
1195  otherwise it's a list of args as per run().
1196 
1197  This function is for compatiblity with memoize.py and is
1198  deprecated. Use run() instead. """
1199  if isinstance(command, string_types):
1200  args = shlex.split(command)
1201  else:
1202  args = args_to_list(command)
1203  try:
1204  self.run(args, **kwargs)
1205  return 0
1206  except ExecutionError as exc:
1207  message, data, status = exc
1208  return status
1209 
def memoize(self, command, kwargs)
Definition: fabricate.py:1190
def args_to_list(args)
Definition: fabricate.py:129
def run(self, args, kwargs)
Definition: fabricate.py:1142
def fabricate.Builder.outofdate (   self,
  func 
)
Return True if given build function is out of date. 

Definition at line 1210 of file fabricate.py.

References fabricate.Builder.checking, func(), and fabricate.Builder.outofdate_flag.

1210  def outofdate(self, func):
1211  """ Return True if given build function is out of date. """
1212  self.checking = True
1213  self.outofdate_flag = False
1214  func()
1215  self.checking = False
1216  return self.outofdate_flag
1217 
double func(double x, double y)
def outofdate(self, func)
Definition: fabricate.py:1210
def fabricate.Builder.read_deps (   self)
Read dependency JSON file into deps object. 

Definition at line 1299 of file fabricate.py.

References fabricate.Builder._deps, fabricate.Builder.depsname, open(), and fabricate.printerr().

Referenced by fabricate.Builder.deps().

1299  def read_deps(self):
1300  """ Read dependency JSON file into deps object. """
1301  try:
1302  f = open(self.depsname)
1303  try:
1304  self._deps = json.load(f)
1305  # make sure the version is correct
1306  if self._deps.get('.deps_version', 0) != deps_version:
1307  printerr('Bad %s dependency file version! Rebuilding.'
1308  % self.depsname)
1309  self._deps = {}
1310  self._deps.pop('.deps_version', None)
1311  finally:
1312  f.close()
1313  except IOError:
1314  self._deps = {}
1315 
def printerr(message)
Definition: fabricate.py:118
def read_deps(self)
Definition: fabricate.py:1299
procfile open("FD_BRL_v0.txt")
def fabricate.Builder.run (   self,
  args,
  kwargs 
)
Run command given in args with kwargs per shell(), but only if its
    dependencies or outputs have changed or don't exist. Return tuple
    of (command_line, deps_list, outputs_list) so caller or subclass
    can use them.

    Parallel operation keyword args "after" specifies a group or
    iterable of groups to wait for after they finish, "group" specifies
    the group to add this command to.

    Optional "echo" keyword arg is passed to echo_command() so you can
    override its output if you want.

Definition at line 1142 of file fabricate.py.

References nova::dbi::DQSubrunInfo._run, and fabricate.Builder._run().

Referenced by fabricate.Builder.memoize().

1142  def run(self, *args, **kwargs):
1143  """ Run command given in args with kwargs per shell(), but only if its
1144  dependencies or outputs have changed or don't exist. Return tuple
1145  of (command_line, deps_list, outputs_list) so caller or subclass
1146  can use them.
1147 
1148  Parallel operation keyword args "after" specifies a group or
1149  iterable of groups to wait for after they finish, "group" specifies
1150  the group to add this command to.
1151 
1152  Optional "echo" keyword arg is passed to echo_command() so you can
1153  override its output if you want.
1154  """
1155  try:
1156  return self._run(*args, **kwargs)
1157  finally:
1158  sys.stderr.flush()
1159  sys.stdout.flush()
1160 
def _run(self, args, kwargs)
Definition: fabricate.py:1099
def run(self, args, kwargs)
Definition: fabricate.py:1142
def fabricate.Builder.set_runner (   self,
  runner 
)
Set the runner for this builder.  "runner" is either a Runner
   subclass (e.g. SmartRunner), or a string selecting one of the
   standard runners ("atimes_runner", "strace_runner",
   "always_runner", or "smart_runner").

Definition at line 1337 of file fabricate.py.

References fabricate.Builder._runner_map, and fabricate.Builder.runner.

1337  def set_runner(self, runner):
1338  """Set the runner for this builder. "runner" is either a Runner
1339  subclass (e.g. SmartRunner), or a string selecting one of the
1340  standard runners ("atimes_runner", "strace_runner",
1341  "always_runner", or "smart_runner")."""
1342  try:
1343  self.runner = self._runner_map[runner](self)
1344  except KeyError:
1345  if isinstance(runner, string_types):
1346  # For backwards compatibility, allow runner to be the
1347  # name of a method in a derived class:
1348  self.runner = getattr(self, runner)
1349  else:
1350  # pass builder to runner class to get a runner instance
1351  self.runner = runner(self)
1352 
dictionary _runner_map
Definition: fabricate.py:1330
def set_runner(self, runner)
Definition: fabricate.py:1337
def fabricate.Builder.write_deps (   self,
  depsname = None 
)
Write out deps object into JSON dependency file. 

Definition at line 1316 of file fabricate.py.

References fabricate.Builder._deps, fabricate.StraceProcess.deps, fabricate.Builder.deps(), fabricate.Builder.depsname, and open().

Referenced by fabricate.Builder.deps().

1316  def write_deps(self, depsname=None):
1317  """ Write out deps object into JSON dependency file. """
1318  if self._deps is None:
1319  return # we've cleaned so nothing to save
1320  self.deps['.deps_version'] = deps_version
1321  if depsname is None:
1322  depsname = self.depsname
1323  f = open(depsname, 'w')
1324  try:
1325  json.dump(self.deps, f, indent=4, sort_keys=True)
1326  finally:
1327  f.close()
1328  self._deps.pop('.deps_version', None)
1329 
def deps(self)
Definition: fabricate.py:1292
def write_deps(self, depsname=None)
Definition: fabricate.py:1316
procfile open("FD_BRL_v0.txt")

Member Data Documentation

fabricate.Builder._deps
private
dictionary fabricate.Builder._runner_map
staticprivate
Initial value:
1 = {
2  'atimes_runner' : AtimesRunner,
3  'strace_runner' : StraceRunner,
4  'always_runner' : AlwaysRunner,
5  'smart_runner' : SmartRunner,
6  }

Definition at line 1330 of file fabricate.py.

Referenced by fabricate.Builder.set_runner().

fabricate.Builder.checking

Definition at line 1048 of file fabricate.py.

Referenced by fabricate.Builder.outofdate().

fabricate.Builder.debug

Definition at line 1046 of file fabricate.py.

Referenced by fabricate.Builder.echo_debug().

fabricate.Builder.depsname
fabricate.Builder.dirdepth

Definition at line 1038 of file fabricate.py.

Referenced by fabricate.Builder._is_relevant().

fabricate.Builder.dirs

Definition at line 1037 of file fabricate.py.

Referenced by fabricate.Builder._is_relevant().

fabricate.Builder.hash_cache

Definition at line 1049 of file fabricate.py.

Referenced by fabricate.Builder.cmdline_outofdate(), and fabricate.Builder.done().

fabricate.Builder.hasher

Definition at line 1044 of file fabricate.py.

Referenced by fabricate.Builder.cmdline_outofdate(), and fabricate.Builder.done().

fabricate.Builder.ignore
fabricate.Builder.ignoreprefix

Definition at line 1039 of file fabricate.py.

Referenced by fabricate.Builder._is_relevant().

fabricate.Builder.inputs_only

Definition at line 1047 of file fabricate.py.

Referenced by fabricate.Builder.cmdline_outofdate().

char object::name
inherited
short int object::number
inherited

Definition at line 115 of file novas.h.

fabricate.Builder.outofdate_flag

Definition at line 1114 of file fabricate.py.

Referenced by fabricate.Builder.outofdate().

fabricate.Builder.parallel_ok

Definition at line 1062 of file fabricate.py.

Referenced by fabricate.Builder._run().

fabricate.Builder.quiet

Definition at line 1045 of file fabricate.py.

Referenced by fabricate.Builder.echo().

fabricate.Builder.runner

Definition at line 1059 of file fabricate.py.

Referenced by fabricate.Builder.set_runner().

cat_entry object::star
inherited

Definition at line 117 of file novas.h.

short int object::type
inherited

Definition at line 114 of file novas.h.


The documentation for this class was generated from the following file: