From 9f08757f0a0c1fc42b488822f2745ee03ed72de9 Mon Sep 17 00:00:00 2001 From: cclauss Date: Thu, 1 Feb 2018 12:27:26 +0100 Subject: [PATCH] Define StateSamplerInfo for line 58 __StateSamplerInfo__ definition copied from https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/statesampler.py#L32-L34 flake8 testing of https://github.com/apache/beam $ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__ ``` ./sdks/python/apache_beam/runners/worker/statesampler_slow.py:54:12: F821 undefined name 'StateSamplerInfo' return StateSamplerInfo( ^ ``` --- .../runners/worker/statesampler.py | 8 +------ .../runners/worker/statesampler_slow.py | 2 ++ .../runners/worker/statesamplerinfo.py | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 sdks/python/apache_beam/runners/worker/statesamplerinfo.py diff --git a/sdks/python/apache_beam/runners/worker/statesampler.py b/sdks/python/apache_beam/runners/worker/statesampler.py index 03af644846d7..667d416b7936 100644 --- a/sdks/python/apache_beam/runners/worker/statesampler.py +++ b/sdks/python/apache_beam/runners/worker/statesampler.py @@ -16,8 +16,7 @@ # # This module is experimental. No backwards-compatibility guarantees. -from collections import namedtuple - +from apache_beam.runners.worker.statesamplerinfo import StateSamplerInfo from apache_beam.utils.counters import Counter from apache_beam.utils.counters import CounterName @@ -29,11 +28,6 @@ FAST_SAMPLER = False -StateSamplerInfo = namedtuple( - 'StateSamplerInfo', - ['state_name', 'transition_count', 'time_since_transition']) - - # Default period for sampling current state of pipeline execution. DEFAULT_SAMPLING_PERIOD_MS = 200 diff --git a/sdks/python/apache_beam/runners/worker/statesampler_slow.py b/sdks/python/apache_beam/runners/worker/statesampler_slow.py index dafe3b46887b..2e986f84ffd7 100644 --- a/sdks/python/apache_beam/runners/worker/statesampler_slow.py +++ b/sdks/python/apache_beam/runners/worker/statesampler_slow.py @@ -17,6 +17,8 @@ # This module is experimental. No backwards-compatibility guarantees. +from apache_beam.runners.worker.statesamplerinfo import StateSamplerInfo + class StateSampler(object): diff --git a/sdks/python/apache_beam/runners/worker/statesamplerinfo.py b/sdks/python/apache_beam/runners/worker/statesamplerinfo.py new file mode 100644 index 000000000000..96b8ff8f1823 --- /dev/null +++ b/sdks/python/apache_beam/runners/worker/statesamplerinfo.py @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# This module is experimental. No backwards-compatibility guarantees. +from collections import namedtuple + +StateSamplerInfo = namedtuple( + 'StateSamplerInfo', + ['state_name', 'transition_count', 'time_since_transition'])