Skip to content
Merged
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Face
## Prerequisites
The following is required to run this example:
- [git](https://git-scm.com/)
- [AWS CDK](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html)
- [AWS CDK v2](https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html)
- [Python](https://www.python.org/) 3.6+
- [A virtual env](https://docs.python.org/3/library/venv.html#module-venv) (optional)

Expand Down Expand Up @@ -111,7 +111,7 @@ cached model:
```python
fs = efs.FileSystem(self, 'FileSystem',
vpc=vpc,
removal_policy=cdk.RemovalPolicy.DESTROY)
removal_policy=RemovalPolicy.DESTROY)
access_point = fs.add_access_point('MLAccessPoint',
create_acl=efs.Acl(
owner_gid='1001', owner_uid='1001', permissions='750'),
Expand All @@ -134,7 +134,7 @@ function = lambda_.DockerImageFunction(
code=lambda_.DockerImageCode.from_image_asset(docker_folder,
cmd=[filename+".handler"]),
memory_size=8096,
timeout=cdk.Duration.seconds(600),
timeout=Duration.seconds(600),
vpc=vpc,
filesystem=lambda_.FileSystem.from_efs_access_point(
access_point, '/mnt/hf_models_cache'),
Expand Down
16 changes: 8 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
aws_lambda as lambda_,
aws_apigateway as api_gw,
aws_efs as efs,
aws_ec2 as ec2,
core as cdk
aws_ec2 as ec2
)
from aws_cdk import App, Stack, Duration, RemovalPolicy
from constructs import Construct


class ServerlessHuggingFaceStack(cdk.Stack):
def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
class ServerlessHuggingFaceStack(Stack):
def __init__(self, scope: Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)

# EFS needs to be setup in a VPC
Expand All @@ -24,7 +24,7 @@ def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
# creates a file system in EFS to store cache models
fs = efs.FileSystem(self, 'FileSystem',
vpc=vpc,
removal_policy=cdk.RemovalPolicy.DESTROY)
removal_policy=RemovalPolicy.DESTROY)
access_point = fs.add_access_point('MLAccessPoint',
create_acl=efs.Acl(
owner_gid='1001', owner_uid='1001', permissions='750'),
Expand All @@ -46,7 +46,7 @@ def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
filename+".handler"]
),
memory_size=8096,
timeout=cdk.Duration.seconds(600),
timeout=Duration.seconds(600),
vpc=vpc,
filesystem=lambda_.FileSystem.from_efs_access_point(
access_point, '/mnt/hf_models_cache'),
Expand All @@ -62,7 +62,7 @@ def __init__(self, scope: cdk.Construct, id: str, **kwargs) -> None:
})
])

app = cdk.App()
app = App()

ServerlessHuggingFaceStack(app, "ServerlessHuggingFaceStack")

Expand Down
3 changes: 1 addition & 2 deletions cdk.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"app": "python3 app.py",
"app": "python3.9 app.py",
"context": {
"@aws-cdk/core:enableStackNameDuplicates": "true",
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true"
}
Expand Down
6 changes: 2 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
aws-cdk.core
aws-cdk.aws_ecr
aws-cdk.aws_lambda
aws-cdk.aws_apigateway
aws-cdk-lib>=2.0.0
constructs>=10.0.0