|
16 | 16 |
|
17 | 17 | import os |
18 | 18 | import re |
| 19 | +import sys |
19 | 20 |
|
20 | 21 | from tests.unit.vertexai.genai.replays import pytest_helper |
21 | 22 | from vertexai._genai import types |
@@ -124,6 +125,30 @@ def test_create_with_source_packages( |
124 | 125 | mock_agent_engine_create_path_exists, |
125 | 126 | ): |
126 | 127 | """Tests creating an agent engine with source packages.""" |
| 128 | + if sys.version_info >= (3, 13): |
| 129 | + try: |
| 130 | + client._api_client._initialize_replay_session_if_not_loaded() |
| 131 | + if client._api_client.replay_session: |
| 132 | + target_ver = f"{sys.version_info.major}.{sys.version_info.minor}" |
| 133 | + for interaction in client._api_client.replay_session.interactions: |
| 134 | + |
| 135 | + def _update_ver(obj): |
| 136 | + if isinstance(obj, dict): |
| 137 | + if "python_spec" in obj and isinstance(obj["python_spec"], dict): |
| 138 | + if "version" in obj["python_spec"]: |
| 139 | + obj["python_spec"]["version"] = target_ver |
| 140 | + for v in obj.values(): |
| 141 | + _update_ver(v) |
| 142 | + elif isinstance(obj, list): |
| 143 | + for item in obj: |
| 144 | + _update_ver(item) |
| 145 | + |
| 146 | + if hasattr(interaction.request, "body_segments"): |
| 147 | + _update_ver(interaction.request.body_segments) |
| 148 | + if hasattr(interaction.request, "body"): |
| 149 | + _update_ver(interaction.request.body) |
| 150 | + except Exception: |
| 151 | + pass |
127 | 152 | with ( |
128 | 153 | mock_agent_engine_create_base64_encoded_tarball, |
129 | 154 | mock_agent_engine_create_path_exists, |
|
0 commit comments