From 28975540a82be6a5d831a011f3bb10f4fac1f8c0 Mon Sep 17 00:00:00 2001 From: Dian Fu Date: Thu, 7 Jan 2021 13:40:33 +0800 Subject: [PATCH] [hotfix][python][docs] Improve the documentation about Python dependency management --- .../datastream-api-users-guide/dependency_management.md | 9 +++++---- .../dependency_management.zh.md | 9 +++++---- .../table-api-users-guide/dependency_management.md | 9 +++++---- .../table-api-users-guide/dependency_management.zh.md | 9 +++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/docs/dev/python/datastream-api-users-guide/dependency_management.md b/docs/dev/python/datastream-api-users-guide/dependency_management.md index f14c71b2ca0..fffeed03e88 100644 --- a/docs/dev/python/datastream-api-users-guide/dependency_management.md +++ b/docs/dev/python/datastream-api-users-guide/dependency_management.md @@ -71,7 +71,7 @@ echo numpy==1.16.5 > requirements.txt pip download -d cached_dir -r requirements.txt --no-binary :all: # python code -stream_execution_environment.set_python_requirements("requirements.txt", "cached_dir") +stream_execution_environment.set_python_requirements("/path/to/requirements.txt", "cached_dir") {% endhighlight %}

Please make sure the installation packages matches the platform of the cluster and the python version used. These packages will be installed using pip, so also make sure the version of Pip (version >= 7.1.0) and the version of Setuptools (version >= 37.0.0).

@@ -86,9 +86,9 @@ stream_execution_environment.set_python_requirements("requirements.txt", "cached zip -r py_env.zip py_env # python code -stream_execution_environment.add_python_archive("py_env.zip") +stream_execution_environment.add_python_archive("/path/to/py_env.zip") # or -stream_execution_environment.add_python_archive("py_env.zip", "myenv") +stream_execution_environment.add_python_archive("/path/to/py_env.zip", "myenv") # the files contained in the archive file can be accessed in UDF def my_func(): @@ -103,9 +103,10 @@ def my_func():

Sets the path of the python interpreter which is used to execute the python udf workers, e.g., "/usr/local/bin/python3".

{% highlight python %} -stream_execution_environment.add_python_archive("py_env.zip") +stream_execution_environment.add_python_archive("/path/to/py_env.zip") stream_execution_environment.get_config().set_python_executable("py_env.zip/py_env/bin/python") {% endhighlight %} +

Please note that if the path of the python interpreter comes from the uploaded python archive, the path specified in set_python_executable should be a relative path.

Please make sure that the specified environment matches the platform that the cluster is running on.

diff --git a/docs/dev/python/datastream-api-users-guide/dependency_management.zh.md b/docs/dev/python/datastream-api-users-guide/dependency_management.zh.md index 2941b979037..66d7b271b84 100644 --- a/docs/dev/python/datastream-api-users-guide/dependency_management.zh.md +++ b/docs/dev/python/datastream-api-users-guide/dependency_management.zh.md @@ -72,7 +72,7 @@ echo numpy==1.16.5 > requirements.txt pip download -d cached_dir -r requirements.txt --no-binary :all: # Python 代码 -stream_execution_environment.set_python_requirements("requirements.txt", "cached_dir") +stream_execution_environment.set_python_requirements("/path/to/requirements.txt", "cached_dir") {% endhighlight %}

请确保这些依赖安装包和集群运行环境所使用的 Python 版本相匹配。此外,这些依赖将通过 Pip 安装, 请确保 Pip 的版本(version >= 7.1.0) 和 Setuptools 的版本(version >= 37.0.0)符合要求。

@@ -87,9 +87,9 @@ stream_execution_environment.set_python_requirements("requirements.txt", "cached zip -r py_env.zip py_env # python 代码 -stream_execution_environment.add_python_archive("py_env.zip") +stream_execution_environment.add_python_archive("/path/to/py_env.zip") # 或者 -stream_execution_environment.add_python_archive("py_env.zip", "myenv") +stream_execution_environment.add_python_archive("/path/to/py_env.zip", "myenv") # 归档文件中的文件可以被 Python 函数读取 def my_func(): @@ -104,9 +104,10 @@ def my_func():

配置用于执行 Python Worker 的 Python 解释器路径,如 "/usr/local/bin/python3"。

{% highlight python %} -stream_execution_environment.add_python_archive("py_env.zip") +stream_execution_environment.add_python_archive("/path/to/py_env.zip") stream_execution_environment.get_config().set_python_executable("py_env.zip/py_env/bin/python") {% endhighlight %} +

如果 Python 解释器的路径指向上传的 Python 归档文件,那么通过 set_python_executable 设置的 Python 解释器的路径必须是相对路径。

请确保配置的 Python 环境和集群运行环境匹配。

diff --git a/docs/dev/python/table-api-users-guide/dependency_management.md b/docs/dev/python/table-api-users-guide/dependency_management.md index 247f485dafb..9eac7284490 100644 --- a/docs/dev/python/table-api-users-guide/dependency_management.md +++ b/docs/dev/python/table-api-users-guide/dependency_management.md @@ -71,7 +71,7 @@ echo numpy==1.16.5 > requirements.txt pip download -d cached_dir -r requirements.txt --no-binary :all: # python code -table_env.set_python_requirements("requirements.txt", "cached_dir") +table_env.set_python_requirements("/path/to/requirements.txt", "cached_dir") {% endhighlight %}

Please make sure the installation packages matches the platform of the cluster and the python version used. These packages will be installed using pip, so also make sure the version of Pip (version >= 7.1.0) and the version of SetupTools (version >= 37.0.0).

@@ -86,9 +86,9 @@ table_env.set_python_requirements("requirements.txt", "cached_dir") zip -r py_env.zip py_env # python code -table_env.add_python_archive("py_env.zip") +table_env.add_python_archive("/path/to/py_env.zip") # or -table_env.add_python_archive("py_env.zip", "myenv") +table_env.add_python_archive("/path/to/py_env.zip", "myenv") # the files contained in the archive file can be accessed in UDF def my_udf(): @@ -103,9 +103,10 @@ def my_udf():

Sets the path of the python interpreter which is used to execute the python udf workers, e.g., "/usr/local/bin/python3".

{% highlight python %} -table_env.add_python_archive("py_env.zip") +table_env.add_python_archive("/path/to/py_env.zip") table_env.get_config().set_python_executable("py_env.zip/py_env/bin/python") {% endhighlight %} +

Please note that if the path of the python interpreter comes from the uploaded python archive, the path specified in set_python_executable should be a relative path.

Please make sure that the specified environment matches the platform that the cluster is running on.

diff --git a/docs/dev/python/table-api-users-guide/dependency_management.zh.md b/docs/dev/python/table-api-users-guide/dependency_management.zh.md index f1a021bb186..2e03f6eaa00 100644 --- a/docs/dev/python/table-api-users-guide/dependency_management.zh.md +++ b/docs/dev/python/table-api-users-guide/dependency_management.zh.md @@ -75,7 +75,7 @@ echo numpy==1.16.5 > requirements.txt pip download -d cached_dir -r requirements.txt --no-binary :all: # python 代码 -table_env.set_python_requirements("requirements.txt", "cached_dir") +table_env.set_python_requirements("/path/to/requirements.txt", "cached_dir") {% endhighlight %}

请确保这些依赖安装包和集群运行环境所使用的 Python 版本相匹配。此外,这些依赖将通过 Pip 安装, 请确保 Pip 的版本(version >= 7.1.0) 和 Setuptools 的版本(version >= 37.0.0)符合要求。

@@ -90,9 +90,9 @@ table_env.set_python_requirements("requirements.txt", "cached_dir") zip -r py_env.zip py_env # python 代码 -table_env.add_python_archive("py_env.zip") +table_env.add_python_archive("/path/to/py_env.zip") # 或者 -table_env.add_python_archive("py_env.zip", "myenv") +table_env.add_python_archive("/path/to/py_env.zip", "myenv") # 归档文件中的文件可以被 Python 函数读取 def my_udf(): @@ -107,9 +107,10 @@ def my_udf():

配置用于执行 Python Worker 的 Python 解释器路径,如 "/usr/local/bin/python3"。

{% highlight python %} -table_env.add_python_archive("py_env.zip") +table_env.add_python_archive("/path/to/py_env.zip") table_env.get_config().set_python_executable("py_env.zip/py_env/bin/python") {% endhighlight %} +

如果 Python 解释器的路径指向上传的 Python 归档文件,那么通过 set_python_executable 设置的 Python 解释器的路径必须是相对路径。

请确保配置的 Python 环境和集群运行环境匹配。

-- GitLab