aws fargate_使用AWS Fargate部署PyCaret和Streamlit应用程序-无服务器基础架构

aws fargate

收获 (RECAP)

In our last post, we demonstrated how to develop a machine learning pipeline using PyCaret and serve it as a Streamlit web application deployed onto Google Kubernetes Engine. If you haven’t heard about PyCaret before, you can read this announcement to get started.

在上一篇文章中 ,我们演示了如何使用PyCaret开发机器学习管道并将其用作部署到Google Kubernetes Engine上的Streamlit Web应用程序。 如果您以前从未听说过PyCaret,则可以阅读此声明以开始使用。

In this tutorial, we will use the same web app and machine learning pipeline that we had built previously and demonstrate how to deploy it using AWS Fargate which is a serverless compute for containers.

在本教程中,我们将使用与先前构建的相同的Web应用程序和机器学习管道,并演示如何使用AWS Fargate部署它,该工具是用于容器的无服务器计算。

By the end of this tutorial, you will be able to build and host a fully functional containerized web app on AWS without provisioning any server infrastructure.

在本教程结束时,您将能够在AWS上构建和托管功能齐全的容器化Web应用程序,而无需置备任何服务器基础架构。

Web Application Web应用程序

Tu本教程的学习目标 ( Learning Goals of this Tutorial)

  • What is a Container? What is Docker? What is Kubernetes?

    什么是容器? 什么是Docker? 什么是Kubernetes?
  • What is Amazon Elastic Container Service (ECS), AWS Fargate and serverless deployment?

    什么是Amazon Elastic Container Service(ECS),AWS Fargate和无服务器部署?
  • Build and push a Docker image onto Amazon Elastic Container Registry.

    将Docker映像构建并推送到Amazon Elastic Container Registry。
  • Deploy web app using serverless infrastructure i.e. AWS Fargate.

    使用无服务器基础架构即AWS Fargate部署Web应用程序。

This tutorial will cover the entire workflow starting from building a docker image locally, uploading it onto Amazon Elastic Container Registry, creating a cluster and then defining and executing task using AWS-managed infrastructure.

本教程将涵盖整个工作流程,从本地构建docker映像,将其上传到Amazon Elastic Container Registry,创建集群,然后使用AWS管理的基础架构定义和执行任务。

In the past, we have covered deployment on other cloud platforms such as Azure and Google. If you are interested in learning more about those, you can read the following tutorials:

过去,我们介绍了在其他云平台(如Azure和Google)上的部署。 如果您有兴趣进一步了解这些内容,可以阅读以下教程:

  • Deploy Streamlit app onto Google Kubernetes Engine

    将Streamlit应用程序部署到Google Kubernetes Engine上

  • Build and deploy machine learning web app using PyCaret and Streamlit

    使用PyCaret和Streamlit构建和部署机器学习Web应用

  • Deploy Machine Learning Pipeline on AWS Fargate

    在AWS Fargate上部署机器学习管道

  • Deploy Machine Learning Pipeline on Google Kubernetes Engine

    在Google Kubernetes Engine上部署机器学习管道

  • Deploy Machine Learning Pipeline on AWS Web Service

    在AWS Web Service上部署机器学习管道

  • Build and deploy your first machine learning web app on Heroku PaaS

    在Heroku PaaS上构建和部署您的第一个机器学习Web应用程序

tutorial本教程的工具箱 ( Toolbox for this tutorial)

PyCaret (PyCaret)

PyCaret is an open source, low-code machine learning library in Python that is used to train and deploy machine learning pipelines and models into production. PyCaret can be installed easily using pip.

PyCaret是Python中的开放源代码,低代码机器学习库,用于训练和部署机器学习管道和模型到生产中。 使用pip可以轻松安装PyCaret。

pip install pycaret

流光 (Streamlit)

Streamlit is an open-source Python library that makes it easy to build beautiful custom web-apps for machine learning and data science. Streamlit can be installed easily using pip.

Streamlit是一个开放源代码的Python库,可轻松构建用于机器学习和数据科学的精美自定义Web应用程序。 可以使用pip轻松安装Streamlit。

pip install streamlit

适用于Windows 10 Home的Docker Toolbox (Docker Toolbox for Windows 10 Home)

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers are used to package up an application with all of its necessary components, such as libraries and other dependencies, and ship it all out as one package. If you haven’t used docker before, this tutorial also covers the installation of Docker Toolbox (legacy) on Windows 10 Home. In the previous tutorial we covered how to install Docker Desktop on Windows 10 Pro edition.

码头工人 是一种工具,旨在使使用容器更容易创建,部署和运行应用程序。 容器用于将应用程序及其所有必需的组件(如库和其他依赖项)打包在一起,并将其全部打包为一个包。 如果您以前从未使用过Docker,则本教程还将介绍Windows 10 Home上Docker Toolbox(旧版)的安装。 在上一教程中,我们介绍了如何在Windows 10 Pro版上安装Docker Desktop。

亚马逊网络服务(AWS) (Amazon Web Services (AWS))

Amazon Web Services (AWS) is a comprehensive and broadly adopted cloud platform, offered by Amazon. It has over 175 fully-featured services from data centers globally. If you haven’t used AWS before, you can sign-up for a free account.

亚马逊网络服务(AWS)是由亚马逊提供的,广泛使用的云平台。 它具有来自全球数据中心的175多种功能齐全的服务。 如果您以前从未使用过AWS,则可以注册一个免费帐户。

✔️我们开始吧..... (✔️Let’s get started…..)

什么是容器? (What is a Container?)

Before we get into implementation using AWS Fargate, let’s understand what a container is and why we would need one?

在使用AWS Fargate进行实施之前,让我们了解什么是容器以及为什么需要一个容器?

https://www.freepik.com/free-photos-vectors/cargo-ship https://www.freepik.com/free-photos-vectors/cargo-ship

Have you ever had the problem where your code works fine on your computer but when a friend tries to run the exact same code, it doesn’t work? If your friend is repeating the exact same steps, they should get the same results, right? The one-word answer to this is the environment. Your friend’s environment is different than yours.

您是否曾经遇到过这样的问题:您的代码在计算机上可以正常运行,但是当朋友尝试运行完全相同的代码却无法正常工作时呢? 如果您的朋友重复完全相同的步骤,他们应该得到相同的结果,对吗? 一言以蔽之的答案就是环境。 朋友的环境与您的环境不同。

What does an environment include? → The programing language such as Python and all the libraries and dependencies with the exact versions using which application was built and tested.

环境包括什么? →诸如Python之类的编程语言以及所有库和依赖项,以及使用其构建和测试应用程序的确切版本。

If we can create an environment that we can transfer to other machines (for example: your friend’s computer or a cloud service provider like Google Cloud Platform), we can reproduce the results anywhere. Hence, a container is a type of software that packages up an application and all its dependencies so the application runs reliably from one computing environment to another.

如果我们可以创建可以转移到其他计算机(例如:您朋友的计算机或Google Cloud Platform之类的云服务提供商)的环境,那么我们可以在任何地方重现结果。 因此 容器是一种软件,可以打包应用程序及其所有依赖性,因此应用程序可以从一个计算环境可靠地运行到另一个计算环境。

什么是Docker? (What is Docker?)

Docker is a company that provides software (also called Docker) that allows users to build, run and manage containers. While Docker’s container are the most common, there are other less famous alternatives such as LXD and LXC.

Docker是一家提供软件(也称为Docker )的公司,该软件允许用户构建,运行和管理容器。 尽管Docker的容器是最常见的,但还有其他不太知名的替代方案,例如LXD和LXC 。

Now that you theoretically understand what a container is and how Docker is used to containerize applications, let’s imagine a scenario where you have to run multiple containers across a fleet of machines to support an enterprise level machine learning application with varied workloads during day and night. This is pretty common for real-life and as simple as it may sound, it is a lot of work to do manually.

现在您已从理论上了解了什么是容器以及如何使用Docker来对应用程序进行容器化,让我们想象一下一个场景,其中您必须在一组机器上运行多个容器,以支持昼夜工作量不同的企业级机器学习应用程序。 这在现实生活中非常普遍,听起来似乎很简单,但是手动完成很多工作。

You need to start the right containers at the right time, figure out how they can talk to each other, handle storage considerations, deal with failed containers or hardware and million other things!

您需要在正确的时间启动正确的容器,弄清楚它们如何相互通信,处理存储注意事项,处理发生故障的容器或硬件以及数百万其他事情!

This entire process of managing hundreds and thousands of containers to keep the application up and running is known as container orchestration. Don’t get caught up in the technical details yet.

管理成千上万个容器以保持应用程序正常运行的整个过程称为容器编排 。 尚未陷入技术细节中。

At this point, you must recognize that managing real-life applications require more than one container and managing all of the infrastructure to keep containers up and running is cumbersome, manual and an administrative burden.

在这一点上,您必须认识到,管理现实生活中的应用程序需要多个容器,并且管理所有基础结构以保持容器的正常运行是繁琐,手动和管理负担。

This brings us to Kubernetes.

这将我们带到Kubernetes

什么是Kubernetes? (What is Kubernetes?)

Kubernetes is an open-source system developed by Google in 2014 for managing containerized applications. In simple words, Kubernetes is a system for running and coordinating containerized applications across a cluster of machines.

Kubernetes是Google在2014年开发的用于管理容器化应用程序的开源系统。 简单来说就是Kubernetes 是一个用于在机器集群中运行和协调容器化应用程序的系统。

Photo by chuttersnap on Unsplash chuttersnap在 Unsplash上 拍摄的照片

While Kubernetes is an open-source system developed by Google, almost all major cloud service providers offer Kubernetes as a Managed Service. For example: Amazon Elastic Kubernetes Service (EKS) offered by Amazon, Google Kubernetes Engine (GKE) offered by Google, and Azure Kubernetes Service (AKS) offered by Microsoft.

尽管Kubernetes是Google开发的开源系统,但几乎所有主要的云服务提供商都将Kubernetes作为托管服务提供。 例如: 亚马逊弹性Kubernetes服务由谷歌提供的(EKS)由亚马逊,谷歌Kubernetes引擎(GKE)所提供并通过微软提供的Azure的Kubernetes服务(AKS)。

So far we have discussed and understood:

到目前为止,我们已经讨论并理解:

✔️ A container

✔️一个容器

✔️ Docker

✔️码头工人

✔️ Kubernetes

✔️Kubernetes

Before introducing AWS Fargate, there is only one thing left to discuss and that is Amazon’s own container orchestration service Amazon Elastic Container Service (ECS).

在介绍AWS Fargate之前,只剩下要讨论的一件事,那就是Amazon自己的容器编排服务Amazon Elastic Container Service(ECS)。

AWS弹性容器服务(ECS) (AWS Elastic Container Service (ECS))

Amazon Elastic Container Service (Amazon ECS) is Amazon’s home-grown container orchestration platform. The idea behind ECS is similar to Kubernetes (both of them are orchestration services).

Amazon Elastic Container Service(Amazon ECS)是Amazon自主开发的容器编排平台。 ECS背后的想法类似于Kubernetes (它们都是业务流程服务)

ECS is an AWS-native service, meaning that it is only possible to use on AWS infrastructure. On the other hand, EKS is based on Kubernetes, an open-source project which is available to users running on multi-cloud (AWS, GCP, Azure) and even On-Premise.

ECS是AWS本地服务,这意味着只能在AWS基础设施上使用。 另一方面, EKS基于Kubernetes,Kubernetes是一个开源项目,可供在多云(AWS,GCP,Azure)甚至本地部署上运行的用户使用。

Amazon also offers a Kubernetes based container orchestration service known as Amazon Elastic Kubernetes Service (Amazon EKS). Even though the purpose of ECS and EKS is pretty similar i.e. orchestrating containerized applications, there are quite a few differences in pricing, compatibility and security. There is no best answer and the choice of solution depends on the use-case.

Amazon还提供了基于Kubernetes的容器编排服务,称为Amazon Elastic Kubernetes服务(Amazon EKS)。 即使ECS和EKS的目的非常相似(即协调容器化的应用程序) ,但在价格,兼容性和安全性上还是有很多差异。 没有最佳答案,解决方案的选择取决于用例。

Irrespective of whichever container orchestration service you are using (ECS or EKS), there are two ways you can implement the underlying infrastructure:

无论您使用哪种容器编排服务(ECS或EKS),都有两种方法可以实现基础结构:

  1. Manually manage the cluster and underlying infrastructure such as Virtual Machines / Servers / (also known as EC2 instances).

    手动管理群集和基础架构,例如虚拟机/服务器/(也称为EC2实例)。
  2. Serverless — Absolutely no need to manage anything. Just upload the container and that’s it. ← This is AWS Fargate.

    无服务器-完全不需要管理任何东西。 只需上传容器即可。 ← 这是AWS Fargate。

Amazon ECS underlying infrastructure Amazon ECS基础基础架构

AWS Fargate —容器的无服务器计算 (AWS Fargate — serverless compute for containers)

AWS Fargate is a serverless compute engine for containers that works with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). Fargate makes it easy for you to focus on building your applications. Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application, and improves security through application isolation by design.

AWS Fargate是用于容器的无服务器计算引擎,可与Amazon Elastic Container Service(ECS)和Amazon Elastic Kubernetes Service(EKS)一起使用。 Fargate使您可以轻松地专注于构建应用程序。 Fargate消除了供应和管理服务器的需要,使您可以为每个应用程序指定和支付资源,并通过设计隔离应用程序来提高安全性。

Fargate allocates the right amount of compute, eliminating the need to choose instances and scale cluster capacity. You only pay for the resources required to run your containers, so there is no over-provisioning and paying for additional servers.

Fargate分配了适当的计算量,从而无需选择实例和扩展集群容量。 您只需为运行容器所需的资源付费,因此不会超额配置并为其他服务器付费。

https://aws.amazon.com/fargate/ https://aws.amazon.com/fargate/

There is no best answer as to which approach is better. The choice between going serverless or manually managing an EC2 cluster depends on the use-case. Some pointers that can assist with this choice include:

关于哪种方法更好,没有最佳答案。 转向无服务器还是手动管理EC2集群取决于使用情况。 可以帮助进行此选择的一些指针包括:

ECS EC2 (Manual Approach)

ECS EC2(手动方法)

  • You are all-in on AWS.

    您全都使用AWS。
  • You have a dedicated Ops team in place to manage AWS resources.

    您拥有一支专门的Ops团队来管理AWS资源。
  • You have an existing footprint on AWS i.e. you are already managing EC2 instances

    您在AWS上已有一个足迹,即您已经在管理EC2实例

AWS Fargate

AWS Fargate

  • You do not have huge Ops team to manage AWS resources.

    您没有庞大的Ops团队来管理AWS资源。
  • You do not want operational responsibility or want to reduce it.

    您不想要运营责任或希望减少责任。
  • Your application is stateless (A stateless app is an application that does not save client data generated in one session for use in the next session with that client).

    您的应用程序是无状态的(无状态应用程序是不保存在一个会话中生成的客户端数据以在与该客户端的下一个会话中使用的应用程序)

设置业务环境 (Setting the Business Context)

An insurance company wants to improve its cash flow forecasting by better predicting patient charges using demographic and basic patient health risk metrics at the time of hospitalization.

一家保险公司希望通过在住院时使用人口统计和基本患者健康风险指标更好地预测患者费用来改善现金流量预测。

(data source)

( 数据源 )

目的 (Objective)

To build and deploy a web application where the demographic and health information of a patient is entered into a web-based form which then outputs a predicted charge amount.

要构建和部署Web应用程序,将患者的人口统计和健康信息输入基于Web的形式,然后输出预测的费用金额。

任务 (Tasks)

  • Train, validate and develop a machine learning pipeline using PyCaret.

    使用PyCaret训练,验证和开发机器学习管道。
  • Build a front-end web application with two functionalities: (i) online prediction and (ii) batch prediction.

    构建具有两个功能的前端Web应用程序:(i)在线预测和(ii)批处理预测。
  • Create a Dockerfile

    创建一个Dockerfile
  • Create and execute a task to deploy the app using AWS Fargate serverless infrastructure.

    创建并执行任务以使用AWS Fargate无服务器基础架构来部署应用程序。

Since we have already covered the first two tasks in our last tutorial, we will quickly recap them and then focus on the remaining items in the list above. If you are interested in learning more about developing a machine learning pipeline in Python using PyCaret and building a web app using a Streamlit framework, please read this tutorial.

由于我们已经在上一个教程中介绍了前两个任务,因此我们将快速回顾一下它们,然后集中注意上面列表中的其余项目。 如果您想了解更多有关使用PyCaret在Python中开发机器学习管道以及使用Streamlit框架构建Web应用程序的信息,请阅读本教程 。

任务1-模型训练和验证 ( Task 1 — Model Training and Validation)

We are using PyCaret in Python for training and developing a machine learning pipeline which will be used as part of our web app. The Machine Learning Pipeline can be developed in an Integrated Development Environment (IDE) or Notebook. We have used a notebook to run the below code:

我们正在Python中使用PyCaret进行培训和开发机器学习管道,该管道将用作我们的Web应用程序。 机器学习管道可以在集成开发环境(IDE)或笔记本电脑中开发。 我们使用笔记本运行以下代码:

When you save a model in PyCaret, the entire transformation pipeline based on the configuration defined in the setup() function is created . All inter-dependencies are orchestrated automatically. See the pipeline and model stored in the ‘deployment_28042020’ variable:

当您在PyCaret中保存模型时,将基于setup()函数中定义的配置创建整个转换管道。 所有相互依赖关系都是自动编排的。 请参阅存储在'deployment_28042020'变量中的管道和模型:

Machine Learning Pipeline created using PyCaret 使用PyCaret创建的机器学习管道

任务2-构建前端Web应用程序 ( Task 2 — Build a front-end web application)

Now that our machine learning pipeline and model are ready to start building a front-end web application that can generate predictions on new datapoints. This application will support ‘Online’ as well as ‘Batch’ predictions through a csv file upload. Let’s breakdown the application code into three main parts:

现在,我们的机器学习管道和模型已准备就绪,可以开始构建可以生成新数据点预测的前端Web应用程序。 此应用程序将通过csv文件上传支持“在线”和“批量”预测。 让我们将应用程序代码分解为三个主要部分:

页眉/布局 (Header / Layout)

This section imports libraries, loads the trained model and creates a basic layout with a logo on top, a jpg image and a dropdown menu on the sidebar to toggle between ‘Online’ and ‘Batch’ prediction.

本部分将导入库,加载经过训练的模型,并创建基本布局,在顶部带有徽标,jpg图像和侧栏上的下拉菜单,以在“在线”和“批量”预测之间切换。

app.py — code snippet part 1 app.py-代码段第1部分

在线预测 (Online Predictions)

This section deals with the initial app function, Online one-by-one predictions. We are using streamlit widgets such as number input, text input, drop down menu and checkbox to collect the datapoints used to train the model such as Age, Sex, BMI, Children, Smoker, Region.

本节介绍了初始的应用程序功能,在线一对一预测。 我们使用流线型的小部件,例如数字输入,文本输入,下拉菜单和复选框来收集用于训练模型的数据点,例如年龄,性别,BMI,儿童,吸烟者,区域。

app.py — code snippet part 2 app.py-代码段第2部分

批量预测 (Batch Predictions)

Predictions by batch is the second layer of the app’s functionality. The file_uploader widget in streamlit is used to upload a csv file and then called the native predict_model() function from PyCaret to generate predictions that are displayed using streamlit’s write() function.

分批预测是应用程序功能的第二层。 streamlit中的file_uploader窗口小部件用于上载csv文件,然后从PyCaret调用本机的Forecast_model()函数以生成使用streamlit的write()函数显示的预测。

app.py — code snippet part 3 app.py-代码段第3部分

Testing AppOne final step before we deploy the application on AWS Fargate is to test the app locally. Open Anaconda Prompt and navigate to your project folder and execute the following code:

测试应用程序在AWS Fargate上部署应用程序之前,最后一步是在本地测试应用程序。 打开Anaconda Prompt并导航到您的项目文件夹,然后执行以下代码:

streamlit run app.py
Streamlit application testing — Online Prediction Streamlit应用程序测试—在线预测

任务3-创建Dockerfile ( Task 3 — Create a Dockerfile)

To containerize our application for deployment we need a docker image that becomes a container at runtime. A docker image is created using a Dockerfile. A Dockerfile is just a file with a set of instructions. The Dockerfile for this project looks like this:

为了将应用程序容器化以进行部署,我们需要一个Docker映像,该映像在运行时成为容器。 Docker映像是使用Dockerfile创建的。 Dockerfile只是具有一组指令的文件。 该项目的Dockerfile如下所示:

The last part of this Dockerfile (starting at line 23) is Streamlit specific. Dockerfile is case-sensitive and must be in the project folder with the other project files.

该Dockerfile的最后一部分(从第23行开始)特定于Streamlit。 Dockerfile区分大小写,并且必须与其他项目文件位于项目文件夹中。

任务4 –在AWS Fargate上部署: ( Task 4–Deploy on AWS Fargate:)

Follow these simple 9 steps to deploy app on AWS Fargate:

请按照以下9个简单步骤在AWS Fargate上部署应用程序:

步骤1 —安装Docker Toolbox(适用于Windows 10 Home) ( Step 1 — Install Docker Toolbox (for Windows 10 Home))

In order to build a docker image locally, you will need Docker installed on your computer. If you are using Windows 10 64-bit: Pro, Enterprise, or Education (Build 15063 or later) you can download Docker Desktop from DockerHub.

为了在本地构建Docker映像,您需要在计算机上安装Docker。 如果您使用的是Windows 10 64位:Pro,Enterprise或Education(内部版本15063或更高版本),则可以从DockerHub下载Docker Desktop。

However, if you are using Windows 10 Home, you would need to install the last release of legacy Docker Toolbox (v19.03.1) from Dockers GitHub page.

但是,如果您使用的是Windows 10 Home,则需要从Dockers GitHub页面安装最新版本的旧版Docker Toolbox(v19.03.1)。

https://github.com/docker/toolbox/releases https://github.com/docker/toolbox/releases

Download and Run DockerToolbox-19.03.1.exe file.

下载并运行DockerToolbox-19.03.1.exe文件。

The easiest way to check if the installation was successful is by opening the command prompt and typing in ‘docker’. It should print the help menu.

检查安装是否成功的最简单方法是打开命令提示符并键入“ docker”。 它应该打印帮助菜单。

Anaconda Prompt to check docker Anaconda提示检查Docker

步骤2 —在Elastic Container Registry(ECR)中创建存储库 ( Step 2 — Create a Repository in Elastic Container Registry (ECR))

(a) Login to your AWS console and search for Elastic Container Registry:

(a)登录到您的AWS控制台并搜索Elastic Container Registry:

AWS Console AWS控制台

(b) Create a new repository:

(b)创建一个新的存储库:

Create New Repository on Amazon Elastic Container Registry 在Amazon Elastic Container Registry上创建新存储库
Create Repository 创建存储库

Click on “Create Repository”.

单击“创建存储库”。

(c) Click on “View push commands”:

(c)点击“查看推送命令”:

Push commands for pycaret-streamlit-aws repository pycaret-streamlit-aws存储库的推送命令

步骤3 —执行推送命令 ( Step 3— Execute push commands)

Navigate to your project folder using Anaconda Prompt and execute the commands you have copied in the step above. You must be in the folder where the Dockerfile and the rest of your code reside before executing these commands.

使用Anaconda Prompt导航到项目文件夹,然后执行在上述步骤中复制的命令。 在执行这些命令之前,您必须位于Dockerfile和其余代码所在的文件夹中。

These commands are for building docker image and then uploading it on AWS ECR.

这些命令用于构建docker映像,然后将其上传到AWS ECR。

步骤4 —检查您上传的图片 ( Step 4 — Check your uploaded image)

Click on the repository you created and you will see an image URI of the uploaded image in the step above. Copy the image URI (it would be needed in step 6 below).

单击您创建的存储库,您将在上面的步骤中看到上载图像的图像URI。 复制图像URI(在下面的步骤6中将需要它)。

步骤5 —创建和配置集群 ( Step 5 — Create and Configure a Cluster)

(a) Click on “Clusters” on left-side menu:

(a)在左侧菜单上单击“集群”:

Create Cluster — Step 1 创建群集-步骤1

(b) Select “Networking only” and click Next step:

(b)选择“仅联网”,然后单击下一步:

Select Networking Only Template 选择仅联网模板

(c) Configure Cluster (Enter cluster name) and click on Create:

(c)配置集群(输入集群名称),然后单击创建:

Configure Cluster 配置集群

Click on “Create”.

点击“创建”。

(d) Cluster Created:

(d)创建的集群:

Cluster Created 集群创建

步骤6 —创建一个新的任务定义 ( Step 6 — Create a new Task definition)

A task definition is required to run Docker containers in Amazon ECS. Some of the parameters you can specify in a task definition include: The Docker image to use with each container in your task. How much CPU and memory to use with each task or each container within a task.

在Amazon ECS中运行Docker容器需要任务定义。 您可以在任务定义中指定的一些参数包括:与Task中的每个容器一起使用的Docker映像。 每个任务或一个任务中的每个容器要使用多少CPU和内存。

(a) Click on “Create new task definition”:

(a)单击“创建新任务定义”:

Create a new task definition 创建一个新的任务定义

(b) Select “FARGATE” as launch type:

(b)选择“ FARGATE”作为启动类型:

Select Launch Type Compatibility 选择启动类型兼容性

(c) Fill in the details:

(c)填写详细信息:

Configure Task and container definitions (part 1) 配置任务和容器定义(第1部分)
Configure Task and container definitions (part 2) 配置任务和容器定义(第2部分)

(d) Click on “Add Containers” and fill in the details:

(d)点击“添加容器”并填写详细信息:

Adding Container in task definitions 在任务定义中添加容器

Click “Create Task” on the bottom right.

点击右下角的“创建任务”。

步骤7 —执行任务定义 ( Step 7— Execute Task Definition)

In last step we created a task that will start the container. Now we will execute the task by clicking “Run Task” under Actions.

在最后一步中,我们创建了一个任务,将启动容器。 现在,我们将通过单击操作下的“运行任务”来执行任务。

(a) Click on “Switch to launch type” to change the type to Fargate:

(a)单击“切换到启动类型”以将类型更改为Fargate:

(b) Select the VPC and Subnet from the dropdown:

(b)从下拉列表中选择VPC和子网:

Click on “Run Task” on bottom right.

点击右下角的“运行任务”。

步骤8-允许来自网络设置的入站端口8501 ( Step 8— Allow inbound port 8501 from Network settings)

One last step before we can see our application in action on Public IP address is to allow port 8501 (used by streamlit) by creating a new rule. In order to do that, follow these steps:

在看到我们的应用程序对公共IP地址起作用之前,最后一步是通过创建新规则来允许端口8501(由streamlit使用)。 为此,请按照下列步骤操作:

(a) Click on Task

(a)点击任务

(b) Click on ENI Id:

(b)单击ENI ID:

(c) Click on Security groups

(c)单击安全组

(d) Scroll down and click on “Edit inbound rules”

(d)向下滚动并单击“编辑入站规则”

(e) Add a Custom TCP rule of port 8501

(e)添加端口8501的自定义TCP规则

恭喜! 您已在AWS Fargate上无服务器发布应用程序。 使用带有端口8501的公共IP地址访问应用程序。 ( Congratulations! You have published your app serverless on AWS Fargate. Use public IP address with port 8501 to access the application.)

App published on 99.79.189.46:8501 应用发布于99.79.189.46:8501

Note: By the time this story is published, the app will be removed from the public address to restrict resource consumption.

注意:在发布此故事时,该应用将从公共地址中删除,以限制资源消耗。

Link to GitHub Repository for this tutorial

链接到本教程的GitHub Repository

Link to GitHub Repository for Google Kubernetes Deployment

链接到GitHub Repository以进行Google Kubernetes部署

Link to GitHub Repository for Heroku Deployment

链接到GitHub存储库以进行Heroku部署

PyCaret 2.0.0即将发布! (PyCaret 2.0.0 is coming!)

We have received overwhelming support and feedback from the community. We are actively working on improving PyCaret and preparing for our next release. PyCaret 2.0.0 will be bigger and better. If you would like to share your feedback and help us improve further, you may fill this form on the website or leave a comment on our GitHub or LinkedIn page.

我们收到了社区的压倒性支持和反馈。 我们正在积极改进PyCaret,并为我们的下一个版本做准备。 PyCaret 2.0.0将变得更大更好 。 如果您想分享您的反馈意见并帮助我们进一步改进,则可以在网站上填写此表格 ,或在我们的GitHub或LinkedIn页面上发表评论。

Follow our LinkedIn and subscribe to our YouTube channel to learn more about PyCaret.

关注我们的LinkedIn,并订阅我们的YouTube频道,以了解有关PyCaret的更多信息。

想了解一个特定的模块吗? (Want to learn about a specific module?)

As of the first release 1.0.0, PyCaret has the following modules available for use. Click on the links below to see the documentation and working examples in Python.

从第一个版本1.0.0开始,PyCaret可以使用以下模块。 单击下面的链接以查看Python的文档和工作示例。

ClassificationRegressionClusteringAnomaly DetectionNatural Language ProcessingAssociation Rule Mining

分类 回归 聚类 异常检测 自然语言处理 关联规则挖掘

另请参阅: (Also see:)

PyCaret getting started tutorials in Notebook:

笔记本中的PyCaret入门教程:

ClassificationRegressionClusteringAnomaly DetectionNatural Language ProcessingAssociation Rule Mining

分类 回归 聚类 异常检测 自然语言处理 关联规则挖掘

您想贡献吗? (Would you like to contribute?)

PyCaret is an open source project. Everybody is welcome to contribute. If you would like to contribute, please feel free to work on open issues. Pull requests are accepted with unit tests on dev-1.0.1 branch.

PyCaret是一个开源项目。 欢迎大家贡献力量。 如果您想做出贡献,请随时处理未解决的问题 。 dev-1.0.1分支上的单元测试接受了请求请求。

Please give us ⭐️ on our GitHub repo if you like PyCaret.

如果您喜欢PyCaret,请在我们的GitHub存储库中给我们提供⭐️。

Medium: https://medium.com/@moez_62905/

媒介: https : //medium.com/@moez_62905/

LinkedIn: https://www.linkedin.com/in/profile-moez/

领英(LinkedIn): https : //www.linkedin.com/in/profile-moez/

Twitter: https://twitter.com/moezpycaretorg1

推特: https : //twitter.com/moezpycaretorg1

翻译自: https://towardsdatascience.com/deploy-pycaret-and-streamlit-app-using-aws-fargate-serverless-infrastructure-8b7d7c0584c2

aws fargate

你可能感兴趣的:(java,python,docker,linux,mysql)