Using SageMaker as a backend for a web app

0

Continued/simplified from this post.

Let's say I have a web app UI and I want to connect it to a SageMaker notebook using the Churn Predictor model in SageMaker Sudio. Think of it like using that model hosted in SageMaker as a backend to my web app.

I could create an API endpoint but my web app has a very simple solution for opening a web socket which I'd like to use. Question: Whats the simplest/best way to deploy the SageMaker notebook so that it keeps the kernel running and connection open?

The websocket means I don't need to set up and configure individual API endpoints which is what all the documentation I can find suggests.

The desired workflow is:

  • Configure model in SageMaker notebook environment
  • Add a cell that establishes a websocket connection
  • Export notebook as a Python script (Maybe?)
  • Host & Run Python script on an AWS service

With the web socket I can simply establish the connection:

anvil.server.connect(app_key)

And then give each function that I want my web app to call a decorator. i.e:

@anvil.server.callable
def function(foo):
  return foo
질문됨 2년 전1185회 조회
1개 답변
0

Hello, According to the description, I assume you are going to use the Sagemaker notebooks for the development of the inference code and then export the code as a script.

If you model is light weight, you can cache the model inside you server application and call the predictions in it.

model = load_model()

@anvil.server.callable
def function(foo):
  return model.predict("")

Alternatively you can create a SageMaker endpoint and inside the same function above you can call the Sagemaker endpoint and pass it back to the client as a response to the web-socket invocation.

AWS
전문가
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠