Skip to content

Commit

Permalink
fix(vllm): Ensure appropriate errors are raised
Browse files Browse the repository at this point in the history
  • Loading branch information
bramelfrink committed Oct 9, 2024
1 parent 8cef40e commit bcd7729
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions src/damavand/cloud/aws/resources/vllm_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,6 @@ def api_resource_chat(self) -> aws.apigateway.Resource:
def api_resource_completions(self) -> aws.apigateway.Resource:
"""
Return a resource for the API Gateway.
Raises
------
AttributeError
When public_internet_access is False.
"""

return aws.apigateway.Resource(
Expand Down Expand Up @@ -374,7 +369,16 @@ def api_method(self) -> aws.apigateway.Method:
def admin_api_key(self) -> aws.apigateway.ApiKey:
"""
Return the admin API key for the API Gateway
Raises
------
AttributeError
When public_internet_access is True.
"""
if self.args.public_internet_access:
raise AttributeError("`admin_api_key` is only available when public_internet_access is False")

return aws.apigateway.ApiKey(
resource_name=f"{self._name}-api-key",
opts=ResourceOptions(parent=self),
Expand All @@ -385,7 +389,15 @@ def admin_api_key(self) -> aws.apigateway.ApiKey:
def api_key_secret(self) -> aws.secretsmanager.Secret:
"""
Return the secret for the API key
Raises
------
AttributeError
When public_internet_access is True.
"""
if self.args.public_internet_access:
raise AttributeError("`admin_api_secret` is only available when public_internet_access is False")

return aws.secretsmanager.Secret(
resource_name=f"{self._name}-api-key-secret",
Expand All @@ -397,7 +409,14 @@ def api_key_secret(self) -> aws.secretsmanager.Secret:
def api_key_secret_version(self) -> aws.secretsmanager.SecretVersion:
"""
Return the secret version for the API key
Raises
------
AttributeError
When public_internet_access is True.
"""
if self.args.public_internet_access:
raise AttributeError("`api_key_secret_version` is only available when public_internet_access is False")

return aws.secretsmanager.SecretVersion(
resource_name=f"{self._name}-api-key-secret-version",
Expand All @@ -412,7 +431,14 @@ def api_key_secret_version(self) -> aws.secretsmanager.SecretVersion:
def default_usage_plan(self) -> aws.apigateway.UsagePlan:
"""
Return a default usage plan for the API Gateway, that does not limit the usage.
Raises
------
AttributeError
When public_internet_access is True.
"""
if self.args.public_internet_access:
raise AttributeError("`default_usage_plan` is only available when public_internet_access is False")

return aws.apigateway.UsagePlan(
resource_name=f"{self._name}-api-usage-plan",
Expand All @@ -432,7 +458,14 @@ def default_usage_plan(self) -> aws.apigateway.UsagePlan:
def api_key_usage_plan(self) -> aws.apigateway.UsagePlanKey:
"""
Return the usage plan key for the API Gateway
Raises
------
AttributeError
When public_internet_access is True.
"""
if self.args.public_internet_access:
raise AttributeError("`api_key_usage_plan` is only available when public_internet_access is False")

return aws.apigateway.UsagePlanKey(
resource_name=f"{self._name}-api-usage-plan-key",
Expand Down

0 comments on commit bcd7729

Please sign in to comment.