如何在 Glue Job 中使用 Awswrangler?
How to use Awswrangler inside a Glue Job?
出于某些原因,我想在 Python 3 Glue Job 中使用 python 包 awswrangler
。我考虑过两种主要的安装方式 awswrangler
:
为粘合作业指定额外的库。通过考虑 .whl
文件,然后通过 --extra-py-files
将其传递给 Glue Job
使用 subprocess
或 os
在 python 脚本中安装。例如带os
的代码示例如下
import os
os.system('python -m pip install --user awswrangler==0.0.b0')
请注意,在最后一个案例中,我什至使用了 awswrangler
的第一个预发布版本。可以找到完整的版本列表 here。但是,即使是第一次预发布,我也无法在 Glue 脚本上使用 awswrangler
。有办法实现吗?
事实证明,官方 Awswrangler Documentation 为您提供了一个 .whl
文件,其中包含所需的包版本,用于在 Glue Job 的 Python library path field
上指定.根据文档,要遵循的步骤是:
从 here 下载与您要安装的 awswrangler
版本相关的 .whl
文件。
将 .whl
文件上传到 s3 存储桶,注意您分配给胶水作业的角色应该有权读取该存储桶。
在Python库路径字段中指定wheel文件的位置。例如,对于当前的 1.9.3 版本,它是 s3://your-bucket/glue_wheels/awswrangler-1.9.3-py3-none-any.whl
安装和使用 awswrangler 对我来说很有效。在 Glue Job 参数中添加 key/values。
键:--additional-python-modules
值:pyarrow==2,awswrangler==2.4.0
用这个对我有用
import os
import sys
import subprocess
subprocess.call('pip3 install awswrangler -t /tmp/ --no-cache-dir'.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
sys.path.insert(1, '/tmp/')
出于某些原因,我想在 Python 3 Glue Job 中使用 python 包 awswrangler
。我考虑过两种主要的安装方式 awswrangler
:
为粘合作业指定额外的库。通过考虑
将其传递给 Glue Job.whl
文件,然后通过--extra-py-files
使用
subprocess
或os
在 python 脚本中安装。例如带os
的代码示例如下
import os
os.system('python -m pip install --user awswrangler==0.0.b0')
请注意,在最后一个案例中,我什至使用了 awswrangler
的第一个预发布版本。可以找到完整的版本列表 here。但是,即使是第一次预发布,我也无法在 Glue 脚本上使用 awswrangler
。有办法实现吗?
事实证明,官方 Awswrangler Documentation 为您提供了一个 .whl
文件,其中包含所需的包版本,用于在 Glue Job 的 Python library path field
上指定.根据文档,要遵循的步骤是:
从 here 下载与您要安装的
awswrangler
版本相关的.whl
文件。将
.whl
文件上传到 s3 存储桶,注意您分配给胶水作业的角色应该有权读取该存储桶。在Python库路径字段中指定wheel文件的位置。例如,对于当前的 1.9.3 版本,它是
s3://your-bucket/glue_wheels/awswrangler-1.9.3-py3-none-any.whl
安装和使用 awswrangler 对我来说很有效。在 Glue Job 参数中添加 key/values。
键:--additional-python-modules
值:pyarrow==2,awswrangler==2.4.0
用这个对我有用
import os
import sys
import subprocess
subprocess.call('pip3 install awswrangler -t /tmp/ --no-cache-dir'.split(), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
sys.path.insert(1, '/tmp/')