Skip to content

Commit

Permalink
Fix some codes to support python3
Browse files Browse the repository at this point in the history
Signed-off-by: Luyao Huang <[email protected]>
  • Loading branch information
LuyaoHuang committed Aug 15, 2019
1 parent 860b436 commit a84d37c
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 39 deletions.
5 changes: 4 additions & 1 deletion depend_test_framework/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
TODO
"""

from base import route_permutations, hashable_list
from .base import route_permutations, hashable_list
from depend_test_framework.log import get_logger

LOGGER = get_logger(__name__)

try:
from DL import LSTM
Expand Down
2 changes: 1 addition & 1 deletion depend_test_framework/base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import types
from functools import partial

from log import get_logger
from .log import get_logger

LOGGER = get_logger(__name__)

Expand Down
19 changes: 12 additions & 7 deletions depend_test_framework/case_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

import itertools
import random

from progressbar import ProgressBar, SimpleProgress, Counter, Timer

from log import get_logger
from env import Env
from utils import pretty
from case import Case
from algorithms import route_permutations
from .log import get_logger
from .env import Env
from .utils import pretty
from .case import Case
from .algorithms import route_permutations

LOGGER = get_logger(__name__)

Expand Down Expand Up @@ -124,7 +125,10 @@ def gen_depend_map(self, test_funcs, drop_env=None, start_node=None):
nodes = [start_node]
widgets = ['Processed: ', Counter(), ' nodes (', Timer(), ')']
LOGGER.info("Start gen depend map...")
pbar = ProgressBar(widgets=widgets, max_value=100000)
try:
pbar = ProgressBar(widgets=widgets, max_value=100000)
except TypeError:
pbar = ProgressBar(widgets=widgets, maxval=100000)
pbar.start()
while nodes:
node = nodes.pop()
Expand All @@ -135,6 +139,7 @@ def gen_depend_map(self, test_funcs, drop_env=None, start_node=None):
if drop_env and len(new_node) > drop_env:
continue
if new_node not in dep_graph.keys():
LOGGER.debug('New Node: %s func: %s', new_node, func)
dep_graph.setdefault(new_node, {})
nodes.append(new_node)
data = dep_graph[node]
Expand All @@ -153,7 +158,7 @@ def build_graph_map(self):
if not self.dep_graph:
return

self._nodes_map = self.dep_graph.keys()
self._nodes_map = list(self.dep_graph.keys())
v_graph = {}

for node in self._nodes_map:
Expand Down
2 changes: 1 addition & 1 deletion depend_test_framework/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import copy
import importlib

from base_class import Params
from .base_class import Params


def _check_param(param, name, typ=None):
Expand Down
8 changes: 4 additions & 4 deletions depend_test_framework/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""
import copy

from base_class import Entrypoint, check_func_entrys, get_entrypoint
from .base_class import Entrypoint, check_func_entrys, get_entrypoint

from log import get_logger
from .log import get_logger

LOGGER = get_logger(__name__)

Expand Down Expand Up @@ -47,8 +47,8 @@ def effect_env(self, env):
sub_env = env.get_data(self.src)
new_env = copy.deepcopy(sub_env)
env.set_data(self.tgt, new_env)
if not sub_env.data:
sub_env.data = True
if not new_env.data:
new_env.data = True

def gen_trans_depend(self, dep):
# TODO this is a work around
Expand Down
20 changes: 10 additions & 10 deletions depend_test_framework/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import random
import contextlib

from base_class import Container, Params, get_func_params_require
from test_object import is_TestObject, is_Action, is_CheckPoint, is_Hybrid, StaticMist
from dependency import is_Graft, get_all_depend, Provider, Consumer, Graft
from log import get_logger, get_file_logger, make_timing_logger
from case_generator import DependGraphCaseGenerator
from runner_handlers import MistsHandler
from runners import Runner
from learning import StepsSeqScorer
from hook import EnvHook, CaseHook
from .base_class import Container, Params, get_func_params_require
from .test_object import is_TestObject, is_Action, is_CheckPoint, is_Hybrid, StaticMist
from .dependency import is_Graft, get_all_depend, Provider, Consumer, Graft
from .log import get_logger, get_file_logger, make_timing_logger
from .case_generator import DependGraphCaseGenerator
from .runner_handlers import MistsHandler
from .runners import Runner
from .learning import StepsSeqScorer
from .hook import EnvHook, CaseHook

LOGGER = get_logger(__name__)
time_log = make_timing_logger(LOGGER)
Expand Down Expand Up @@ -236,7 +236,7 @@ def _start_test(self, test_func, need_cleanup=False,
break

def _create_training_data(self, cases, test_func):
# TODO: TMP
# TODO: Only for testing
def score_a(case):
if case.step_num >= 13:
score = 1
Expand Down
4 changes: 2 additions & 2 deletions depend_test_framework/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import contextlib
import copy

from log import get_logger
from dependency import Consumer, Provider, Cut, Graft, get_all_depend
from .log import get_logger
from .dependency import Consumer, Provider, Cut, Graft, get_all_depend

LOGGER = get_logger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions depend_test_framework/learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import random
import pickle

from log import get_logger
from algorithms import LSTM
from .log import get_logger
from .algorithms import LSTM

LOGGER = get_logger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions depend_test_framework/runner_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import itertools
import contextlib

from test_object import MistClearException, TestEndException, StaticMist, MistDeadEndException
from case import Case
from log import get_logger
from .test_object import MistClearException, TestEndException, StaticMist, MistDeadEndException
from .case import Case
from .log import get_logger

LOGGER = get_logger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions depend_test_framework/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Helper classes to help run test case
"""

from log import get_logger
from env import Env
from dependency import get_all_depend, Consumer
from test_object import TestEndException
from .log import get_logger
from .env import Env
from .dependency import get_all_depend, Consumer
from .test_object import TestEndException

LOGGER = get_logger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions depend_test_framework/test_object.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Test object related class
"""
from base_class import Entrypoint, check_func_entrys
from env import Env
from .base_class import Entrypoint, check_func_entrys
from .env import Env

from log import get_logger
from .log import get_logger

LOGGER = get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion depend_test_framework/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def run_cmd(cmd):
def pretty(d, indent=0):
ret = ""
ret += ('\t' * indent + '{\n')
for key, value in d.iteritems():
for key, value in d.items():
ret += ('\t' * indent + str(key) + ' :\n')
if isinstance(value, dict):
ret += pretty(value, indent + 1)
Expand Down

0 comments on commit a84d37c

Please sign in to comment.