diff --git a/CHANGELOG.md b/CHANGELOG.md index 02487c4..d64ef68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated covalent version to use a variable instead of a hard-coded value - Updates __init__ signature kwargs replaced with parent for better documentation. - Changed license to Apache +- Updated AWS terraform provider version to ~> 5.17 +- Covalent version to be installed on the EC2 instance can now be specified by the user - including the ability to specify extras (e.g. `covalent[qiskit]`) + +### Fixed + +- Fixed the lookup of the tfstate file +- Fixed networking due to the provider version update +- Fixed the banner which was broken in README.md when viewed from the PyPi page ## [0.13.1] - 2023-02-09 diff --git a/README.md b/README.md index 986faf1..3a60bab 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@
- +
diff --git a/covalent_ec2_plugin/ec2.py b/covalent_ec2_plugin/ec2.py index 66eba53..1291ec0 100644 --- a/covalent_ec2_plugin/ec2.py +++ b/covalent_ec2_plugin/ec2.py @@ -21,7 +21,7 @@ import os import subprocess from pathlib import Path -from typing import Any, Callable, Coroutine, Dict, List, Tuple, Union +from typing import Dict, List import boto3 from covalent._shared_files import logger @@ -53,9 +53,6 @@ EC2_KEYPAIR_NAME = "covalent-ec2-executor-keypair" EC2_SSH_DIR = "~/.ssh/covalent" -# TODO: Remove this once AWSExecutor has a `covalent_version` attribute -TEMP_COVALENT_VERSION = "0.221.1rc0" - class EC2Executor(SSHExecutor, AWSExecutor): """ @@ -76,6 +73,8 @@ class EC2Executor(SSHExecutor, AWSExecutor): then the execution is run on the local machine. poll_freq: Number of seconds to wait for before retrying the result poll do_cleanup: Whether to delete all the intermediate files or not + covalent_version_to_install: Which version of covalent to be installed on the EC2 instance. Default: "==0.220.0.post2", + it can also include the extras if needed as "[qiskit, braket]==0.220.0.post2" """ _TF_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "infra")) @@ -100,6 +99,7 @@ def __init__( run_local_on_ssh_fail: bool = False, poll_freq: int = 15, do_cleanup: bool = True, + covalent_version_to_install: str = "", # Current stable version ) -> None: username = username or get_config("executors.ec2.username") @@ -142,7 +142,7 @@ def __init__( # TODO: Remove this once AWSExecutor has a `covalent_version` attribute # Setting covalent version to be used in the EC2 instance - self.covalent_version = TEMP_COVALENT_VERSION + self.covalent_version = covalent_version_to_install async def _run_async_subprocess(self, cmd: List[str], cwd=None, log_output: bool = False): @@ -176,7 +176,9 @@ async def _run_async_subprocess(self, cmd: List[str], cwd=None, log_output: bool return proc, stdout, stderr def _get_tf_statefile_path(self, task_metadata: Dict) -> str: - state_file = f"{self.cache_dir}/ec2-{task_metadata['dispatch_id']}-{task_metadata['node_id']}.tfstate" + state_file = ( + f"{self._TF_DIR}/ec2-{task_metadata['dispatch_id']}-{task_metadata['node_id']}.tfstate" + ) return state_file async def _get_tf_output(self, var: str, state_file: str) -> str: diff --git a/covalent_ec2_plugin/infra/main.tf b/covalent_ec2_plugin/infra/main.tf index 3eee6f5..ae0f219 100644 --- a/covalent_ec2_plugin/infra/main.tf +++ b/covalent_ec2_plugin/infra/main.tf @@ -78,7 +78,7 @@ resource "null_resource" "deps_install" { "echo 'Installing Covalent...'", # TODO: Update to a variable version - "pip install covalent==${var.covalent_version}", + "pip install \"covalent${var.covalent_version}\"", "chmod +x /tmp/script.sh", "sudo bash /tmp/script.sh", "echo ok" diff --git a/covalent_ec2_plugin/infra/networking.tf b/covalent_ec2_plugin/infra/networking.tf index 3bd2e18..131122c 100644 --- a/covalent_ec2_plugin/infra/networking.tf +++ b/covalent_ec2_plugin/infra/networking.tf @@ -32,6 +32,7 @@ module "vpc" { enable_nat_gateway = false single_nat_gateway = false enable_dns_hostnames = true + map_public_ip_on_launch = true } data "http" "myip" { diff --git a/covalent_ec2_plugin/infra/variables.tf b/covalent_ec2_plugin/infra/variables.tf index 40a7e04..2b42afb 100644 --- a/covalent_ec2_plugin/infra/variables.tf +++ b/covalent_ec2_plugin/infra/variables.tf @@ -80,6 +80,6 @@ variable "key_file" { } variable "covalent_version" { - default = "0.202.0" + default = "" description = "Covalent version to install on the EC2 instance" } diff --git a/covalent_ec2_plugin/infra/versions.tf b/covalent_ec2_plugin/infra/versions.tf index e8fcb17..af04ad3 100644 --- a/covalent_ec2_plugin/infra/versions.tf +++ b/covalent_ec2_plugin/infra/versions.tf @@ -2,8 +2,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = "~> 4.23" + version = "~> 5.17" } } - required_version = ">= 1.1.7" }