Skip to content

Commit

Permalink
Fixes for PyPi release (#50)
Browse files Browse the repository at this point in the history
* Updated broken banner image on PyPi

* fixed and tested

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updated changelog

* Update ec2.py

* Update variables.tf

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
kessler-frost and pre-commit-ci[bot] authored Nov 1, 2023
1 parent 43b56dc commit dfb5e75
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div align="center">

<img src="https://github.com/AgnostiqHQ/covalent-ec2-plugin/blob/main/assets/ec2_readme_banner.jpg" width=150%>
<img src="https://raw.githubusercontent.com/AgnostiqHQ/covalent-ec2-plugin/main/assets/ec2_readme_banner.jpg" width=150%>

</div>

Expand Down
14 changes: 8 additions & 6 deletions covalent_ec2_plugin/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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"))
Expand All @@ -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")
Expand Down Expand Up @@ -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):

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion covalent_ec2_plugin/infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions covalent_ec2_plugin/infra/networking.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion covalent_ec2_plugin/infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ variable "key_file" {
}

variable "covalent_version" {
default = "0.202.0"
default = ""
description = "Covalent version to install on the EC2 instance"
}
3 changes: 1 addition & 2 deletions covalent_ec2_plugin/infra/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.23"
version = "~> 5.17"
}
}
required_version = ">= 1.1.7"
}

0 comments on commit dfb5e75

Please sign in to comment.