dianfu commented on a change in pull request #10017: [FLINK-14019][python] add 
support for managing environment and dependencies of Python UDF in Flink Python 
API
URL: https://github.com/apache/flink/pull/10017#discussion_r348486024
 
 

 ##########
 File path: flink-python/pyflink/fn_execution/boot.py
 ##########
 @@ -45,105 +46,195 @@
 
 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
-
 
 def check_not_empty(check_str, error_message):
     if check_str == "":
         logging.fatal(error_message)
         exit(1)
 
 
-check_not_empty(worker_id, "No id provided.")
-check_not_empty(logging_endpoint, "No logging endpoint provided.")
-check_not_empty(artifact_endpoint, "No artifact endpoint provided.")
-check_not_empty(provision_endpoint, "No provision endpoint provided.")
-check_not_empty(control_endpoint, "No control endpoint provided.")
-
-logging.info("Initializing python harness: %s" % " ".join(sys.argv))
-
-metadata = [("worker_id", worker_id)]
-
-# read job information from provision stub
-with grpc.insecure_channel(provision_endpoint) as channel:
-    client = ProvisionServiceStub(channel=channel)
-    info = client.GetProvisionInfo(GetProvisionInfoRequest(), 
metadata=metadata).info
-    options = json_format.MessageToJson(info.pipeline_options)
-
-staged_dir = os.path.join(semi_persist_dir, "staged")
-
-# download files
-with grpc.insecure_channel(artifact_endpoint) as channel:
-    client = ArtifactRetrievalServiceStub(channel=channel)
-    # get file list via retrieval token
-    response = 
client.GetManifest(GetManifestRequest(retrieval_token=info.retrieval_token),
-                                  metadata=metadata)
-    artifacts = response.manifest.artifact
-    # download files and check hash values
-    for artifact in artifacts:
-        name = artifact.name
-        permissions = artifact.permissions
-        sha256 = artifact.sha256
-        file_path = os.path.join(staged_dir, name)
-        if os.path.exists(file_path):
-            with open(file_path, "rb") as f:
+python_exec = sys.executable
+
+PYTHON_REQUIREMENTS_FILE = "_PYTHON_REQUIREMENTS_FILE"
+PYTHON_REQUIREMENTS_CACHE = "_PYTHON_REQUIREMENTS_CACHE"
+PYTHON_REQUIREMENTS_DIR_ENV = "_PYTHON_REQUIREMENTS_INSTALL_DIR"
+
+
+def pip_install_requirements_process_mode():
+    if (PYTHON_REQUIREMENTS_FILE in os.environ
+            and PYTHON_REQUIREMENTS_DIR_ENV in os.environ):
+        requirements_file_path = os.environ[PYTHON_REQUIREMENTS_FILE]
+        requirements_target_path = os.environ[PYTHON_REQUIREMENTS_DIR_ENV]
+        requirements_dir_path = None
 
 Review comment:
   rename to requirements_cache_path?

----------------------------------------------------------------
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

Reply via email to