Skip to content

Apache DataFusion SQL Query Engine

ARROW-3249: [Python] Run flake8 on integration_test.py and crossbow.py

Krisztián Szűcs62d668d3ee56
diff --git a/ci/detect-changes.py b/ci/detect-changes.py
index d1d2c9805c..df041b921c 100644
--- a/ci/detect-changes.py
+++ b/ci/detect-changes.py
@@ -28,7 +28,7 @@ perr = functools.partial(print, file=sys.stderr)
LANGUAGE_TOPICS = ['c_glib', 'cpp', 'go', 'java', 'js', 'python', 'ruby', 'rust']
-ALL_TOPICS = LANGUAGE_TOPICS + ['integration', 'site']
+ALL_TOPICS = LANGUAGE_TOPICS + ['integration', 'site', 'dev']
def run_cmd(cmdline):
@@ -129,7 +129,7 @@ def get_affected_topics(affected_files):
fn = parts[-1]
if fn.startswith('README'):
continue
- if p in ('ci', 'dev', '.travis.yml'):
+ if p in ('ci', '.travis.yml'):
# For these changes, test everything
for k in ALL_TOPICS:
affected[k] = True
@@ -144,7 +144,8 @@ def get_affected_topics(affected_files):
elif p in ('c_glib'):
affected[p] = True
affected['ruby'] = True
- elif p in ('go', 'integration', 'python', 'ruby', 'rust', 'site'):
+ elif p in ('go', 'integration', 'python', 'ruby', 'rust', 'site',
+ 'dev'):
affected[p] = True
return affected
diff --git a/ci/travis_env_common.sh b/ci/travis_env_common.sh
index 009dff19ec..f5748b2a04 100755
--- a/ci/travis_env_common.sh
+++ b/ci/travis_env_common.sh
@@ -28,6 +28,7 @@ export ARROW_C_GLIB_DIR=$TRAVIS_BUILD_DIR/c_glib
export ARROW_JAVA_DIR=${TRAVIS_BUILD_DIR}/java
export ARROW_JS_DIR=${TRAVIS_BUILD_DIR}/js
export ARROW_INTEGRATION_DIR=$TRAVIS_BUILD_DIR/integration
+export ARROW_CROSSBOW_DIR=$TRAVIS_BUILD_DIR/dev/tasks
export ARROW_RUBY_DIR=$TRAVIS_BUILD_DIR/ruby
export ARROW_RUST_DIR=${TRAVIS_BUILD_DIR}/rust
export ARROW_R_DIR=${TRAVIS_BUILD_DIR}/r
diff --git a/ci/travis_lint.sh b/ci/travis_lint.sh
index 7e2b05d33c..8ebb58483f 100755
--- a/ci/travis_lint.sh
+++ b/ci/travis_lint.sh
@@ -43,13 +43,25 @@ fi
# Fail fast on style checks
+if [ "$ARROW_CI_DEV_AFFECTED" != "0" ]; then
+ # crossbow requires python3
+ sudo apt-get install -y -q python3-pip
+ sudo pip3 install -q flake8
+ python3 -m flake8 --count $ARROW_CROSSBOW_DIR
+fi
+
+if [ "$ARROW_CI_INTEGRATION_AFFECTED" != "0" ]; then
+ sudo pip install -q flake8
+ python -m flake8 --count $ARROW_INTEGRATION_DIR
+fi
if [ "$ARROW_CI_PYTHON_AFFECTED" != "0" ]; then
sudo pip install -q flake8
- flake8 --count $ARROW_PYTHON_DIR
+ python -m flake8 --count $ARROW_PYTHON_DIR
# Check Cython files with some checks turned off
- flake8 --count --config=$ARROW_PYTHON_DIR/.flake8.cython \
- $ARROW_PYTHON_DIR
+ python -m flake8 --count \
+ --config=$ARROW_PYTHON_DIR/.flake8.cython \
+ $ARROW_PYTHON_DIR
fi
diff --git a/dev/tasks/crossbow.py b/dev/tasks/crossbow.py
index cb7a13dc90..5f7f3d08fa 100755
--- a/dev/tasks/crossbow.py
+++ b/dev/tasks/crossbow.py
@@ -430,8 +430,9 @@ class Task:
def render_files(self, **extra_params):
path = CWD / self.template
+ params = toolz.merge(self.params, extra_params)
template = Template(path.read_text(), undefined=StrictUndefined)
- rendered = template.render(task=self, **self.params, **extra_params)
+ rendered = template.render(task=self, **params)
return {self.filename: rendered}
@property
@@ -605,7 +606,7 @@ def submit(ctx, task, group, job_prefix, config_path, arrow_version, dry_run):
# replace version number and create task instance from configuration
artifacts = task.pop('artifacts', None) or [] # because of yaml
artifacts = [fn.format(version=target.version) for fn in artifacts]
- tasks[name] = Task(**task, artifacts=artifacts)
+ tasks[name] = Task(artifacts=artifacts, **task)
# create job instance, doesn't mutate git data yet
job = Job(target=target, tasks=tasks)
diff --git a/integration/integration_test.py b/integration/integration_test.py
index 89145804f3..8021aa6432 100644
--- a/integration/integration_test.py
+++ b/integration/integration_test.py
@@ -478,7 +478,8 @@ class FixedSizeBinaryType(PrimitiveType):
return FixedSizeBinaryColumn
def _get_type(self):
- return OrderedDict([('name', 'fixedsizebinary'), ('byteWidth', self.byte_width)])
+ return OrderedDict([('name', 'fixedsizebinary'),
+ ('byteWidth', self.byte_width)])
def _get_type_layout(self):
return OrderedDict([
@@ -777,7 +778,9 @@ def get_field(name, type_, nullable=True):
return StringType(name, nullable=nullable)
elif type_.startswith('fixedsizebinary_'):
byte_width = int(type_.split('_')[1])
- return FixedSizeBinaryType(name, byte_width=byte_width, nullable=nullable)
+ return FixedSizeBinaryType(name,
+ byte_width=byte_width,
+ nullable=nullable)
dtype = np.dtype(type_)
@@ -928,8 +931,9 @@ class IntegrationRunner(object):
self.debug = debug
def run(self):
- for producer, consumer in itertools.product(filter(lambda t: t.PRODUCER, self.testers),
- filter(lambda t: t.CONSUMER, self.testers)):
+ for producer, consumer in itertools.product(
+ filter(lambda t: t.PRODUCER, self.testers),
+ filter(lambda t: t.CONSUMER, self.testers)):
self._compare_implementations(producer, consumer)
def _compare_implementations(self, producer, consumer):
@@ -1091,6 +1095,7 @@ class CPPTester(Tester):
print(cmd)
os.system(cmd)
+
class JSTester(Tester):
PRODUCER = True
CONSUMER = True
@@ -1103,7 +1108,8 @@ class JSTester(Tester):
name = 'JS'
- def _run(self, exe_cmd, arrow_path=None, json_path=None, command='VALIDATE'):
+ def _run(self, exe_cmd, arrow_path=None, json_path=None,
+ command='VALIDATE'):
cmd = [exe_cmd]
if arrow_path is not None:
@@ -1123,21 +1129,28 @@ class JSTester(Tester):
return self._run(self.VALIDATE, arrow_path, json_path, 'VALIDATE')
def json_to_file(self, json_path, arrow_path):
- cmd = ['node', '--no-warnings', self.JSON_TO_ARROW, '-a', arrow_path, '-j', json_path]
+ cmd = ['node',
+ '--no-warnings', self.JSON_TO_ARROW,
+ '-a', arrow_path,
+ '-j', json_path]
cmd = ' '.join(cmd)
if self.debug:
print(cmd)
os.system(cmd)
def stream_to_file(self, stream_path, file_path):
- cmd = ['cat', stream_path, '|', 'node', '--no-warnings', self.STREAM_TO_FILE, '>', file_path]
+ cmd = ['cat', stream_path, '|',
+ 'node', '--no-warnings', self.STREAM_TO_FILE, '>',
+ file_path]
cmd = ' '.join(cmd)
if self.debug:
print(cmd)
os.system(cmd)
def file_to_stream(self, file_path, stream_path):
- cmd = ['cat', file_path, '|', 'node', '--no-warnings', self.FILE_TO_STREAM, '>', stream_path]
+ cmd = ['cat', file_path, '|',
+ 'node', '--no-warnings', self.FILE_TO_STREAM, '>',
+ stream_path]
cmd = ' '.join(cmd)
if self.debug:
print(cmd)
@@ -1150,7 +1163,9 @@ def get_static_json_files():
def run_all_tests(debug=False):
- testers = [CPPTester(debug=debug), JavaTester(debug=debug), JSTester(debug=debug)]
+ testers = [CPPTester(debug=debug),
+ JavaTester(debug=debug),
+ JSTester(debug=debug)]
static_json_files = get_static_json_files()
generated_json_files = get_generated_json_files()
json_files = static_json_files + generated_json_files