Skip to content

Enable dependency isolation by default for python 3.10 #922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azure_functions_worker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
PYTHON_THREADPOOL_THREAD_COUNT_MAX_37 = 32

PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT = False
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39 = False
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 = True
PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT = False
PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT_39 = True

Expand Down
14 changes: 7 additions & 7 deletions azure_functions_worker/utils/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
CONTAINER_NAME,
PYTHON_ISOLATE_WORKER_DEPENDENCIES,
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT,
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310
)
from ..utils.common import is_python_version
from ..utils.wrappers import enable_feature_by
Expand Down Expand Up @@ -76,8 +76,8 @@ def is_in_linux_consumption(cls):
@enable_feature_by(
flag=PYTHON_ISOLATE_WORKER_DEPENDENCIES,
flag_default=(
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39 if
is_python_version('3.9') else
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
is_python_version('3.10') else
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
)
)
Expand Down Expand Up @@ -107,8 +107,8 @@ def use_worker_dependencies(cls):
@enable_feature_by(
flag=PYTHON_ISOLATE_WORKER_DEPENDENCIES,
flag_default=(
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39 if
is_python_version('3.9') else
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
is_python_version('3.10') else
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
)
)
Expand Down Expand Up @@ -181,8 +181,8 @@ def reload_customer_libraries(cls, cx_working_dir: str):
use_new_env = os.getenv(PYTHON_ISOLATE_WORKER_DEPENDENCIES)
if use_new_env is None:
use_new = (
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_39 if
is_python_version('3.9') else
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
is_python_version('3.10') else
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
)
else:
Expand Down
41 changes: 20 additions & 21 deletions tests/unittests/test_utilities_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_get_cx_deps_path_in_script_root_with_sys_path_linux_py36(self):
os.environ['AzureWebJobsScriptRoot'] = '/home/site/wwwroot'
result = DependencyManager._get_cx_deps_path()
self.assertEqual(result, '/home/site/wwwroot/.python_packages/sites/'
'lib/python3.6/site-packages/')
'lib/python3.6/site-packages/')

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

def test_get_cx_deps_path_in_script_root_with_sys_path_windows(self):
# Test for Windows Core Tools Environment
Expand Down Expand Up @@ -523,9 +523,6 @@ def test_clear_path_importer_cache_and_modules_retain_namespace(self):
os.path.join(self._worker_deps_path, 'common_module')
)

@unittest.skip(
'This feature is not ready due to azure. namespace not found bugs.'
)
def test_use_worker_dependencies(self):
# Setup app settings
os.environ['PYTHON_ISOLATE_WORKER_DEPENDENCIES'] = 'true'
Expand Down Expand Up @@ -558,11 +555,11 @@ def test_use_worker_dependencies_disable(self):
import common_module # NoQA

@unittest.skipUnless(
sys.version_info.major == 3 and sys.version_info.minor in (6, 7, 8),
'Test only available for Python 3.6, 3.7, or 3.8'
sys.version_info.major == 3 and sys.version_info.minor != 10,
'Test only available for Python 3.6, 3.7, 3.8 or 3.9'
)
def test_use_worker_dependencies_default_python_36_37_38(self):
# Feature should be disabled in Python 3.6, 3.7, and 3.8
def test_use_worker_dependencies_default_python_36_37_38_39(self):
# Feature should be disabled in Python 3.6, 3.7, 3.8 and 3.9
# Setup paths
DependencyManager.worker_deps_path = self._worker_deps_path
DependencyManager.cx_deps_path = self._customer_deps_path
Expand All @@ -573,11 +570,12 @@ def test_use_worker_dependencies_default_python_36_37_38(self):
with self.assertRaises(ImportError):
import common_module # NoQA

@unittest.skip(
'This feature is not ready due to azure. namespace not found bugs.'
@unittest.skipUnless(
sys.version_info.major == 3 and sys.version_info.minor == 10,
'Test only available for python 3.10'
)
def test_use_worker_dependencies_default_python_39(self):
# Feature should be enabled in Python 3.9 by default
def test_use_worker_dependencies_default_python_310(self):
# Feature should be enabled in Python 3.10 by default
# Setup paths
DependencyManager.worker_deps_path = self._worker_deps_path
DependencyManager.cx_deps_path = self._customer_deps_path
Expand Down Expand Up @@ -630,11 +628,11 @@ def test_prioritize_customer_dependencies_disable(self):
import common_module # NoQA

@unittest.skipIf(
sys.version_info.major == 3 and sys.version_info.minor in (6, 7, 8),
'Test only available for Python 3.6, 3.7, or 3.8'
sys.version_info.major == 3 and sys.version_info.minor == 10,
'Test not available for python 3.10'
)
def test_prioritize_customer_dependencies_default_python_36_37_38(self):
# Feature should be disabled in Python 3.6, 3.7, and 3.8
def test_prioritize_customer_dependencies_default_python_36_37_38_39(self):
# Feature should be disabled in Python 3.6, 3.7, 3.8 and 3.9
# Setup paths
DependencyManager.worker_deps_path = self._worker_deps_path
DependencyManager.cx_deps_path = self._customer_deps_path
Expand All @@ -645,11 +643,12 @@ def test_prioritize_customer_dependencies_default_python_36_37_38(self):
with self.assertRaises(ImportError):
import common_module # NoQA

@unittest.skip(
'This feature is not ready due to azure. namespace not found bugs.'
@unittest.skipUnless(
sys.version_info.major == 3 and sys.version_info.minor == 10,
'Test only available for python 3.10'
)
def test_prioritize_customer_dependencies_default_python_39(self):
# Feature should be enabled in Python 3.9 by default
def test_prioritize_customer_dependencies_default_python_310(self):
# Feature should be enabled in Python 3.10 by default
# Setup paths
DependencyManager.worker_deps_path = self._worker_deps_path
DependencyManager.cx_deps_path = self._customer_deps_path
Expand Down