Skip to content

Commit b5fbb58

Browse files
authored
Merge branch 'dev' into pthummar/add_py311_tests
2 parents 6aedb9d + 222883c commit b5fbb58

File tree

7 files changed

+17
-51
lines changed

7 files changed

+17
-51
lines changed

azure_functions_worker/constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
"""
3131
UNIX_SHARED_MEMORY_DIRECTORIES = "FUNCTIONS_UNIX_SHARED_MEMORY_DIRECTORIES"
3232

33-
# Flag to enable loading functions at init request
34-
PYTHON_LOAD_FUNCTIONS_INIT = "PYTHON_LOAD_FUNCTIONS_INIT"
35-
3633
# Setting Defaults
3734
PYTHON_THREADPOOL_THREAD_COUNT_DEFAULT = 1
3835
PYTHON_THREADPOOL_THREAD_COUNT_MIN = 1

azure_functions_worker/dispatcher.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
PYTHON_THREADPOOL_THREAD_COUNT_MAX_37,
2727
PYTHON_THREADPOOL_THREAD_COUNT_MIN,
2828
PYTHON_ENABLE_DEBUG_LOGGING, SCRIPT_FILE_NAME,
29-
PYTHON_LANGUAGE_RUNTIME, PYTHON_LOAD_FUNCTIONS_INIT)
29+
PYTHON_LANGUAGE_RUNTIME)
3030
from .extension import ExtensionManager
3131
from .logging import disable_console_logging, enable_console_logging
3232
from .logging import enable_debug_logging_recommendation
@@ -288,10 +288,9 @@ async def _handle__worker_init_request(self, request):
288288
if not DependencyManager.is_in_linux_consumption():
289289
DependencyManager.prioritize_customer_dependencies()
290290

291-
if DependencyManager.is_in_linux_consumption() \
292-
and is_envvar_true(PYTHON_LOAD_FUNCTIONS_INIT):
291+
if DependencyManager.is_in_linux_consumption():
293292
logger.info(
294-
"PYTHON_LOAD_FUNCTIONS_INIT enabled. Importing azure functions")
293+
"Importing azure functions in WorkerInitRequest")
295294
import azure.functions # NoQA
296295

297296
# loading bindings registry and saving results to a static
@@ -539,12 +538,6 @@ async def _handle__function_environment_reload_request(self, request):
539538
func_env_reload_request = \
540539
request.function_environment_reload_request
541540

542-
if not is_envvar_true(PYTHON_LOAD_FUNCTIONS_INIT):
543-
# Import before clearing path cache so that the default
544-
# azure.functions modules is available in sys.modules for
545-
# customer use
546-
import azure.functions # NoQA
547-
548541
# Append function project root to module finding sys.path
549542
if func_env_reload_request.function_app_directory:
550543
sys.path.append(func_env_reload_request.function_app_directory)

azure_functions_worker/functions.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,6 @@ def get_return_binding(binding_name: str,
8080

8181
return return_binding_name
8282

83-
@staticmethod
84-
def validate_binding_route(func_name: str, binding: BindingInfo,
85-
func_type: str):
86-
if hasattr(binding, 'route') and binding.route.startswith(
87-
'/') and func_type == 'function':
88-
raise FunctionLoadError(
89-
func_name,
90-
f'Invalid route name: {binding.route}. Route name cannot begin'
91-
f' with a /')
92-
9383
@staticmethod
9484
def validate_binding_direction(binding_name: str,
9585
binding_direction: str,
@@ -105,14 +95,6 @@ def validate_binding_direction(binding_name: str,
10595
func_name,
10696
'"$return" binding must have direction set to "out"')
10797

108-
def validate_binding(self, func_name: str, binding: BindingInfo,
109-
func_type: str):
110-
self.validate_binding_route(func_name, binding, func_type)
111-
112-
self.validate_binding_direction(binding.name,
113-
binding.direction,
114-
func_name)
115-
11698
@staticmethod
11799
def is_context_required(params, bound_params: dict,
118100
annotations: dict,
@@ -377,7 +359,6 @@ def add_function(self, function_id: str,
377359
def add_indexed_function(self, function):
378360
func = function.get_user_function()
379361
func_name = function.get_function_name()
380-
func_type = function.http_type
381362
function_id = str(uuid.uuid5(namespace=uuid.NAMESPACE_OID,
382363
name=func_name))
383364
return_binding_name: typing.Optional[str] = None
@@ -391,7 +372,9 @@ def add_indexed_function(self, function):
391372

392373
bound_params = {}
393374
for binding in function.get_bindings():
394-
self.validate_binding(func_name, binding, func_type)
375+
self.validate_binding_direction(binding.name,
376+
binding.direction,
377+
func_name)
395378

396379
has_explicit_return, has_implicit_return = \
397380
self.get_explicit_and_implicit_return(

azure_functions_worker/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4-
VERSION = '4.15.0'
4+
VERSION = '4.16.0'

setup.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,18 @@
107107

108108
INSTALL_REQUIRES = [
109109
"azure-functions==1.15.1b2",
110-
"python-dateutil~=2.8.2",
111-
"protobuf~=4.22.0",
112-
"grpcio-tools~=1.54.2",
113-
"grpcio~=1.54.2"
110+
"python-dateutil~=2.8.2"
114111
]
115112

113+
if sys.version_info[:2] == (3, 7):
114+
INSTALL_REQUIRES.extend(
115+
("protobuf~=3.19.3", "grpcio-tools~=1.43.0", "grpcio~=1.43.0")
116+
)
117+
else:
118+
INSTALL_REQUIRES.extend(
119+
("protobuf~=4.22.0", "grpcio-tools~=1.54.2", "grpcio~=1.54.2")
120+
)
121+
116122
EXTRA_REQUIRES = {
117123
"dev": [
118124
"azure-eventhub~=5.7.0", # Used for EventHub E2E tests

tests/unittests/test_dispatcher.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,6 @@ async def test_dispatcher_load_azfunc_in_init(self):
632632
"""Test if the dispatcher's log can be flushed out during worker
633633
initialization
634634
"""
635-
os.environ.update({"CONTAINER_NAME": 'test',
636-
"PYTHON_LOAD_FUNCTIONS_INIT": "1"})
637635
async with self._ctrl as host:
638636
r = await host.init_worker('4.15.1')
639637
self.assertEqual(

tests/unittests/test_functions_registry.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ def dummy():
2121
self.func = Function(self.dummy, "test.py")
2222
self.function_registry = functions.Registry()
2323

24-
def test_add_indexed_function_invalid_route(self):
25-
trigger1 = HttpTrigger(name="req1", route="/")
26-
self.func.add_trigger(trigger=trigger1)
27-
28-
with self.assertRaises(FunctionLoadError) as ex:
29-
self.function_registry.add_indexed_function(function=self.func)
30-
31-
self.assertEqual(str(ex.exception),
32-
'cannot load the dummy function: Invalid route name: '
33-
'/. Route name cannot begin with a /')
34-
3524
def test_add_indexed_function_invalid_direction(self):
3625
trigger1 = HttpTrigger(name="req1", route="test")
3726
binding = BlobInput(name="$return", path="testpath",

0 commit comments

Comments
 (0)