Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8a8ed63

Browse files
committed
minor cleanup
1 parent 96d9f5b commit 8a8ed63

4 files changed

Lines changed: 18 additions & 18 deletions

File tree

sdks/python/apache_beam/runners/portability/portable_runner.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060
__all__ = ['PortableRunner']
6161

6262
MESSAGE_LOG_LEVELS = {
63-
beam_job_api_pb2.JobMessage.MESSAGE_IMPORTANCE_UNSPECIFIED: logging.WARNING,
64-
beam_job_api_pb2.JobMessage.JOB_MESSAGE_DEBUG: logging.WARNING,
65-
beam_job_api_pb2.JobMessage.JOB_MESSAGE_DETAILED: logging.WARNING,
66-
beam_job_api_pb2.JobMessage.JOB_MESSAGE_BASIC: logging.WARNING,
63+
beam_job_api_pb2.JobMessage.MESSAGE_IMPORTANCE_UNSPECIFIED: logging.INFO,
64+
beam_job_api_pb2.JobMessage.JOB_MESSAGE_DEBUG: logging.DEBUG,
65+
beam_job_api_pb2.JobMessage.JOB_MESSAGE_DETAILED: logging.DEBUG,
66+
beam_job_api_pb2.JobMessage.JOB_MESSAGE_BASIC: logging.INFO,
6767
beam_job_api_pb2.JobMessage.JOB_MESSAGE_WARNING: logging.WARNING,
6868
beam_job_api_pb2.JobMessage.JOB_MESSAGE_ERROR: logging.ERROR,
6969
}
@@ -158,7 +158,7 @@ def add_runner_options(parser):
158158
# only in this case is duplicate not treated as error
159159
if 'conflicting option string' not in str(e):
160160
raise
161-
_LOGGER.warning("Runner option '%s' was already added" % option.name)
161+
_LOGGER.debug("Runner option '%s' was already added" % option.name)
162162

163163
all_options = self.options.get_all_options(
164164
add_extra_args_fn=add_runner_options,
@@ -384,7 +384,7 @@ def run_portable_pipeline(
384384
if cleanup_callbacks:
385385
# Register an exit handler to ensure cleanup on exit.
386386
atexit.register(functools.partial(result._cleanup, on_exit=True))
387-
_LOGGER.warning(
387+
_LOGGER.info(
388388
'Environment "%s" has started a component necessary for the '
389389
'execution. Be sure to run the pipeline using\n'
390390
' with Pipeline() as p:\n'
@@ -532,11 +532,14 @@ def read_messages() -> None:
532532
previous_state = -1
533533
for message in self._message_stream:
534534
if message.HasField('message_response'):
535-
logging.warning("%s", message.message_response.message_text)
535+
logging.log(
536+
MESSAGE_LOG_LEVELS[message.message_response.importance],
537+
"%s",
538+
message.message_response.message_text)
536539
else:
537540
current_state = message.state_response.state
538541
if current_state != previous_state:
539-
_LOGGER.warning(
542+
_LOGGER.info(
540543
"Job state changed to %s",
541544
self.runner_api_state_to_pipeline_state(current_state))
542545
previous_state = current_state
@@ -586,7 +589,7 @@ def _observe_state(self, message_thread):
586589

587590
def _cleanup(self, on_exit: bool = False) -> None:
588591
if on_exit and self._cleanup_callbacks:
589-
_LOGGER.warning(
592+
_LOGGER.info(
590593
'Running cleanup on exit. If your pipeline should continue running, '
591594
'be sure to use the following syntax:\n'
592595
' with Pipeline() as p:\n'

sdks/python/apache_beam/runners/portability/prism_runner.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class PrismJobServer(job_server.SubprocessJobServer):
116116
BIN_CACHE = os.path.expanduser("~/.apache_beam/cache/prism/bin")
117117

118118
def __init__(self, options):
119-
120119
super().__init__()
121120
prism_options = options.view_as(pipeline_options.PrismRunnerOptions)
122121
# Options flow:
@@ -332,12 +331,9 @@ def subprocess_cmd_and_endpoint(
332331
return (subprocess_cmd, f"localhost:{job_port}")
333332

334333
def prism_arguments(self, job_port) -> typing.List[typing.Any]:
335-
# TODO: Remove or expose log_level more nicely.
336334
return [
337335
'--job_port',
338336
job_port,
339337
'--serve_http',
340338
False,
341-
'--log_level',
342-
'should_fail',
343339
]

sdks/python/apache_beam/utils/windowed_value.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,9 @@ def end(self):
432432
return self._end_object
433433

434434
def __hash__(self):
435-
# Cut of window at start/end timestamps for comparison purposes since some
436-
# portable runners do this already.
435+
# Cut off window at start/end timestamps for comparison purposes since some
436+
# portable runners do this already, and timestamps outside of the bands of
437+
# Min/Max timestamps are functionally equal to Min/Max.
437438
start = max(self._start_micros, MIN_TIMESTAMP.micros)
438439
end = min(self._end_micros, MAX_TIMESTAMP.micros)
439440
return hash((start, end))
@@ -442,8 +443,9 @@ def __eq__(self, other):
442443
if type(self) != type(other):
443444
return False
444445

445-
# Cut of window at start/end timestamps for comparison purposes since some
446-
# portable runners do this already.
446+
# Cut off window at start/end timestamps for comparison purposes since some
447+
# portable runners do this already, and timestamps outside of the bands of
448+
# Min/Max timestamps are functionally equal to Min/Max.
447449
self_start = max(self._start_micros, MIN_TIMESTAMP.micros)
448450
self_end = min(self._end_micros, MAX_TIMESTAMP.micros)
449451
other_start = max(other._start_micros, MIN_TIMESTAMP.micros)

sdks/python/apache_beam/yaml/readme_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ def extract_name(input_spec):
341341
'\n'.join(code_lines),
342342
Loader=yaml_utils.SafeLineLoader)['tests']):
343343
suffix = test_spec.get('name', str(sub_ix))
344-
345344
yield (
346345
test_name + '_' + suffix,
347346
# The yp=... ts=... is to capture the looped closure values.

0 commit comments

Comments
 (0)