AWS代码构建未在构建阶段进行

2024-04-29 00:53:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下buildspec.yml文件

version: 0.2

env:
  parameter-store:
    s3DestFileName: "/CodeBuild/s3DestFileName"
    s3SourceFileName: "/CodeBuild/s3SourceFileName"
    imgFileName: "/CodeBuild/imgFileName"
    imgPickleFileName: "/CodeBuild/imgPickleFileName"
        
phases:
  install:
    on-failure: ABORT
    runtime-versions:
      python: 3.7
    commands:
      - echo Entered the install phase. Downloading new assets to /tmp
      - aws s3 cp s3://xxxx/yyy/test.csv /tmp/test.csv
      - aws s3 cp s3://xxxx/yyy/test2.csv /tmp/test2.csv
      - ls -la /tmp
      - curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -
      - export PATH=$PATH:$HOME/.poetry/bin
      - poetry --version
      - cd ./create-model/ && poetry install
  build:
    on-failure: ABORT
    commands:
      - echo Entered the build phase...
      - echo Build started on `date`
      - ls -la
      - poetry run python3 knn.py

我正在使用poetry来管理我的所有包。我没有要使用的任何工件

这是knn.py文件的内容(实际上是部分内容)

import pandas as pd

print("started...")

df = pd.read_csv('/tmp/n1.csv', index_col=False)

print("df read...")
print(df.head())

我在日志中没有看到任何错误。install阶段运行正常,但是当build阶段启动时,我看到它调用了knn.py文件。 我已经等了将近30分钟,但我在日志中看到的都是“开始…”

我在日志中没有看到任何打印语句。它可能没有任何进展。我尝试过使用不同的AWS管理映像,但结果仍然相同

如果我在我的机器上本地运行该代码,它运行得非常好

编辑: 我尝试了高级构建覆盖,并使用SSM连接到容器。我在本地安装了pandas,并运行了read_csv(),它运行正常。但是,来自buildspec.yml的命令poetry run python3 knn.py仍然挂起


Tags: install文件csvpyechobuilddfpoetry