I generated a job in Canvas via CSV file. After deploying, an endpoint was generated.
Now I am trying to generate predictions via a Python script on my desktop. The script is as follows:
import requests
import pandas as pd
import json
import os
# Definir o endpoint do Canvas
endpoint = "https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/canvas-new-deployment-03-12-2024-4-51-PM/invocations"
# Carregar o arquivo CSV
data = pd.read_csv("C:\\Users\\Druida\\Desktop\\dados_binance.csv")
# Converter o DataFrame para JSON
data_json = data.to_json(orient="records")
# Obter o token de autenticação
token = os.environ.get("canvas-new-deployment-03-12-2024-4-51-PM")
# Criar a requisição
headers = {
"Content-Type": "application/json",
"X-Amzn-SageMaker-Custom-Auth": token
}
body = data_json
response = requests.post(endpoint, headers=headers, data=body)
# Tratar a resposta
if response.status_code == 200:
prediction = json.loads(response.content)
print(prediction)
else:
print(f"Erro: {response.status_code}")
print(response.content)
However, instead of the prediction, I get the following message regarding the token:
C:\Users\Druida\PycharmProjects\pythonProject.venv\Scripts\python.exe "C:\Users\Druida\PycharmProjects\pythonProject\regressão linear.py"
Erro: 403
b'{"message":"Missing Authentication Token"}'
Process finished with exit code 0
Please help me because I can't generate the predictions.