Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _load_custom_config(run_config):
"""Load custom configuration input HOCON file for cromwell.
"""
from pyhocon import ConfigFactory, HOCONConverter, ConfigTree
conf = ConfigFactory.parse_file(run_config)
out = {}
if "database" in conf:
out["database"] = HOCONConverter.to_hocon(ConfigTree({"database": conf.get_config("database")}))
return out
def to_str(self, fmt='hocon'):
return HOCONConverter.convert(self._config_tree, fmt)
def to_str(self):
return HOCONConverter.convert(self._config_tree, 'hocon')
recursive_remove_secrets(config, secret_keys=remove_secret_keys)
# remove logging.loggers.urllib3.level from the print
try:
config['logging']['loggers']['urllib3'].pop('level', None)
except (KeyError, TypeError, AttributeError):
pass
try:
config['logging'].pop('version', None)
except (KeyError, TypeError, AttributeError):
pass
config = ConfigFactory.from_dict(config)
self.log.debug("Run by interpreter: %s", sys.executable)
print(
"Current configuration (trains_agent v{}, location: {}):\n"
"----------------------\n{}\n".format(
self.version, self._config_file, HOCONConverter.convert(config, "properties")
)
def initialize_from_env(eval_test=False):
if "GPU" in os.environ:
set_gpus(int(os.environ["GPU"]))
name = sys.argv[1]
print("Running experiment: {}".format(name))
if eval_test:
config = pyhocon.ConfigFactory.parse_file("test.experiments.conf")[name]
else:
config = pyhocon.ConfigFactory.parse_file("experiments.conf")[name]
config["log_dir"] = mkdirs(os.path.join(config["log_root"], name))
print(pyhocon.HOCONConverter.convert(config, "hocon"))
return config
def initialize_from_env():
if "GPU" in os.environ:
set_gpus(int(os.environ["GPU"]))
else:
set_gpus()
name = sys.argv[1]
print("Running experiment: {}".format(name))
config = pyhocon.ConfigFactory.parse_file("experiments.conf")[name]
config["log_dir"] = mkdirs(os.path.join(config["log_root"], name))
print(pyhocon.HOCONConverter.convert(config, "hocon"))
return config
def print_config(config):
print (pyhocon.HOCONConverter.convert(config, "hocon"))
def to_json(self):
return json.loads(HOCONConverter.convert(self._config_tree, 'json'))