Skip to content

Commit a4bbacd

Browse files
committed
clear repo
1 parent 6747cef commit a4bbacd

File tree

5 files changed

+291
-0
lines changed

5 files changed

+291
-0
lines changed

test_model/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Python-generated files
2+
__pycache__/
3+
*.py[oc]
4+
build/
5+
dist/
6+
wheels/
7+
*.egg-info
8+
9+
# Virtual environments
10+
.venv
11+
12+
.pytest_cache/
13+
.mypy_cache/

test_model/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

test_model/pyproject.toml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[project]
2+
name = "aws-sagemaker-hf-model-deployment"
3+
version = "0.1.0"
4+
description = "AWS SageMaker Hugging Face Model Deployment"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = ["boto3>=1.35.97"]
8+
9+
[tool.mypy]
10+
disallow_untyped_calls = true
11+
12+
[tool.ruff]
13+
target-version = "py312"
14+
15+
[tool.ruff.lint]
16+
select = [
17+
"F", # Pyflakes
18+
"I", # isort
19+
"E", # pycodestyle
20+
"S", # flake8-bandit
21+
"N", # pep8-naming
22+
"PERF",
23+
]
24+
25+
[dependency-groups]
26+
dev = [
27+
"boto3-stubs>=1.36.1",
28+
]

test_model/test_endpoint.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import json
2+
import time
3+
4+
import boto3
5+
6+
AWS_REGION = "us-east-1"
7+
ENDPOINT_NAME = "prod-multilingual-sentiment-analysis-endpoint"
8+
9+
sagemaker_runtime = boto3.client("sagemaker-runtime", region_name=AWS_REGION)
10+
11+
texts = [
12+
# English
13+
"I absolutely love the new design of this app!",
14+
"The customer service was disappointing.",
15+
"The weather is fine, nothing special.",
16+
# Chinese
17+
"这家餐厅的菜味道非常棒!",
18+
"我对他的回答很失望。",
19+
"天气今天一般。",
20+
# Spanish
21+
"¡Me encanta cómo quedó la decoración!",
22+
"El servicio fue terrible y muy lento.",
23+
"El libro estuvo más o menos.",
24+
# Arabic
25+
"الخدمة في هذا الفندق رائعة جدًا!",
26+
"لم يعجبني الطعام في هذا المطعم.",
27+
"كانت الرحلة عادية。",
28+
# Ukrainian
29+
"Мені дуже сподобалася ця вистава!",
30+
"Обслуговування було жахливим.",
31+
"Книга була посередньою。",
32+
# Hindi
33+
"यह जगह सच में अद्भुत है!",
34+
"यह अनुभव बहुत खराब था।",
35+
"फिल्म ठीक-ठाक थी।",
36+
# Bengali
37+
"এখানকার পরিবেশ অসাধারণ!",
38+
"সেবার মান একেবারেই খারাপ।",
39+
"খাবারটা মোটামুটি ছিল।",
40+
# Portuguese
41+
"Este livro é fantástico! Eu aprendi muitas coisas novas e inspiradoras.",
42+
"Não gostei do produto, veio quebrado.",
43+
"O filme foi ok, nada de especial.",
44+
# Japanese
45+
"このレストランの料理は本当に美味しいです!",
46+
"このホテルのサービスはがっかりしました。",
47+
"天気はまあまあです。",
48+
# Russian
49+
"Я в восторге от этого нового гаджета!",
50+
"Этот сервис оставил у меня только разочарование.",
51+
"Встреча была обычной, ничего особенного.",
52+
# French
53+
"J'adore ce restaurant, c'est excellent !",
54+
"L'attente était trop longue et frustrante.",
55+
"Le film était moyen, sans plus.",
56+
# Turkish
57+
"Bu otelin manzarasına bayıldım!",
58+
"Ürün tam bir hayal kırıklığıydı.",
59+
"Konser fena değildi, ortalamaydı.",
60+
# Italian
61+
"Adoro questo posto, è fantastico!",
62+
"Il servizio clienti è stato pessimo.",
63+
"La cena era nella media.",
64+
# Polish
65+
"Uwielbiam tę restaurację, jedzenie jest świetne!",
66+
"Obsługa klienta była rozczarowująca.",
67+
"Pogoda jest w porządku, nic szczególnego.",
68+
# Tagalog
69+
"Ang ganda ng lugar na ito, sobrang aliwalas!",
70+
"Hindi maganda ang serbisyo nila dito.",
71+
"Maayos lang ang palabas, walang espesyal.",
72+
# Dutch
73+
"Ik ben echt blij met mijn nieuwe aankoop!",
74+
"De klantenservice was echt slecht.",
75+
"De presentatie was gewoon oké, niet bijzonder.",
76+
# Malay
77+
"Saya suka makanan di sini, sangat sedap!",
78+
"Pengalaman ini sangat mengecewakan.",
79+
"Hari ini cuacanya biasa sahaja.",
80+
# Korean
81+
"이 가게의 케이크는 정말 맛있어요!",
82+
"서비스가 너무 별로였어요.",
83+
"날씨가 그저 그렇네요.",
84+
# Swiss German
85+
"Ich find dä Service i de Beiz mega guet!",
86+
"Däs Esä het mir nöd gfalle.",
87+
"D Wätter hüt isch so naja.",
88+
]
89+
90+
start = time.time()
91+
92+
response = sagemaker_runtime.invoke_endpoint(
93+
EndpointName=ENDPOINT_NAME,
94+
ContentType="application/json",
95+
Body=json.dumps({"inputs": texts}),
96+
)
97+
98+
duration = time.time() - start
99+
100+
result = json.loads(response["Body"].read())
101+
for text, sentiment in zip(texts, result):
102+
print(f"Text: {text}")
103+
print(f"Sentiment: {sentiment}")
104+
print()
105+
106+
print(f"Duration: {duration:.2f}s for {len(texts)} texts")

test_model/uv.lock

Lines changed: 143 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)