Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making this work with stable Covalent #93

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
with:
persist-credentials: false
fetch-depth: 0
ref: post-qelectron-fixes

- name: Setup QEMU
uses: docker/setup-qemu-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ scratch
**/*.tfstate*
**/.terraform.lock.hcl
**/*.tfvars
**/*.plan
**/*.plan
2 changes: 1 addition & 1 deletion covalent_awslambda_plugin/assets/infra/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

variable "name" {
default = "covalent-lambda"
default = "sankalp-covalent-lambda"
description = "Prefix to use for all provisioned resources"
}

Expand Down
2 changes: 1 addition & 1 deletion covalent_awslambda_plugin/assets/infra/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.17.0"
version = "~> 5.17.0"
}
}
}
14 changes: 13 additions & 1 deletion covalent_awslambda_plugin/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import json
import os
import sys
import traceback
from unittest.mock import MagicMock

import boto3
import cloudpickle as pickle
Expand All @@ -40,6 +43,9 @@ def handler(event, context):
s3 = boto3.client("s3")
s3.download_file(s3_bucket, func_filename, local_func_filename)

# Patching mpire to avoid issues with multiprocessing on AWS Lambda
sys.modules["mpire"] = MagicMock()

with open(local_func_filename, "rb") as f:
function, args, kwargs = pickle.load(f)

Expand All @@ -49,8 +55,14 @@ def handler(event, context):

s3.upload_file(local_result_filename, s3_bucket, result_filename)
except Exception as ex:

# Capture the full traceback
tb = "".join(traceback.TracebackException.from_exception(ex).format())

# Write json and upload to S3
with open(local_exception_filename, "w") as f:
json.dump(str(ex), f)
json.dump(tb, f)

s3.upload_file(local_exception_filename, s3_bucket, exception_filename)

raise ex
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
boto3==1.24.35
covalent-aws-plugins>=0.12.0,<1
boto3>=1.28.5
covalent-aws-plugins>=0.19.0,<1