diff --git a/dask_cloudprovider/aws/helper.py b/dask_cloudprovider/aws/helper.py index e93ca13a..4b3ace4a 100644 --- a/dask_cloudprovider/aws/helper.py +++ b/dask_cloudprovider/aws/helper.py @@ -82,7 +82,7 @@ async def get_security_group(client, vpc, create_default=True): if create_default: try: return await create_default_security_group( - client, DEFAULT_SECURITY_GROUP_NAME, vpc + client, DEFAULT_SECURITY_GROUP_NAME, vpc, tags=None ) except Exception as e: raise RuntimeError( @@ -95,20 +95,20 @@ async def get_security_group(client, vpc, create_default=True): async def create_default_security_group(client, group_name, vpc, tags): + tag_list = [{"Key": k, "Value": v} for k, v in (tags or {}).items() if k and v] response = await client.create_security_group( Description="A default security group for Dask", GroupName=group_name, VpcId=vpc, - TagSpecifications=[ + **( { - "ResourceType": "security-group", - "Tags": [ - {"Key": k, "Value": v} - for k, v in (tags or {}).items() - if k and v # Filter out empty tags - ], + "TagSpecifications": [ + {"ResourceType": "security-group", "Tags": tag_list} + ] } - ], + if tag_list + else {} + ), DryRun=False, ) diff --git a/dask_cloudprovider/aws/tests/test_ec2.py b/dask_cloudprovider/aws/tests/test_ec2.py index 496ed073..896aabc6 100644 --- a/dask_cloudprovider/aws/tests/test_ec2.py +++ b/dask_cloudprovider/aws/tests/test_ec2.py @@ -24,7 +24,6 @@ async def skip_without_credentials(): @pytest.fixture -@pytest.mark.external async def cluster(): await skip_without_credentials() async with EC2Cluster(asynchronous=True) as cluster: @@ -32,7 +31,6 @@ async def cluster(): @pytest.fixture -@pytest.mark.external async def cluster_sync(): await skip_without_credentials() cluster = EC2Cluster() @@ -40,7 +38,6 @@ async def cluster_sync(): @pytest.fixture -@pytest.mark.external async def cluster_rapids(): await skip_without_credentials() async with EC2Cluster( @@ -57,7 +54,6 @@ async def cluster_rapids(): @pytest.fixture -@pytest.mark.external async def cluster_rapids_packer(): await skip_without_credentials() async with EC2Cluster( @@ -74,7 +70,6 @@ async def cluster_rapids_packer(): @pytest.fixture -@pytest.mark.external async def cluster_packer(): await skip_without_credentials() async with EC2Cluster( @@ -99,6 +94,7 @@ async def test_init(): @pytest.mark.asyncio @pytest.mark.timeout(600) +@pytest.mark.external async def test_create_cluster(cluster): assert cluster.status == Status.running @@ -113,6 +109,7 @@ async def test_create_cluster(cluster): @pytest.mark.asyncio @pytest.mark.timeout(600) +@pytest.mark.external async def test_create_cluster_sync(cluster_sync): assert cluster_sync.status == Status.running @@ -125,6 +122,7 @@ async def test_create_cluster_sync(cluster_sync): @pytest.mark.asyncio @pytest.mark.timeout(600) +@pytest.mark.external async def test_create_cluster_with_packer(cluster_packer): assert cluster_packer.status == Status.running @@ -139,6 +137,7 @@ async def test_create_cluster_with_packer(cluster_packer): @pytest.mark.asyncio @pytest.mark.timeout(1200) +@pytest.mark.external async def test_create_rapids_cluster(cluster_rapids): assert cluster_rapids.status == Status.running @@ -158,6 +157,7 @@ def f(): @pytest.mark.asyncio @pytest.mark.timeout(1200) +@pytest.mark.external async def test_create_rapids_cluster_with_packer(cluster_rapids_packer): assert cluster_rapids_packer.status == Status.running diff --git a/dask_cloudprovider/digitalocean/tests/test_droplet.py b/dask_cloudprovider/digitalocean/tests/test_droplet.py index 8be129eb..a67af99f 100644 --- a/dask_cloudprovider/digitalocean/tests/test_droplet.py +++ b/dask_cloudprovider/digitalocean/tests/test_droplet.py @@ -36,7 +36,6 @@ async def config(): @pytest.fixture -@pytest.mark.external async def cluster(config): await skip_without_credentials(config) async with DropletCluster(asynchronous=True) as cluster: diff --git a/dask_cloudprovider/hetzner/tests/test_vserver.py b/dask_cloudprovider/hetzner/tests/test_vserver.py index c1b2af54..a23788bb 100644 --- a/dask_cloudprovider/hetzner/tests/test_vserver.py +++ b/dask_cloudprovider/hetzner/tests/test_vserver.py @@ -36,7 +36,6 @@ async def config(): @pytest.fixture -@pytest.mark.external async def cluster(config): await skip_without_credentials(config) async with HetznerCluster(asynchronous=True) as cluster: @@ -51,6 +50,7 @@ async def test_init(): @pytest.mark.asyncio @pytest.mark.timeout(600) +@pytest.mark.external async def test_create_cluster(cluster): assert cluster.status == Status.running diff --git a/dask_cloudprovider/nebius/tests/test_nebius.py b/dask_cloudprovider/nebius/tests/test_nebius.py index 0d83c21e..fd115bd5 100644 --- a/dask_cloudprovider/nebius/tests/test_nebius.py +++ b/dask_cloudprovider/nebius/tests/test_nebius.py @@ -40,7 +40,6 @@ async def config(): @pytest.fixture -@pytest.mark.external async def cluster(config): await skip_without_credentials(config) async with NebiusCluster(asynchronous=True, debug=True) as cluster: diff --git a/dask_cloudprovider/openstack/tests/test_instances.py b/dask_cloudprovider/openstack/tests/test_instances.py index eae815bf..c71b9f26 100644 --- a/dask_cloudprovider/openstack/tests/test_instances.py +++ b/dask_cloudprovider/openstack/tests/test_instances.py @@ -34,7 +34,6 @@ async def config(): @pytest.fixture -@pytest.mark.external async def cluster(config): await skip_without_credentials(config) @@ -50,6 +49,7 @@ async def test_init(): @pytest.mark.asyncio @pytest.mark.timeout(600) +@pytest.mark.external async def test_create_cluster(cluster): assert cluster.status == Status.running cluster.scale(1)