Skip to content

Instantly share code, notes, and snippets.

@jhw
Last active May 20, 2024 12:13
Show Gist options
  • Save jhw/7f9cc0bf459031c7ca4588c09410a1f0 to your computer and use it in GitHub Desktop.
Save jhw/7f9cc0bf459031c7ca4588c09410a1f0 to your computer and use it in GitHub Desktop.
How to build a Docker image (Bert Word Alignment model) on Codebuild

overview

How to build a Docker image (Bert Word Alignment model) on Codebuild

So as to ensure the the container gets build on Amazon Linux

create bucket

(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./create_bucket.sh 
Creating S3 bucket 'bwa-artifacts-20121970' in region 'eu-west-1'...
-----------------------------------------------------------------
|                         CreateBucket                          |
+----------+----------------------------------------------------+
|  Location|  http://bwa-artifacts-20121970.s3.amazonaws.com/   |
+----------+----------------------------------------------------+
S3 bucket 'bwa-artifacts-20121970' created successfully in region 'eu-west-1'.

dump model

(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % python dump_model.py 
(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % 

push artifacts

(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./push_artifacts.sh 
Creating zip file docker-artifacts.zip...
  adding: Dockerfile (deflated 52%)
  adding: tokenizer/ (stored 0%)
  adding: tokenizer/tokenizer_config.json (deflated 75%)
  adding: tokenizer/special_tokens_map.json (deflated 42%)
  adding: tokenizer/vocab.txt (deflated 45%)
  adding: pipeline.py (deflated 68%)
  adding: model/ (stored 0%)
  adding: model/model.safetensors (deflated 7%)
  adding: model/config.json (deflated 54%)
  adding: app.py (deflated 51%)
  adding: inference.py (deflated 60%)
  adding: serve.sh (deflated 27%)
Uploading docker-artifacts.zip to s3://bwa-artifacts-20121970/...
upload: ./docker-artifacts.zip to s3://bwa-artifacts-20121970/docker-artifacts.zip
Artifacts uploaded successfully to s3://bwa-artifacts-20121970/docker-artifacts.zip
Temporary files cleaned up.
(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % 

deploy stack

(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./deploy_stack.sh 
Creating CloudFormation stack 'bert-word-alignment-stack'...
-----------------------------------------------------------------------------------------------------------------------------------
|                                                           CreateStack                                                           |
+---------+-----------------------------------------------------------------------------------------------------------------------+
|  StackId|  arn:aws:cloudformation:eu-west-1:119552584133:stack/bert-word-alignment-stack/84325c20-154e-11ef-a7f9-0a39438880a7   |
+---------+-----------------------------------------------------------------------------------------------------------------------+
CloudFormation stack 'bert-word-alignment-stack' has been created successfully.
(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./list_resources.sh
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
|                                                                     DescribeStackResources                                                                      |
+--------------------------+-----------------------+---------------------------------------------------------------+--------------------------+-------------------+
|        1.Timestamp       |      2.LogicalId      |                         3.PhysicalId                          |         4.Type           |     5.Status      |
+--------------------------+-----------------------+---------------------------------------------------------------+--------------------------+-------------------+
|  2024-05-18T19:41:13.083Z|  CodeBuildProject     |  bert-word-alignment                                          |  AWS::CodeBuild::Project |  CREATE_COMPLETE  |
|  2024-05-18T19:41:10.720Z|  CodeBuildServiceRole |  bert-word-alignment-stack-CodeBuildServiceRole-r3NbJ7hlwxTP  |  AWS::IAM::Role          |  CREATE_COMPLETE  |
+--------------------------+-----------------------+---------------------------------------------------------------+--------------------------+-------------------+

run build

(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./start_build.sh 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       StartBuild                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         build                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|
||  arn                                                                                                                                                                                                            |  arn:aws:codebuild:eu-west-1:119552584133:build/bert-word-alignment:88391de4-2042-4d17-a426-b293de8c14e5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
||  buildComplete                                                                                                                                                                                                  |  False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ||
||  buildNumber                                                                                                                                                                                                    |  1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ||
||  buildStatus                                                                                                                                                                                                    |  IN_PROGRESS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ||
||  currentPhase                                                                                                                                                                                                   |  QUEUED                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ||
||  encryptionKey                                                                                                                                                                                                  |  arn:aws:kms:eu-west-1:119552584133:alias/aws/s3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ||
||  id                                                                                                                                                                                                             |  bert-word-alignment:88391de4-2042-4d17-a426-b293de8c14e5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
||  initiator                                                                                                                                                                                                      |  woldeploy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ||
||  projectName                                                                                                                                                                                                    |  bert-word-alignment                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ||
||  queuedTimeoutInMinutes                                                                                                                                                                                         |  480                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ||
||  serviceRole                                                                                                                                                                                                    |  arn:aws:iam::119552584133:role/bert-word-alignment-stack-CodeBuildServiceRole-r3NbJ7hlwxTP                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
||  startTime                                                                                                                                                                                                      |  1716061312.563                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ||
||  timeoutInMinutes                                                                                                                                                                                               |  60                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ||
|+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|
|||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      artifacts                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |||
||+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||  location                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                                                                                             |||
||+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        cache                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |||
||+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||  type                                                                                                                                                                                                                                                                                                                                                                                                                                       |  NO_CACHE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |||
||+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     environment                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |||
||+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||  computeType                                                                                                                                                                                                                                                                                                                                                                                    |  BUILD_GENERAL1_LARGE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |||
|||  image                                                                                                                                                                                                                                                                                                                                                                                          |  aws/codebuild/amazonlinux2-x86_64-standard:3.0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |||
|||  imagePullCredentialsType                                                                                                                                                                                                                                                                                                                                                                       |  CODEBUILD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |||
|||  privilegedMode                                                                                                                                                                                                                                                                                                                                                                                 |  True                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |||
|||  type                                                                                                                                                                                                                                                                                                                                                                                           |  LINUX_CONTAINER                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |||
||+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
||||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               environmentVariables                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ||||
|||+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|||
||||                                                                                                                                                                             name                                                                                                                                                                             |                                                                                                                     type                                                                                                                       |                                                                                                                                                                                                                                              value                                                                                                                                                                                                                                               ||||
|||+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|||
||||  S3_BUCKET_NAME                                                                                                                                                                                                                                                                                                                                              |  PLAINTEXT                                                                                                                                                                                                                                     |  bwa-artifacts-20121970                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||||
||||  REPOSITORY_NAME                                                                                                                                                                                                                                                                                                                                             |  PLAINTEXT                                                                                                                                                                                                                                     |  bert-word-alignment                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ||||
||||  ECR_REPO_NAME                                                                                                                                                                                                                                                                                                                                               |  PLAINTEXT                                                                                                                                                                                                                                     |  bert-word-alignment                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ||||
|||+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|||
|||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        logs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |||
||+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||  cloudWatchLogsArn                                                                                                                      |  arn:aws:logs:eu-west-1:119552584133:log-group:null:log-stream:null                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |||
|||  deepLink                                                                                                                               |  https://console.aws.amazon.com/cloudwatch/home?region=eu-west-1#logsV2:log-groups                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |||
|||  s3DeepLink                                                                                                                             |  https://s3.console.aws.amazon.com/s3/object/bwa-artifacts-20121970/codebuild-logs/88391de4-2042-4d17-a426-b293de8c14e5.gz?region=eu-west-1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |||
|||  s3LogsArn                                                                                                                              |  arn:aws:s3:::bwa-artifacts-20121970/codebuild-logs/88391de4-2042-4d17-a426-b293de8c14e5.gz                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |||
||+-----------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
||||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      s3Logs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ||||
|||+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|||
||||  encryptionDisabled                                                                                                                                                                                                                                                                                                                                                                  |  False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ||||
||||  location                                                                                                                                                                                                                                                                                                                                                                            |  bwa-artifacts-20121970/codebuild-logs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ||||
||||  status                                                                                                                                                                                                                                                                                                                                                                              |  ENABLED                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||||
|||+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|||
|||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       phases                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |||
||+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||                                                                                                                            durationInSeconds                                                                                                                           |                                                                                                              endTime                                                                                                              |                                                                                         phaseStatus                                                                                         |                                                                             phaseType                                                                              |                                                                                                             startTime                                                                                                              |||
||+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||  0                                                                                                                                                                                                                                                                     |  1716061312.631                                                                                                                                                                                                                   |  SUCCEEDED                                                                                                                                                                                  |  SUBMITTED                                                                                                                                                         |  1716061312.563                                                                                                                                                                                                                    |||
|||                                                                                                                                                                                                                                                                        |                                                                                                                                                                                                                                   |                                                                                                                                                                                             |  QUEUED                                                                                                                                                            |  1716061312.631                                                                                                                                                                                                                    |||
||+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       source                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |||
||+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
|||  buildspec  |  version: 0.2
phases:
  pre_build:
    commands:
      - echo Defining variables...
      - export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
      - echo Logging in to Amazon ECR...
      - aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
      - aws ecr describe-repositories --repository-names $ECR_REPO_NAME || aws ecr create-repository --repository-name $ECR_REPO_NAME
      - echo Fetching artifacts from S3...
      - aws s3 cp s3://$S3_BUCKET_NAME/docker-artifacts.zip ./docker-artifacts.zip
      - unzip docker-artifacts.zip
  build:
    commands:
      - echo Building the Docker image...
      - docker build -t $ECR_REPO_NAME:latest .
  post_build:
    commands:
      - echo Pushing the Docker image to ECR...
      - docker tag $ECR_REPO_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPO_NAME:latest
      - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPO_NAME:latest
   |||
|||  insecureSsl|  False                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |||
|||  type       |  NO_SOURCE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |||
||+-------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+||
CodeBuild project 'bert-word-alignment' has been started successfully.

poll build

(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./poll_build.sh 
Latest build ID for project 'bert-word-alignment' is 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3'.
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'PROVISIONING'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'PRE_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'PRE_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'PRE_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'PRE_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'PRE_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'PRE_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'PRE_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' is in status 'IN_PROGRESS'. Current phase: 'POST_BUILD'. Waiting...
Build 'bert-word-alignment:1a10cb19-33c8-471b-b42c-30abcc97f4c3' succeeded. Current phase: 'COMPLETED'.

list images

(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./list_images.sh 
Listing images in ECR repository 'bert-word-alignment'...
-----------------------------------------------------------------------------------------
|                                      ListImages                                       |
+---------------------------------------------------------------------------+-----------+
|                                imageDigest                                | imageTag  |
+---------------------------------------------------------------------------+-----------+
|  sha256:ec15855ff875f90c85f5ecf0b6a70881ad4999ca98661722a9d307c0e90e5a59  |  latest   |
+---------------------------------------------------------------------------+-----------+
Images listed successfully in ECR repository 'bert-word-alignment'.

export logs

(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./list_objects.sh 
Listing objects in S3 bucket 'bwa-artifacts-20121970'...
2024-05-19 08:43:18      18292 codebuild-logs/1a10cb19-33c8-471b-b42c-30abcc97f4c3.gz
2024-05-19 08:33:55  660222672 docker-artifacts.zip
Objects listed successfully in S3 bucket 'bwa-artifacts-20121970'.
(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % ./export_logs.sh codebuild-logs/1a10cb19-33c8-471b-b42c-30abcc97f4c3.gz
Downloading logs from s3://bwa-artifacts-20121970/codebuild-logs/1a10cb19-33c8-471b-b42c-30abcc97f4c3.gz...
download: s3://bwa-artifacts-20121970/codebuild-logs/1a10cb19-33c8-471b-b42c-30abcc97f4c3.gz to tmp/codebuild-logs/1a10cb19-33c8-471b-b42c-30abcc97f4c3.gz
Extracting logs to ./tmp/codebuild-logs...
Logs have been extracted to ./tmp/codebuild-logs
(env) jhw@Justins-Air 7f9cc0bf459031c7ca4588c09410a1f0 % 
*.pyc
__pycache__
env
tmp
model
tokenizer
*artifacts.zip # created in local directory
setenv-priv.sh
"""
Custom images must provide their own webserver, with port 8080 and GET ping and POST invocations endpoints
This webserver calls inference.py which follows standard sagemaker entry_point conventions, but as a custom webserver you could define your own convention
"""
from flask import Flask, request, Response
from inference import model_fn, input_fn, predict_fn, output_fn
app = Flask(__name__)
model = None
@app.before_request
def load_model():
global model
if not model:
model = model_fn('.')
@app.route('/ping', methods=['GET'])
def ping():
return '', 200
@app.route('/invocations', methods=['POST'])
def invocations():
if not model:
return Response(response='Model not loaded', status=503)
input_data = input_fn(request.data, request.content_type)
predictions = predict_fn(input_data, model)
output = output_fn(predictions, request.accept_mimetypes)
return Response(output,
status=200,
mimetype='application/json')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
version: 0.2
phases:
pre_build:
commands:
- echo Defining variables...
- export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
- aws ecr describe-repositories --repository-names $ECR_REPO_NAME || aws ecr create-repository --repository-name $ECR_REPO_NAME
- echo Fetching artifacts from S3...
- aws s3 cp s3://$S3_BUCKET_NAME/model-artifacts.zip ./model-artifacts.zip
- unzip model-artifacts.zip
- aws s3 cp s3://$S3_BUCKET_NAME/app-artifacts.zip ./app-artifacts.zip
- unzip app-artifacts.zip
- echo Logging in to Docker Hub...
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
build:
commands:
- echo Building the Docker image...
- docker build -t $ECR_REPO_NAME:latest .
post_build:
commands:
- echo Pushing the Docker image to ECR...
- docker tag $ECR_REPO_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPO_NAME:latest
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPO_NAME:latest
cache:
paths:
- '/root/.cache'
- '/var/lib/docker'
artifacts:
files:
- '**/*'
discard-paths: yes
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
BUCKET_NAME=$S3_BUCKET_NAME
# Get the current AWS region
AWS_REGION=$(aws configure get region)
if [ -z "$AWS_REGION" ]; then
echo "AWS region not configured. Please configure your AWS CLI."
exit 1
fi
# Create the S3 bucket
echo "Creating S3 bucket '$BUCKET_NAME' in region '$AWS_REGION'..."
aws s3api create-bucket --bucket "$BUCKET_NAME" --create-bucket-configuration LocationConstraint="$AWS_REGION" --region "$AWS_REGION"
if [ $? -ne 0 ]; then
echo "Failed to create S3 bucket '$BUCKET_NAME'."
exit 1
fi
echo "S3 bucket '$BUCKET_NAME' created successfully in region '$AWS_REGION'."
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
BUCKET_NAME=$S3_BUCKET_NAME
# Function to delete all objects in the S3 bucket
delete_objects() {
local bucket_name=$1
echo "Deleting all objects in S3 bucket '$bucket_name'..."
aws s3 rm "s3://$bucket_name" --recursive
if [ $? -ne 0 ]; then
echo "Failed to delete objects in S3 bucket '$bucket_name'."
exit 1
fi
}
# Function to delete the S3 bucket
delete_bucket() {
local bucket_name=$1
echo "Deleting S3 bucket '$bucket_name'..."
aws s3api delete-bucket --bucket "$bucket_name"
if [ $? -ne 0 ]; then
echo "Failed to delete S3 bucket '$bucket_name'."
exit 1
fi
}
# Delete all objects in the bucket
delete_objects "$BUCKET_NAME"
# Delete the bucket itself
delete_bucket "$BUCKET_NAME"
echo "S3 bucket '$BUCKET_NAME' and all its objects have been deleted successfully."
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
BUCKET_NAME=$S3_BUCKET_NAME
# Function to delete all objects in the S3 bucket
delete_objects() {
local bucket_name=$1
echo "Deleting all objects in S3 bucket '$bucket_name'..."
aws s3 rm "s3://$bucket_name" --recursive
if [ $? -ne 0 ]; then
echo "Failed to delete objects in S3 bucket '$bucket_name'."
exit 1
fi
}
# Delete all objects in the bucket
delete_objects "$BUCKET_NAME"
echo "S3 bucket '$BUCKET_NAME' objects have been deleted successfully."
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# Check if ECR_REPO_NAME is set
if [ -z "$ECR_REPO_NAME" ]; then
echo "ECR_REPO_NAME environment variable is not set."
exit 1
fi
# Delete all images in the ECR repository
image_ids=$(aws ecr list-images --repository-name "$ECR_REPO_NAME" --query 'imageIds[*]' --output json)
if [ "$image_ids" != "[]" ]; then
echo "Deleting all images in the ECR repository '$ECR_REPO_NAME'..."
aws ecr batch-delete-image --repository-name "$ECR_REPO_NAME" --image-ids "$image_ids"
if [ $? -eq 0 ]; then
echo "All images in the ECR repository '$ECR_REPO_NAME' have been deleted successfully."
else
echo "Failed to delete images in the ECR repository '$ECR_REPO_NAME'."
exit 1
fi
else
echo "No images found in the ECR repository '$ECR_REPO_NAME'."
fi
# Delete the ECR repository
echo "Deleting the ECR repository '$ECR_REPO_NAME'..."
aws ecr delete-repository --repository-name "$ECR_REPO_NAME" --force
if [ $? -eq 0 ]; then
echo "ECR repository '$ECR_REPO_NAME' has been deleted successfully."
else
echo "Failed to delete ECR repository '$ECR_REPO_NAME'."
exit 1
fi
#!/usr/bin/env bash
# Ensure the CODEBUILD_PROJECT_NAME environment variable is set
if [ -z "$CODEBUILD_PROJECT_NAME" ]; then
echo "Error: CODEBUILD_PROJECT_NAME environment variable is not set."
exit 1
fi
STACK_NAME="${CODEBUILD_PROJECT_NAME}-stack"
aws cloudformation delete-stack --stack-name $STACK_NAME
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# Assign arguments to variables
PROJECT_NAME=$CODEBUILD_PROJECT_NAME
BUCKET_NAME=$S3_BUCKET_NAME
REPOSITORY_NAME=$ECR_REPO_NAME
DOCKER_USERNAME=$DOCKER_USERNAME
DOCKER_PASSWORD=$DOCKER_PASSWORD
STACK_NAME="${PROJECT_NAME}-stack"
BUILDSPEC_FILE="buildspec.yaml"
ZIP_FILE="buildspec.zip"
S3_BUILDSPEC_KEY="buildspecs/$ZIP_FILE"
# Check if the buildspec.yaml file exists
if [ ! -f $BUILDSPEC_FILE ]; then
echo "buildspec.yaml file not found!"
exit 1
fi
# Create a ZIP file containing the buildspec.yaml
zip -j $ZIP_FILE $BUILDSPEC_FILE
if [ $? -ne 0 ]; then
echo "Failed to create ZIP file"
exit 1
fi
# Upload the ZIP file to the specified S3 bucket
aws s3 cp $ZIP_FILE s3://$BUCKET_NAME/$S3_BUILDSPEC_KEY
if [ $? -ne 0 ]; then
echo "Failed to upload ZIP file to S3"
exit 1
fi
# Check if the project.yaml file exists
if [ ! -f project.yaml ]; then
echo "project.yaml file not found!"
exit 1
fi
# Check if the stack exists
stack_exists=$(aws cloudformation describe-stacks --stack-name "$STACK_NAME" 2>&1)
if [[ $stack_exists == *"does not exist"* ]]; then
# Create the CloudFormation stack
echo "Creating CloudFormation stack '$STACK_NAME'..."
aws cloudformation create-stack \
--stack-name "$STACK_NAME" \
--template-body file://project.yaml \
--parameters \
ParameterKey=ProjectName,ParameterValue="$PROJECT_NAME" \
ParameterKey=S3BucketName,ParameterValue="$BUCKET_NAME" \
ParameterKey=RepositoryName,ParameterValue="$REPOSITORY_NAME" \
ParameterKey=S3BuildSpecKey,ParameterValue="$S3_BUILDSPEC_KEY" \
ParameterKey=DockerUsername,ParameterValue="$DOCKER_USERNAME" \
ParameterKey=DockerPassword,ParameterValue="$DOCKER_PASSWORD" \
--capabilities CAPABILITY_NAMED_IAM
# Check if the stack creation was successful
if [ $? -eq 0 ]; then
echo "CloudFormation stack '$STACK_NAME' has been created successfully."
else
echo "Failed to create CloudFormation stack '$STACK_NAME'."
exit 1
fi
else
# Update the CloudFormation stack
echo "Updating CloudFormation stack '$STACK_NAME'..."
aws cloudformation update-stack \
--stack-name "$STACK_NAME" \
--template-body file://project.yaml \
--parameters \
ParameterKey=ProjectName,ParameterValue="$PROJECT_NAME" \
ParameterKey=S3BucketName,ParameterValue="$BUCKET_NAME" \
ParameterKey=RepositoryName,ParameterValue="$REPOSITORY_NAME" \
ParameterKey=S3BuildSpecKey,ParameterValue="$S3_BUILDSPEC_KEY" \
ParameterKey=DockerUsername,ParameterValue="$DOCKER_USERNAME" \
ParameterKey=DockerPassword,ParameterValue="$DOCKER_PASSWORD" \
--capabilities CAPABILITY_NAMED_IAM
# Check if the stack update was successful
if [ $? -eq 0 ]; then
echo "CloudFormation stack '$STACK_NAME' has been updated successfully."
else
echo "Failed to update CloudFormation stack '$STACK_NAME'."
exit 1
fi
fi
# Clean up the ZIP file
rm $ZIP_FILE
# Use a standard Python base image
FROM python:3.10-slim
# Set the working directory to the root of the container
WORKDIR /app
# Install package
RUN pip install --upgrade pip
RUN pip install torch transformers flask gunicorn
# Copy files into the image
COPY pipeline.py .
COPY inference.py .
COPY app.py .
COPY serve.sh .
# Copy directories into the image
COPY model model/
COPY tokenizer tokenizer/
# Expose port 8080
EXPOSE 8080
# Make the serve script executable
RUN chmod +x serve.sh
# Make a symbolic link to ensure 'serve' is available globally
RUN ln -s /app/serve.sh /usr/local/bin/serve
# Command to run when starting the container
CMD ["serve"]
# this is now run inside the Dockerfile, but could still be run locally for testing purposes
import transformers
model = transformers.BertModel.from_pretrained('bert-base-multilingual-cased')
model.save_pretrained('./model')
tokenizer = transformers.BertTokenizer.from_pretrained('bert-base-multilingual-cased')
tokenizer.save_pretrained('./tokenizer')
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# Check if the bucket name and S3 key were provided as arguments
if [ -z "$1" ]; then
echo "Usage: $0 <s3_key>"
exit 1
fi
BUCKET_NAME=$S3_BUCKET_NAME
OBJECT_KEY=$1
FILE_NAME=$(basename "$OBJECT_KEY")
TMP_DIR="./tmp/${OBJECT_KEY%/*}" # Remove the file name from OBJECT_KEY for directory creation
# Create the local directory if necessary
mkdir -p "$TMP_DIR"
# Download the logs from S3
echo "Downloading logs from s3://$BUCKET_NAME/$OBJECT_KEY..."
aws s3 cp "s3://$BUCKET_NAME/$OBJECT_KEY" "$TMP_DIR/$FILE_NAME"
if [ $? -ne 0 ]; then
echo "Failed to download logs from s3://$BUCKET_NAME/$OBJECT_KEY"
exit 1
fi
# Determine file extension and extract logs
if [[ "$FILE_NAME" == *.zip ]]; then
echo "Extracting logs to $TMP_DIR..."
unzip -d "$TMP_DIR" "$TMP_DIR/$FILE_NAME"
elif [[ "$FILE_NAME" == *.gz ]]; then
echo "Extracting logs to $TMP_DIR..."
gunzip "$TMP_DIR/$FILE_NAME"
else
echo "Unknown file type: $FILE_NAME"
exit 1
fi
if [ $? -ne 0 ]; then
echo "Failed to extract logs"
exit 1
fi
echo "Logs have been extracted to $TMP_DIR"
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null; then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# Define the S3 key for the zip file and the local directory to save it
S3_KEY="app-artifacts.zip"
LOCAL_DIR="tmp"
LOCAL_FILE="$LOCAL_DIR/app-artifacts.zip"
# Create the local directory if it doesn't exist
mkdir -p "$LOCAL_DIR"
# Fetch the zip file from the S3 bucket and save it to the local directory
echo "Fetching $S3_KEY from s3://$S3_BUCKET_NAME/ and saving it to $LOCAL_FILE..."
aws s3 cp "s3://$S3_BUCKET_NAME/$S3_KEY" "$LOCAL_FILE"
if [ $? -ne 0 ]; then
echo "Failed to fetch $S3_KEY from s3://$S3_BUCKET_NAME/"
exit 1
fi
echo "$S3_KEY successfully fetched and saved to $LOCAL_FILE"
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null; then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# Define the S3 key for the zip file and the local directory to save it
S3_KEY="model-artifacts.zip"
LOCAL_DIR="tmp"
LOCAL_FILE="$LOCAL_DIR/model-artifacts.zip"
# Create the local directory if it doesn't exist
mkdir -p "$LOCAL_DIR"
# Fetch the zip file from the S3 bucket and save it to the local directory
echo "Fetching $S3_KEY from s3://$S3_BUCKET_NAME/ and saving it to $LOCAL_FILE..."
aws s3 cp "s3://$S3_BUCKET_NAME/$S3_KEY" "$LOCAL_FILE"
if [ $? -ne 0 ]; then
echo "Failed to fetch $S3_KEY from s3://$S3_BUCKET_NAME/"
exit 1
fi
echo "$S3_KEY successfully fetched and saved to $LOCAL_FILE"
"""
inference.py follows the standard interface pattern accepted by sagemaker
Pre- built images contain their own webserver and inference.py can be specified using the sagemaker.model.Model entry_point parameter, slotting in neatly as a a request handler
Custom images need to define their own webserver, again following the pattern acceptable to sagemaker, but accordingly don't necessarily need to follow the same format for inference.py
However it can be useful to follow the same pattern by way of convention; if the community were ever to read this code, or if AWS were ever to provide a custom image containing BertModel and BertTokenizer
"""
from transformers import BertModel, BertTokenizer
from pipeline import run_pipeline
import json, os
def model_fn(model_dir):
model_path = os.path.join(model_dir, "model")
tokenizer_path = os.path.join(model_dir, "tokenizer")
model = BertModel.from_pretrained(model_path)
tokenizer = BertTokenizer.from_pretrained(tokenizer_path)
return {"model": model,
"tokenizer": tokenizer}
def input_fn(request_body, request_content_type):
if request_content_type == 'application/json':
input_data = json.loads(request_body)
return input_data
else:
raise ValueError("Unsupported content type: {}".format(request_content_type))
def predict_fn(input_data, model_artifacts):
return run_pipeline(model = model_artifacts['model'],
tokenizer = model_artifacts['tokenizer'],
src = input_data["src"],
tgt = input_data["tgt"])
def output_fn(prediction_output, accept):
if str(accept) == "application/json":
response = prediction_output
return json.dumps(response)
else:
raise ValueError("Unsupported accept type: {}".format(accept))
if __name__ == "__main__":
pass
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
PROJECT_NAME=$CODEBUILD_PROJECT_NAME
# Fetch the list of build IDs for the specified project
echo "Fetching build IDs for project '$PROJECT_NAME'..."
build_ids=$(aws codebuild list-builds-for-project --project-name "$PROJECT_NAME" --query "ids" --output text)
if [ -z "$build_ids" ]; then
echo "No builds found for project '$PROJECT_NAME'."
exit 0
fi
# Display the build IDs and their start timestamps
echo "Build IDs and start timestamps for project '$PROJECT_NAME':"
for build_id in $build_ids; do
start_time=$(aws codebuild batch-get-builds --ids "$build_id" --query "builds[0].startTime" --output text)
echo "- Build ID: $build_id, Start Time: $start_time"
done
#!/usr/bin/env bash
# Ensure the CODEBUILD_PROJECT_NAME environment variable is set
if [ -z "$CODEBUILD_PROJECT_NAME" ]; then
echo "Error: CODEBUILD_PROJECT_NAME environment variable is not set."
exit 1
fi
STACK_NAME="${CODEBUILD_PROJECT_NAME}-stack"
# Describe stack events
aws cloudformation describe-stack-events --stack-name $STACK_NAME --query "StackEvents[].{\"1.Timestamp\":Timestamp,\"2.Id\":LogicalResourceId,\"3.Type\":ResourceType,\"4.Status\":ResourceStatus,\"5.Reason\":ResourceStatusReason}"
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# Check if the ECR repository name is provided
if [ -z "$ECR_REPO_NAME" ]; then
echo "ECR repository name not provided. Please set the ECR_REPO_NAME environment variable."
exit 1
fi
# List images in the specified ECR repository
echo "Listing images in ECR repository '$ECR_REPO_NAME'..."
aws ecr list-images --repository-name "$ECR_REPO_NAME" --query 'imageIds[*]' --output table
# Check if the command was successful
if [ $? -eq 0 ]; then
echo "Images listed successfully in ECR repository '$ECR_REPO_NAME'."
else
echo "Failed to list images in ECR repository '$ECR_REPO_NAME'."
exit 1
fi
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
BUCKET_NAME=$S3_BUCKET_NAME
# List objects in the S3 bucket
echo "Listing objects in S3 bucket '$BUCKET_NAME'..."
aws s3 ls --recursive "s3://$BUCKET_NAME"
if [ $? -ne 0 ]; then
echo "Failed to list objects in S3 bucket '$BUCKET_NAME'."
exit 1
fi
echo "Objects listed successfully in S3 bucket '$BUCKET_NAME'."
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# List all CodeBuild projects
echo "Fetching list of CodeBuild projects..."
projects=$(aws codebuild list-projects --query "projects" --output text)
if [ -z "$projects" ]; then
echo "No CodeBuild projects found."
exit 0
fi
# Display the project names
echo "CodeBuild Projects:"
for project in $projects; do
echo "- $project"
done
#!/usr/bin/env bash
# Ensure the CODEBUILD_PROJECT_NAME environment variable is set
if [ -z "$CODEBUILD_PROJECT_NAME" ]; then
echo "Error: CODEBUILD_PROJECT_NAME environment variable is not set."
exit 1
fi
STACK_NAME="${CODEBUILD_PROJECT_NAME}-stack"
aws cloudformation describe-stack-resources --stack-name $STACK_NAME --query "StackResources[].{\"1.Timestamp\":Timestamp,\"2.LogicalId\":LogicalResourceId,\"3.PhysicalId\":PhysicalResourceId,\"4.Type\":ResourceType,\"5.Status\":ResourceStatus}"
#!/usr/bin/env bash
aws cloudformation describe-stacks --query "Stacks[].{\"1.Name\":StackName,\"2.Status\":StackStatus}"

docker image management 19/05/24

  • docker build -t bert-word-alignment .
  • docker images
  • docker run -p 8080:8080 bert-word-alignment serve # <-- following sagemaker process
  • docker ps
  • docker stop [process id]
  • docker ps -a
  • docker container prune
  • docker rmi bert-word-alignment
import boto3, json, urllib.request
def translate_text(text, source_language_code = "ru", target_language_code = "en"):
translate = boto3.client('translate')
result = translate.translate_text(
Text=text,
SourceLanguageCode=source_language_code,
TargetLanguageCode=target_language_code
)
return result['TranslatedText']
if __name__ == "__main__":
try:
import sys
if len(sys.argv) < 2:
raise RuntimeError("please enter Russian text")
src = sys.argv[1]
tgt = translate_text(src)
request_body = json.dumps({
"src": src,
"tgt": tgt,
})
req = urllib.request.Request("http://localhost:8080/invocations",
data=request_body.encode("utf-8"),
headers={"Content-Type": "application/json",
"Accept": "application/json"},
method='POST')
pairs = json.loads(urllib.request.urlopen(req).read())
def format_text(text, n = 48):
return text[:n] if len(text) > n else text+" ".join(["" for i in range(n-len(text))])
for text, translation in pairs:
print (f"{format_text(text)}\t{format_text(translation)}")
except RuntimeError as error:
print ("Error: %s" % str(error))
"""
https://colab.research.google.com/drive/1205ubqebM0OsZa1nRgbGJBtitgHqIVv6?usp=sharing#scrollTo=FfDM0w2kfHyJ
"""
import itertools, torch
def init_ids(tokenizer, wid):
return tokenizer.prepare_for_model(list(itertools.chain(*wid)),
return_tensors='pt',
model_max_length=tokenizer.model_max_length,
truncation=True)['input_ids']
def init_sub2word_map(token):
sub2word_map = []
for i, word_list in enumerate(token):
sub2word_map += [i for x in word_list]
return sub2word_map
def preprocess(tokenizer, src, tgt):
sent = {k: v.strip().split() for k, v in [("src", src), ("tgt", tgt)]}
token = {k: [tokenizer.tokenize(word) for word in sent[k]] for k in ["src", "tgt"]}
wid = {k: [tokenizer.convert_tokens_to_ids(x) for x in token[k]] for k in ["src", "tgt"]}
ids = {k: init_ids(tokenizer, wid[k]) for k in ["src", "tgt"]}
sub2word_map = {k: init_sub2word_map(token[k]) for k in ["src", "tgt"]}
return {
"sent": sent,
"ids": ids,
"sub2word_map": sub2word_map
}
def run_model(model, struct, align_layer = 8, threshold = 1e-3):
model.eval()
with torch.no_grad():
out = {k: model(struct["ids"][k].unsqueeze(0),
output_hidden_states=True)[2][align_layer][0, 1:-1]
for k in ["src", "tgt"]}
dot_prod = torch.matmul(out["src"], out["tgt"].transpose(-1, -2))
softmax_srctgt = torch.nn.Softmax(dim=-1)(dot_prod)
softmax_tgtsrc = torch.nn.Softmax(dim=-2)(dot_prod)
softmax_inter = (softmax_srctgt > threshold)*(softmax_tgtsrc > threshold)
return torch.nonzero(softmax_inter, as_tuple=False)
def align_words(struct, align_subwords):
align_words = set()
for i, j in align_subwords:
align_words.add((struct["sub2word_map"]["src"][i],
struct["sub2word_map"]["tgt"][j]))
return [(struct["sent"]["src"][i],
struct["sent"]["tgt"][j])
for i, j in sorted(align_words)]
class Buffer:
def __init__(self, term = [], translation = []):
self.term = term if isinstance(term, list) else [term]
self.translation = translation if isinstance(translation, list) else [translation]
def matches_term(self, term):
return (self.term != [] and
self.term[-1] == term)
def matches_translation(self, translation):
return (self.translation != [] and
self.translation[-1] == translation)
@property
def is_populated(self):
return (self.term != [] and
self.translation != [])
def render(self):
return (" ".join(self.term),
" ".join(self.translation))
class Terms(list):
def __init__(self):
list.__init__(self)
self.buf = Buffer()
def add(self, term, translation):
if (self.buf.matches_term(term) and
self.buf.matches_translation(translation)):
pass
elif self.buf.matches_translation(translation):
self.buf.term.append(term)
elif self.buf.matches_term(term):
self.buf.translation.append(translation)
else:
if self.buf.is_populated:
self.append(self.buf.render())
self.buf = Buffer(term = term,
translation = translation)
def cluster_terms(terms):
clustered = Terms()
for text, translation in terms:
clustered.add(text, translation)
if clustered.buf.is_populated:
clustered.append(clustered.buf.render())
return clustered
def run_pipeline(tokenizer, model, src, tgt):
struct = preprocess(tokenizer, src, tgt)
align_subwords = run_model(model, struct)
return cluster_terms(align_words(struct, align_subwords))
if __name__ == "__main__":
pass
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# Assign argument to variable
PROJECT_NAME=$CODEBUILD_PROJECT
# Get the list of builds for the specified project and retrieve the latest build ID
BUILD_ID=$(aws codebuild list-builds-for-project --project-name "$PROJECT_NAME" --query 'ids[0]' --output text)
if [ -z "$BUILD_ID" ] || [ "$BUILD_ID" == "None" ]; then
echo "No builds found for the project '$PROJECT_NAME'."
exit 1
fi
echo "Latest build ID for project '$PROJECT_NAME' is '$BUILD_ID'."
# Poll the build for its status
while true; do
# BUILD_STATUS=$(aws codebuild batch-get-builds --ids "$BUILD_ID" --query 'builds[0].buildStatus' --output text)
BUILD_INFO=$(aws codebuild batch-get-builds --ids "$BUILD_ID" --output json)
BUILD_STATUS=$(echo "$BUILD_INFO" | grep -o '"buildStatus": "[^"]*' | grep -o '[^"]*$')
CURRENT_PHASE=$(echo "$BUILD_INFO" | grep -o '"currentPhase": "[^"]*' | grep -o '[^"]*$')
if [ "$BUILD_STATUS" == "SUCCEEDED" ]; then
echo "Build '$BUILD_ID' succeeded. Current phase: '$CURRENT_PHASE'."
exit 0
elif [ "$BUILD_STATUS" == "FAILED" ]; then
echo "Build '$BUILD_ID' failed. Current phase: '$CURRENT_PHASE'."
exit 1
elif [ "$BUILD_STATUS" == "FAULT" ]; then
echo "Build '$BUILD_ID' encountered a fault. Current phase: '$CURRENT_PHASE'."
exit 1
elif [ "$BUILD_STATUS" == "STOPPED" ]; then
echo "Build '$BUILD_ID' was stopped. Current phase: '$CURRENT_PHASE'."
exit 1
else
echo "Build '$BUILD_ID' is in status '$BUILD_STATUS'. Current phase: '$CURRENT_PHASE'. Waiting..."
sleep 3
fi
done
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
ProjectName:
Type: String
S3BucketName:
Type: String
S3BuildSpecKey:
Type: String
RepositoryName:
Type: String
DockerUsername:
Type: String
DockerPassword:
Type: String
CodeBuildImage:
Type: String
Default: "aws/codebuild/amazonlinux2-x86_64-standard:3.0"
CodeBuildComputeType:
Type: String
Default: BUILD_GENERAL1_LARGE
Resources:
CodeBuildServiceRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: codebuild.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: CodeBuildPolicy
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- 'codebuild:*'
- 's3:GetObject'
- 's3:PutObject'
- 'logs:*'
- 'cloudwatch:*'
- 'ecr:*'
Resource: '*'
CodeBuildProject:
Type: 'AWS::CodeBuild::Project'
Properties:
Name: !Ref ProjectName
Source:
Type: S3
Location: !Join [ '/', [ !Ref S3BucketName, !Ref S3BuildSpecKey ] ]
Artifacts:
Type: NO_ARTIFACTS
Environment:
Type: LINUX_CONTAINER
Image: !Ref CodeBuildImage
ComputeType: !Ref CodeBuildComputeType
EnvironmentVariables:
- Name: S3_BUCKET_NAME
Value: !Ref S3BucketName
Type: PLAINTEXT
- Name: ECR_REPO_NAME
Value: !Ref RepositoryName
Type: PLAINTEXT
- Name: DOCKER_USERNAME
Value: !Ref DockerUsername
Type: PLAINTEXT
- Name: DOCKER_PASSWORD
Value: !Ref DockerPassword
Type: PLAINTEXT
PrivilegedMode: true
ServiceRole: !GetAtt CodeBuildServiceRole.Arn
LogsConfig:
S3Logs:
Status: ENABLED
Location: !Sub '${S3BucketName}/codebuild-logs'
Outputs:
CodeBuildProjectName:
Value: !Ref CodeBuildProject
CodeBuildServiceRoleArn:
Value: !GetAtt CodeBuildServiceRole.Arn
#!/bin/bash
# Check if AWS CLI and zip are installed
if ! command -v aws &> /dev/null; then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
if ! command -v zip &> /dev/null; then
echo "zip not found. Please install zip utility."
exit 1
fi
BUCKET_NAME=$S3_BUCKET_NAME
ZIP_FILE="app-artifacts.zip"
TMP_DIR="tmp/app-artifacts"
# Create a temporary directory
rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR"
# Copy the Dockerfile and the required files into the temporary directory
cp Dockerfile "$TMP_DIR/"
cp pipeline.py "$TMP_DIR/"
cp inference.py "$TMP_DIR/"
cp app.py "$TMP_DIR/"
cp serve.sh "$TMP_DIR/"
# Save the current directory
CURRENT_DIR=$(pwd)
# Change to the temporary directory
cd "$TMP_DIR"
# Create a zip file of the artifacts
echo "Creating zip file $ZIP_FILE..."
zip -r "$ZIP_FILE" .
# Move the zip file to the original directory
mv "$ZIP_FILE" "$CURRENT_DIR"
# Change back to the original directory
cd "$CURRENT_DIR"
# Upload the zip file to the specified S3 bucket
echo "Uploading $ZIP_FILE to s3://$BUCKET_NAME/..."
aws s3 cp "$ZIP_FILE" "s3://$BUCKET_NAME/$ZIP_FILE"
if [ $? -ne 0 ]; then
echo "Failed to upload $ZIP_FILE to s3://$BUCKET_NAME/"
exit 1
fi
echo "App artifacts uploaded successfully to s3://$BUCKET_NAME/$ZIP_FILE"
# Clean up
rm -rf "$TMP_DIR"
rm "$ZIP_FILE"
echo "Temporary files cleaned up."
#!/bin/bash
# Check if AWS CLI and zip are installed
if ! command -v aws &> /dev/null; then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
if ! command -v zip &> /dev/null; then
echo "zip not found. Please install zip utility."
exit 1
fi
BUCKET_NAME=$S3_BUCKET_NAME
ZIP_FILE="model-artifacts.zip"
TMP_DIR="tmp/model-artifacts"
# Create a temporary directory
rm -rf "$TMP_DIR"
mkdir -p "$TMP_DIR"
# Copy the directories and their contents
cp -r model "$TMP_DIR/model"
cp -r tokenizer "$TMP_DIR/tokenizer"
# Save the current directory
CURRENT_DIR=$(pwd)
# Change to the temporary directory
cd "$TMP_DIR"
# Create a zip file of the artifacts
echo "Creating zip file $ZIP_FILE..."
zip -r "$ZIP_FILE" .
# Move the zip file to the original directory
mv "$ZIP_FILE" "$CURRENT_DIR"
# Change back to the original directory
cd "$CURRENT_DIR"
# Upload the zip file to the specified S3 bucket
echo "Uploading $ZIP_FILE to s3://$BUCKET_NAME/..."
aws s3 cp "$ZIP_FILE" "s3://$BUCKET_NAME/$ZIP_FILE"
if [ $? -ne 0 ]; then
echo "Failed to upload $ZIP_FILE to s3://$BUCKET_NAME/"
exit 1
fi
echo "Model artifacts uploaded successfully to s3://$BUCKET_NAME/$ZIP_FILE"
# Clean up
rm -rf "$TMP_DIR"
rm "$ZIP_FILE"
echo "Temporary files cleaned up."
awscli
boto3
botocore
flask
gunicorn
torch
transformers
#!/usr/bin/env bash
# gunicorn -w 4 -b 0.0.0.0:8080 "app:app"
gunicorn -b 0.0.0.0:8080 "app:app"
import os, re, sys
def refactor_src(pat, rep, root):
def refactor(tokens):
path = "/".join(tokens)
for entry in os.listdir(path):
newtokens = tokens+[entry]
filename = "/".join(newtokens)
if os.path.isdir(filename):
if not filename == "__pycache__":
refactor(newtokens)
elif filename.endswith("pyc"):
pass
else:
text = open(filename).read()
newtext = re.sub(pat, rep, text)
newfilename = re.sub(pat, rep, filename)
if (text!=newtext or
filename!=newfilename):
print (newfilename)
dest = open(newfilename, 'w')
dest.write(newtext)
dest.close()
refactor(root.split("/"))
if __name__ == "__main__":
try:
if len(sys.argv) < 4:
raise RuntimeError("please enter pat, rep, root")
pat, rep, root = sys.argv[1:5]
refactor_src(pat, rep, root)
except RuntimeError as error:
print ("Error: %s" % str(error))
#!/bin/bash
# Example server startup script for Gunicorn serving a Flask application
# Start Gunicorn with specified number of workers and bind to the necessary port
exec gunicorn -w 4 -b 0.0.0.0:8080 app:app
#!/usr/bin/env bash
export AWS_PROFILE=
export AWS_DEFAULT_OUTPUT=
export AWS_REGION=
export AWS_ACCOUNT_ID=
export S3_BUCKET_NAME=
export CODEBUILD_PROJECT_NAME=
export ECR_REPO_NAME=
export DOCKER_USERNAME=
export DOCKER_PASSWORD=
#!/bin/bash
# Check if AWS CLI is installed
if ! command -v aws &> /dev/null
then
echo "AWS CLI not found. Please install and configure the AWS CLI."
exit 1
fi
# Assign arguments to variables
PROJECT_NAME=$CODEBUILD_PROJECT_NAME
BUCKET_NAME=$S3_BUCKET_NAME
REPOSITORY_NAME=$ECR_REPO_NAME
# Prepare environment variables in JSON format
ENV_VARIABLES_JSON="[
{ \"name\": \"S3_BUCKET_NAME\", \"value\": \"$BUCKET_NAME\", \"type\": \"PLAINTEXT\" },
{ \"name\": \"REPOSITORY_NAME\", \"value\": \"$REPOSITORY_NAME\", \"type\": \"PLAINTEXT\" }
]"
# Start the CodeBuild project
aws codebuild start-build \
--project-name "$PROJECT_NAME" \
--environment-variables-override "$ENV_VARIABLES_JSON"
# Check if the build start was successful
if [ $? -eq 0 ]; then
echo "CodeBuild project '$PROJECT_NAME' has been started successfully."
else
echo "Failed to start CodeBuild project '$PROJECT_NAME'."
exit 1
fi

short

  • move docker creds to secrets

thoughts

  • include all artifacts in codebuild s3 src?
    • but then you can't split model artifacts from app
  • fix passing of inline buildspec.yaml containing quotes?
    • only if s3 method doesn't work

done

  • new setenv-priv containing docker creds
  • create docker account and get username/password
  • deploy_stack to pass docker username and password to cloudformation
  • cloudformation to pass docker variables to buildspec
  • buildspec to login docker
  • separate artifacts for model vs app
  • amazon/aws-lambda-python:3.10
  • project to do model dumping
  • SSL build issue
  • check if Dockerfile changed since approx 1500 on 18/05/24
  • poll build to show current phase
  • list images in repo
[Container] 2024/05/18 14:47:47.143467 Running command aws ecr describe-repositories --repository-names $ECR_REPO_NAME || aws ecr create-repository --repository-name $ECR_REPO_NAME

Parameter validation failed:
Invalid length for parameter repositoryNames, value: 0, valid min length: 1
usage: 
Note: AWS CLI version 2, the latest major version of the AWS CLI, is now stable and recommended for general use. For more information, see the AWS CLI version 2 installation instructions at: https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
  • rename logs as export
  • seems like AWS_REGION not set in buildspec.yaml
  • run build
  • delete repo
  • check deploy use of parameters
  • change deploy to update as well as create
  • remove buildspec.yaml from bucket
  • use build spec directly
 2024-05-17T19:22:16.266Z|  CodeBuildProject          |  AWS::CodeBuild::Project    |  CREATE_FAILED        |  Invalid project source: location must be a valid S3 source (Service: AWSCodeBuild; Status Code: 400; Error Code: InvalidInputException; Request ID: af422127-d798-400f-89a9-0d1741e5984b; Proxy: null) 
  • ^^^ just embed buildspec.yaml directly

  • list resources

  • delete stack

  • EnvironmentVariables not being passed

  • scripts for local webserver testing

  • check contents of docker artifacts versus references to them in dockerfile

  • check eng variables used by buildspec and population of them from run build

  • check if docker logs are captured as part of s3 logs

  • change build size

  • change python:3.10-slim to amazonlinux:2

  • change aws/codebuild/standard:5.0 to aws/codebuild/amazonlinux2-x86_64-standard:3.0

  • check pushing of buildspec to bucket and referencing of it from create project

  • when zipping artifacts, need to cd into tmp/artifacts

  • don't delete artifacts file

  • fetch artifacts

  • push artifacts

  • create bucket

  • dump models

  • setenv

  • add models and tokenizer to gitignore

  • script to dump artifacts to tmp

  • refactor poll build to take the latest build

  • check code doing arg list checks

  • env variables for bucket, project, repo

  • rename stack

  • rename push artifacts local directory

  • check REPO_NAME vs REPOSITORY_NAME

  • check refs to S3_* in buildspec

  • rename S3_BUCKET_NAME as S3_BUCKET_NAME

  • use BUCKET_NAME internally

  • replace bucket_name with env variable

  • check that run_build.sh includes a check for the necessary environment variables

  • replace $(aws ecr get-login --no-include-email --region $AWS_REGION) with aws ecr get-login-password

  • check if passing of buildspec.yml as cloudformation arg exceeds parameter length restrictions

    • maybe push to s3 beforehand
  • push artifacts to push stack.yaml to s3

  • rename stack.yaml as project yaml

  • see if you can use an image with docker pre- installed

  • delete bucket

  • analyse start_build

  • create bucket

  • list objects

  • delete project

  • fetch logs

  • list projects

  • list builds for project

  • poll build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment