Skip to content

Commit d8ba8a1

Browse files
kingernupurkshitij-microsoft
authored andcommitted
Catch exception for missing duration value (#40244)
* catch exception for missing duration value * Log exception warning * Add util tests * Fix pylint and isort errors
1 parent 327afb3 commit d8ba8a1

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_workspace_operations_base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,9 +1128,12 @@ def resource(self) -> Any:
11281128
error_msg = f"Unable to create resource. \n {error}\n"
11291129
module_logger.error(error_msg)
11301130
raise error
1131-
module_logger.info(
1132-
"Total time : %s\n", from_iso_duration_format_min_sec(total_duration) # pylint: disable=E0606
1133-
)
1131+
1132+
try:
1133+
# duration comes in format: "PT1M56.3454108S"
1134+
module_logger.info("Total time : %s\n", from_iso_duration_format_min_sec(total_duration))
1135+
except Exception as e: # pylint: disable=W0718
1136+
module_logger.warning("Exception occurred while logging total duration: %s", e)
11341137
return self.func()
11351138

11361139
# pylint: disable=docstring-missing-param

sdk/ml/azure-ai-ml/tests/utils/__init__.py

Whitespace-only changes.

sdk/ml/azure-ai-ml/tests/utils/unittests/__init__.py

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
from azure.ai.ml._utils.utils import from_iso_duration_format_min_sec
4+
5+
6+
@pytest.mark.unittest
7+
@pytest.mark.core_sdk_test
8+
class TestUtils:
9+
def test_from_iso_duration_format_min_sec(self) -> None:
10+
duration = from_iso_duration_format_min_sec("PT10M41.7894561S")
11+
assert duration == "10m 41s"

0 commit comments

Comments
 (0)