def test_lazy_initialization(self): from python_settings import settings from python_settings.tests.settings import lazy_settings try: os.environ["SETTINGS_MODULE"] = "python_settings.tests.settings.lazy_settings" except Exception: raise BaseException('Error: Trying to set the environment') settings.configure(default_settings=lazy_settings) self.assertTrue(settings.configured) self.assertTrue(settings.LAZY_TASK) self.assertTrue(settings.LAZY_TASK_HEAVY_INITIALIZATION)
def create_chrome_browser_and_login(_url: str) -> dict: """Create a chrome type browser :param _url: web url :return: Logged browser cookies in dict format """ _cookies = {} try: _browser = webdriver.Chrome() _browser.get('https://shimo.im/login?from=home') # Get login credentials from settings.py and login settings.configure(my_local_settings) _email, _password = settings.USER_EMAIL, settings.USER_PASSWORD # Login to shimo login_shimo_by_email(_browser, _email, _password) _cookies = _browser.get_cookies() except Exception as e: sys.exit(f'[ERROR]: Failed creating chrome browser, {e}') finally: _browser.close() return _cookies
import numpy as np from python_settings import settings as s import my_settings as local_settings from functions.dataset_functions import create_tfrecords_from_tfdatasets from functions.training_functions import train_anomaly_detection_model, k_fold_training, gans_training, \ experimental_training os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' import tensorflow as tf gpu = tf.config.list_physical_devices('GPU') tf.config.experimental.set_memory_growth(gpu[0], True) if __name__ == '__main__': s.configure(local_settings) if s.MODE == 'test': print('running tests') # classes_dict = {'normal': 0, 'tumor': 1} classes_dict = {'parasitized': 0, 'uninfected': 1} create_tfrecords_from_tfdatasets(s.DATASET_NAME, s.DATASET_SPLIT, classes_dict, s.TFRECORDS_SAVE_PATH) elif s.MODE == 'simple_train': # Example experiment_16_global_params = { 'TRAIN_BATCH_SIZE': 4, 'INFER_BATCH_SIZE': 32, 'OPTIMIZER_PARAMS': {
from os.path import join, dirname import sys import ruamel.yaml import json from flask import Flask, jsonify, request from flask_cors import cross_origin from flask_talisman import Talisman import os from flask import Flask from python_settings import settings import settings as api_settings settings.configure(api_settings) assert settings.configured def create_app(test_config=None): # create and configure the app if settings.IS_DEV: app = Flask(__name__, instance_relative_config=True) else: app = Flask(__name__, instance_relative_config=True, static_folder='api_static') Talisman(app, strict_transport_security_max_age=300, content_security_policy={ 'default-src': [
import base64 import hashlib import hmac import json import time import requests from python_settings import settings from . import setting as mysetting from selenium import webdriver from selenium.webdriver.common.keys import Keys settings.configure(mysetting) def create_auth_url(): from urllib.parse import urlencode url = "https://access.line.me/oauth2/v2.1/authorize" data = {} data['response_type'] = 'code' data['client_id'] = settings.line_client_id data['redirect_uri'] = settings.callback_URL data['state'] = 'test' data['scope'] = 'openid profile' res = "{}?{}".format(url, urlencode(data)) #print(res) return res def get_token(auth_code): url = 'https://api.line.me/oauth2/v2.1/token' header = {'Content-Type': 'application/x-www-form-urlencoded'}
for _row in _sql_results: print(_row) print(f'{"-" * 40}\npandas') index_names = _df1[_df1['id'] == 'CA001'].index _df1.drop(index_names, inplace=True) print(_df1.values) if key == '10': print(f'{_statements[_key]}') # '10': 'ALTER TABLE data1 DROP COLUMN column_name;' print(f'{"-" * 40}\npandas') print(_df1.drop(columns=['cost'])) if __name__ == '__main__': database = 'testdb' # Get login credentials from settings.py and login settings.configure(my_local_settings) db_info = read_db_settings_from_file() db = DBConnector.DBConnector(db_info) db_conn = db.create_db_connection(database) # Test statement 1 ~ 5 statements = settings.STATEMENTS_ONE df = pd.read_sql('select * from data;', db_conn) # Load table data into pandas for key, sql in statements.items(): sql_results = db.run_given_database_query(database, sql, db_conn) compare_results_one(key, sql_results, df, statements) # Test statement 6 ~ 10 statements = settings.STATEMENTS_TWO df1 = pd.read_sql('select * from data1;', db_conn)