def __init__(self, file_path, start_date=None, end_date=None, today=False, this_week=False, this_month=False): self.today = today if today: self.start_date = get_today() self.end_date = get_tomorrow() elif this_week: self.start_date = get_last_week() self.end_date = get_tomorrow() elif this_month: self.start_date = get_last_month() self.end_date = get_tomorrow() else: self.start_date = start_date self.end_date = end_date self.components_total = read_calendar(file_path, self.start_date, self.end_date) self.name = file_path.split('/')[-1] self.time_delta_dict = get_time_by_date(self.components_total) if len(self.components_total) == 0: no_cal_data_warning = 'No tasks found in {} calendar for period between {} and {}. Did you remember to export an up-to-date version of {} to timetrack/data/calendars/?'.format( self.name, self.start_date, self.end_date, self.name) warnings.warn(no_cal_data_warning)
def pbf_download_needed(pbf_file_with_date, md5_file_with_date, pgosm_date): """Decides if the PBF/MD5 files need to be downloaded. Parameters ------------------------------- pbf_file_with_date : str md5_file_with_date : str Returns -------------------------- download_needed : bool """ logger = logging.getLogger('pgosm-flex') # If the PBF file exists, check for the MD5 file too. if os.path.exists(pbf_file_with_date): logger.info(f'PBF File exists {pbf_file_with_date}') if os.path.exists(md5_file_with_date): logger.info('PBF & MD5 files exist. Download not needed') download_needed = False else: if pgosm_date == helpers.get_today(): print('PBF for today available but not MD5... download needed') download_needed = True else: err = f'Missing MD5 file for {pgosm_date}. Cannot validate.' logger.error(err) raise FileNotFoundError(err) else: if not pgosm_date == helpers.get_today(): err = f'Missing PBF file for {pgosm_date}. Cannot proceed.' logger.error(err) raise FileNotFoundError(err) logger.info('PBF file not found locally. Download required') download_needed = True return download_needed
def init_socket_wrapper(socket, config): return SocketWrapper(socket, config.SOCKET_NAMESPACE) def init_tryer(app): return Tryer(app.logger) def init_voter(socket_wrapper): return Voter(socket_wrapper) ############## # Initialize # ############## config = init_config() application = init_app(config) limiter = init_limiter() searcher = init_searcher(config) socket = init_socket(application) socket_wrapper = init_socket_wrapper(socket, config) today = get_today() tryer = init_tryer(application) voter = init_voter(socket_wrapper) def run(): socket.run(application, port=config.PORT)
'--layerset-path', required=False, help= 'Custom path to load layerset INI from. Custom paths should be mounted to Docker via docker run -v ...' ) @click.option( '--language', default=None, envvar="PGOSM_LANGUAGE", help= "Set default language in loaded OpenStreetMap data when available. e.g. 'en' or 'kn'." ) @click.option( '--pgosm-date', required=False, default=helpers.get_today(), envvar="PGOSM_DATE", help= "Date of the data in YYYY-MM-DD format. If today (default), automatically downloads when files not found locally. Set to historic date to load locally archived PBF/MD5 file, will fail if both files do not exist." ) @click.option('--schema-name', required=False, default='osm', help="Change the final schema name, defaults to 'osm'.") @click.option( '--skip-dump', default=False, is_flag=True, help= 'Skips the final pg_dump at the end. Useful for local testing when not loading into more permanent instance.' )
# random forest model_rf = rfr(random_state=1) model_rf.fit(train_X, train_y) get_mae(model_rf, val_X, val_y) # xgboost model_xgb = xgb(random_state=1, n_estimators=10000, learning_rate=0.01) model_xgb.fit(train_X, train_y, early_stopping_rounds=10, eval_set=[(val_X, val_y)], verbose=False) get_mae(model_xgb, val_X, val_y) # make predictions for today year, month, day = get_today() om = 30.15 od = 23.96 r = 727 rm = 701.35 t = 6.45 ts = 1.79 td = 1.6 d = { 'Year': [year], 'Month': [month], 'Date': [day], 'OM': om, 'OD': od, 'R': r,
def __init__(self, text, date=helpers.get_today(), time=helpers.get_now()): self.date = date self.time = time self.text = text