def explore(ctx, name, ids, recalculate=None, **kwargs): kwargs.update(ctx.parent.objs) engine = kwargs['engine'] config = kwargs['config'] mod.reflect(engine) try: setup.expand_stage_pattern(name, 'recalculate', kwargs) setup.expand_stage_pattern(name, 'skip_stage', kwargs) except introspect.UnknownStageError as err: click.secho("Unknown stage %s" % err.args, err=True, fg='red') ctx.exit(1) if not ids: ids = setup.pdbs(config, kwargs) kwargs['exclude'] = kwargs.get('skip_stage') dispatcher = Dispatcher(name, config, sessionmaker(engine), **kwargs) result = [] for stage in dispatcher.stages(name): recalc = '' if recalculate is True or stage.name in recalculate: recalc = 'Will Recalculate' result.append((stage.name, recalc)) formatter = click.HelpFormatter(width=90) formatter.write_dl(result) click.echo(formatter.getvalue(), nl=False)
def test_can_exclude_stages_in_container(self): dispatcher = Dispatcher('motifs.loader', CONFIG, Session, skip_dependencies=True, exclude=['motifs.release']) val = [o.name for o in dispatcher.stages('motifs.loader')] assert 'motifs.release' not in val assert val == [ 'motifs.discrepancies', 'motifs.info', 'motifs.assignments', 'motifs.loop_order', 'motifs.loop_positions', ]
class StagesTest(ut.TestCase): def setUp(self): self.dispatcher = Dispatcher('units.info', CONFIG, Session) def stages(self, *args): return [o.name for o in self.dispatcher.stages(*args)] def test_can_load_requested_stages(self): assert self.stages('units.info') == [ 'download', 'pdbs.info', 'units.info', ] def test_when_skipping_produces_container_stages_in_correct_order(self): self.dispatcher.skip_dependencies = True assert self.stages('units.loader') == [ 'units.info', 'units.centers', 'units.coordinates', 'units.distances', 'units.incomplete', 'units.rotation', ] def test_it_can_load_stage_container(self): assert self.stages('units.loader') == [ 'download', 'pdbs.info', 'units.info', 'units.centers', 'units.coordinates', 'units.distances', 'units.incomplete', 'units.rotation', ] def test_can_exclude_specific_stages(self): self.dispatcher.exclude = set(['units.distances']) val = self.stages('units.loader') assert 'units.distances' not in val assert val == [ 'download', 'pdbs.info', 'units.info', 'units.centers', 'units.coordinates', 'units.incomplete', 'units.rotation', ] def test_can_exclude_a_stage_collection(self): self.dispatcher.exclude = set(['pdbs.loader', 'units.distances']) assert self.stages('units.loader') == [ 'download', 'units.info', 'units.centers', 'units.coordinates', 'units.incomplete', 'units.rotation', ] @pytest.mark.xfail(reason="Haven't worked on yet") def test_complains_if_nothing_to_run(self): self.dispatcher.skip_dependencies = True self.dispatcher.exclude.add('units.info') with pytest.raises(core.InvalidState): self.stages('units.info') def test_can_get_one_stage_built(self): self.dispatcher.skip_dependencies = True assert self.stages('units.info') == ['units.info'] def test_running_with_nested_container_dependencies(self): val = self.stages('ife.loader') assert val.index('interactions.pairwise') < val.index('ife.info') assert val == [ 'download', 'pdbs.info', 'export.cifatom', 'pdbs.obsolete', 'units.info', 'chains.info', 'mat_files', 'units.centers', 'units.coordinates', 'units.distances', 'units.incomplete', 'units.rotation', 'interactions.flanking', 'interactions.pairwise', 'species_mapping', 'chains.species', 'interactions.summary', 'ife.info', ]