Skip to content

Commit fa9f040

Browse files
authored
Change schedule and WS conn print behavior (Azure#27804)
* change schedule and WS conn print behavior
1 parent 3fa3e1c commit fa9f040

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

sdk/ml/azure-ai-ml/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release History
22

3+
## 1.3.0 (Unreleased)
4+
5+
### Features Added
6+
- Change print behavior of entity classes to show object yaml in notebooks, can be configured on in other contexts.
7+
38
## 1.2.0 (2022-12-05)
49

510
### Breaking Changes

sdk/ml/azure-ai-ml/azure/ai/ml/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# ---------------------------------------------------------
44

5-
VERSION = "1.2.0"
5+
VERSION = "1.3.0"

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_resource.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
from azure.ai.ml._restclient.v2021_10_01 import models
1515

16+
from azure.ai.ml._utils.utils import dump_yaml
17+
from azure.ai.ml._telemetry.logging_handler import in_jupyter_notebook
18+
1619
from ._system_data import SystemData
1720

1821

@@ -39,15 +42,23 @@ def __init__(
3942
:type description: str, optional
4043
:param tags: Tag dictionary. Tags can be added, removed, and updated., defaults to None
4144
:type tags: Dict, optional
42-
:param properties: The asset property dictionary., defaults to None
45+
:param properties: The asset property dictionary. Defaults to None
4346
:type properties: Dict, optional
47+
:param: print_as_yaml: If set to true, then printing out this resource will produce a YAML-formatted object.
48+
False will force a more-compact printing style. By default, the YAML output is only used in jupyter
49+
notebooks. Be aware that some bookkeeping values are shown only in the non-YAML output.
50+
:type print_as_yaml: bool, optional
4451
:param kwargs: A dictionary of additional configuration parameters.
4552
:type kwargs: dict
4653
"""
4754
self.name = name
4855
self.description = description
4956
self.tags = dict(tags) if tags else {}
5057
self.properties = dict(properties) if properties else {}
58+
# Conditional assignment to prevent entity bloat when unused.
59+
print_as_yaml = kwargs.pop("print_as_yaml", in_jupyter_notebook())
60+
if print_as_yaml:
61+
self.print_as_yaml = True
5162

5263
# Hide read only properties in kwargs
5364
self._id = kwargs.pop("id", None)
@@ -184,4 +195,8 @@ def __repr__(self) -> str:
184195
return f"{self.__class__.__name__}({var_dict})"
185196

186197
def __str__(self) -> str:
198+
if hasattr(self, "print_as_yaml") and self.print_as_yaml:
199+
# pylint: disable=no-member
200+
yaml_serialized = self._to_dict()
201+
return dump_yaml(yaml_serialized, default_flow_style=False)
187202
return self.__repr__()

0 commit comments

Comments
 (0)