Importing azure functions in InitRequest by default (#1250)

* Revert "Added worker to pythonpath (#1215)"

This reverts commit a60ef25cd7.

* Update Python SDK Version to 1.14.1b3 (#1232)

* Update Python SDK Version to 1.14.1b3

* Update setup.py

---------

Co-authored-by: AzureFunctionsPython <funcdisc@microsoft.com>

* Update Python Worker Version to 4.13.0

* Update Python Worker Version to 4.14.0

* Importing azure functions in InitRequest by default

* Updated tests

---------

Co-authored-by: Gavin Aguiar <gavin@GavinPC>
Co-authored-by: AzureFunctionsPython <funcdisc@microsoft.com>
This commit is contained in:
gavin-aguiar 2023-07-28 15:47:31 -05:00 коммит произвёл GitHub
Родитель f9bf8ff951
Коммит 14cc39672c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 3 добавлений и 15 удалений

Просмотреть файл

@ -30,9 +30,6 @@ data transfer between host and worker.
"""
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

Просмотреть файл

@ -26,7 +26,7 @@ from .constants import (PYTHON_THREADPOOL_THREAD_COUNT,
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 @@ class Dispatcher(metaclass=DispatcherMeta):
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 @@ class Dispatcher(metaclass=DispatcherMeta):
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)

Просмотреть файл

@ -632,8 +632,6 @@ class TestDispatcherLoadFunctionInInitRequest(testutils.AsyncTestCase):
"""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(