AWS_SageMaker_with_Python
AWS_SageMaker_with_Python
2. Step-by-Step Implementation
access_key = 'YOUR_ACCESS_KEY'
secret_key = 'YOUR_SECRET_KEY'
region = 'us-east-1'
service = 'sagemaker'
headers = {
'Content-Type': 'application/json'
}
if response.status_code == 200:
print("Response: ", response.json())
else:
print("Error: ", response.status_code, response.text)
```
Complete Code:
```python
import requests
import json
from requests_aws4auth import AWS4Auth
access_key = 'YOUR_ACCESS_KEY'
secret_key = 'YOUR_SECRET_KEY'
region = 'us-east-1'
service = 'sagemaker'
endpoint_url = 'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/your-
endpoint/invocations'
input_payload = {
"inputs": "Your input text here"
}
headers = {
'Content-Type': 'application/json'
}
if response.status_code == 200:
print("Response: ", response.json())
else:
print("Error: ", response.status_code, response.text)
```
3. Advantages
- Scalability: Automatically scales to handle large datasets and workloads.
- Integration: Easily integrates with other AWS services.
- Flexibility: Supports multiple machine learning frameworks.
- Cost-Effective: Pay only for the resources you use.
- Managed Environment: Simplifies the process of model training, deployment, and
management.
4. Disadvantages
- Complexity: May require a steep learning curve for beginners.
- Cost: Can become expensive with large-scale operations.
- Vendor Lock-In: Dependency on AWS services can make migration difficult.
import requests
import json
access_key = 'AKIAZI2LGGNXZWWP7UGU'
secret_key = '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'
region = 'us-east-1'
service = 'sagemaker'
endpoint_url = 'https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/canvas-meta/
invocations'
input_payload = {
"inputs": "what is zoho"
# Define headers
headers = {
'Content-Type': 'application/json'
if response.status_code == 200:
else:
Output_------
PS D:\sahibfolder> &
C:/Users/Sahib/AppData/Local/Programs/Python/Python310/python.exe
d:/sahibfolder/openai.py
PS D:\sahibfolder>