Skip to content

Commit

Permalink
chore: fix deployment test
Browse files Browse the repository at this point in the history
Deployment tests were broken due to conflicting strings.
Adding unique ids to the name of the instance, security groups, etc
should solve this.
  • Loading branch information
fd0r committed Jun 1, 2023
1 parent abfcc1d commit 9c406fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/concrete/ml/deployment/deploy_to_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
import subprocess
import time
import uuid
import zipfile
from contextlib import closing
from datetime import datetime
Expand Down Expand Up @@ -126,7 +127,11 @@ def create_instance(
with closing(boto3.client("ec2", region_name=region_name)) as client:
resources = boto3.resource("ec2", region_name=region_name)
str_now = datetime.now().strftime(DATE_FORMAT)
name = f"deploy-cml-{str_now}" if instance_name is None else f"{instance_name}-{str_now}"
name = (
f"deploy-cml-{str_now}-{uuid.uuid4()}"
if instance_name is None
else f"{instance_name}-{str_now}"
)

# Get VPC
vpc_id: str = client.describe_vpcs().get("Vpcs", [{}])[0].get("VpcId", "")
Expand Down
5 changes: 3 additions & 2 deletions tests/deployment/test_deployment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test deployment."""
import io
import time
import uuid
import warnings
from pathlib import Path

Expand Down Expand Up @@ -42,7 +43,7 @@ def test_instance_management():
with AWSInstance(
instance_type="t3.nano",
region_name="eu-west-3",
instance_name="cml_test_aws_deploy",
instance_name=f"cml_test_aws_deploy-{uuid.uuid4()}",
verbose=True,
) as metadata:
time.sleep(1)
Expand Down Expand Up @@ -94,7 +95,7 @@ def test_deploy(load_data, tmp_path): # pylint: disable=too-many-locals,too-man

with AWSInstance(
instance_type="c5.large",
instance_name="cml_test_aws_deploy",
instance_name=f"cml_test_aws_deploy-{uuid.uuid4()}",
open_port=5000,
region_name="eu-west-3",
verbose=True,
Expand Down

0 comments on commit 9c406fc

Please sign in to comment.