Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def main(args, loglevel):
instance_thread.start()

while True:
active_endpoints = list_sagemaker_endpoints()
active_endpoints = list_sagemaker_endpoints(onlyActive=True)
questions = [
inquirer.List(
'action',
Expand Down
6 changes: 4 additions & 2 deletions src/sagemaker/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import List, Tuple, Dict, Optional


def list_sagemaker_endpoints(filter_str: str = None) -> List[str]:
def list_sagemaker_endpoints(filter_str: str = None, onlyActive: bool = False) -> List[str]:
sagemaker_client = boto3.client('sagemaker')

endpoints = sagemaker_client.list_endpoints()['Endpoints']
Expand All @@ -17,12 +17,14 @@ def list_sagemaker_endpoints(filter_str: str = None) -> List[str]:
x['EndpointName'], endpoints))

for endpoint in endpoints:
# The 'InService' state indicates that the endpoint is ready to accept requests.
if onlyActive and ('EndpointStatus' not in endpoint or endpoint['EndpointStatus'] != 'InService'):
continue
endpoint_config = sagemaker_client.describe_endpoint_config(
EndpointConfigName=endpoint['EndpointName'])['ProductionVariants'][0]
endpoint['InstanceType'] = endpoint_config['InstanceType']
return endpoints


def get_sagemaker_endpoint(endpoint_name: str) -> Optional[Dict[str, Optional[Dict]]]:
endpoints = list_sagemaker_endpoints(endpoint_name)
if not endpoints:
Expand Down