def __init__(self): super(Sou, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['sou']['bucket']+'-local' else: self.bucketname = self.config['sou']['bucket']
def __init__(self): super(Sou, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['sou']['bucket'] + '-local' else: self.bucketname = self.config['sou']['bucket']
def __init__(self): super(Wishes, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['wishes']['bucket']+'-local' else: self.bucketname = self.config['wishes']['bucket'] self.parser = json.loads
def __init__(self): super(WishesLabelled, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['wishes-labelled']['bucket']+'-local' else: self.bucketname = self.config['wishes-labelled']['bucket'] self.parser = json.loads
def __init__(self): super(rcv1, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['rcv1']['bucket']+'-local' else: self.bucketname = self.config['rcv1']['bucket'] self.parser = json.loads self.decompress = "unzip"
def __init__(self): super(Ngrams, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['ngrams']['bucket'] + '-local' else: self.bucketname = self.config['ngrams']['bucket'] self.parser = parsegram self.decompress = "unzip"
def __init__(self): super(Ngrams, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['ngrams']['bucket']+'-local' else: self.bucketname = self.config['ngrams']['bucket'] self.parser = parsegram self.decompress = "unzip"
def __init__(self): super(Crime, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['crime']['bucket']+'-local' else: self.bucketname = self.config['crime']['bucket'] self.decompress = "unzip" self.parser = json.loads
def __init__(self,original=None): super(LightCurves, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['lightcurves']['bucket']+'-local' else: self.bucketname = self.config['lightcurves']['bucket'] if original is not None: self.bucketname = 'ml-lightcurves-q14' self.decompress = "unzip" self.parser = None
def __init__(self): super(TinyMetaData, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['tinyimages']['meta-bucket']+'-local' self.img_count = 6400 else: self.bucketname = self.config['tinyimages']['meta-bucket'] self.img_count = 79302017 self.parser = None self.block_size = 768 self.iterator = block_iterator(self.block_size)
def __init__(self): super(TinyImages, self).__init__() self.config = config.config() if config.local(): self.bucketname = self.config['tinyimages']['bucket'] + '-local' self.img_count = 6400 else: self.bucketname = self.config['tinyimages']['bucket'] self.img_count = 79302017 self.parser = None self.block_size = 3072 self.iterator = block_iterator(self.block_size) self.metadata = TinyMetaData()
def config_loop(Model, config_folder, model_params, parameters, database_path): # New logger log_file_path = config_folder + '/' + 'log.txt' with open(log_file_path, 'wb') as f: f.close() formatter = logging.Formatter( '%(asctime)s %(name)-12s %(levelname)-8s %(message)s') logger_config = logging.getLogger(config_folder) hdlr = logging.FileHandler(log_file_path) hdlr.setFormatter(formatter) logger_config.addHandler(hdlr) # Prompt model parameters logger_config.info('#' * 60) logger_config.info('#### ' + config_folder) logger_config.info('#### Model parameters') logger_config.info('** Model : ' + Model.name()) for k, v in model_params.items(): logger_config.info('** ' + k + ' : ' + str(v)) # Get dimensions of batches (will be the same for pretraining) dimensions = { 'temporal_order': model_params['temporal_order'], 'orch_dim': parameters['N_orchestra'] } if parameters["embedded_piano"]: dimensions['piano_embedded_dim'] = parameters["N_piano_embedded"] else: dimensions['piano_embedded_dim'] = parameters["N_piano"] if parameters["duration_piano"]: dimensions['piano_input_dim'] = dimensions['piano_embedded_dim'] + 1 else: dimensions['piano_input_dim'] = dimensions['piano_embedded_dim'] pkl.dump(dimensions, open(config_folder + '/dimensions.pkl', 'wb')) Training_strategy = import_training_strategy.import_training_strategy( parameters["training_strategy"]) training_strategy = Training_strategy(num_k_folds=parameters["k_folds"], config_folder=config_folder, database_path=database_path, logger=logger_config) with open(config_folder + "/K_fold_strategy", 'w') as ff: ff.write(training_strategy.name() + '\n') training_strategy.get_folds(parameters, model_params) # gpu_id_locked = lock_gpu() training_strategy.submit_jobs(parameters, model_params, dimensions, SAVE, GENERATE, config.local()) # unlock_gpu(gpu_id_locked) return
def __init__(self): self.ap = network.WLAN(network.AP_IF) self.ap.active(True) self.ap.config(authmode=3, password='******') self.led_green = machine.Pin(17, machine.Pin.OUT) self.led_green.off() self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.s.bind(('', 80)) self.s.listen(5) self.s.settimeout(1) self.config_handler = config.local() self.t_ssid, self.t_pass = self.config_handler.getSettings( ['ssid', 'password']) self.t_custom_name, = self.config_handler.getSettings(['custom_name']) self.mqtt_server, self.mqtt_port, self.mqtt_user, self.mqtt_pass = self.config_handler.getSettings( ['mqtt_server', 'mqtt_port', 'mqtt_user', 'mqtt_pass'])
def __init__(self): #interpreter = interpreter.interpreter() self.boot_time = utime.time() self.config_handler = config.local() self.receiver_enabled, self.external_sensor_enabled, self.disable_status_led = self.config_handler.getSettings( [ 'receiver_enabled', 'external_sensor_enabled', 'disable_status_led' ]) if type(self.receiver_enabled) != bool: self.receiver_enabled = False if type(self.external_sensor_enabled) != bool: self.external_sensor_enabled = False if type(self.disable_status_led) != bool: self.disable_status_led = False # t_disable_local_config = self.config_handler.getSettings(['disable_local_config']) # if type(t_disable_local_config) != bool: # t_disable_local_config = False # if t_disable_local_config: # localserver.stop() self.dht11_enabled, self.dht22_enabled = self.config_handler.getSettings( ['dht11_enabled', 'dht22_enabled']) if type(self.dht11_enabled) != bool: self.dht11_enabled = False if type(self.dht22_enabled) != bool: self.dht22_enabled = False self.data_handler = interpreter.interpreter() self.sensor = sht30.SHT30(scl_pin=SCL_PIN, sda_pin=SDA_PIN) if self.receiver_enabled: print('******Receiver enabled') self.irrcv = irget.receiver(ADC_PIN) self.helper = test_helper.helper(self.irrcv, self.data_handler) else: print('******Analog input enabled') self.adc_input = ADC(Pin(ADC_PIN)) self.adc_input.atten(ADC.ATTN_11DB) if self.external_sensor_enabled: print('******External sensor enabled') self.external_sensor = dht.DHT22(Pin(CURR_PIN)) else: self.curr_input = ADC(Pin(CURR_PIN)) self.curr_input.atten(ADC.ATTN_11DB) if self.dht11_enabled: self.onboard_dht_sensor = dht.DHT11(Pin(DHT_PIN)) elif self.dht22_enabled: self.onboard_dht_sensor = dht.DHT22(Pin(DHT_PIN)) self.led_blue = Pin(LED_BLUE, Pin.OUT) self.led_red = Pin(LED_RED, Pin.OUT) self.led_green = Pin(LED_GREEN, Pin.OUT) self.led_red.on() #leds turn on with ground, so on() turn it off self.led_green.on() self.led_blue.on() self.player = buzzer self.player.play(2217, 100) self.player.play(2489, 100) self.player.play(2794, 200) self.device_id = 'node-' + ubinascii.hexlify( unique_id()).decode('utf-8') self.irout = irsend.sender(38000, LED_IR) self.temp_sensor_cal_prop = 1.0 self.temp_sensor_cal_offset = 0 self.hum_sensor_cal_prop = 1.0 self.hum_sensor_cal_offset = 0 try: t_server, t_port, t_user, t_pass = self.config_handler.getSettings( ['mqtt_server', 'mqtt_port', 'mqtt_user', 'mqtt_pass']) except: t_server = None t_port = None t_user = None t_pass = None self.mqtt_client = mqtt_sub.handler(devicename=self.device_id, server=t_server, port=t_port, username=t_user, password=t_pass) t_uplink_period, = self.config_handler.getSettings(['uplink_period']) if t_uplink_period == None: self.uplink_period = 300000 else: self.uplink_period = (t_uplink_period if type(t_uplink_period) == int else int(t_uplink_period)) self.curr_conversion, = self.config_handler.getSettings( ['current_conversion']) if self.curr_conversion == None: self.curr_conversion = 1.0 self.vol_conversion, = self.config_handler.getSettings( ['vol_conversion']) if self.vol_conversion == None: self.vol_conversion = 1.0 t_sensor_cal_tuple_temp, = self.config_handler.getSettings( ['sensor_calibration_temp']) if type(t_sensor_cal_tuple_temp) == list: self.temp_sensor_cal_prop = t_sensor_cal_tuple_temp[0] self.temp_sensor_cal_offset = t_sensor_cal_tuple_temp[1] t_sensor_cal_tuple_hum, = self.config_handler.getSettings( ['sensor_calibration_hum']) if type(t_sensor_cal_tuple_hum) == list: self.hum_sensor_cal_prop = t_sensor_cal_tuple_hum[0] self.hum_sensor_cal_offset = t_sensor_cal_tuple_hum[1] self.msg_to_publish = {} self.player.play(2489, 200) self.prev_millis = utime.ticks_ms()
import requests, os, time from bs4 import BeautifulSoup import config import io_func _config = config.local() logging = _config['logging'] script_path = _config['script_path'] feed_src_path = _config['resource_path'] + 'feeds.json' def get_rss_list(): return io_func.load_json_data(feed_src_path)['data'] def download_xml(url): res = requests.get(url, verify=True) return BeautifulSoup(res.content, 'lxml') def get_feeds(rss): return download_xml(rss).findAll('item')[:5] def write_log(catched_site, msg): logging.warning(str(msg) + '</br>') logging.warning('URL = ' + catched_site + '</br>') def extract_site_by_anchor(site_url, anchor): try: