def main(self, argv): args = self.parser.parse_args(args=argv) self.logger.debug('Arguments: %s', args) proj_ctrl = Project.controller() trial_ctrl = Trial.controller(proj_ctrl.storage) proj = proj_ctrl.selected() expr = proj.experiment() try: number = int(args.number) except ValueError: self.parser.error("Invalid trial number: %s" % args.number) fields = {'experiment': expr.eid, 'number': number} if not trial_ctrl.exists(fields): self.parser.error("No trial number %s in the current experiment. " "See `tau trial list` to see all trial numbers." % number) trial_ctrl.delete(fields) self.logger.info('Deleted trial %s', number) return EXIT_SUCCESS
def show(self, tool_name=None, trial_numbers=None): """Show experiment trial data. Shows the most recent trial or all trials with given numbers. Args: tool_name (str): Name of the visualization or data processing tool to use, e.g. `pprof`. trial_numbers (list): Numbers of trials to show. Raises: ConfigurationError: Invalid trial numbers or no trial data for this experiment. """ if trial_numbers: trials = [] for num in trial_numbers: found = Trial.controller(self.storage).one({'experiment': self.eid, 'number': num}) if not found: raise ConfigurationError("No trial number %d in experiment %s" % (num, self.name())) trials.append(found) else: all_trials = self.populate('trials') if not all_trials: raise ConfigurationError("No trials in experiment %s" % self.name(), "See `tau trial create --help`") else: found = all_trials[0] for trial in all_trials[1:]: if trial['begin_time'] > found['begin_time']: found = trial trials = [found] if trials: tau = self.configure() for trial in trials: prefix = trial.prefix profiles = glob.glob(os.path.join(prefix, 'profile.*.*.*')) if not profiles: profiles = glob.glob(os.path.join(prefix, 'MULTI__*')) if profiles: tau.show_profile(prefix, tool_name)
def managed_run(self, launcher_cmd, application_cmd): """Uses this experiment to run an application command. Performs all relevent system preparation tasks to run the user's application under the specified experimental configuration. Args: launcher_cmd (list): Application launcher with command line arguments. application_cmd (list): Application executable with command line arguments. Raises: ConfigurationError: The experiment is not configured to perform the desired run. Returns: int: Application subprocess return code. """ command = util.which(application_cmd[0]) if not command: raise ConfigurationError("Cannot find executable: %s" % application_cmd[0]) tau = self.configure() cmd, env = tau.get_application_command(launcher_cmd, application_cmd) return Trial.controller(self.storage).perform(self, cmd, os.getcwd(), env)