def _branch_config(self, conflicts, branching_configuration): """Ask for a different identifier for this experiment. Set :attr:`refers` key to previous experiment's name, the one that we branched from. :param config: Conflicting configuration that will change based on prompt. """ experiment_brancher = ExperimentBranchBuilder(conflicts, branching_configuration) needs_manual_resolution = (not experiment_brancher.is_resolved or experiment_brancher.auto_resolution) if needs_manual_resolution: branching_prompt = BranchingPrompt(experiment_brancher) if not sys.__stdin__.isatty(): raise ValueError( "Configuration is different and generates a branching event:\n{}" .format(branching_prompt.get_status())) branching_prompt.cmdloop() if branching_prompt.abort or not experiment_brancher.is_resolved: sys.exit() adapter = experiment_brancher.create_adapters() self._instantiate_config(experiment_brancher.conflicting_config) self.refers['adapter'] = adapter self.refers['parent_id'] = self._id
def _branch_experiment(experiment, conflicts, version, branching_arguments): """Create a new branch experiment with adapters for the given conflicts""" experiment_brancher = ExperimentBranchBuilder(conflicts, **branching_arguments) needs_manual_resolution = (not experiment_brancher.is_resolved or experiment_brancher.manual_resolution) if not experiment_brancher.is_resolved: name_conflict = conflicts.get([ExperimentNameConflict])[0] if not name_conflict.is_resolved and not version: raise RaceCondition( 'There was likely a race condition during version increment.') if needs_manual_resolution: # TODO: This should only be possible when using cmdline API branching_prompt = BranchingPrompt(experiment_brancher) if not sys.__stdin__.isatty(): raise BranchingEvent(branching_prompt.get_status()) branching_prompt.cmdloop() if branching_prompt.abort or not experiment_brancher.is_resolved: sys.exit() config = experiment_brancher.conflicting_config config['refers']['adapter'] = experiment_brancher.create_adapters( ).configuration config['refers']['parent_id'] = experiment.id config.pop('_id') return create_experiment(**config)
def _branch_experiment(experiment, conflicts, version, branching_arguments): """Create a new branch experiment with adapters for the given conflicts""" experiment_brancher = ExperimentBranchBuilder(conflicts, **branching_arguments) needs_manual_resolution = (not experiment_brancher.is_resolved or experiment_brancher.manual_resolution) if not experiment_brancher.is_resolved: name_conflict = conflicts.get([ExperimentNameConflict])[0] if not name_conflict.is_resolved and not version: log.debug( "A race condition likely occured during conflicts resolutions. " "Now rolling back and attempting re-building the branched experiment." ) raise RaceCondition( "There was likely a race condition during version increment.") if needs_manual_resolution: log.debug("Some conflicts cannot be solved automatically.") # TODO: This should only be possible when using cmdline API branching_prompt = BranchingPrompt(experiment_brancher) if not sys.__stdin__.isatty(): log.debug( "No interactive prompt available to manually resolve conflicts." ) raise BranchingEvent(branching_prompt.get_status()) branching_prompt.cmdloop() if branching_prompt.abort or not experiment_brancher.is_resolved: sys.exit() log.debug("Creating new branched configuration") config = experiment_brancher.conflicting_config config["refers"]["adapter"] = experiment_brancher.create_adapters( ).configuration config["refers"]["parent_id"] = experiment.id config.pop("_id") return create_experiment(mode="x", **config)
def _branch_config(self, conflicts, branching_configuration): """Ask for a different identifier for this experiment. Set :attr:`refers` key to previous experiment's name, the one that we branched from. :param config: Conflicting configuration that will change based on prompt. """ experiment_brancher = ExperimentBranchBuilder(conflicts, branching_configuration) if not experiment_brancher.is_resolved or experiment_brancher.auto_resolution: branching_prompt = BranchingPrompt(experiment_brancher) branching_prompt.cmdloop() if branching_prompt.abort or not experiment_brancher.is_resolved: sys.exit() adapter = experiment_brancher.create_adapters() self._instantiate_config(experiment_brancher.conflicting_config) self.refers['adapter'] = adapter self.refers['parent_id'] = self._id
def branch_solver_prompt(branch_builder): """Generate the branch solved prompt""" return BranchingPrompt(branch_builder)
def _get_branching_status_string(conflicts, branching_arguments): experiment_brancher = ExperimentBranchBuilder(conflicts, enabled=False, **branching_arguments) branching_prompt = BranchingPrompt(experiment_brancher) return branching_prompt.get_status()