Skip to content

Fix Travis-CI build error. #858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions python/paddle/trainer/PyDataProvider2.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,24 +202,26 @@ def loop_check(callback, item):
for each in item:
callback(each)


class CheckInputTypeWrapper(object):
def __init__(self, generator, input_types, logger):
self.generator = generator
self.input_types = input_types
self.logger = logger

def __call__(self, obj, filename):
for items in self.generator(obj, filename):
try:
# dict type is required for input_types when item is dict type
assert (isinstance(items, dict) and \
not isinstance(self.input_types, dict))==False
yield items
except AssertionError as e:
self.logger.error(
def __call__(self, obj, filename):
for items in self.generator(obj, filename):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python初学者好奇:这个PR修复的问题是由错误的indentation导致的呀?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是因为目前Paddle在持续集成的Travis-CI上面检查了代码风格。原理是直接用yapf format python code,用clang-format格式化cpp code,如果有diff,那么就直接CI报错。

由于这个检查是最近一些PR加进去的,之前的PR并没有强制的跑这个检查。所以出错了。

解决办法就是直接重新format一遍就好了。命令是pre-commit run -a

try:
# dict type is required for input_types when item is dict type
assert (isinstance(items, dict) and \
not isinstance(self.input_types, dict))==False
yield items
except AssertionError as e:
self.logger.error(
"%s type is required for input type but got %s" %
(repr(type(items)), repr(type(self.input_types))))
raise
raise


def provider(input_types=None,
should_shuffle=None,
Expand Down Expand Up @@ -374,8 +376,8 @@ def __init__(self, file_list, **kwargs):
self.generator = InputOrderWrapper(self.generator,
self.input_order)
else:
self.generator = CheckInputTypeWrapper(self.generator, self.slots,
self.logger)
self.generator = CheckInputTypeWrapper(
self.generator, self.slots, self.logger)
if self.check:
self.generator = CheckWrapper(self.generator, self.slots,
check_fail_continue,
Expand Down