From 73c98bc985b13ed14e2387e389b2cf5290495df4 Mon Sep 17 00:00:00 2001 From: Gavin Aguiar Date: Fri, 5 May 2023 15:59:31 -0500 Subject: [PATCH 1/6] Revert "Added worker to pythonpath (#1215)" This reverts commit a60ef25cd77d0ad53f4c3fc0c233fc9e7db84b8c. --- python/prodV4/worker.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/python/prodV4/worker.py b/python/prodV4/worker.py index 609d02bc..b3c0faf0 100644 --- a/python/prodV4/worker.py +++ b/python/prodV4/worker.py @@ -6,7 +6,6 @@ # User packages PKGS_PATH = "site/wwwroot/.python_packages" VENV_PKGS_PATH = "site/wwwroot/worker_venv" -WORKER_DIR = "azure_functions_worker" PKGS = "lib/site-packages" @@ -51,8 +50,6 @@ def determine_user_pkg_paths(): if __name__ == '__main__': # worker.py lives in the same directory as azure_functions_worker - current_dir = str(Path(__file__).absolute()) - worker_path = os.path.join(current_dir, WORKER_DIR) func_worker_dir = str(Path(__file__).absolute().parent) env = os.environ @@ -60,11 +57,11 @@ def determine_user_pkg_paths(): # third-party user packages over worker packages in PYTHONPATH user_pkg_paths = determine_user_pkg_paths() joined_pkg_paths = os.pathsep.join(user_pkg_paths) - env['PYTHONPATH'] = f'{worker_path}:{joined_pkg_paths}:{func_worker_dir}' + env['PYTHONPATH'] = f'{joined_pkg_paths}:{func_worker_dir}' if is_azure_environment(): os.execve(sys.executable, - [sys.executable, '-m', WORKER_DIR] + [sys.executable, '-m', 'azure_functions_worker'] + sys.argv[1:], env) else: From b3b7c7116d0d3090f06d18cce1bd37fb4eb1099a Mon Sep 17 00:00:00 2001 From: gavin-aguiar <80794152+gavin-aguiar@users.noreply.github.com> Date: Fri, 5 May 2023 17:16:24 -0500 Subject: [PATCH 2/6] Update Python SDK Version to 1.14.1b3 (#1232) * Update Python SDK Version to 1.14.1b3 * Update setup.py --------- Co-authored-by: AzureFunctionsPython --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 22b5cbc3..9c2cf26d 100644 --- a/setup.py +++ b/setup.py @@ -106,7 +106,7 @@ ] INSTALL_REQUIRES = [ - "azure-functions==1.14.1b2", + "azure-functions==1.14.1b3", "python-dateutil~=2.8.2" ] From 4fc836bffa65ba38ba171add437109fbd40cba01 Mon Sep 17 00:00:00 2001 From: AzureFunctionsPython Date: Tue, 2 May 2023 21:44:29 +0000 Subject: [PATCH 3/6] Update Python Worker Version to 4.13.0 --- azure_functions_worker/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure_functions_worker/version.py b/azure_functions_worker/version.py index db1c2148..4021f66e 100644 --- a/azure_functions_worker/version.py +++ b/azure_functions_worker/version.py @@ -1,4 +1,4 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -VERSION = '4.12.0' +VERSION = '4.13.0' From b6dc4225778b0496c6cc345cdb89f8ff9e7cea62 Mon Sep 17 00:00:00 2001 From: AzureFunctionsPython Date: Mon, 8 May 2023 15:39:46 +0000 Subject: [PATCH 4/6] Update Python Worker Version to 4.14.0 --- azure_functions_worker/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure_functions_worker/version.py b/azure_functions_worker/version.py index 4021f66e..e02b652e 100644 --- a/azure_functions_worker/version.py +++ b/azure_functions_worker/version.py @@ -1,4 +1,4 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -VERSION = '4.13.0' +VERSION = '4.14.0' From e9af8d7e1908b0931f72694017ca2eb7175c716a Mon Sep 17 00:00:00 2001 From: Gavin Aguiar Date: Tue, 6 Jun 2023 10:54:34 -0500 Subject: [PATCH 5/6] Importing azure functions in InitRequest by default --- azure_functions_worker/constants.py | 3 --- azure_functions_worker/dispatcher.py | 13 +++---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/azure_functions_worker/constants.py b/azure_functions_worker/constants.py index a0606d1f..86a9dd59 100644 --- a/azure_functions_worker/constants.py +++ b/azure_functions_worker/constants.py @@ -30,9 +30,6 @@ """ UNIX_SHARED_MEMORY_DIRECTORIES = "FUNCTIONS_UNIX_SHARED_MEMORY_DIRECTORIES" -# Flag to enable loading functions at init request -PYTHON_LOAD_FUNCTIONS_INIT = "PYTHON_LOAD_FUNCTIONS_INIT" - # Setting Defaults PYTHON_THREADPOOL_THREAD_COUNT_DEFAULT = 1 PYTHON_THREADPOOL_THREAD_COUNT_MIN = 1 diff --git a/azure_functions_worker/dispatcher.py b/azure_functions_worker/dispatcher.py index 2d5543d2..c9f7869d 100644 --- a/azure_functions_worker/dispatcher.py +++ b/azure_functions_worker/dispatcher.py @@ -26,7 +26,7 @@ PYTHON_THREADPOOL_THREAD_COUNT_MAX_37, PYTHON_THREADPOOL_THREAD_COUNT_MIN, PYTHON_ENABLE_DEBUG_LOGGING, SCRIPT_FILE_NAME, - PYTHON_LANGUAGE_RUNTIME, PYTHON_LOAD_FUNCTIONS_INIT) + PYTHON_LANGUAGE_RUNTIME) from .extension import ExtensionManager from .logging import disable_console_logging, enable_console_logging from .logging import enable_debug_logging_recommendation @@ -288,10 +288,9 @@ async def _handle__worker_init_request(self, request): if not DependencyManager.is_in_linux_consumption(): DependencyManager.prioritize_customer_dependencies() - if DependencyManager.is_in_linux_consumption() \ - and is_envvar_true(PYTHON_LOAD_FUNCTIONS_INIT): + if DependencyManager.is_in_linux_consumption(): logger.info( - "PYTHON_LOAD_FUNCTIONS_INIT enabled. Importing azure functions") + "Importing azure functions in WorkerInitRequest") import azure.functions # NoQA # loading bindings registry and saving results to a static @@ -539,12 +538,6 @@ async def _handle__function_environment_reload_request(self, request): func_env_reload_request = \ request.function_environment_reload_request - if not is_envvar_true(PYTHON_LOAD_FUNCTIONS_INIT): - # Import before clearing path cache so that the default - # azure.functions modules is available in sys.modules for - # customer use - import azure.functions # NoQA - # Append function project root to module finding sys.path if func_env_reload_request.function_app_directory: sys.path.append(func_env_reload_request.function_app_directory) From 0eed990c5ae7eafe3fcf95c30a93166a26664892 Mon Sep 17 00:00:00 2001 From: Gavin Aguiar Date: Mon, 26 Jun 2023 20:44:46 -0500 Subject: [PATCH 6/6] Updated tests --- tests/unittests/test_dispatcher.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unittests/test_dispatcher.py b/tests/unittests/test_dispatcher.py index 02f4a31e..20434985 100644 --- a/tests/unittests/test_dispatcher.py +++ b/tests/unittests/test_dispatcher.py @@ -621,8 +621,6 @@ async def test_dispatcher_load_azfunc_in_init(self): """Test if the dispatcher's log can be flushed out during worker initialization """ - os.environ.update({"CONTAINER_NAME": 'test', - "PYTHON_LOAD_FUNCTIONS_INIT": "1"}) async with self._ctrl as host: r = await host.init_worker('4.15.1') self.assertEqual(