Skip to content

Commit 4375dba

Browse files
author
Gavin Aguiar
committed
Enable dependency isolation by default for python 3.10
1 parent 93738f1 commit 4375dba

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

azure_functions_worker/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
PYTHON_THREADPOOL_THREAD_COUNT_MAX_37 = 32
4444

4545
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT = False
46-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39 = False
46+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 = True
4747
PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT = False
4848
PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT_39 = True
4949

azure_functions_worker/utils/dependency.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
CONTAINER_NAME,
1414
PYTHON_ISOLATE_WORKER_DEPENDENCIES,
1515
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT,
16-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39
16+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310
1717
)
1818
from ..utils.common import is_python_version
1919
from ..utils.wrappers import enable_feature_by
@@ -76,8 +76,8 @@ def is_in_linux_consumption(cls):
7676
@enable_feature_by(
7777
flag=PYTHON_ISOLATE_WORKER_DEPENDENCIES,
7878
flag_default=(
79-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39 if
80-
is_python_version('3.9') else
79+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
80+
is_python_version('3.10') else
8181
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
8282
)
8383
)
@@ -107,8 +107,8 @@ def use_worker_dependencies(cls):
107107
@enable_feature_by(
108108
flag=PYTHON_ISOLATE_WORKER_DEPENDENCIES,
109109
flag_default=(
110-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39 if
111-
is_python_version('3.9') else
110+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
111+
is_python_version('3.10') else
112112
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
113113
)
114114
)
@@ -181,8 +181,8 @@ def reload_customer_libraries(cls, cx_working_dir: str):
181181
use_new_env = os.getenv(PYTHON_ISOLATE_WORKER_DEPENDENCIES)
182182
if use_new_env is None:
183183
use_new = (
184-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39 if
185-
is_python_version('3.9') else
184+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
185+
is_python_version('3.10') else
186186
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
187187
)
188188
else:

tests/unittests/test_utilities_dependency.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_get_cx_deps_path_in_script_root_with_sys_path_linux_py36(self):
136136
os.environ['AzureWebJobsScriptRoot'] = '/home/site/wwwroot'
137137
result = DependencyManager._get_cx_deps_path()
138138
self.assertEqual(result, '/home/site/wwwroot/.python_packages/sites/'
139-
'lib/python3.6/site-packages/')
139+
'lib/python3.6/site-packages/')
140140

141141
def test_get_cx_deps_path_in_script_root_with_sys_path_linux(self):
142142
# Test for Python 3.7+ Azure Environment
@@ -145,7 +145,7 @@ def test_get_cx_deps_path_in_script_root_with_sys_path_linux(self):
145145
os.environ['AzureWebJobsScriptRoot'] = '/home/site/wwwroot'
146146
result = DependencyManager._get_cx_deps_path()
147147
self.assertEqual(result, '/home/site/wwwroot/.python_packages/sites/'
148-
'lib/site-packages/')
148+
'lib/site-packages/')
149149

150150
def test_get_cx_deps_path_in_script_root_with_sys_path_windows(self):
151151
# Test for Windows Core Tools Environment
@@ -523,9 +523,6 @@ def test_clear_path_importer_cache_and_modules_retain_namespace(self):
523523
os.path.join(self._worker_deps_path, 'common_module')
524524
)
525525

526-
@unittest.skip(
527-
'This feature is not ready due to azure. namespace not found bugs.'
528-
)
529526
def test_use_worker_dependencies(self):
530527
# Setup app settings
531528
os.environ['PYTHON_ISOLATE_WORKER_DEPENDENCIES'] = 'true'
@@ -558,11 +555,11 @@ def test_use_worker_dependencies_disable(self):
558555
import common_module # NoQA
559556

560557
@unittest.skipUnless(
561-
sys.version_info.major == 3 and sys.version_info.minor in (6, 7, 8),
562-
'Test only available for Python 3.6, 3.7, or 3.8'
558+
sys.version_info.major == 3 and sys.version_info.minor in (6, 7, 8, 9),
559+
'Test only available for Python 3.6, 3.7, 3.8 or 3.9'
563560
)
564-
def test_use_worker_dependencies_default_python_36_37_38(self):
565-
# Feature should be disabled in Python 3.6, 3.7, and 3.8
561+
def test_use_worker_dependencies_default_python_36_37_38_39(self):
562+
# Feature should be disabled in Python 3.6, 3.7, 3.8 and 3.9
566563
# Setup paths
567564
DependencyManager.worker_deps_path = self._worker_deps_path
568565
DependencyManager.cx_deps_path = self._customer_deps_path
@@ -573,11 +570,12 @@ def test_use_worker_dependencies_default_python_36_37_38(self):
573570
with self.assertRaises(ImportError):
574571
import common_module # NoQA
575572

576-
@unittest.skip(
577-
'This feature is not ready due to azure. namespace not found bugs.'
573+
@unittest.skipUnless(
574+
sys.version_info.major == 3 and sys.version_info.minor == 10,
575+
'Test only available for python 3.10'
578576
)
579-
def test_use_worker_dependencies_default_python_39(self):
580-
# Feature should be enabled in Python 3.9 by default
577+
def test_use_worker_dependencies_default_python_310(self):
578+
# Feature should be enabled in Python 3.10 by default
581579
# Setup paths
582580
DependencyManager.worker_deps_path = self._worker_deps_path
583581
DependencyManager.cx_deps_path = self._customer_deps_path
@@ -630,11 +628,11 @@ def test_prioritize_customer_dependencies_disable(self):
630628
import common_module # NoQA
631629

632630
@unittest.skipIf(
633-
sys.version_info.major == 3 and sys.version_info.minor in (6, 7, 8),
634-
'Test only available for Python 3.6, 3.7, or 3.8'
631+
sys.version_info.major == 3 and sys.version_info.minor == 10,
632+
'Test not available for python 3.10'
635633
)
636-
def test_prioritize_customer_dependencies_default_python_36_37_38(self):
637-
# Feature should be disabled in Python 3.6, 3.7, and 3.8
634+
def test_prioritize_customer_dependencies_default_python_36_37_38_39(self):
635+
# Feature should be disabled in Python 3.6, 3.7, 3.8 and 3.9
638636
# Setup paths
639637
DependencyManager.worker_deps_path = self._worker_deps_path
640638
DependencyManager.cx_deps_path = self._customer_deps_path
@@ -645,11 +643,12 @@ def test_prioritize_customer_dependencies_default_python_36_37_38(self):
645643
with self.assertRaises(ImportError):
646644
import common_module # NoQA
647645

648-
@unittest.skip(
649-
'This feature is not ready due to azure. namespace not found bugs.'
646+
@unittest.skipUnless(
647+
sys.version_info.major == 3 and sys.version_info.minor == 10,
648+
'Test only available for python 3.10'
650649
)
651-
def test_prioritize_customer_dependencies_default_python_39(self):
652-
# Feature should be enabled in Python 3.9 by default
650+
def test_prioritize_customer_dependencies_default_python_310(self):
651+
# Feature should be enabled in Python 3.10 by default
653652
# Setup paths
654653
DependencyManager.worker_deps_path = self._worker_deps_path
655654
DependencyManager.cx_deps_path = self._customer_deps_path

0 commit comments

Comments
 (0)