hequn8128 commented on a change in pull request #9655: [FLINK-14017][python] Support to start up Python worker in process mode. URL: https://github.com/apache/flink/pull/9655#discussion_r325477942
########## File path: flink-python/pyflink/fn_execution/boot.py ########## @@ -0,0 +1,155 @@ +#!/usr/bin/env python +################################################################################# +# 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 script is a python implementation of the "boot.go" script in "beam-sdks-python-container" +project of Apache Beam, see in: + +https://github.com/apache/beam/blob/release-2.14.0/sdks/python/container/boot.go + +It is implemented in golang and will introduce unnecessary dependencies if used in pure python +project. So we add a python implementation which will be used when the python worker runs in +process mode. It downloads and installs users' python artifacts, then launches the python SDK +harness of Apache Beam. +""" +import argparse +import hashlib +import os +from subprocess import call + +import grpc +import logging +import sys + +from apache_beam.portability.api.beam_provision_api_pb2_grpc import ProvisionServiceStub +from apache_beam.portability.api.beam_provision_api_pb2 import GetProvisionInfoRequest +from apache_beam.portability.api.beam_artifact_api_pb2_grpc import ArtifactRetrievalServiceStub +from apache_beam.portability.api.beam_artifact_api_pb2 import (GetManifestRequest, + GetArtifactRequest) +from apache_beam.portability.api.endpoints_pb2 import ApiServiceDescriptor + +from google.protobuf import json_format, text_format + +parser = argparse.ArgumentParser() + +parser.add_argument("--id", default="", help="Local identifier (required).") +parser.add_argument("--logging_endpoint", default="", + help="Logging endpoint (required).") +parser.add_argument("--artifact_endpoint", default="", + help="Artifact endpoint (required).") +parser.add_argument("--provision_endpoint", default="", + help="Provision endpoint (required).") +parser.add_argument("--control_endpoint", default="", + help="Control endpoint (required).") +parser.add_argument("--semi_persist_dir", default="/tmp", + help="Local semi-persistent directory (optional).") + +args = parser.parse_args() + +worker_id = args.id +logging_endpoint = args.logging_endpoint +artifact_endpoint = args.artifact_endpoint +provision_endpoint = args.provision_endpoint +control_endpoint = args.control_endpoint +semi_persist_dir = args.semi_persist_dir + +if worker_id == "": + logging.fatal("No id provided.") Review comment: We should also exit for these required arguments while logging.fatal only prints some logs. Also, add some validation tests to verify these errors. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
