From 3b4cca39dcf09f7ba3ec623e6b2524644c962b16 Mon Sep 17 00:00:00 2001 From: Gorav Arora Date: Wed, 3 Oct 2018 21:28:03 -0700 Subject: [PATCH 01/56] Ignore venv directory for virtual environments --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 4b36cff..4f5a7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,6 @@ target/ # Python environment .python-version + +# Vitual Environments +venv/ From f61c0a33a79fa4670874f4469e7ceb76c644bf4b Mon Sep 17 00:00:00 2001 From: Gorav Arora Date: Wed, 3 Oct 2018 21:28:40 -0700 Subject: [PATCH 02/56] Split the parsing of input and the exporting of the variables for reuse --- lambda_local/environment_variables.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lambda_local/environment_variables.py b/lambda_local/environment_variables.py index b518309..ea102bd 100644 --- a/lambda_local/environment_variables.py +++ b/lambda_local/environment_variables.py @@ -2,6 +2,11 @@ import os +def export_variables(environment_variables): + for env_name, env_value in environment_variables.items(): + os.environ[str(env_name)] = str(env_value) + + def set_environment_variables(json_file_path): """ Read and set environment variables from a flat json file. @@ -25,5 +30,4 @@ def set_environment_variables(json_file_path): with open(json_file_path) as json_file: env_vars = json.loads(json_file.read()) - for env_name, env_value in env_vars.items(): - os.environ[str(env_name)] = str(env_value) + export_variables(env_vars) From 45ffcdc1af877625aabc35ee8a173efdab502166 Mon Sep 17 00:00:00 2001 From: Gorav Arora Date: Wed, 3 Oct 2018 21:31:12 -0700 Subject: [PATCH 03/56] Added the function so that lambda functions can be called from pytests. The return value of the functions is returned so the test can check the output. --- lambda_local/main.py | 27 ++++++++++++++--- tests/test_direct_invocations.py | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 tests/test_direct_invocations.py diff --git a/lambda_local/main.py b/lambda_local/main.py index 95d4358..c09146b 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -15,7 +15,7 @@ from . import event from . import context -from .environment_variables import set_environment_variables +from .environment_variables import set_environment_variables, export_variables from .timeout import time_limit from .timeout import TimeoutException @@ -31,6 +31,17 @@ EXITCODE_ERR = 1 +def call(func, event, timeout, environment_variables={}, arn_string="", version_name="", library=None): + export_variables(environment_variables) + e = json.loads(event) + c = context.Context(timeout, arn_string, version_name) + if library is not None: + load_lib(library) + request_id = uuid.uuid4() + + return _runner(request_id, e, c, func) + + def run(args): # set env vars if path to json file was given set_environment_variables(args.environment_variables) @@ -41,16 +52,23 @@ def run(args): load_lib(args.library) request_id = uuid.uuid4() func = load(request_id, args.file, args.function) + + (result, err_type) = _runner(request_id, e, c, func) + + if err_type is not None: + sys.exit(EXITCODE_ERR) + +def _runner(request_id, event, context, func): logger = logging.getLogger() result = None - logger.info("Event: {}".format(e)) + logger.info("Event: {}".format(event)) logger.info("START RequestId: {}".format(request_id)) start_time = timeit.default_timer() - result, err_type = execute(func, e, c) + result, err_type = execute(func, event, context) end_time = timeit.default_timer() logger.info("END RequestId: {}".format(request_id)) @@ -64,8 +82,7 @@ def run(args): logger.info("REPORT RequestId: {}\tDuration: {}".format( request_id, duration)) - if err_type is not None: - sys.exit(EXITCODE_ERR) + return (result, err_type) def load_lib(path): diff --git a/tests/test_direct_invocations.py b/tests/test_direct_invocations.py new file mode 100644 index 0000000..d952981 --- /dev/null +++ b/tests/test_direct_invocations.py @@ -0,0 +1,52 @@ +''' +python-lambda-local: Test Direct Inovactions +(command-line and direct). + +Meant for use with py.test. + +Copyright 2015 HDE, Inc. +Licensed under MIT +''' +import json +import argparse +from multiprocessing import Process +import os +from lambda_local.main import run as lambda_run +from lambda_local.main import call as lambda_call + + +def my_lambda_function(event, context): + print("Hello World from My Lambda Function!") + return 42 + +def test_function_call_for_pytest(): + request = json.dumps({}) + (result, error_type) = lambda_call(func=my_lambda_function, event=request, timeout=1) + + assert error_type is None + + assert result == 42 + + +def test_check_command_line(): + request = json.dumps({}) + request_file = 'check_command_line_event.json' + with open (request_file, "w") as f: + f.write(request) + + args = argparse.Namespace(event=request_file, + file='tests/test_direct_invocations.py', + function='my_lambda_function', + timeout=1, + environment_variables='', + library=None, + version_name='', + arn_string='' + ) + p = Process(target=lambda_run, args=(args,)) + p.start() + p.join() + + os.remove(request_file) + assert p.exitcode == 0 + \ No newline at end of file From 3ac6eec788d798eab95da818290aa2fe7cc30d51 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 23 Oct 2018 11:19:56 +0900 Subject: [PATCH 04/56] Setup encoding. --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 595797c..57d0c90 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ Copyright 2015-2017 HDE, Inc. Licensed under MIT. ''' +import io import sys from setuptools import setup, find_packages from setuptools.command.test import test as TestCommand @@ -27,7 +28,7 @@ def run_tests(self): setup(name="python-lambda-local", version=version, description="Run lambda function in python on local machine.", - long_description=open("README.rst").read(), + long_description=io.open("README.rst", encoding="utf-8").read(), classifiers=[ 'Development Status :: 3 - Alpha', 'Operating System :: POSIX', From f4a84f90f95382929659c5502c4894df7413d457 Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Tue, 23 Oct 2018 11:48:00 +0900 Subject: [PATCH 05/56] Update copyright year and use Python 3.7 --- LICENSE | 2 +- README.md | 2 +- README.rst | 2 +- lambda_local/__init__.py | 2 +- lambda_local/context.py | 2 +- lambda_local/event.py | 2 +- lambda_local/main.py | 2 +- lambda_local/timeout.py | 2 +- setup.py | 4 ++-- wercker.yml | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/LICENSE b/LICENSE index a3a3ed5..c4d8dfd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2017 HDE, Inc. +Copyright (c) 2015-2018 HDE, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index c314974..12ba9f9 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Run lambda function on local machine ## Prepare development environment -Please use a newly created virtualenv of Python 2.7 or Python 3.6 . +Please use a newly created virtualenv of Python 2.7 or Python 3.7. ## Installation diff --git a/README.rst b/README.rst index deb21a0..38756b1 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ Run lambda function on local machine Prepare development environment ------------------------------- -Please use a newly created virtualenv of Python 2.7 or Python 3.6 . +Please use a newly created virtualenv of Python 2.7 or Python 3.7. Installation ------------ diff --git a/lambda_local/__init__.py b/lambda_local/__init__.py index f56a061..eabee17 100644 --- a/lambda_local/__init__.py +++ b/lambda_local/__init__.py @@ -1,7 +1,7 @@ ''' python-lambda-local: Main module -Copyright 2015-2017 HDE, Inc. +Copyright 2015-2018 HDE, Inc. Licensed under MIT. ''' diff --git a/lambda_local/context.py b/lambda_local/context.py index 4be412e..d1288b4 100644 --- a/lambda_local/context.py +++ b/lambda_local/context.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2017 HDE, Inc. +Copyright 2015-2018 HDE, Inc. Licensed under MIT. ''' diff --git a/lambda_local/event.py b/lambda_local/event.py index 3030ff1..3d0f23f 100644 --- a/lambda_local/event.py +++ b/lambda_local/event.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2017 HDE, Inc. +Copyright 2015-2018 HDE, Inc. Licensed under MIT. ''' diff --git a/lambda_local/main.py b/lambda_local/main.py index c09146b..9d97e23 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2017 HDE, Inc. +Copyright 2015-2018 HDE, Inc. Licensed under MIT. ''' diff --git a/lambda_local/timeout.py b/lambda_local/timeout.py index 17646c3..9d0354a 100644 --- a/lambda_local/timeout.py +++ b/lambda_local/timeout.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2017 HDE, Inc. +Copyright 2015-2018 HDE, Inc. Licensed under MIT. ''' diff --git a/setup.py b/setup.py index 57d0c90..6de3121 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ ''' python-lambda-local: Run lambda function in python on local machine. -Copyright 2015-2017 HDE, Inc. +Copyright 2015-2018 HDE, Inc. Licensed under MIT. ''' import io @@ -34,7 +34,7 @@ def run_tests(self): 'Operating System :: POSIX', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'License :: OSI Approved :: MIT License' ], keywords="AWS Lambda", diff --git a/wercker.yml b/wercker.yml index 25613d5..fde1478 100644 --- a/wercker.yml +++ b/wercker.yml @@ -27,7 +27,7 @@ build-py2: python setup.py sdist bdist_wheel build-py3: - box: python:3.6-slim + box: python:3.7-slim steps: - script: name: virtualenv install From a9693f07c9ddc8862d7f9505d847045f46743b95 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 23 Oct 2018 11:51:33 +0900 Subject: [PATCH 06/56] Bump version. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 57d0c90..77f04f1 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def run_tests(self): sys.exit(pytest.main(self.test_args)) -version = "0.1.6" +version = "0.1.7" setup(name="python-lambda-local", version=version, From b92ba32370fe2d3afe57b3f6f821ac90f1af61b1 Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Tue, 23 Oct 2018 11:53:41 +0900 Subject: [PATCH 07/56] Revert to 3.6 --- README.md | 2 +- README.rst | 2 +- wercker.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 12ba9f9..39b34b4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Run lambda function on local machine ## Prepare development environment -Please use a newly created virtualenv of Python 2.7 or Python 3.7. +Please use a newly created virtualenv of Python 2.7 or Python 3.6. ## Installation diff --git a/README.rst b/README.rst index 38756b1..c85b854 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ Run lambda function on local machine Prepare development environment ------------------------------- -Please use a newly created virtualenv of Python 2.7 or Python 3.7. +Please use a newly created virtualenv of Python 2.7 or Python 3.6. Installation ------------ diff --git a/wercker.yml b/wercker.yml index fde1478..25613d5 100644 --- a/wercker.yml +++ b/wercker.yml @@ -27,7 +27,7 @@ build-py2: python setup.py sdist bdist_wheel build-py3: - box: python:3.7-slim + box: python:3.6-slim steps: - script: name: virtualenv install From abf7813742657a248822448cffb04fd7e6f4bb50 Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Tue, 23 Oct 2018 12:04:26 +0900 Subject: [PATCH 08/56] Try running test --- setup.py | 2 +- wercker.yml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6de3121..9dee85f 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def run_tests(self): 'Operating System :: POSIX', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.6', 'License :: OSI Approved :: MIT License' ], keywords="AWS Lambda", diff --git a/wercker.yml b/wercker.yml index 25613d5..7d3c6bf 100644 --- a/wercker.yml +++ b/wercker.yml @@ -26,6 +26,11 @@ build-py2: code: | python setup.py sdist bdist_wheel + - script: + name: test + code: | + python setup.py test + build-py3: box: python:3.6-slim steps: @@ -49,6 +54,11 @@ build-py3: code: | python setup.py sdist bdist_wheel + - script: + name: test + code: | + python setup.py test + deploy: pypi: - script: From 0fa224ba04043d8c45c858a585c8c1227fd4c7be Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Thu, 8 Nov 2018 17:17:12 +0900 Subject: [PATCH 09/56] Fix context implementation. --- lambda_local/context.py | 46 +++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/lambda_local/context.py b/lambda_local/context.py index d1288b4..067dfa0 100644 --- a/lambda_local/context.py +++ b/lambda_local/context.py @@ -2,32 +2,46 @@ Copyright 2015-2018 HDE, Inc. Licensed under MIT. ''' +from __future__ import print_function from datetime import datetime from datetime import timedelta +import uuid class Context(object): - def __init__(self, timeout, arn_string, version_name): - self.function_name = "undefined" - self.function_version = version_name - self.invoked_function_arn = arn_string - self.memory_limit_in_mb = 0 - self.aws_request_id = "undefined" - self.log_group_name = "undefined" - self.log_stream_name = "undefined" - self.identity = None - self.client_context = None - self.timeout = timeout - self.duration = timedelta(seconds=timeout) + def __init__(self, timeout_in_seconds, + aws_request_id=uuid.uuid4(), + function_name="undefined", + function_version="$LATEST", + log_group_name="undefined", + log_stream_name="undefined", + invoked_function_arn="undefined", + memory_limit_in_mb='0', + client_context=None, + identity=None): + self.function_name = function_name + self.function_version = function_version + self.invoked_function_arn = invoked_function_arn + self.memory_limit_in_mb = memory_limit_in_mb + self.aws_request_id = aws_request_id + self.log_group_name = log_group_name + self.log_stream_name = log_stream_name + self.identity = identity + self.client_context = client_context + + self._duration = timedelta(seconds=timeout_in_seconds) def get_remaining_time_in_millis(self): - if self.timelimit is None: + if self._timelimit is None: raise Exception("Context not activated.") - return millis_interval(datetime.now(), self.timelimit) + return millis_interval(datetime.now(), self._timelimit) + + def log(self, msg): + print(msg) - def activate(self): - self.timelimit = datetime.now() + self.duration + def _activate(self): + self._timelimit = datetime.now() + self._duration return self From 980229ff7a9fafc0feaf9cacc355b08a42a053b0 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Thu, 8 Nov 2018 18:07:03 +0900 Subject: [PATCH 10/56] Fix context usage. --- lambda_local/context.py | 1 + lambda_local/main.py | 46 ++++++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lambda_local/context.py b/lambda_local/context.py index 067dfa0..1f21657 100644 --- a/lambda_local/context.py +++ b/lambda_local/context.py @@ -30,6 +30,7 @@ def __init__(self, timeout_in_seconds, self.identity = identity self.client_context = client_context + self._timeout_in_seconds = timeout_in_seconds self._duration = timedelta(seconds=timeout_in_seconds) def get_remaining_time_in_millis(self): diff --git a/lambda_local/main.py b/lambda_local/main.py index 9d97e23..8bc722d 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -31,15 +31,20 @@ EXITCODE_ERR = 1 -def call(func, event, timeout, environment_variables={}, arn_string="", version_name="", library=None): +class ContextFilter(logging.Filter): + def __init__(self, context): + super(ContextFilter, self).__init__() + self.context = context + + def filter(self, record): + record.aws_request_id = self.context.aws_request_id + return True + + +def call(func, event, context, environment_variables={}): export_variables(environment_variables) - e = json.loads(event) - c = context.Context(timeout, arn_string, version_name) - if library is not None: - load_lib(library) - request_id = uuid.uuid4() - return _runner(request_id, e, c, func) + return _runner(func, event, context) def run(args): @@ -47,32 +52,35 @@ def run(args): set_environment_variables(args.environment_variables) e = event.read_event(args.event) - c = context.Context(args.timeout, args.arn_string, args.version_name) + c = context.Context( + args.timeout, + invoked_function_arn=args.arn_string, + function_version=args.version_name) if args.library is not None: load_lib(args.library) - request_id = uuid.uuid4() - func = load(request_id, args.file, args.function) - - (result, err_type) = _runner(request_id, e, c, func) + func = load(c.aws_request_id, args.file, args.function) + + (result, err_type) = _runner(func, e, c) if err_type is not None: sys.exit(EXITCODE_ERR) -def _runner(request_id, event, context, func): +def _runner(func, event, context): logger = logging.getLogger() + log_filter = ContextFilter(context) + logger.addFilter(log_filter) + result = None logger.info("Event: {}".format(event)) - - logger.info("START RequestId: {}".format(request_id)) + logger.info("START RequestId: {}".format(context.aws_request_id)) start_time = timeit.default_timer() result, err_type = execute(func, event, context) end_time = timeit.default_timer() - logger.info("END RequestId: {}".format(request_id)) - + logger.info("END RequestId: {}".format(context.aws_request_id)) if type(result) is TimeoutException: logger.error("RESULT:\n{}".format(result)) else: @@ -80,7 +88,7 @@ def _runner(request_id, event, context, func): duration = "{0:.2f} ms".format((end_time - start_time) * 1000) logger.info("REPORT RequestId: {}\tDuration: {}".format( - request_id, duration)) + context.aws_request_id, duration)) return (result, err_type) @@ -105,7 +113,7 @@ def execute(func, event, context): err_type = None try: - with time_limit(context.timeout): + with time_limit(context._timeout_in_seconds): result = func(event, context.activate()) except TimeoutException as err: result = err From bb185c6557c081b46d65f17a890ecaafc74d9da4 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Thu, 8 Nov 2018 19:03:36 +0900 Subject: [PATCH 11/56] Refine process execution. --- lambda_local/__init__.py | 7 +------ lambda_local/main.py | 41 ++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/lambda_local/__init__.py b/lambda_local/__init__.py index eabee17..1c4381b 100644 --- a/lambda_local/__init__.py +++ b/lambda_local/__init__.py @@ -19,12 +19,7 @@ def main(): args = parse_args() - - p = Process(target=run, args=(args,)) - p.start() - p.join() - - sys.exit(p.exitcode) + run(args) def parse_args(): diff --git a/lambda_local/main.py b/lambda_local/main.py index 8bc722d..315962e 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -8,10 +8,10 @@ import traceback import json import logging -import uuid import os import timeit from botocore.vendored.requests.packages import urllib3 +import multiprocessing from . import event from . import context @@ -68,28 +68,28 @@ def run(args): def _runner(func, event, context): logger = logging.getLogger() - log_filter = ContextFilter(context) - logger.addFilter(log_filter) - - result = None logger.info("Event: {}".format(event)) - logger.info("START RequestId: {}".format(context.aws_request_id)) + logger.info("START RequestId: {} Version: {}".format( + context.aws_request_id, context.function_version)) - start_time = timeit.default_timer() - result, err_type = execute(func, event, context) - end_time = timeit.default_timer() + queue = multiprocessing.Queue() + p = multiprocessing.Process( + target=execute_in_process, + args=(queue, func, event, context,)) + p.start() + (result, err_type, duration) = queue.get() + p.join() logger.info("END RequestId: {}".format(context.aws_request_id)) + duration = "{0:.2f} ms".format(duration) + logger.info("REPORT RequestId: {}\tDuration: {}".format( + context.aws_request_id, duration)) if type(result) is TimeoutException: logger.error("RESULT:\n{}".format(result)) else: logger.info("RESULT:\n{}".format(result)) - duration = "{0:.2f} ms".format((end_time - start_time) * 1000) - logger.info("REPORT RequestId: {}\tDuration: {}".format( - context.aws_request_id, duration)) - return (result, err_type) @@ -112,9 +112,13 @@ def load(request_id, path, function_name): def execute(func, event, context): err_type = None + logger = logging.getLogger() + log_filter = ContextFilter(context) + logger.addFilter(log_filter) + try: with time_limit(context._timeout_in_seconds): - result = func(event, context.activate()) + result = func(event, context._activate()) except TimeoutException as err: result = err err_type = ERR_TYPE_TIMEOUT @@ -128,3 +132,12 @@ def execute(func, event, context): err_type = ERR_TYPE_EXCEPTION return result, err_type + + +def execute_in_process(queue, func, event, context): + start_time = timeit.default_timer() + result, err_type = execute(func, event, context) + end_time = timeit.default_timer() + duration = (end_time - start_time) * 1000 + + queue.put((result, err_type, duration)) From 0e4b5db795a0d51f74152fb1a6b3f3dd1c6c6c0e Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Thu, 8 Nov 2018 19:14:13 +0900 Subject: [PATCH 12/56] Fix test. --- tests/test_direct_invocations.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_direct_invocations.py b/tests/test_direct_invocations.py index d952981..129666c 100644 --- a/tests/test_direct_invocations.py +++ b/tests/test_direct_invocations.py @@ -13,15 +13,17 @@ import os from lambda_local.main import run as lambda_run from lambda_local.main import call as lambda_call +from lambda_local.context import Context def my_lambda_function(event, context): print("Hello World from My Lambda Function!") return 42 + def test_function_call_for_pytest(): - request = json.dumps({}) - (result, error_type) = lambda_call(func=my_lambda_function, event=request, timeout=1) + (result, error_type) = lambda_call( + my_lambda_function, {}, Context(1)) assert error_type is None @@ -31,7 +33,7 @@ def test_function_call_for_pytest(): def test_check_command_line(): request = json.dumps({}) request_file = 'check_command_line_event.json' - with open (request_file, "w") as f: + with open(request_file, "w") as f: f.write(request) args = argparse.Namespace(event=request_file, @@ -49,4 +51,3 @@ def test_check_command_line(): os.remove(request_file) assert p.exitcode == 0 - \ No newline at end of file From 03f7e853b243d8ab271695b16b89a0b020a4dd74 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 20 Nov 2018 17:44:53 +0900 Subject: [PATCH 13/56] Update readme. --- README.md | 48 +++++++++++--- README.rst | 181 ++++++++++++++++++++++++++++++++--------------------- 2 files changed, 152 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 39b34b4..26c2b2c 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,14 @@ $ pip install python-lambda-local This will install the package with name `python-lambda-local` in the virtualenv. Now you can use the command `python-lambda-local` to run your AWS Lambda function written in Python on your own machine. -## Usage +## Usage as a shell command Run `python-lambda-local -h` to see the help. ``` usage: python-lambda-local [-h] [-l LIBRARY_PATH] [-f HANDLER_FUNCTION] [-t TIMEOUT] [-a ARN_STRING] [-v VERSION_NAME] - [--version] + [-e ENVIRONMENT_VARIABLES] [--version] FILE EVENT Run AWS Lambda function written in Python on local machine. @@ -118,16 +118,50 @@ python-lambda-local -l lib/ -f handler -t 5 test.py event.json The output will be like: ``` -[root - INFO - 2017-04-19 12:39:05,512] Event: {u'answer': 42} -[root - INFO - 2017-04-19 12:39:05,512] START RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 +[root - INFO - 2018-11-20 17:10:53,352] Event: {'answer': 42} +[root - INFO - 2018-11-20 17:10:53,352] START RequestId: 3c8e6db4-886a-43da-a1c7-5e6f715de531 Version: 0 49 196 441 784 1225 -[root - INFO - 2017-04-19 12:39:05,515] END RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 -[root - INFO - 2017-04-19 12:39:05,515] RESULT: +[root - INFO - 2018-11-20 17:10:53,359] END RequestId: 3c8e6db4-886a-43da-a1c7-5e6f715de531 +[root - INFO - 2018-11-20 17:10:53,360] REPORT RequestId: 3c8e6db4-886a-43da-a1c7-5e6f715de531 Duration: 2.17 ms +[root - INFO - 2018-11-20 17:10:53,360] RESULT: None -[root - INFO - 2017-04-19 12:39:05,515] REPORT RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 Duration: 2.27 ms +``` + +## Usage as a library + +### API signature + +``` python +call(func, event, context, environment_variables={}) +``` + +Call a handler function `func` with given `event`, `context` and custom `environment_variables`. + +### Sample + +1. Make sure the 3rd party libraries used in the AWS Lambda function can be imported. + +``` bash +pip install rx +``` + +2. To call the lambda function above with your python code: + +``` python +from lambda_local.main import call +from lambda_local.context import Context + +import test + +event = { + "answer": 42 +} +context = Context(5) + +call(test.handler, event, context) ``` diff --git a/README.rst b/README.rst index c85b854..b77f67e 100644 --- a/README.rst +++ b/README.rst @@ -18,43 +18,45 @@ Within virtualenv, run the following command. .. code:: bash - $ pip install python-lambda-local + $ pip install python-lambda-local This will install the package with name ``python-lambda-local`` in the virtualenv. Now you can use the command ``python-lambda-local`` to run your AWS Lambda function written in Python on your own machine. -Usage ------ +Usage as a shell command +------------------------ Run ``python-lambda-local -h`` to see the help. :: - usage: python-lambda-local [-h] [-l LIBRARY_PATH] [-f HANDLER_FUNCTION] - [-t TIMEOUT] [-a ARN_STRING] [-v VERSION_NAME] - [--version] - FILE EVENT - - Run AWS Lambda function written in Python on local machine. - - positional arguments: - FILE lambda function file name - EVENT event data file name - - optional arguments: - -h, --help show this help message and exit - -l LIBRARY_PATH, --library LIBRARY_PATH - path of 3rd party libraries - -f HANDLER_FUNCTION, --function HANDLER_FUNCTION - lambda function handler name, default: "handler" - -t TIMEOUT, --timeout TIMEOUT - seconds until lambda function timeout, default: 3 - -a ARN_STRING, --arn-string ARN_STRING - ARN string for lambda function - -v VERSION_NAME, --version-name VERSION_NAME - lambda function version name - --version print the version of python-lambda-local and exit + usage: python-lambda-local [-h] [-l LIBRARY_PATH] [-f HANDLER_FUNCTION] + [-t TIMEOUT] [-a ARN_STRING] [-v VERSION_NAME] + [-e ENVIRONMENT_VARIABLES] [--version] + FILE EVENT + + Run AWS Lambda function written in Python on local machine. + + positional arguments: + FILE lambda function file name + EVENT event data file name + + optional arguments: + -h, --help show this help message and exit + -l LIBRARY_PATH, --library LIBRARY_PATH + path of 3rd party libraries + -f HANDLER_FUNCTION, --function HANDLER_FUNCTION + lambda function handler name, default: "handler" + -t TIMEOUT, --timeout TIMEOUT + seconds until lambda function timeout, default: 3 + -a ARN_STRING, --arn-string ARN_STRING + ARN string for lambda function + -v VERSION_NAME, --version-name VERSION_NAME + lambda function version name + -e ENVIRONMENT_VARIABLES, --environment-variables ENVIRONMENT_VARIABLES + path to flat json file with environment variables + --version print the version of python-lambda-local and exit Prepare development directory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -66,25 +68,25 @@ Suppose your project directory is like this: :: - ├── event.json - ├── lib - │   ├── rx - │   │   ├── abstractobserver.py - │   │   ├── ... (package content of rx) - ... - │   │   └── testscheduler.py - │   └── Rx-1.2.3.dist-info - │   ├── DESCRIPTION.rst - │   ├── METADATA - │   ├── metadata.json - │   ├── pbr.json - │   ├── RECORD - │   ├── top_level.txt - │   ├── WHEEL - │   └── zip-safe - └── test.py - -The handler's code is in ``test.py`` and the function name of the + ├── event.json + ├── lib + │   ├── rx + │   │   ├── abstractobserver.py + │   │   ├── ... (package content of rx) + ... + │   │   └── testscheduler.py + │   └── Rx-1.2.3.dist-info + │   ├── DESCRIPTION.rst + │   ├── METADATA + │   ├── metadata.json + │   ├── pbr.json + │   ├── RECORD + │   ├── top_level.txt + │   ├── WHEEL + │   └── zip-safe + └── test.py + +The handler’s code is in ``test.py`` and the function name of the handler is ``handler``. The source depends on 3rd party library ``rx`` and it is installed in the directory ``lib``. The test event in json format is in ``event.json`` file. @@ -94,25 +96,25 @@ Content of ``test.py``: .. code:: python - from __future__ import print_function - from rx import Observable + from __future__ import print_function + from rx import Observable - def handler(event, context): - xs = Observable.from_(range(event['answer'])) - ys = xs.to_blocking() - zs = (x*x for x in ys if x % 7 == 0) - for x in zs: - print(x) + def handler(event, context): + xs = Observable.from_(range(event['answer'])) + ys = xs.to_blocking() + zs = (x*x for x in ys if x % 7 == 0) + for x in zs: + print(x) Content of ``event.json``: ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code:: json - { - "answer": 42 - } + { + "answer": 42 + } Run the lambda function ^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,24 +124,63 @@ the following command :: - python-lambda-local -l lib/ -f handler -t 5 test.py event.json + python-lambda-local -l lib/ -f handler -t 5 test.py event.json The output will be like: :: - [root - INFO - 2017-04-19 12:39:05,512] Event: {u'answer': 42} - [root - INFO - 2017-04-19 12:39:05,512] START RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 - 0 - 49 - 196 - 441 - 784 - 1225 - [root - INFO - 2017-04-19 12:39:05,515] END RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 - [root - INFO - 2017-04-19 12:39:05,515] RESULT: - None - [root - INFO - 2017-04-19 12:39:05,515] REPORT RequestId: b918f9ae-0ca1-44af-9937-dd5f9eeedcc1 Duration: 2.27 ms + [root - INFO - 2018-11-20 17:10:53,352] Event: {'answer': 42} + [root - INFO - 2018-11-20 17:10:53,352] START RequestId: 3c8e6db4-886a-43da-a1c7-5e6f715de531 Version: + 0 + 49 + 196 + 441 + 784 + 1225 + [root - INFO - 2018-11-20 17:10:53,359] END RequestId: 3c8e6db4-886a-43da-a1c7-5e6f715de531 + [root - INFO - 2018-11-20 17:10:53,360] REPORT RequestId: 3c8e6db4-886a-43da-a1c7-5e6f715de531 Duration: 2.17 ms + [root - INFO - 2018-11-20 17:10:53,360] RESULT: + None + +Usage as a library +------------------ + +API signature +~~~~~~~~~~~~~ + +.. code:: python + + call(func, event, context, environment_variables={}) + +Call a handler function ``func`` with given ``event``, ``context`` and +custom ``environment_variables``. + +Sample +~~~~~~ + +1. Make sure the 3rd party libraries used in the AWS Lambda function can + be imported. + +.. code:: bash + + pip install rx + +2. To call the lambda function above with your python code: + +.. code:: python + + from lambda_local.main import call + from lambda_local.context import Context + + import test + + event = { + "answer": 42 + } + context = Context(5) + + call(test.handler, event, context) .. |Join the chat at https://gitter.im/HDE/python-lambda-local| image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/HDE/python-lambda-local?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge From 1ef03a1d3ca579596440aaf7eec2946704f08da4 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 20 Nov 2018 17:45:07 +0900 Subject: [PATCH 14/56] Remove unused import. --- lambda_local/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lambda_local/__init__.py b/lambda_local/__init__.py index 1c4381b..45b457b 100644 --- a/lambda_local/__init__.py +++ b/lambda_local/__init__.py @@ -7,13 +7,10 @@ from __future__ import print_function import argparse -import sys -from multiprocessing import Process import pkg_resources from .main import run - __version__ = pkg_resources.require("python-lambda-local")[0].version From 7fe2d75cf05a3cb5569f09a27eedee5343289938 Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Wed, 30 Jan 2019 18:42:16 +0900 Subject: [PATCH 15/56] Bump version to 0.1.8 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e7a029e..b569510 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def run_tests(self): sys.exit(pytest.main(self.test_args)) -version = "0.1.7" +version = "0.1.8" setup(name="python-lambda-local", version=version, From 7e9d437a2f4239e9f0adc55f95c3ff9a0aece0c7 Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Wed, 30 Jan 2019 18:51:47 +0900 Subject: [PATCH 16/56] Fix setup.cfg --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index bbfda55..444a061 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,6 @@ tag_build = tag_svn_revision = false -[pytest] +[tool:pytest] addopts = --ignore=setup.py --ignore=build --ignore=dist --doctest-modules norecursedirs=*.egg From 49ad011a039974f1d8f904435eb8db895558d2d9 Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Wed, 30 Jan 2019 19:31:50 +0900 Subject: [PATCH 17/56] Migrate pypi deployment tool to twine --- deploy.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 109fc59..4fc9305 100644 --- a/deploy.sh +++ b/deploy.sh @@ -11,4 +11,6 @@ username: ${PYPI_USERNAME} password: ${PYPI_PASSWORD} EOF -python setup.py sdist upload +pip install twine +twine upload -r pypi dist/* + From 6f27faf0d252d160398e838d6e691dfd0a6a3324 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 12 Nov 2019 18:08:39 +0900 Subject: [PATCH 18/56] Remove config on vendored library because it is removed. --- lambda_local/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lambda_local/main.py b/lambda_local/main.py index 315962e..1e42398 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -10,7 +10,6 @@ import logging import os import timeit -from botocore.vendored.requests.packages import urllib3 import multiprocessing from . import event @@ -22,7 +21,6 @@ logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='[%(name)s - %(levelname)s - %(asctime)s] %(message)s') -urllib3.disable_warnings() ERR_TYPE_EXCEPTION = 0 From 321efb25f1dafbba05deb8960cffe725d194d3d1 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 12 Nov 2019 18:29:18 +0900 Subject: [PATCH 19/56] Try to fix pytest error on py27. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index b569510..6965ef5 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ def run_tests(self): packages=find_packages(exclude=['examples', 'tests']), include_package_data=True, zip_safe=False, + python_requires='>=2.7 >=3.6', tests_require=['pytest'], cmdclass={'test': PyTest}, install_requires=['boto3'], From fb17e7f49b23a873520a6572abb888f204bc021c Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 12 Nov 2019 18:34:37 +0900 Subject: [PATCH 20/56] Fix versions. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6965ef5..fbb65fd 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ def run_tests(self): packages=find_packages(exclude=['examples', 'tests']), include_package_data=True, zip_safe=False, - python_requires='>=2.7 >=3.6', + python_requires='>=2.7,!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4', tests_require=['pytest'], cmdclass={'test': PyTest}, install_requires=['boto3'], From 7c2583a7e4936a59dbe0883736efc007387a3ac2 Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Tue, 12 Nov 2019 19:16:33 +0900 Subject: [PATCH 21/56] Set specific pytest version for Python 2 --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fbb65fd..04f9858 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,10 @@ def run_tests(self): version = "0.1.8" +TEST_REQUIRE = ['pytest'] +if sys.version_info[0] == 2: + TEST_REQUIRE = ['pytest==4.6.3'] + setup(name="python-lambda-local", version=version, description="Run lambda function in python on local machine.", @@ -46,7 +50,7 @@ def run_tests(self): include_package_data=True, zip_safe=False, python_requires='>=2.7,!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4', - tests_require=['pytest'], + tests_require=TEST_REQUIRE, cmdclass={'test': PyTest}, install_requires=['boto3'], entry_points={ From 6429155529e14438185ada8bc7c8ccc4097134be Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Tue, 12 Nov 2019 19:21:05 +0900 Subject: [PATCH 22/56] Remove python_requires line --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 04f9858..1d26fe7 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,6 @@ def run_tests(self): packages=find_packages(exclude=['examples', 'tests']), include_package_data=True, zip_safe=False, - python_requires='>=2.7,!=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4', tests_require=TEST_REQUIRE, cmdclass={'test': PyTest}, install_requires=['boto3'], From 6462db47e40e7ee6ea3d5e2d3b393301fb07c095 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 18:13:40 +0900 Subject: [PATCH 23/56] Add missing CHANGELOG entries. --- CHANGELOG.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5776446..7a70fcd 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -22,3 +22,23 @@ Version 0.1.4 ------------- - Support Python 3.6. + +Version 0.1.5 +------------- + + - Support reading environment variables from file. + +Version 0.1.6 +------------- + + - Add timeout feature for Windows. + +Version 0.1.7 +------------- + + - Add tests in CI. + +Version 0.1.8 +------------- + + - Support running as a library. From 80cd952f1f24fd42049626b3dff9ec391e4d1c58 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 18:31:22 +0900 Subject: [PATCH 24/56] Update copyright information. --- lambda_local/__init__.py | 2 +- lambda_local/context.py | 2 +- lambda_local/event.py | 2 +- lambda_local/main.py | 2 +- lambda_local/timeout.py | 2 +- setup.py | 4 ++-- tests/__init__.py | 2 +- tests/basic_test.py | 2 +- tests/test_direct_invocations.py | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lambda_local/__init__.py b/lambda_local/__init__.py index 45b457b..2a21140 100644 --- a/lambda_local/__init__.py +++ b/lambda_local/__init__.py @@ -1,7 +1,7 @@ ''' python-lambda-local: Main module -Copyright 2015-2018 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/context.py b/lambda_local/context.py index 1f21657..dbc287e 100644 --- a/lambda_local/context.py +++ b/lambda_local/context.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2018 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' from __future__ import print_function diff --git a/lambda_local/event.py b/lambda_local/event.py index 3d0f23f..a9d3c98 100644 --- a/lambda_local/event.py +++ b/lambda_local/event.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2018 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/main.py b/lambda_local/main.py index 1e42398..f3ff166 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2018 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/timeout.py b/lambda_local/timeout.py index 9d0354a..5dcbd58 100644 --- a/lambda_local/timeout.py +++ b/lambda_local/timeout.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2018 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/setup.py b/setup.py index 1d26fe7..a6a85b5 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ ''' python-lambda-local: Run lambda function in python on local machine. -Copyright 2015-2018 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' import io @@ -23,7 +23,7 @@ def run_tests(self): sys.exit(pytest.main(self.test_args)) -version = "0.1.8" +version = "0.1.9" TEST_REQUIRE = ['pytest'] if sys.version_info[0] == 2: diff --git a/tests/__init__.py b/tests/__init__.py index 98c7f83..9e074ad 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,6 +5,6 @@ Organize tests into files, each named xxx_test.py Read more here: http://pytest.org/ -Copyright 2015 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' diff --git a/tests/basic_test.py b/tests/basic_test.py index 427173d..46e81d2 100644 --- a/tests/basic_test.py +++ b/tests/basic_test.py @@ -5,7 +5,7 @@ Write each test as a function named test_. Read more here: http://pytest.org/ -Copyright 2015 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' diff --git a/tests/test_direct_invocations.py b/tests/test_direct_invocations.py index 129666c..c496a4d 100644 --- a/tests/test_direct_invocations.py +++ b/tests/test_direct_invocations.py @@ -4,7 +4,7 @@ Meant for use with py.test. -Copyright 2015 HDE, Inc. +Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' import json From 5aaad087928e878961c42daf4a7b3fdd839157d7 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 18:38:47 +0900 Subject: [PATCH 25/56] Update changelog. --- CHANGELOG.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 7a70fcd..5325016 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -42,3 +42,8 @@ Version 0.1.8 ------------- - Support running as a library. + +Version 0.1.9 +------------- + + - Support latest boto3. From 5b9d3eae90658ae57aa6b76f662c49cbc095b626 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 18:41:42 +0900 Subject: [PATCH 26/56] Update for python 3.7. --- setup.py | 2 +- wercker.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index a6a85b5..de50429 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ def run_tests(self): 'Operating System :: POSIX', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'License :: OSI Approved :: MIT License' ], keywords="AWS Lambda", diff --git a/wercker.yml b/wercker.yml index 7d3c6bf..4dd83fd 100644 --- a/wercker.yml +++ b/wercker.yml @@ -1,4 +1,4 @@ -box: python:2.7-slim +box: python:3.7-slim build: steps: @@ -32,7 +32,7 @@ build-py2: python setup.py test build-py3: - box: python:3.6-slim + box: python:3.7-slim steps: - script: name: virtualenv install From e906ccfc12e135977a723d1320c45c80c0fa76f3 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 19:15:21 +0900 Subject: [PATCH 27/56] Try fix wercker. --- wercker.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wercker.yml b/wercker.yml index 4dd83fd..2db0266 100644 --- a/wercker.yml +++ b/wercker.yml @@ -61,7 +61,8 @@ build-py3: deploy: pypi: - - script: - name: deploy to pypi - code: | - sh deploy.sh + steps: + - script: + name: deploy to pypi + code: | + sh deploy.sh From 41dce071f32ecaa78b709a21b615c8e561fd72d6 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 19:23:43 +0900 Subject: [PATCH 28/56] Fix pipeline. --- wercker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wercker.yml b/wercker.yml index 2db0266..3bb21a7 100644 --- a/wercker.yml +++ b/wercker.yml @@ -60,7 +60,7 @@ build-py3: python setup.py test deploy: - pypi: + box: python:3.7-slim steps: - script: name: deploy to pypi From 26c3e7420502f9699c93af2ff03fe7eebc606b33 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 19:29:12 +0900 Subject: [PATCH 29/56] Try show source. --- wercker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/wercker.yml b/wercker.yml index 3bb21a7..736986a 100644 --- a/wercker.yml +++ b/wercker.yml @@ -65,4 +65,5 @@ deploy: - script: name: deploy to pypi code: | + ls sh deploy.sh From 099d3f2f4e9ac63ed190973738c8f080ba6ba1ed Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 19:39:00 +0900 Subject: [PATCH 30/56] Try change to root dir. --- wercker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wercker.yml b/wercker.yml index 736986a..4e4f129 100644 --- a/wercker.yml +++ b/wercker.yml @@ -65,5 +65,5 @@ deploy: - script: name: deploy to pypi code: | - ls + cd $WERCKER_ROOT sh deploy.sh From b8a078ca6709f76b5a8c82d753d4962a8eb93d23 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 15 Nov 2019 19:48:05 +0900 Subject: [PATCH 31/56] Use pipeline. --- wercker.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wercker.yml b/wercker.yml index 4e4f129..bcefb93 100644 --- a/wercker.yml +++ b/wercker.yml @@ -60,10 +60,9 @@ build-py3: python setup.py test deploy: - box: python:3.7-slim steps: - script: name: deploy to pypi code: | - cd $WERCKER_ROOT + cd build-py3 sh deploy.sh From fa1e14f25e7b01073ce829b09244ac018b90bc2a Mon Sep 17 00:00:00 2001 From: Dan Pope Date: Wed, 20 Nov 2019 12:22:52 +0000 Subject: [PATCH 32/56] Handle exceptions by using traceback.format_exc instead of extract_tb --- lambda_local/main.py | 2 +- tests/test_direct_invocations.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lambda_local/main.py b/lambda_local/main.py index f3ff166..849c2a4 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -124,7 +124,7 @@ def execute(func, event, context): err = sys.exc_info() result = json.dumps({ "errorMessage": str(err[1]), - "stackTrace": traceback.extract_tb(err[2]), + "stackTrace": traceback.format_exc(), "errorType": err[0].__name__ }, indent=4, separators=(',', ': ')) err_type = ERR_TYPE_EXCEPTION diff --git a/tests/test_direct_invocations.py b/tests/test_direct_invocations.py index c496a4d..c767906 100644 --- a/tests/test_direct_invocations.py +++ b/tests/test_direct_invocations.py @@ -1,5 +1,5 @@ ''' -python-lambda-local: Test Direct Inovactions +python-lambda-local: Test Direct Invocations (command-line and direct). Meant for use with py.test. @@ -13,6 +13,7 @@ import os from lambda_local.main import run as lambda_run from lambda_local.main import call as lambda_call +from lambda_local.main import ERR_TYPE_EXCEPTION from lambda_local.context import Context @@ -21,6 +22,10 @@ def my_lambda_function(event, context): return 42 +def my_failing_lambda_function(event, context): + raise Exception('Oh no') + + def test_function_call_for_pytest(): (result, error_type) = lambda_call( my_lambda_function, {}, Context(1)) @@ -30,6 +35,13 @@ def test_function_call_for_pytest(): assert result == 42 +def test_handle_exceptions_gracefully(): + (result, error_type) = lambda_call( + my_failing_lambda_function, {}, Context(1)) + + assert error_type is ERR_TYPE_EXCEPTION + + def test_check_command_line(): request = json.dumps({}) request_file = 'check_command_line_event.json' From bb145008cc995ed438708e59825288e1ccf07b4b Mon Sep 17 00:00:00 2001 From: Dan Pope Date: Wed, 20 Nov 2019 14:06:19 +0000 Subject: [PATCH 33/56] Add command line test --- tests/test_direct_invocations.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_direct_invocations.py b/tests/test_direct_invocations.py index c767906..b49eaf7 100644 --- a/tests/test_direct_invocations.py +++ b/tests/test_direct_invocations.py @@ -63,3 +63,26 @@ def test_check_command_line(): os.remove(request_file) assert p.exitcode == 0 + + +def test_check_command_line_error(): + request = json.dumps({}) + request_file = 'check_command_line_event.json' + with open(request_file, "w") as f: + f.write(request) + + args = argparse.Namespace(event=request_file, + file='tests/test_direct_invocations.py', + function='my_failing_lambda_function', + timeout=1, + environment_variables='', + library=None, + version_name='', + arn_string='' + ) + p = Process(target=lambda_run, args=(args,)) + p.start() + p.join() + + os.remove(request_file) + assert p.exitcode == 1 From 392cb6e2f95fe434b5a8ab366521f5b0ad960c41 Mon Sep 17 00:00:00 2001 From: Dan Pope Date: Sat, 23 Nov 2019 15:25:47 +0000 Subject: [PATCH 34/56] Use format_tb to return a list of strings --- lambda_local/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda_local/main.py b/lambda_local/main.py index 849c2a4..1f5f83f 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -124,7 +124,7 @@ def execute(func, event, context): err = sys.exc_info() result = json.dumps({ "errorMessage": str(err[1]), - "stackTrace": traceback.format_exc(), + "stackTrace": traceback.format_tb(err[2]), "errorType": err[0].__name__ }, indent=4, separators=(',', ': ')) err_type = ERR_TYPE_EXCEPTION From ed6ca57ac1dbcc1526fdac71449b5adff01f3809 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Mon, 25 Nov 2019 14:26:18 +0900 Subject: [PATCH 35/56] Update copyright information. --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index c4d8dfd..282b0e8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2018 HDE, Inc. +Copyright (c) 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From f7ac5e9b30dcc8fae66f558aeaeae87374c8ad46 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Mon, 25 Nov 2019 14:28:17 +0900 Subject: [PATCH 36/56] Bump version. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index de50429..8ba4ac3 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def run_tests(self): sys.exit(pytest.main(self.test_args)) -version = "0.1.9" +version = "0.1.10" TEST_REQUIRE = ['pytest'] if sys.version_info[0] == 2: From fdb973b36e1a32ca6f1a6db42d5be0d5eb207aad Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Mon, 25 Nov 2019 14:28:41 +0900 Subject: [PATCH 37/56] Add changelog. --- CHANGELOG.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5325016..9c747d2 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -47,3 +47,8 @@ Version 0.1.9 ------------- - Support latest boto3. + +Version 0.1.10 +-------------- + + - Fix traceback output when exception happens. From 1caa2f4e1eca160306ebe8455d29b301959de457 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 29 Nov 2019 14:22:21 +0900 Subject: [PATCH 38/56] Fix build workflow. --- deploy.sh | 6 +++++- wercker.yml | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 4fc9305..fbe5d5f 100644 --- a/deploy.sh +++ b/deploy.sh @@ -12,5 +12,9 @@ password: ${PYPI_PASSWORD} EOF pip install twine -twine upload -r pypi dist/* +mkdir dist +cp build-py2/dist/* dist/ +cp build-py3/dist/* dist/ + +twine upload -r pypi dist/* diff --git a/wercker.yml b/wercker.yml index bcefb93..88011aa 100644 --- a/wercker.yml +++ b/wercker.yml @@ -64,5 +64,4 @@ deploy: - script: name: deploy to pypi code: | - cd build-py3 sh deploy.sh From 28c3a359bcce64d0a4bd00a5915a379b8fca96f4 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 29 Nov 2019 14:26:44 +0900 Subject: [PATCH 39/56] Add test for python 3.8. --- deploy.sh | 3 ++- wercker.yml | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/deploy.sh b/deploy.sh index fbe5d5f..7bc15d2 100644 --- a/deploy.sh +++ b/deploy.sh @@ -15,6 +15,7 @@ pip install twine mkdir dist cp build-py2/dist/* dist/ -cp build-py3/dist/* dist/ +cp build-py37/dist/* dist/ +cp build-py38/dist/* dist/ twine upload -r pypi dist/* diff --git a/wercker.yml b/wercker.yml index 88011aa..44d44cb 100644 --- a/wercker.yml +++ b/wercker.yml @@ -1,4 +1,4 @@ -box: python:3.7-slim +box: python:3-slim build: steps: @@ -13,7 +13,7 @@ build-py2: - virtualenv: name: setup virtual environment - install_wheel: true # Enable wheel to speed up builds (experimental) + install_wheel: true - script: name: echo python information @@ -31,7 +31,7 @@ build-py2: code: | python setup.py test -build-py3: +build-py37: box: python:3.7-slim steps: - script: @@ -41,7 +41,35 @@ build-py3: - virtualenv: name: setup virtual environment - install_wheel: true # Enable wheel to speed up builds (experimental) + install_wheel: true + + - script: + name: echo python information + code: | + echo "python version $(python --version) running" + echo "pip version $(pip --version) running" + + - script: + name: build + code: | + python setup.py sdist bdist_wheel + + - script: + name: test + code: | + python setup.py test + +build-py38: + box: python:3.8-slim + steps: + - script: + name: virtualenv install + code: | + pip install virtualenv + + - virtualenv: + name: setup virtual environment + install_wheel: true - script: name: echo python information From af6779f9b6caa4f9404c90be4c5a15dc694bf55b Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 29 Nov 2019 14:27:37 +0900 Subject: [PATCH 40/56] Update readme. --- README.md | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 26c2b2c..39d8b79 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Run lambda function on local machine ## Prepare development environment -Please use a newly created virtualenv of Python 2.7 or Python 3.6. +Please use a newly created virtualenv of Python 2.7 or Python 3.7. ## Installation diff --git a/README.rst b/README.rst index b77f67e..2710d84 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ Run lambda function on local machine Prepare development environment ------------------------------- -Please use a newly created virtualenv of Python 2.7 or Python 3.6. +Please use a newly created virtualenv of Python 2.7 or Python 3.7. Installation ------------ From 42210f6c3929da0b91eedae63ee1e6523f53d95d Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 29 Nov 2019 14:42:03 +0900 Subject: [PATCH 41/56] Bump version. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8ba4ac3..26f49dd 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def run_tests(self): sys.exit(pytest.main(self.test_args)) -version = "0.1.10" +version = "0.1.11" TEST_REQUIRE = ['pytest'] if sys.version_info[0] == 2: From 3aa330964a6929df7f09f0edd25095d490c9679c Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 29 Nov 2019 14:49:50 +0900 Subject: [PATCH 42/56] Copy from source. --- wercker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/wercker.yml b/wercker.yml index 44d44cb..0e4c8f4 100644 --- a/wercker.yml +++ b/wercker.yml @@ -92,4 +92,5 @@ deploy: - script: name: deploy to pypi code: | + cp build-py2/deploy.sh . sh deploy.sh From 81499333bc45c4f14ad3b91c7da4191dbb13b7e3 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 6 Dec 2019 11:18:34 +0900 Subject: [PATCH 43/56] Use different import. --- lambda_local/main.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lambda_local/main.py b/lambda_local/main.py index 1f5f83f..90e461e 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -102,7 +102,17 @@ def load(request_id, path, function_name): file_directory = os.path.dirname(file_path) sys.path.append(file_directory) - mod = imp.load_source(mod_name, path) + if sys.version_info.major == 2: + mod = imp.load_source(mod_name, path) + elif sys.version_info.major == 3 and sys.version_info.minor >= 5: + import importlib + spec = importlib.util.spec_from_file_location(mod_name, path) + mod = importlib.util.module_from_spec(spec) + sys.modules[mod_name] = mod + spec.loader.exec_module(mod) + else: + raise Exception("unsupported python version") + func = getattr(mod, function_name) return func From 7868e46cd6d0b7071c41d8032a65049db41bb75a Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Fri, 6 Dec 2019 11:55:25 +0900 Subject: [PATCH 44/56] Move import. --- lambda_local/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda_local/main.py b/lambda_local/main.py index 90e461e..0f248cd 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -3,7 +3,6 @@ Licensed under MIT. ''' -import imp import sys import traceback import json @@ -103,6 +102,7 @@ def load(request_id, path, function_name): sys.path.append(file_directory) if sys.version_info.major == 2: + import imp mod = imp.load_source(mod_name, path) elif sys.version_info.major == 3 and sys.version_info.minor >= 5: import importlib From 62563884cbc65c977a223545e2d1d21e5e96f03f Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 10 Dec 2019 11:42:27 +0900 Subject: [PATCH 45/56] Load function in child process. --- lambda_local/main.py | 48 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/lambda_local/main.py b/lambda_local/main.py index 0f248cd..b3645d2 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -38,10 +38,32 @@ def filter(self, record): return True +class FunctionLoader(): + def __init__(self, + request_id=None, + source=None, + function_name=None, + library_path=None, + func=None): + self.request_id = request_id + self.source = source + self.function_name = function_name + self.library_path = library_path + + self.func = func + + def load(self): + if self.library_path is not None: + load_lib(self.library_path) + + self.func = load_source( + self.request_id, self.source, self.function_name) + + def call(func, event, context, environment_variables={}): export_variables(environment_variables) - - return _runner(func, event, context) + loader = FunctionLoader(func=func) + return _runner(loader, event, context) def run(args): @@ -53,17 +75,19 @@ def run(args): args.timeout, invoked_function_arn=args.arn_string, function_version=args.version_name) - if args.library is not None: - load_lib(args.library) - func = load(c.aws_request_id, args.file, args.function) + loader = FunctionLoader( + request_id=c.aws_request_id, + source=args.file, + function_name=args.function, + library_path=args.library) - (result, err_type) = _runner(func, e, c) + (result, err_type) = _runner(loader, e, c) if err_type is not None: sys.exit(EXITCODE_ERR) -def _runner(func, event, context): +def _runner(loader, event, context): logger = logging.getLogger() logger.info("Event: {}".format(event)) @@ -73,7 +97,7 @@ def _runner(func, event, context): queue = multiprocessing.Queue() p = multiprocessing.Process( target=execute_in_process, - args=(queue, func, event, context,)) + args=(queue, loader, event, context,)) p.start() (result, err_type, duration) = queue.get() p.join() @@ -94,7 +118,7 @@ def load_lib(path): sys.path.append(os.path.abspath(path)) -def load(request_id, path, function_name): +def load_source(request_id, path, function_name): mod_name = 'request-' + str(request_id) file_path = os.path.abspath(path) @@ -142,9 +166,11 @@ def execute(func, event, context): return result, err_type -def execute_in_process(queue, func, event, context): +def execute_in_process(queue, loader, event, context): + if loader.func is None: + loader.load() start_time = timeit.default_timer() - result, err_type = execute(func, event, context) + result, err_type = execute(loader.func, event, context) end_time = timeit.default_timer() duration = (end_time - start_time) * 1000 From 25c4362a0e10b9967b35952d44749eeefaebc262 Mon Sep 17 00:00:00 2001 From: YANG Xudong Date: Tue, 10 Dec 2019 12:05:53 +0900 Subject: [PATCH 46/56] Update metadata and bump version. --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 26f49dd..fc9290c 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def run_tests(self): sys.exit(pytest.main(self.test_args)) -version = "0.1.11" +version = "0.1.12" TEST_REQUIRE = ['pytest'] if sys.version_info[0] == 2: @@ -39,11 +39,12 @@ def run_tests(self): 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License' ], keywords="AWS Lambda", author="YANG Xudong", - author_email="xudong.yang@hde.co.jp", + author_email="xudong.yang@hennge.com", url="https://github.com/HDE/python-lambda-local", license="MIT", packages=find_packages(exclude=['examples', 'tests']), From 93b7f692032b5feeb36940555c17ca4495136871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Susannah=20Klane=C4=8Dek?= Date: Sun, 22 Nov 2020 11:03:20 -0600 Subject: [PATCH 47/56] Drop support of Python 2.7 Closes #65 --- .gitignore | 4 ++++ README.md | 2 +- README.rst | 2 +- lambda_local/timeout.py | 2 +- setup.py | 1 - wercker.yml | 28 ---------------------------- 6 files changed, 7 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 4f5a7f6..6a5671f 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,7 @@ target/ # Vitual Environments venv/ +.env/ + +# direnv +.envrc diff --git a/README.md b/README.md index 39d8b79..fb59490 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Run lambda function on local machine ## Prepare development environment -Please use a newly created virtualenv of Python 2.7 or Python 3.7. +Please use a newly created virtualenv of Python 3.7+. ## Installation diff --git a/README.rst b/README.rst index 2710d84..9c5bd6a 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ Run lambda function on local machine Prepare development environment ------------------------------- -Please use a newly created virtualenv of Python 2.7 or Python 3.7. +Please use a newly created virtualenv of Python 3.7+. Installation ------------ diff --git a/lambda_local/timeout.py b/lambda_local/timeout.py index 5dcbd58..d13c619 100644 --- a/lambda_local/timeout.py +++ b/lambda_local/timeout.py @@ -6,7 +6,7 @@ import signal import threading from contextlib import contextmanager -from six.moves import _thread +import _thread class TimeoutException(Exception): diff --git a/setup.py b/setup.py index fc9290c..9c2aa1a 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,6 @@ def run_tests(self): 'Development Status :: 3 - Alpha', 'Operating System :: POSIX', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'License :: OSI Approved :: MIT License' diff --git a/wercker.yml b/wercker.yml index 0e4c8f4..9ef8edf 100644 --- a/wercker.yml +++ b/wercker.yml @@ -3,34 +3,6 @@ box: python:3-slim build: steps: -build-py2: - box: python:2.7-slim - steps: - - script: - name: virtualenv install - code: | - pip install virtualenv - - - virtualenv: - name: setup virtual environment - install_wheel: true - - - script: - name: echo python information - code: | - echo "python version $(python --version) running" - echo "pip version $(pip --version) running" - - - script: - name: build - code: | - python setup.py sdist bdist_wheel - - - script: - name: test - code: | - python setup.py test - build-py37: box: python:3.7-slim steps: From c8daf4b11e8706556b840db6f79946c3beb031c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Susannah=20Klane=C4=8Dek?= Date: Sun, 22 Nov 2020 11:05:54 -0600 Subject: [PATCH 48/56] Fix it --- deploy.sh | 1 - wercker.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 7bc15d2..b5ba2bd 100644 --- a/deploy.sh +++ b/deploy.sh @@ -14,7 +14,6 @@ EOF pip install twine mkdir dist -cp build-py2/dist/* dist/ cp build-py37/dist/* dist/ cp build-py38/dist/* dist/ diff --git a/wercker.yml b/wercker.yml index 9ef8edf..8e4f3f4 100644 --- a/wercker.yml +++ b/wercker.yml @@ -64,5 +64,5 @@ deploy: - script: name: deploy to pypi code: | - cp build-py2/deploy.sh . + cp build-py37/deploy.sh . sh deploy.sh From ca783c1ff3242f0b5a326f7b3d87c1bd065940a7 Mon Sep 17 00:00:00 2001 From: Iskandar Setiadi Date: Wed, 25 Nov 2020 11:05:04 +0900 Subject: [PATCH 49/56] Various update and cleanup --- LICENSE | 2 +- README.md | 4 ++-- README.rst | 4 ++-- lambda_local/__init__.py | 2 +- lambda_local/context.py | 2 +- lambda_local/event.py | 2 +- lambda_local/main.py | 2 +- lambda_local/timeout.py | 2 +- setup.py | 5 ++--- tests/__init__.py | 2 +- tests/basic_test.py | 2 +- tests/test_direct_invocations.py | 2 +- wercker.yml | 28 ++++++++++++++++++++++++++++ 13 files changed, 43 insertions(+), 16 deletions(-) diff --git a/LICENSE b/LICENSE index 282b0e8..44eb621 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright (c) 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fb59490..4dc9dd7 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Suppose your project directory is like this: │   │   ├── ... (package content of rx) ... │   │   └── testscheduler.py -│   └── Rx-1.2.3.dist-info +│   └── Rx-1.6.1.dist-info │   ├── DESCRIPTION.rst │   ├── METADATA │   ├── metadata.json @@ -147,7 +147,7 @@ Call a handler function `func` with given `event`, `context` and custom `environ 1. Make sure the 3rd party libraries used in the AWS Lambda function can be imported. ``` bash -pip install rx +pip install rx==1.6.1 ``` 2. To call the lambda function above with your python code: diff --git a/README.rst b/README.rst index 9c5bd6a..8fb606d 100644 --- a/README.rst +++ b/README.rst @@ -75,7 +75,7 @@ Suppose your project directory is like this: │   │   ├── ... (package content of rx) ... │   │   └── testscheduler.py - │   └── Rx-1.2.3.dist-info + │   └── Rx-1.6.1.dist-info │   ├── DESCRIPTION.rst │   ├── METADATA │   ├── metadata.json @@ -164,7 +164,7 @@ Sample .. code:: bash - pip install rx + pip install rx==1.6.1 2. To call the lambda function above with your python code: diff --git a/lambda_local/__init__.py b/lambda_local/__init__.py index 2a21140..2112c24 100644 --- a/lambda_local/__init__.py +++ b/lambda_local/__init__.py @@ -1,7 +1,7 @@ ''' python-lambda-local: Main module -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/context.py b/lambda_local/context.py index dbc287e..c183a3d 100644 --- a/lambda_local/context.py +++ b/lambda_local/context.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' from __future__ import print_function diff --git a/lambda_local/event.py b/lambda_local/event.py index a9d3c98..f76b3ec 100644 --- a/lambda_local/event.py +++ b/lambda_local/event.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/main.py b/lambda_local/main.py index b3645d2..738079f 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/timeout.py b/lambda_local/timeout.py index d13c619..a699bc0 100644 --- a/lambda_local/timeout.py +++ b/lambda_local/timeout.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/setup.py b/setup.py index 9c2aa1a..1196146 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ ''' python-lambda-local: Run lambda function in python on local machine. -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' import io @@ -26,8 +26,6 @@ def run_tests(self): version = "0.1.12" TEST_REQUIRE = ['pytest'] -if sys.version_info[0] == 2: - TEST_REQUIRE = ['pytest==4.6.3'] setup(name="python-lambda-local", version=version, @@ -39,6 +37,7 @@ def run_tests(self): 'Programming Language :: Python', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'License :: OSI Approved :: MIT License' ], keywords="AWS Lambda", diff --git a/tests/__init__.py b/tests/__init__.py index 9e074ad..b3ed574 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,6 +5,6 @@ Organize tests into files, each named xxx_test.py Read more here: http://pytest.org/ -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' diff --git a/tests/basic_test.py b/tests/basic_test.py index 46e81d2..5a79481 100644 --- a/tests/basic_test.py +++ b/tests/basic_test.py @@ -5,7 +5,7 @@ Write each test as a function named test_. Read more here: http://pytest.org/ -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' diff --git a/tests/test_direct_invocations.py b/tests/test_direct_invocations.py index b49eaf7..1a418fd 100644 --- a/tests/test_direct_invocations.py +++ b/tests/test_direct_invocations.py @@ -4,7 +4,7 @@ Meant for use with py.test. -Copyright 2015-2019 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' import json diff --git a/wercker.yml b/wercker.yml index 8e4f3f4..1362f1e 100644 --- a/wercker.yml +++ b/wercker.yml @@ -59,6 +59,34 @@ build-py38: code: | python setup.py test +build-py39: + box: python:3.9-slim + steps: + - script: + name: virtualenv install + code: | + pip install virtualenv + + - virtualenv: + name: setup virtual environment + install_wheel: true + + - script: + name: echo python information + code: | + echo "python version $(python --version) running" + echo "pip version $(pip --version) running" + + - script: + name: build + code: | + python setup.py sdist bdist_wheel + + - script: + name: test + code: | + python setup.py test + deploy: steps: - script: From 0a5dfa8b3d667bb6a67725530894b97a80e331a7 Mon Sep 17 00:00:00 2001 From: Kyle Moore Date: Mon, 21 Dec 2020 21:51:09 -0500 Subject: [PATCH 50/56] Add __main__ file for using the package as a module --- lambda_local/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 lambda_local/__main__.py diff --git a/lambda_local/__main__.py b/lambda_local/__main__.py new file mode 100644 index 0000000..868d99e --- /dev/null +++ b/lambda_local/__main__.py @@ -0,0 +1,4 @@ +from . import main + +if __name__ == "__main__": + main() From 00f78945a13e8e363af5ce8f653d732fb3eacf17 Mon Sep 17 00:00:00 2001 From: freedomofkeima Date: Thu, 2 Jun 2022 18:22:20 +0900 Subject: [PATCH 51/56] Add Github Actions workflow file --- .github/workflows/execute_tests.yml | 31 +++++++++++++++++++++++++++++ README.md | 2 +- README.rst | 7 +++---- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/execute_tests.yml diff --git a/.github/workflows/execute_tests.yml b/.github/workflows/execute_tests.yml new file mode 100644 index 0000000..5d04158 --- /dev/null +++ b/.github/workflows/execute_tests.yml @@ -0,0 +1,31 @@ +name: Execute tests + +on: push + +jobs: + execute_tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9'] + name: Python ${{ matrix.python-version }} tests + steps: + - uses: actions/checkout@v3 + + - name: Setup python + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + + - name: Print information + run: | + echo "python version $(python --version) running" + echo "pip version $(pip --version) running" + + - name: Build + run: | + python setup.py sdist bdist_wheel + + - name: Test + run: | + python setup.py test diff --git a/README.md b/README.md index 4dc9dd7..6cd0b85 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # python-lambda-local [![Join the chat at https://gitter.im/HDE/python-lambda-local](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/HDE/python-lambda-local?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![wercker status](https://app.wercker.com/status/04f5bc5b7de3d5c6f13eb5b871035226/s "wercker status")](https://app.wercker.com/project/bykey/04f5bc5b7de3d5c6f13eb5b871035226) +[![Github Actions status](https://github.com/HDE/python-lambda-local/actions/workflows/execute_tests.yml/badge.svg)](https://github.com/HDE/python-lambda-local/actions/) [![PyPI version](https://badge.fury.io/py/python-lambda-local.svg)](https://badge.fury.io/py/python-lambda-local) Run lambda function on local machine diff --git a/README.rst b/README.rst index 8fb606d..493b1f7 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,7 @@ python-lambda-local =================== -|Join the chat at https://gitter.im/HDE/python-lambda-local| |wercker -status| |PyPI version| +|Join the chat at https://gitter.im/HDE/python-lambda-local| |Github Actions status| |PyPI version| Run lambda function on local machine @@ -184,7 +183,7 @@ Sample .. |Join the chat at https://gitter.im/HDE/python-lambda-local| image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/HDE/python-lambda-local?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge -.. |wercker status| image:: https://app.wercker.com/status/04f5bc5b7de3d5c6f13eb5b871035226/s - :target: https://app.wercker.com/project/bykey/04f5bc5b7de3d5c6f13eb5b871035226 +.. |Github Actions status| image:: https://github.com/github/docs/actions/workflows/main.yml/badge.svg + :target: https://github.com/HDE/python-lambda-local/actions/ .. |PyPI version| image:: https://badge.fury.io/py/python-lambda-local.svg :target: https://badge.fury.io/py/python-lambda-local From 51349d07fcf291ab750e2d2bf551ae8b1d67eb51 Mon Sep 17 00:00:00 2001 From: freedomofkeima Date: Thu, 2 Jun 2022 18:25:49 +0900 Subject: [PATCH 52/56] Add wheel installation --- .github/workflows/execute_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/execute_tests.yml b/.github/workflows/execute_tests.yml index 5d04158..57a6fdf 100644 --- a/.github/workflows/execute_tests.yml +++ b/.github/workflows/execute_tests.yml @@ -24,6 +24,7 @@ jobs: - name: Build run: | + pip install wheel python setup.py sdist bdist_wheel - name: Test From ee56caa5f2a8145ff55d9b7374894dd90da36ba3 Mon Sep 17 00:00:00 2001 From: freedomofkeima Date: Thu, 2 Jun 2022 18:49:27 +0900 Subject: [PATCH 53/56] Update README file --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 493b1f7..84e9653 100644 --- a/README.rst +++ b/README.rst @@ -183,7 +183,7 @@ Sample .. |Join the chat at https://gitter.im/HDE/python-lambda-local| image:: https://badges.gitter.im/Join%20Chat.svg :target: https://gitter.im/HDE/python-lambda-local?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge -.. |Github Actions status| image:: https://github.com/github/docs/actions/workflows/main.yml/badge.svg +.. |Github Actions status| image:: https://github.com/HDE/python-lambda-local/actions/workflows/execute_tests.yml/badge.svg :target: https://github.com/HDE/python-lambda-local/actions/ .. |PyPI version| image:: https://badge.fury.io/py/python-lambda-local.svg :target: https://badge.fury.io/py/python-lambda-local From b34e3d7f1ee77b923769aa79312e3f7bc026d9fb Mon Sep 17 00:00:00 2001 From: freedomofkeima Date: Thu, 2 Jun 2022 18:55:17 +0900 Subject: [PATCH 54/56] Remove wercker --- deploy.sh | 5 --- wercker.yml | 96 ----------------------------------------------------- 2 files changed, 101 deletions(-) delete mode 100644 wercker.yml diff --git a/deploy.sh b/deploy.sh index b5ba2bd..2661370 100644 --- a/deploy.sh +++ b/deploy.sh @@ -12,9 +12,4 @@ password: ${PYPI_PASSWORD} EOF pip install twine - -mkdir dist -cp build-py37/dist/* dist/ -cp build-py38/dist/* dist/ - twine upload -r pypi dist/* diff --git a/wercker.yml b/wercker.yml deleted file mode 100644 index 1362f1e..0000000 --- a/wercker.yml +++ /dev/null @@ -1,96 +0,0 @@ -box: python:3-slim - -build: - steps: - -build-py37: - box: python:3.7-slim - steps: - - script: - name: virtualenv install - code: | - pip install virtualenv - - - virtualenv: - name: setup virtual environment - install_wheel: true - - - script: - name: echo python information - code: | - echo "python version $(python --version) running" - echo "pip version $(pip --version) running" - - - script: - name: build - code: | - python setup.py sdist bdist_wheel - - - script: - name: test - code: | - python setup.py test - -build-py38: - box: python:3.8-slim - steps: - - script: - name: virtualenv install - code: | - pip install virtualenv - - - virtualenv: - name: setup virtual environment - install_wheel: true - - - script: - name: echo python information - code: | - echo "python version $(python --version) running" - echo "pip version $(pip --version) running" - - - script: - name: build - code: | - python setup.py sdist bdist_wheel - - - script: - name: test - code: | - python setup.py test - -build-py39: - box: python:3.9-slim - steps: - - script: - name: virtualenv install - code: | - pip install virtualenv - - - virtualenv: - name: setup virtual environment - install_wheel: true - - - script: - name: echo python information - code: | - echo "python version $(python --version) running" - echo "pip version $(pip --version) running" - - - script: - name: build - code: | - python setup.py sdist bdist_wheel - - - script: - name: test - code: | - python setup.py test - -deploy: - steps: - - script: - name: deploy to pypi - code: | - cp build-py37/deploy.sh . - sh deploy.sh From 84f573861a3d4e15ef6d6da61c1a4f7ddae0f948 Mon Sep 17 00:00:00 2001 From: freedomofkeima Date: Thu, 2 Jun 2022 19:09:13 +0900 Subject: [PATCH 55/56] Add deployment workflow --- .github/workflows/push_to_pypi.yml | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/push_to_pypi.yml diff --git a/.github/workflows/push_to_pypi.yml b/.github/workflows/push_to_pypi.yml new file mode 100644 index 0000000..a5b1afd --- /dev/null +++ b/.github/workflows/push_to_pypi.yml @@ -0,0 +1,40 @@ +name: Push package to pypi + +on: + pull_request: + types: + - closed + branches: + - release + +env: + PYTHON_VERSION: "3.9" + +jobs: + push_to_pypi: + if: github.event.pull_request.merged + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup python + uses: actions/setup-python@v3 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Print information + run: | + echo "python version $(python --version) running" + echo "pip version $(pip --version) running" + + - name: Build + run: | + pip install wheel + python setup.py sdist bdist_wheel + + - name: Deploy + env: + PYPI_USERNAME: "${{ secrets.PYPI_USERNAME }}" + PYPI_PASSWORD: "${{ secrets.PYPI_PASSWORD }}" + run: | + sh deploy.sh From 602e1272acde2e632790462002c69ff923f187a5 Mon Sep 17 00:00:00 2001 From: freedomofkeima Date: Thu, 2 Jun 2022 19:25:15 +0900 Subject: [PATCH 56/56] Bump version, add update several other information --- CHANGELOG.txt | 18 ++++++++++++++++++ LICENSE | 2 +- lambda_local/__init__.py | 2 +- lambda_local/context.py | 2 +- lambda_local/environment_variables.py | 4 ++++ lambda_local/event.py | 2 +- lambda_local/main.py | 2 +- lambda_local/timeout.py | 2 +- setup.py | 8 ++++---- tests/__init__.py | 2 +- tests/basic_test.py | 2 +- tests/test_direct_invocations.py | 2 +- tests/test_environment_variables.py | 4 ++++ 13 files changed, 39 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9c747d2..d732b63 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -52,3 +52,21 @@ Version 0.1.10 -------------- - Fix traceback output when exception happens. + +Version 0.1.11 +-------------- + + - Test on python 3.8. + +Version 0.1.12 +-------------- + + - Fix error when running on Windows with Python 3. + +Version 0.1.13 +-------------- + + - Drop support of Python 2.7. + - Various update and cleanup, add Python 3.9 support. + - Add __main__ file for using the package as a module. + - Implement tests via Github Actions. diff --git a/LICENSE b/LICENSE index 44eb621..9416dcb 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright (c) 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lambda_local/__init__.py b/lambda_local/__init__.py index 2112c24..e5899ab 100644 --- a/lambda_local/__init__.py +++ b/lambda_local/__init__.py @@ -1,7 +1,7 @@ ''' python-lambda-local: Main module -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/context.py b/lambda_local/context.py index c183a3d..1c84b72 100644 --- a/lambda_local/context.py +++ b/lambda_local/context.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' from __future__ import print_function diff --git a/lambda_local/environment_variables.py b/lambda_local/environment_variables.py index ea102bd..484dde7 100644 --- a/lambda_local/environment_variables.py +++ b/lambda_local/environment_variables.py @@ -1,3 +1,7 @@ +''' +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) +Licensed under MIT. +''' import json import os diff --git a/lambda_local/event.py b/lambda_local/event.py index f76b3ec..a831caf 100644 --- a/lambda_local/event.py +++ b/lambda_local/event.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/main.py b/lambda_local/main.py index 738079f..55b22c9 100644 --- a/lambda_local/main.py +++ b/lambda_local/main.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/lambda_local/timeout.py b/lambda_local/timeout.py index a699bc0..9492844 100644 --- a/lambda_local/timeout.py +++ b/lambda_local/timeout.py @@ -1,5 +1,5 @@ ''' -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' diff --git a/setup.py b/setup.py index 1196146..7bcbf9c 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ ''' python-lambda-local: Run lambda function in python on local machine. -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT. ''' import io @@ -23,7 +23,7 @@ def run_tests(self): sys.exit(pytest.main(self.test_args)) -version = "0.1.12" +version = "0.1.13" TEST_REQUIRE = ['pytest'] @@ -41,8 +41,8 @@ def run_tests(self): 'License :: OSI Approved :: MIT License' ], keywords="AWS Lambda", - author="YANG Xudong", - author_email="xudong.yang@hennge.com", + author="YANG Xudong, Iskandar Setiadi", + author_email="iskandar.setiadi@hennge.com", url="https://github.com/HDE/python-lambda-local", license="MIT", packages=find_packages(exclude=['examples', 'tests']), diff --git a/tests/__init__.py b/tests/__init__.py index b3ed574..9052941 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -5,6 +5,6 @@ Organize tests into files, each named xxx_test.py Read more here: http://pytest.org/ -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' diff --git a/tests/basic_test.py b/tests/basic_test.py index 5a79481..0dddec8 100644 --- a/tests/basic_test.py +++ b/tests/basic_test.py @@ -5,7 +5,7 @@ Write each test as a function named test_. Read more here: http://pytest.org/ -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' diff --git a/tests/test_direct_invocations.py b/tests/test_direct_invocations.py index 1a418fd..6b4857f 100644 --- a/tests/test_direct_invocations.py +++ b/tests/test_direct_invocations.py @@ -4,7 +4,7 @@ Meant for use with py.test. -Copyright 2015-2020 HENNGE K.K. (formerly known as HDE, Inc.) +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) Licensed under MIT ''' import json diff --git a/tests/test_environment_variables.py b/tests/test_environment_variables.py index 6582779..7221f89 100644 --- a/tests/test_environment_variables.py +++ b/tests/test_environment_variables.py @@ -1,3 +1,7 @@ +''' +Copyright 2015-2022 HENNGE K.K. (formerly known as HDE, Inc.) +Licensed under MIT. +''' import os from lambda_local.environment_variables import set_environment_variables