How to use the ipdb.launch_ipdb_on_exception function in ipdb

To help you get started, we’ve selected a few ipdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shaofanl / Keras-GAN / legacy / demos / aegan_reid_5000.py View on Github external
def feature(aegan, filename):
    import ipdb
    with ipdb.launch_ipdb_on_exception():
        aegan.load(prefix='./samples/reid_aegan/aegan/50')

        paths = map(lambda x: x.strip(), open('protocol/cuhk01-all.txt').readlines())
        x = transform( np.array([load_image(path, (64, 128)) for path in paths]) )
        code = aegan.autoencoder.encoder.predict(x)

    ipdb.set_trace()
github CenterForOpenScience / osf.io / osf / management / commands / migratedata.py View on Github external
def do_model(self, django_model, options):
        with ipdb.launch_ipdb_on_exception():
            if not options['nodelogsguids']:
                save_bare_models.delay(django_model)
github PacificBiosciences / pbcore / pbcore / util / ToolRunner.py View on Github external
def start(self):
        self._parseArgs()
        self._setupLogging()
        self.validateArgs()

        if self.args.debug:
            try:
                import ipdb
            except ImportError:
                print("--debug requires module 'ipdb'")
                return -1
            with ipdb.launch_ipdb_on_exception():
                self.run()

        elif self.args.profile:
            l = locals()
            cProfile.runctx("_rv=self.run()", globals(), l, "profile.out")
            pstats.Stats("profile.out").sort_stats("time").print_stats(20)
            return l["_rv"]
        else:
            return self.run()
github CenterForOpenScience / osf.io / osf / management / commands / migratedata.py View on Github external
'githubguidfile', 'nodefile', 'boxfile',
                                                         'figshareguidfile', 's3guidfile', 'dataversefile']:
                        orphaned_guids.append(unicode(g._id))
                except TypeError:
                    pass
            # orphaned_guids = [unicode(g._id) for g in guids if g is not None and g.to_storage() is not None and len(g.to_storage['referent']) > 0 and g.to_storage()['referent'][1] in ['dropboxfile', 'osfstorageguidfile', 'osfguidfile', 'githubguidfile', 'nodefile', 'boxfile', 'figshareguidfile', 's3guidfile', 'dataversefile']]
            # get all the guids in postgres
            existing_guids = Guid.objects.all().values_list('_id', flat=True)
            # subtract the orphaned guids from the guids in modm and from that subtract existing guids
            # that should give us the guids that are missing
            guids_to_make = (set(guid_keys) - set(orphaned_guids)) - set(existing_guids)
            logger.info('{} MODM Guids, {} Orphaned Guids, {} Guids to Make, {} Existing guids'.format(len(guid_keys), len(orphaned_guids), len(guids_to_make), len(existing_guids)))
            from django.apps import apps
            model_names = {m._meta.model.__module__.lower(): m._meta.model for m in apps.get_models()}

            with ipdb.launch_ipdb_on_exception():
                # loop through missing guids
                for guid in guids_to_make:
                    # load them from modm
                    guid_dict = MGuid.load(guid).to_storage()
                    # if they don't have a referent toss them
                    if guid_dict['referent'] is None:
                        logger.info('{} has no referent.'.format(guid))
                        continue
                    # get the model string from the referent
                    modm_model_string = guid_dict['referent'][1]
                    if modm_model_string == 'user':
                        modm_model_string = 'osfuser'
                    # if the model string is in our list of models load it up
                    if modm_model_string in model_names:
                        referent_model = model_names[modm_model_string]
                    else:
github Shaofanl / Keras-GAN / legacy / demos / load_and_play.py View on Github external
def test_aegan(aegan, prefix):
    import ipdb
    with ipdb.launch_ipdb_on_exception():
        aegan.load(prefix=prefix)

        from GAN.utils.vis import vis_grid
        vis_grid(inverse_transform(aegan.generator.random_generate(128)), (2, 20), 'random_generate.png')

        paths = map(lambda x: x.strip(), open('protocol/cuhk01-all.txt').readlines())
        from load import load_image
        sample = transform( np.array([load_image(path, (64, 128)) for path in paths[:128]]) )
        
        vis_grid(inverse_transform(sample), (2, 20), 'sample.png')
        vis_grid(inverse_transform(aegan.autoencoder.autoencoder.predict(sample)), (2, 20), 'reconstruct.png')

        import matplotlib
        matplotlib.use('Agg')
        import matplotlib.pyplot as plt
        codes = aegan.autoencoder.encoder.predict(sample)
github CenterForOpenScience / osf.io / osf / management / commands / migratedata.py View on Github external
def do_model(self, django_model, options):
        with ipdb.launch_ipdb_on_exception():
            if not options['nodelogsguids']:
                save_bare_models.delay(django_model)