예제 #1
0
 def test_get_not_empty_vm_id_many_results_by_many_tags(self):
     attackers = get_attackers("vm-555")
     self.assertIn("vm-333", attackers)
     self.assertIn("vm-444", attackers)
     self.assertIn("vm-555", attackers)
     self.assertIn("vm-666", attackers)
     self.assertEqual(4, len(attackers))
예제 #2
0
 def test_get_not_empty_vm_id_one_result(self):
     attackers = get_attackers("vm-222")
     self.assertEqual(attackers, ["vm-111"])
예제 #3
0
 def test_get_not_empty_vm_id_no_results(self):
     attackers = get_attackers("vm-111")
     self.assertEqual(attackers, [])
예제 #4
0
 def test_get_not_empty_non_existing_vm_id(self):
     attackers = get_attackers("vm-123")
     self.assertEqual(attackers, [])
예제 #5
0
 def test_get_empty_vm_id(self):
     attackers = get_attackers("")
     self.assertEqual(attackers, [])
예제 #6
0
if __name__ == '__main__':

    # add run_type cli args
    parser = argparse.ArgumentParser()

    # add base cli args
    options.base_training_cfgs(parser)

    # if run_type_args.run_type=='train_adv':
    options.adv_training_cfg(parser)
    options.adv_attk_params(parser)

    # parse all args
    args = vars(parser.parse_args())

    args['device'] = get_device(**args)
    args['data_loader'] = {
        f'{dataset_type}': get_dataloader(dataset_type=dataset_type, **args)
        for dataset_type in ['val', 'train']
    }
    args['model'] = get_torchvision_models(**args)
    args['optimizer'] = get_optimizer(**args)
    args['lr_scheduler'] = get_lr_scheduler(**args)
    args['attackers'] = get_attackers(loss_fn=nn.CrossEntropyLoss(),
                                      cfg=args,
                                      **args)
    args['criterion'] = get_criterion(**args)
    args['to_device'] = partial(to_device, args['device'])
    args['to_cpu'] = partial(to_device, 'cpu')
    run_trainer(**args)