alfraser commited on
Commit
eb8e0a0
·
1 Parent(s): 8f8b146

Reviewed comments and type hints

Browse files
Files changed (1) hide show
  1. src/common.py +11 -1
src/common.py CHANGED
@@ -55,6 +55,7 @@ def hf_api_token(write: bool = False) -> str:
55
  return token
56
 
57
 
 
58
  HF_RUNNING = 'running'
59
  HF_SCALEDTOZERO = 'scaleToZero'
60
  HF_PAUSED = 'paused'
@@ -64,7 +65,8 @@ HF_FAILED = 'failed'
64
  def hf_endpoint_status(username: str, endpoint_name: str, api_token: str = None) -> Tuple[bool, bool]:
65
  """
66
  Utility to check the status of a hugging face inference endpoint
67
- :return: tuple of booleans first is if it is available, second is if it fully shutdown. False, True indicates it is not fully available or fully shutdown so is in process of starting up or shutting down
 
68
  """
69
  url = f'https://api.endpoints.huggingface.cloud/v2/endpoint/{username}/{endpoint_name}'
70
  if api_token is None:
@@ -78,6 +80,10 @@ def hf_endpoint_status(username: str, endpoint_name: str, api_token: str = None)
78
 
79
 
80
  def pause_hf_endpoint(username: str, endpoint_name: str, api_token: str = None) -> None:
 
 
 
 
81
  url = f'https://api.endpoints.huggingface.cloud/v2/endpoint/{username}/{endpoint_name}/pause'
82
  if api_token is None:
83
  api_token = hf_api_token(write=True)
@@ -85,6 +91,10 @@ def pause_hf_endpoint(username: str, endpoint_name: str, api_token: str = None)
85
 
86
 
87
  def resume_hf_endpoint(username: str, endpoint_name: str, api_token: str = None) -> None:
 
 
 
 
88
  url = f'https://api.endpoints.huggingface.cloud/v2/endpoint/{username}/{endpoint_name}/resume'
89
  if api_token is None:
90
  api_token = hf_api_token(write=True)
 
55
  return token
56
 
57
 
58
+ # Constants for the status values returned from Hugging Face
59
  HF_RUNNING = 'running'
60
  HF_SCALEDTOZERO = 'scaleToZero'
61
  HF_PAUSED = 'paused'
 
65
  def hf_endpoint_status(username: str, endpoint_name: str, api_token: str = None) -> Tuple[bool, bool]:
66
  """
67
  Utility to check the status of a hugging face inference endpoint
68
+ :return: tuple of booleans first is if it is available, second is if it fully shutdown.
69
+ False, True indicates it is not fully available or fully shutdown so is in process of starting up or shutting down
70
  """
71
  url = f'https://api.endpoints.huggingface.cloud/v2/endpoint/{username}/{endpoint_name}'
72
  if api_token is None:
 
80
 
81
 
82
  def pause_hf_endpoint(username: str, endpoint_name: str, api_token: str = None) -> None:
83
+ """
84
+ Utility to pause a hf inference endpoint via API call. Username and endpoint fully qualify the endpoing on
85
+ hugging face
86
+ """
87
  url = f'https://api.endpoints.huggingface.cloud/v2/endpoint/{username}/{endpoint_name}/pause'
88
  if api_token is None:
89
  api_token = hf_api_token(write=True)
 
91
 
92
 
93
  def resume_hf_endpoint(username: str, endpoint_name: str, api_token: str = None) -> None:
94
+ """
95
+ Utility to resume a hf inference endpoint via API call. Username and endpoint fully qualify the endpoing on
96
+ hugging face
97
+ """
98
  url = f'https://api.endpoints.huggingface.cloud/v2/endpoint/{username}/{endpoint_name}/resume'
99
  if api_token is None:
100
  api_token = hf_api_token(write=True)