Skip to content
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

feat: Update to support py312 #1533

Merged
merged 14 commits into from
Jul 22, 2024
2 changes: 2 additions & 0 deletions eng/templates/jobs/ci-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
PYTHON_VERSION: '3.10'
Python311:
PYTHON_VERSION: '3.11'
Python312:
PYTHON_VERSION: '3.12'

steps:
- task: UsePythonVersion@0
Expand Down
3 changes: 3 additions & 0 deletions eng/templates/official/jobs/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
Python311V4:
pythonVersion: '3.11'
workerPath: 'python/prodV4/worker.py'
Python312V4:
pythonVersion: '3.12'
workerPath: 'python/prodV4/worker.py'
templateContext:
outputParentDirectory: $(Build.ArtifactStagingDirectory)
outputs:
Expand Down
9 changes: 9 additions & 0 deletions eng/templates/official/jobs/ci-docker-consumption-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ jobs:
SQL_CONNECTION: $(LinuxSqlConnectionString311)
EVENTGRID_URI: $(LinuxEventGridTopicUriString311)
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString311)
Python312:
PYTHON_VERSION: '3.12'
STORAGE_CONNECTION: $(LinuxStorageConnectionString312)
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString312)
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString312)
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString312)
SQL_CONNECTION: $(LinuxSqlConnectionString312)
EVENTGRID_URI: $(LinuxEventGridTopicUriString312)
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString312)

steps:
- task: UsePythonVersion@0
Expand Down
9 changes: 9 additions & 0 deletions eng/templates/official/jobs/ci-docker-dedicated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ jobs:
SQL_CONNECTION: $(LinuxSqlConnectionString311)
EVENTGRID_URI: $(LinuxEventGridTopicUriString311)
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString311)
Python312:
PYTHON_VERSION: '3.121'
hallvictoria marked this conversation as resolved.
Show resolved Hide resolved
STORAGE_CONNECTION: $(LinuxStorageConnectionString312)
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString312)
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString312)
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString312)
SQL_CONNECTION: $(LinuxSqlConnectionString312)
EVENTGRID_URI: $(LinuxEventGridTopicUriString312)
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString312)

steps:
- task: UsePythonVersion@0
Expand Down
9 changes: 9 additions & 0 deletions eng/templates/official/jobs/ci-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ jobs:
SQL_CONNECTION: $(LinuxSqlConnectionString311)
EVENTGRID_URI: $(LinuxEventGridTopicUriString311)
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString311)
Python312:
PYTHON_VERSION: '3.12'
STORAGE_CONNECTION: $(LinuxStorageConnectionString312)
COSMOSDB_CONNECTION: $(LinuxCosmosDBConnectionString312)
EVENTHUB_CONNECTION: $(LinuxEventHubConnectionString312)
SERVICEBUS_CONNECTION: $(LinuxServiceBusConnectionString312)
SQL_CONNECTION: $(LinuxSqlConnectionString312
EVENTGRID_URI: $(LinuxEventGridTopicUriString312)
EVENTGRID_CONNECTION: $(LinuxEventGridConnectionKeyString312)
steps:
- task: UsePythonVersion@0
inputs:
Expand Down
11 changes: 4 additions & 7 deletions eng/templates/official/jobs/ci-lc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@ jobs:
matrix:
Python37:
PYTHON_VERSION: '3.7'
STORAGE_CONNECTION: $(LinuxStorageConnectionString37)
Python38:
PYTHON_VERSION: '3.8'
STORAGE_CONNECTION: $(LinuxStorageConnectionString38)
Python39:
PYTHON_VERSION: '3.9'
STORAGE_CONNECTION: $(LinuxStorageConnectionString39)
Python310:
PYTHON_VERSION: '3.10'
STORAGE_CONNECTION: $(LinuxStorageConnectionString310)
Python311:
PYTHON_VERSION: '3.11'
STORAGE_CONNECTION: $(LinuxStorageConnectionString311)

Python312:
PYTHON_VERSION: '3.12'

steps:
- task: UsePythonVersion@0
inputs:
Expand All @@ -44,6 +41,6 @@ jobs:
- bash: |
python -m pytest -n auto --dist loadfile -vv --reruns 4 --instafail tests/consumption_tests
env:
AzureWebJobsStorage: $(STORAGE_CONNECTION)
AzureWebJobsStorage: $(LinuxStorageConnectionString312)
_DUMMY_CONT_KEY: $(_DUMMY_CONT_KEY)
displayName: "Running $(PYTHON_VERSION) Linux Consumption tests"
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ dependencies = [
"azure-functions==1.20.0",
"python-dateutil ~=2.9.0",
"protobuf~=3.19.3; python_version == '3.7'",
"protobuf~=4.22.0; python_version >= '3.8'",
"protobuf~=5.27.2; python_version >= '3.8'",
"grpcio-tools~=1.43.0; python_version == '3.7'",
"grpcio-tools~=1.54.2; python_version >= '3.8'",
"grpcio-tools~=1.64.1; python_version >= '3.8'",
"grpcio~=1.43.0; python_version == '3.7'",
"grpcio~=1.54.2; python_version >= '3.8'",
"grpcio~=1.64.1; python_version >= '3.8'",
"azurefunctions-extensions-base; python_version >= '3.8'"
]

Expand Down
4 changes: 2 additions & 2 deletions python/prodV4/worker.config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"description":{
"language":"python",
"defaultRuntimeVersion":"3.10",
"defaultRuntimeVersion":"3.11",
"supportedOperatingSystems":["LINUX", "OSX", "WINDOWS"],
"supportedRuntimeVersions":["3.7", "3.8", "3.9", "3.10", "3.11"],
"supportedRuntimeVersions":["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"],
"supportedArchitectures":["X64", "X86", "Arm64"],
"extensions":[".py"],
"defaultExecutablePath":"python",
Expand Down
7 changes: 2 additions & 5 deletions python/prodV4/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ def determine_user_pkg_paths():
"""
minor_version = sys.version_info[1]

usr_packages_path = []

if minor_version in (7, 8, 9, 10, 11):
usr_packages_path.append(os.path.join(PKGS_PATH, PKGS))
else:
if not (7 <= minor_version <= 12):
raise RuntimeError(f'Unsupported Python version: 3.{minor_version}')

usr_packages_path = [os.path.join(PKGS_PATH, PKGS)]
return usr_packages_path


Expand Down
4 changes: 3 additions & 1 deletion tests/unittests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,15 @@ def test_is_python_version(self):
is_python_version_39 = common.is_python_version('3.9')
is_python_version_310 = common.is_python_version('3.10')
is_python_version_311 = common.is_python_version('3.11')
is_python_version_312 = common.is_python_version('3.12')

self.assertTrue(any([
is_python_version_37,
is_python_version_38,
is_python_version_39,
is_python_version_310,
is_python_version_311
is_python_version_311,
is_python_version_312
]))

def test_get_sdk_from_sys_path(self):
Expand Down
6 changes: 3 additions & 3 deletions tests/unittests/test_utilities_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ def test_newrelic_protobuf_import_scenario_worker_deps(self):

protobuf_version = tuple(int(v) for v in __version__.split("."))
self.assertIsNotNone(protobuf_version)
self.assertEqual(protobuf_version[0], 4)
self.assertEqual(protobuf_version[0], 5)

@unittest.skipIf(sys.version_info.minor > 7,
"The worker brings different protobuf versions"
Expand Down Expand Up @@ -721,7 +721,7 @@ def test_newrelic_protobuf_import_scenario_user_deps_37(self):
self.assertEqual(protobuf_version[0], 3)

# newrelic tries to import protobuf v4
self.assertNotEqual(protobuf_version[0], 4)
self.assertNotEqual(protobuf_version[0], 5)

@unittest.skipIf(sys.version_info.minor <= 7,
"The worker brings different protobuf versions"
Expand All @@ -748,7 +748,7 @@ def test_newrelic_protobuf_import_scenario_user_deps(self):
self.assertIsNotNone(protobuf_version)

# newrelic tries to import protobuf v4
self.assertEqual(protobuf_version[0], 4)
self.assertEqual(protobuf_version[0], 5)

# newrelic tries to import protobuf v3
self.assertNotEqual(protobuf_version[0], 3)
Expand Down
Loading