本文整理汇总了Python中utils.get_config方法的典型用法代码示例。如果您正苦于以下问题:Python utils.get_config方法的具体用法?Python utils.get_config怎么用?Python utils.get_config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils
的用法示例。
在下文中一共展示了utils.get_config方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eval_config
# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_config [as 别名]
def eval_config(config_path):
test = True
config = get_config(config_path)
num_workers = 0 if os.name == 'nt' else 3
root = config.dataset_path
image_folder_name = 'train_hq' if not test else 'test_hq'
c_ds = CarvanaDataset(root, config.img_rows, config.img_cols, image_folder_name=image_folder_name, apply_clahe=config.use_clahe)
ds = H5LikeFileInterface(c_ds)
if not test:
f = 'f04a.csv' if 'f04a' in config.folder else 'fma.csv'
folds = get_csv_folds(os.path.join('..', f), os.listdir(os.path.join(root, image_folder_name)))
else:
folds = [([], list(range(len(c_ds)))) for i in range(5)]
keval = CarvanaEval(config, ds, folds, test=test, flips=flip.FLIP_LR, num_workers=num_workers, border=0)
keval.need_dice = True
skip_folds = [i for i in range(5) if config.fold is not None and i != int(config.fold)]
print('skipping folds: ', skip_folds)
keval.predict(skip_folds=skip_folds)
示例2: train_config
# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_config [as 别名]
def train_config(config_path):
config = get_config(config_path)
root = config.dataset_path
image_folder_name = 'train_hq'
ds = H5LikeFileInterface(CarvanaDataset(root,
config.img_rows, config.img_cols,
image_folder_name=image_folder_name,
apply_clahe=config.use_clahe))
f = 'f04a.csv' if 'f04a' in config.folder else 'fma.csv'
folds = get_csv_folds(os.path.join('..', f), os.listdir(os.path.join(root, image_folder_name)))
num_workers = 0 if os.name == 'nt' else 5
skip_folds = [i for i in range(5) if config.fold is not None and i != int(config.fold)]
print('skipping folds: ', skip_folds)
train(ds, folds, config, num_workers=num_workers, transforms=augment_color, skip_folds=skip_folds)
示例3: __init__
# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_config [as 别名]
def __init__(self, database_config=None):
if not database_config:
database_config = get_config()['database']
try:
self.engine = create_engine(
'postgresql://{pguser}:@{pghost}:{pgport}/{pgdatabase}'.format(
**database_config))
except OperationalError as exc:
panic("fingerprint-securedrop Postgres support relies on use of a "
"PGPASSFILE. Make sure this file exists in your homedir with "
"0600 permissions:\n{}.".format(exc))
示例4: test_read_config
# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_config [as 别名]
def test_read_config(self):
config = get_config()
self.assertTrue(config.has_section('sorter'))
self.assertTrue(config.has_section('crawler'))
self.assertIsInstance(config.getint('sorter', 'page_load_timeout'),
int)
entry_nodes = config['crawler']['entry_nodes'].split(',')
self.assertRegex(entry_nodes[0], "[0-9A-F]{40}")
示例5: test_coalesce_ordered_dict
# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_config [as 别名]
def test_coalesce_ordered_dict(self):
config = get_config()
class_tests = coalesce_ordered_dict(config['sorter']['class_tests'])
self.assertIsInstance(class_tests, OrderedDict)
示例6: main
# 需要导入模块: import utils [as 别名]
# 或者: from utils import get_config [as 别名]
def main():
""" Main entry point.
Used in the console script we setup.
Comment out any handlers you do not wish to use
"""
from zulipRequestHandler import ZulipRequestHandler
from webFillerHandler import WebFillerHandler
from webRequestHandler import WebRequestHandler
from ircRequestHandler import IRCBot
from mqttHandler import mqttHandler
from slackRequestHandler import slackRequestHandler
from utils import get_config
config = get_config()
ZULIP_USERNAME = config.get('zulip', 'username')
ZULIP_API_KEY = config.get('zulip', 'api_key')
HTTP_SERVER_HOST = config.get('http', 'host')
HTTP_SERVER_PORT = config.get('http', 'port')
LED_SCREEN_ADDRESS = config.get('main', 'led_screen_address')
FILLER_TIME_INTERVAL = config.get('fillers','time_interval')
IRC_SERVER = config.get('irc','host')
IRC_CHANNEL = config.get('irc','channel')
IRC_NICK = config.get('irc','nick')
# zulipRequestHandler = ZulipRequestHandler(ZULIP_USERNAME, ZULIP_API_KEY)
webRequestHandler = WebRequestHandler(HTTP_SERVER_HOST,HTTP_SERVER_PORT)
# mqttHandler = mqttHandler()
# ircBot = IRCBot(IRC_CHANNEL,IRC_NICK,IRC_SERVER,port=6667)
# webFillerHandler = WebFillerHandler(FILLER_TIME_INTERVAL)
slackRequestHandler = slackRequestHandler("")
led_bot = LEDBot(
address=LED_SCREEN_ADDRESS, listeners=[webRequestHandler,slackRequestHandler]
)
## Uncomment the lines below to be able to test the bot from the CLI.
# from cli_handler import CLIHandler
# led_bot = LEDBot(
# address=LED_SCREEN_ADDRESS,
# listeners=[CLIHandler(), zulipRequestHandler]
# )
led_bot.run()