Beispiel #1
0
def main(_):
    global FLAGS
    FLAGS = tf.app.flags.FLAGS

    init_random_seeds()
    if FLAGS.env != "local":
        cloud.connect()
    for hparams_name in FLAGS.hparams.split(","):
        _run(hparams_name)
Beispiel #2
0
def experiment():
    hosts = cloud.connect()
    print str(len(hosts))+' hosts'
    print "cleaning up any old jobs that are still running."
    learn_object.clean_old_jobs(hosts)
    experiment = '/var/tmp/experiment'
    learn_object.train_and_test_list(objects,hosts,params_list,experiment)
Beispiel #3
0
    def test_not_allowed(self):
        """Does the auth module prevent access in the correct circumstances?"""
        self.db.rename('fancy')

        table = self.db.create_table('owner', [{
            'name': 'boffo',
            'datatype': Text
        }])
        table2 = self.db.create_table('gungy', [{
            'name': 'boffo',
            'datatype': Text
        }])
        view = self.db.create_view('stinky', {'objid': table})

        table.rename('frango')
        view.rename('spangy')
        col = self.db.Column(table2.columns()[0])
        col.modify({'datatype': 'Float'})

        if target == 'rest':
            bad_cloud = cc.connect("http://localhost:5000", cfg.b)
        elif target == 'local':
            bad_cloud = cc.Cloud(cfg.b)

        bad_db = bad_cloud.Database(self.db)
        with self.assertRaises(cc.NotAuthorized):
            bad_db.rename('gorgo')

        with self.assertRaises(cc.NotAuthorized):
            bad_db.create_table('gorgo', [])

        with self.assertRaises(cc.NotAuthorized):
            bad_db.drop()

        bad_table = bad_cloud.Table(table)
        with self.assertRaises(cc.NotAuthorized):
            bad_table.rename('boofkins')

        with self.assertRaises(cc.NotAuthorized):
            bad_table.add_columns([{'name': 'boofkins', 'datatype': 'Text'}])

        with self.assertRaises(cc.NotAuthorized):
            bad_table.drop()

        bad_view = bad_cloud.View(view)
        with self.assertRaises(cc.NotAuthorized):
            bad_view.rename('lily')

        with self.assertRaises(cc.NotAuthorized):
            bad_view.drop()

        bad_col = bad_cloud.Column(col)
        with self.assertRaises(cc.NotAuthorized):
            bad_col.rename('lacdulac')

        with self.assertRaises(cc.NotAuthorized):
            bad_col.modify('Integer')

        with self.assertRaises(cc.NotAuthorized):
            bad_col.drop()
Beispiel #4
0
 def tearDown(self):
     """Drop the database."""
     
     if target == 'rest':
         cloud = cc.connect("http://localhost:5000",cfg.user)
     elif target == 'local':
         cloud = cc.Cloud(cfg.user)
     
     cloud.Database(self.db).drop()
Beispiel #5
0
    def tearDown(self):
        """Drop the database."""

        if target == 'rest':
            cloud = cc.connect("http://localhost:5000", cfg.user)
        elif target == 'local':
            cloud = cc.Cloud(cfg.user)

        cloud.Database(self.db).drop()
Beispiel #6
0
 def test_not_allowed(self):
     """Does the auth module prevent access in the correct circumstances?"""
     self.db.rename('fancy')
     
     table = self.db.create_table('owner',[{'name':'boffo','datatype':Text}])
     table2 = self.db.create_table('gungy',[{'name':'boffo','datatype':Text}])
     view = self.db.create_view('stinky',{'objid':table})
     
     table.rename('frango')
     view.rename('spangy')
     col = self.db.Column(table2.columns()[0])
     col.modify({'datatype':'Float'})
     
     if target == 'rest':
         bad_cloud = cc.connect("http://localhost:5000",cfg.b)
     elif target == 'local':
         bad_cloud = cc.Cloud(cfg.b)
     
     bad_db = bad_cloud.Database(self.db)
     with self.assertRaises(cc.NotAuthorized):
         bad_db.rename('gorgo')
         
     with self.assertRaises(cc.NotAuthorized):
         bad_db.create_table('gorgo',[])
         
     with self.assertRaises(cc.NotAuthorized):
         bad_db.drop()
     
     bad_table = bad_cloud.Table(table)
     with self.assertRaises(cc.NotAuthorized):
         bad_table.rename('boofkins')
         
     with self.assertRaises(cc.NotAuthorized):
         bad_table.add_columns([{'name':'boofkins','datatype':'Text'}])
     
     with self.assertRaises(cc.NotAuthorized):
         bad_table.drop()
         
     bad_view = bad_cloud.View(view)
     with self.assertRaises(cc.NotAuthorized):
         bad_view.rename('lily')
         
     with self.assertRaises(cc.NotAuthorized):
         bad_view.drop()
     
     bad_col = bad_cloud.Column(col)
     with self.assertRaises(cc.NotAuthorized):
         bad_col.rename('lacdulac')
         
     with self.assertRaises(cc.NotAuthorized):
         bad_col.modify('Integer')
         
     with self.assertRaises(cc.NotAuthorized):
         bad_col.drop()
Beispiel #7
0
#!/usr/bin/env python
import distribute, cloud, subprocess, getpass, time, sys

if __name__ == "__main__" and len(sys.argv) > 1:
    hostfile = sys.argv[1]
else:
    hostfile = None

hosts = cloud.connect(hostfile=hostfile)

#cmd = 'rm -rf /tmp/*'
#distribute.run_on_all(hosts,cmd)

#cmd = 'rm -rf /var/tmp/objrec/data/hold-out'
#distribute.run_on_all(hosts,cmd)

#distribute.copy(hosts,'/var/tmp/objrec/data/hold_out_set.py','/var/tmp/objrec/data')

#cmd = 'cd /var/tmp/objrec/data; ./hold_out_set.py > /tmp/test.sh; chmod u+x /tmp/test.sh; /tmp/test.sh; rm /tmp/test.sh'
#distribute.run_on_all(hosts,cmd)


def clean_old_jobs(hosts):
    jobs = []
    for h in hosts:
        j = distribute.job('killall -9 detect learn Xvfb')
        j.start(h)
        jobs.append(j)
    while len([1 for j in jobs if not j.isdone(verbose=False)]) > 0:
        time.sleep(1)
Beispiel #8
0
import config_cloud as cfg

sys.path.append('../')

from core.pg.datatypes import Text,Integer
import common.api as api

target = 'local'

if target == 'local':
    import cloud as cc
    cloud = cc.Cloud(cfg.user)
elif target == 'rest':
    sys.path.append('../client')
    import pyclient as cc
    cloud = cc.connect("http://*****:*****@unittest.skip('skip')
class TestAuth(unittest.TestCase):
    
    def setUp(self):
        """Instantiate a db, drop and instantiate if the first try fails."""
        try:
            self.db = cloud.create_database('selectdb')
        except cc.IntegrityError:
            db = cloud.Database('selectdb').drop()
            self.db = cloud.create_database('selectdb')
        
    def tearDown(self):
        """Drop the database."""
        
Beispiel #9
0
import config_cloud as cfg

sys.path.append('../')

from core.pg.datatypes import Text, Integer
import common.api as api

target = 'local'

if target == 'local':
    import cloud as cc
    cloud = cc.Cloud(cfg.user)
elif target == 'rest':
    sys.path.append('../client')
    import pyclient as cc
    cloud = cc.connect("http://*****:*****@unittest.skip('skip')
class TestAuth(unittest.TestCase):
    def setUp(self):
        """Instantiate a db, drop and instantiate if the first try fails."""
        try:
            self.db = cloud.create_database('selectdb')
        except cc.IntegrityError:
            db = cloud.Database('selectdb').drop()
            self.db = cloud.create_database('selectdb')

    def tearDown(self):
        """Drop the database."""
Beispiel #10
0
import sds011
import time
import cloud

sensor = sds011.SDS011()
report = cloud.connect()

while True:
    try:
        measurements = sensor.read()
        if measurements is None:
            pass
        else:
            report.compose(*measurements)
            time.sleep_ms(5000)
    except KeyboardInterrupt as e:
        print('KeyboardInterrupt')
Beispiel #11
0
                                          init_scheme="random",
                                          warmup_steps=10000,
                                          encoder_depth=2,
                                          decoder_depth=2,
                                          hidden_size=100,
                                          is_ae=True,
                                          activation=tf.nn.sigmoid,
                                          enc_layers=[50, 50],
                                          dec_layers=[50],
                                          label_shape=[1],
                                          dropout=0,
                                          channels=1,
                                          input_shape=[28, 28, 1],
                                          output_shape=[28, 28, 1])

    train_input_fn = get_mnist("tmp/data", hparams, training=True)
    eval_input_fn = get_mnist("tmp/data", hparams, training=False)

    estimator = tf.estimator.Estimator(model_fn=get_autoencoder(hparams, 0.01),
                                       model_dir="tmp/run",
                                       config=run_config)

    estimator.train(train_input_fn, steps=100)
    estimator.evaluate(eval_input_fn, steps=10)


if __name__ == "__main__":
    FLAGS = tf.app.flags.FLAGS
    cloud.connect()
    main()
    cloud.down()