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

Support python 3.8 in custom runtime #668

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions api/assistants/deployments/aws/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def get_layers_for_lambda(language):
new_layers.append(
"arn:aws:lambda:us-west-2:134071937287:layer:refinery-python36-custom-runtime:29"
)
elif language == "python3.8":
new_layers.append(
"arn:aws:lambda:us-west-2:134071937287:layer:refinery-python38-custom-runtime:29"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make the change to make this point to the real layer

)
elif language == "ruby2.6.4":
new_layers.append(
"arn:aws:lambda:us-west-2:134071937287:layer:refinery-ruby264-custom-runtime:29"
Expand Down
10 changes: 10 additions & 0 deletions api/assistants/task_spawner/task_spawner_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
start_node810_codebuild,
start_node10163_codebuild, start_node10201_codebuild)
from tasks.build.python import (
start_python38_codebuild,
start_python36_codebuild,
start_python27_codebuild
)
Expand Down Expand Up @@ -614,6 +615,15 @@ def delete_lambda_event_source_mapping(self, credentials, event_source_uuid):
def get_final_zip_package_path(self, language, libraries):
return get_final_zip_package_path(language, libraries)

@run_on_executor
@emit_runtime_metrics("start_python38_codebuild")
def start_python38_codebuild(self, credentials, libraries_object):
return start_python38_codebuild(
self.aws_client_factory,
credentials,
libraries_object
)

@run_on_executor
@emit_runtime_metrics("start_python36_codebuild")
def start_python36_codebuild(self, credentials, libraries_object):
Expand Down
5 changes: 5 additions & 0 deletions api/controller/lambdas/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ def post(self):
credentials,
libraries_dict
)
elif self.json["language"] == "python3.8":
build_id = yield self.task_spawner.start_python38_codebuild(
credentials,
libraries_dict
)
elif self.json["language"] == "nodejs8.10":
build_id = yield self.task_spawner.start_node810_codebuild(
credentials,
Expand Down
27 changes: 27 additions & 0 deletions api/lambda_bases/python3.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import traceback
import json
import sys

def _init():
raw_input_data = sys.stdin.read()
input_data = json.loads( raw_input_data )
lambda_input = input_data[ "lambda_input" ]
backpack = input_data[ "backpack" ]

try:
output = main( lambda_input, backpack )
print( "<REFINERY_OUTPUT_CUSTOM_RUNTIME_START_MARKER>" + json.dumps({
"backpack": backpack,
"output": output,
}) + "<REFINERY_OUTPUT_CUSTOM_RUNTIME_END_MARKER>" )
backpack = {}
except:
print( "<REFINERY_ERROR_OUTPUT_CUSTOM_RUNTIME_START_MARKER>" + json.dumps({
"backpack": backpack,
"output": traceback.format_exc()
}) + "<REFINERY_ERROR_OUTPUT_CUSTOM_RUNTIME_END_MARKER>" )
backpack = {}
exit(-1)

exit(0)
_init()
3 changes: 3 additions & 0 deletions api/pyconstants/project_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


LAMBDA_SUPPORTED_LANGUAGES = [
"python3.8",
"python3.6",
"python2.7",
"nodejs8.10",
Expand All @@ -36,11 +37,13 @@
"go1.12",
"python2.7",
"python3.6",
"python3.8",
"ruby2.6.4"
]


LAMBDA_BASE_LIBRARIES: Dict[str, List[str]] = {
"python3.8": [],
"python3.6": [],
"python2.7": [],
"nodejs8.10": [],
Expand Down
10 changes: 9 additions & 1 deletion api/tasks/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tasks.build.golang import get_go_112_base_code
from tasks.build.nodejs import build_nodejs_10163_lambda, build_nodejs_810_lambda, build_nodejs_10201_lambda
from tasks.build.php import build_php_73_lambda
from tasks.build.python import build_python36_lambda, build_python27_lambda
from tasks.build.python import build_python38_lambda, build_python36_lambda, build_python27_lambda
from tasks.s3 import s3_object_exists
from utils.general import logit, log_exception
from utils.wrapped_aws_functions import lambda_list_event_source_mappings, api_gateway_get_rest_api, \
Expand Down Expand Up @@ -220,6 +220,14 @@ def build_lambda(app_config, aws_client_factory, credentials, lambda_object):
lambda_object.code,
lambda_object.libraries
)
elif lambda_object.language == "python3.8":
package_zip_data = build_python38_lambda(
app_config,
aws_client_factory,
credentials,
lambda_object.code,
lambda_object.libraries
)
elif lambda_object.language == "python3.6":
package_zip_data = build_python36_lambda(
app_config,
Expand Down
Loading