Azure 上的 Python (Dash) Web 应用程序部署,管道运行时间过长,并显示消息 Buildingwheel for pandas 仍在运行。如何优化?

问题描述 投票:0回答:1

我有一个Python Web应用程序(Dash),具有以下requirements.txt:

dash==2.17.0
numpy==1.26.4
pandas==1.5.3
dash-mantine-components==0.14.3
python-dotenv==1.0.1
dash-iconify==0.1.2
dash-bootstrap-components==1.6.0
pyspark==3.5.1
pytz==2024.1
package @ git+https://${GITHUB_TOKEN}:[email protected]/package
...

在这个包中,这是 pipfile:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pandas = "==1.5.3"
pyspark = "==3.5.1"
... other dependencies

[dev-packages]

[requires]
python_version = "3.9"

在 Azure 应用服务上,这是配置:使用 Python 版本 3.12 的 Python 堆栈。

但是,当我在 Azure DevOps 上运行管道来构建和部署 Web 应用程序时,每个阶段至少需要 20 分钟。主要是这个步骤需要很长时间(至少大约 10-12 分钟):

  Building wheel for pandas (pyproject.toml): started
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...
  Building wheel for pandas (pyproject.toml): still running...

最后,这是我用来在 build&deploy.yml 文件中安装 python 依赖项的代码:

- script: |
        python -m venv antenv
        source antenv/bin/activate
        python -m pip install --upgrade pip
        pip install setup
        pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
      displayName: 'Install Python dependencies'

此外,构建和部署使用Python版本3.12,versionSpec:'3.12'

有没有办法使用 Azure DevOps 管道来优化 Azure 上的 Python 应用程序部署?我在版本控制和兼容性方面做错了什么吗?

python pandas azure azure-devops plotly-dash
1个回答
0
投票

我可以在使用

pandas==1.5.3
和 Python 3.12 时重现相同的问题。

pandas==1.5.3
不会为您的版本构建轮子,因此您的系统每次都会为自己构建它们。 需要很长时间才能完成。您可以从此处查看可用的下载文件。

熊猫==1.5.3

enter image description here

要解决此问题,您可以将pandas版本升级到

2.2.2

例如:

dash==2.17.0
numpy==1.26.4
pandas==2.2.2
dash-mantine-components==0.14.3
python-dotenv==1.0.1
dash-iconify==0.1.2
dash-bootstrap-components==1.6.0
pyspark==3.5.1
pytz==2024.1

然后将优化软件包安装步骤。

结果:

enter image description here

更详细的信息,您可以参考此发行说明:pandas 2.2.2

© www.soinside.com 2019 - 2024. All rights reserved.