1
0
mirror of https://github.com/gryf/coach.git synced 2025-12-17 19:20:19 +01:00

Cleanup imports.

Till now, most of the modules were importing all of the module objects
(variables, classes, functions, other imports) into module namespace,
which potentially could (and was) cause of unintentional use of class or
methods, which was indirect imported.

With this patch, all the star imports were substituted with top-level
module, which provides desired class or function.

Besides, all imports where sorted (where possible) in a way pep8[1]
suggests - first are imports from standard library, than goes third
party imports (like numpy, tensorflow etc) and finally coach modules.
All of those sections are separated by one empty line.

[1] https://www.python.org/dev/peps/pep-0008/#imports
This commit is contained in:
Roman Dobosz
2018-04-12 19:46:32 +02:00
parent cafa152382
commit 1b095aeeca
75 changed files with 1169 additions and 1139 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright (c) 2017 Intel Corporation
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -13,19 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import argparse
import tensorflow as tf
from architectures import *
from environments import *
from agents import *
from utils import *
import os
import time
import copy
from logger import *
from configurations import *
from presets import *
import shutil
import tensorflow as tf
import agents
import environments
import logger
import presets
start_time = time.time()
@@ -66,15 +63,15 @@ if __name__ == "__main__":
elif args.job_name == "worker":
# get tuning parameters
tuning_parameters = json_to_preset(args.load_json_path)
tuning_parameters = presets.json_to_preset(args.load_json_path)
# dump documentation
if not os.path.exists(tuning_parameters.experiment_path):
os.makedirs(tuning_parameters.experiment_path)
if tuning_parameters.evaluate_only:
logger.set_dump_dir(tuning_parameters.experiment_path, tuning_parameters.task_id, filename='evaluator')
logger.logger.set_dump_dir(tuning_parameters.experiment_path, tuning_parameters.task_id, filename='evaluator')
else:
logger.set_dump_dir(tuning_parameters.experiment_path, tuning_parameters.task_id)
logger.logger.set_dump_dir(tuning_parameters.experiment_path, tuning_parameters.task_id)
# multi-threading parameters
tuning_parameters.start_time = start_time
@@ -98,8 +95,8 @@ if __name__ == "__main__":
cluster=cluster)
# create the agent and the environment
env_instance = create_environment(tuning_parameters)
exec('agent = ' + tuning_parameters.agent.type + '(env_instance, tuning_parameters, replicated_device=device, '
env_instance = environments.create_environment(tuning_parameters)
exec('agent = agents.' + tuning_parameters.agent.type + '(env_instance, tuning_parameters, replicated_device=device, '
'thread_id=tuning_parameters.task_id)')
# building the scaffold
@@ -169,6 +166,6 @@ if __name__ == "__main__":
else:
agent.improve()
else:
screen.error("Invalid mode requested for parallel_actor.")
logger.screen.error("Invalid mode requested for parallel_actor.")
exit(1)