Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
run black, fix pylint complaints
  • Loading branch information
Josh Harrington committed Feb 17, 2023
commit 6a8631fcbe4bc20956f3251f60c33979e202d9ae
2 changes: 1 addition & 1 deletion sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def workspaces(self) -> WorkspaceOperations:
:rtype: WorkspaceOperations
"""
return self._workspaces

@property
def workspace_outbound_rule(self) -> WorkspaceOutboundRuleOperations:
"""A collection of workspace managed network outbound rule related operations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from azure.ai.ml._schema import ExperimentalField


class WorkspaceSchema(PathAwareSchema):
name = fields.Str(required=True)
location = fields.Str()
Expand Down
7 changes: 5 additions & 2 deletions sdk/ml/azure-ai-ml/azure/ai/ml/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@
DiagnoseWorkspaceParameters,
)
from ._workspace.networking import (
OutboundRule, ManagedNetwork, FqdnDestination, ServiceTagDestination,
PrivateEndpointDestination
OutboundRule,
ManagedNetwork,
FqdnDestination,
ServiceTagDestination,
PrivateEndpointDestination,
)
from ._workspace.private_endpoint import EndpointConnection, PrivateEndpoint
from ._workspace.workspace import Workspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from azure.core.credentials import TokenCredential
from azure.core.polling import LROPoller

from azure.ai.ml._utils.utils import _snake_to_camel

ops_logger = OpsLogger(__name__)
module_logger = ops_logger.module_logger

Expand Down
14 changes: 8 additions & 6 deletions sdk/ml/azure-ai-ml/tests/workspace/e2etests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
from azure.ai.ml.entities._credentials import IdentityConfiguration, ManagedIdentityConfiguration
from azure.ai.ml.entities._workspace.diagnose import DiagnoseResponseResultValue
from azure.ai.ml.entities._workspace.workspace import Workspace
from azure.ai.ml.entities._workspace.networking import FqdnDestination, PrivateEndpointDestination, ServiceTagDestination
from azure.core.paging import ItemPaged
from azure.ai.ml.constants._workspace import (
IsolationMode, OutboundRuleCategory, OutboundRuleType
from azure.ai.ml.entities._workspace.networking import (
FqdnDestination,
PrivateEndpointDestination,
ServiceTagDestination,
)
from azure.core.paging import ItemPaged
from azure.ai.ml.constants._workspace import IsolationMode, OutboundRuleCategory, OutboundRuleType
from azure.core.polling import LROPoller
from azure.mgmt.msi._managed_service_identity_client import ManagedServiceIdentityClient

Expand Down Expand Up @@ -344,14 +346,14 @@ def test_update_sai_to_sai_and_uai_workspace_with_uai_deletion(
def test_workspace_create_update_delete_with_managed_network(
self, client: MLClient, randstr: Callable[[], str], location: str
) -> None:
# resource name key word
# resource name key word
wps_name = f"e2etest_{randstr('wps_name')}_mvnet"

wps_description = f"{wps_name} description"
wps_display_name = f"{wps_name} display name"
params_override = [
{"name": wps_name},
# {"location": location}, # using master for now
# {"location": location}, # using master for now
{"description": wps_description},
{"display_name": wps_display_name},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
from azure.ai.ml import MLClient, load_workspace
from azure.ai.ml._utils.utils import camel_to_snake
from azure.ai.ml.entities._workspace.workspace import Workspace
from azure.ai.ml.entities._workspace.networking import FqdnDestination, PrivateEndpointDestination, ServiceTagDestination
from azure.core.paging import ItemPaged
from azure.ai.ml.constants._workspace import (
IsolationMode, OutboundRuleCategory, OutboundRuleType
from azure.ai.ml.entities._workspace.networking import (
FqdnDestination,
PrivateEndpointDestination,
ServiceTagDestination,
)
from azure.core.paging import ItemPaged
from azure.ai.ml.constants._workspace import IsolationMode, OutboundRuleCategory, OutboundRuleType
from azure.core.polling import LROPoller


@pytest.mark.e2etest
@pytest.mark.core_sdk_test
@pytest.mark.usefixtures(
Expand All @@ -39,7 +42,7 @@ def test_workspace_create_with_managed_network_list_show_remove_rules(
wps_display_name = f"{wps_name} display name"
params_override = [
{"name": wps_name},
# {"location": location}, # using master for now
# {"location": location}, # using master for now
{"description": wps_description},
{"display_name": wps_display_name},
]
Expand All @@ -57,9 +60,7 @@ def test_workspace_create_with_managed_network_list_show_remove_rules(
assert workspace.managed_network.isolation_mode == IsolationMode.ALLOW_ONLY_APPROVED_OUTBOUND

# test list outbound rules
rules = client.workspace_outbound_rule.list(
client.resource_group_name, wps_name
)
rules = client.workspace_outbound_rule.list(client.resource_group_name, wps_name)
assert "my-service" in rules.keys()
assert isinstance(rules["my-service"], ServiceTagDestination)
assert rules["my-service"].category == OutboundRuleCategory.USER_DEFINED
Expand All @@ -70,7 +71,10 @@ def test_workspace_create_with_managed_network_list_show_remove_rules(
assert "my-storage" in rules.keys()
assert isinstance(rules["my-storage"], PrivateEndpointDestination)
assert rules["my-storage"].category == OutboundRuleCategory.USER_DEFINED
assert rules["my-storage"].service_resource_id == "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyGroup/providers/Microsoft.Storage/storageAccounts/MyAccount"
assert (
rules["my-storage"].service_resource_id
== "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyGroup/providers/Microsoft.Storage/storageAccounts/MyAccount"
)
assert rules["my-storage"].spark_enabled == False
assert rules["my-storage"].subresource_target == "blob"

Expand All @@ -83,7 +87,9 @@ def test_workspace_create_with_managed_network_list_show_remove_rules(
params_override = [
{"name": wps_name},
]
wps_update = load_workspace("./tests/test_configs/workspace/workspace_update_mvnet.yaml", params_override=params_override)
wps_update = load_workspace(
"./tests/test_configs/workspace/workspace_update_mvnet.yaml", params_override=params_override
)

workspace_poller = client.workspaces.begin_update(workspace=wps_update)
assert isinstance(workspace_poller, LROPoller)
Expand All @@ -93,65 +99,49 @@ def test_workspace_create_with_managed_network_list_show_remove_rules(

# test show rules added
# FQDN rule
rule = client.workspace_outbound_rule.show(
client.resource_group_name, wps_name, "added-fqdnrule"
)
rule = client.workspace_outbound_rule.show(client.resource_group_name, wps_name, "added-fqdnrule")
assert isinstance(rule, FqdnDestination)
assert rule.category == OutboundRuleCategory.USER_DEFINED
assert rule.destination == "test.com"
# ServiceTag rule
rule = client.workspace_outbound_rule.show(
client.resource_group_name, wps_name, "added-servicetagrule"
)
rule = client.workspace_outbound_rule.show(client.resource_group_name, wps_name, "added-servicetagrule")
assert isinstance(rule, ServiceTagDestination)
assert rule.category == OutboundRuleCategory.USER_DEFINED
assert rule.service_tag == "DataFactory"
assert rule.protocol == "TCP"
assert rule.port_ranges == "80, 8080-8089"
# PrivateEndpoint rule
rule = client.workspace_outbound_rule.show(
client.resource_group_name, wps_name, "added-perule"
)
rule = client.workspace_outbound_rule.show(client.resource_group_name, wps_name, "added-perule")
assert isinstance(rule, PrivateEndpointDestination)
assert rule.category == OutboundRuleCategory.USER_DEFINED
assert rule.service_resource_id == "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyGroup/providers/Microsoft.Storage/storageAccounts/MyAccount"
assert (
rule.service_resource_id
== "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyGroup/providers/Microsoft.Storage/storageAccounts/MyAccount"
)
assert rule.subresource_target == "blob"
assert rule.spark_enabled == True

# assert update did not remove existing outbound rules
rules = client.workspace_outbound_rule.list(
client.resource_group_name, wps_name
)
rules = client.workspace_outbound_rule.list(client.resource_group_name, wps_name)
assert "pytorch" in rules.keys()
assert "my-service" in rules.keys()
assert "my-storage" in rules.keys()

# test remove outbound rule
rule_poller = client.workspace_outbound_rule.remove(
client.resource_group_name,
wps_name,
"pytorch")
rule_poller = client.workspace_outbound_rule.remove(client.resource_group_name, wps_name, "pytorch")
assert isinstance(rule_poller, LROPoller)
rule_poller.result()

rule_poller = client.workspace_outbound_rule.remove(
client.resource_group_name,
wps_name,
"my-service")
rule_poller = client.workspace_outbound_rule.remove(client.resource_group_name, wps_name, "my-service")
assert isinstance(rule_poller, LROPoller)
rule_poller.result()

rule_poller = client.workspace_outbound_rule.remove(
client.resource_group_name,
wps_name,
"my-storage")
rule_poller = client.workspace_outbound_rule.remove(client.resource_group_name, wps_name, "my-storage")
assert isinstance(rule_poller, LROPoller)
rule_poller.result()

# assert remove worked removed the outbound rules
rules = client.workspace_outbound_rule.list(
client.resource_group_name, wps_name
)
rules = client.workspace_outbound_rule.list(client.resource_group_name, wps_name)
assert "pytorch" not in rules.keys()
assert "my-service" not in rules.keys()
assert "my-storage" not in rules.keys()
Expand Down