Skip to content

Commit bc135cb

Browse files
Add projects and hubs to AML SDK. (#35142)
* initial dump * run black * black, mypy, lint * test corrections 1 * rerun black * remove outdated test * refactor polymorphism to not need more load functions * syntax checks * refactor constant to not be enum to avoid type problems * update assets * more test corrections * more test corrections, feature store kind refactor * rename type to kind * show associated workspaces in yaml view * assign project values from hub during creation * formatting * record pna in projects * rename remove project from default_project_resource_group * Update sdk/ml/azure-ai-ml/azure/ai/ml/constants/_common.py Co-authored-by: kdestin <[email protected]> * Update sdk/ml/azure-ai-ml/azure/ai/ml/operations/_workspace_operations.py Co-authored-by: kdestin <[email protected]> * Update sdk/ml/azure-ai-ml/azure/ai/ml/operations/_workspace_operations.py Co-authored-by: kdestin <[email protected]> * Update sdk/ml/azure-ai-ml/azure/ai/ml/operations/_workspace_operations.py Co-authored-by: kdestin <[email protected]> * name consistency * undo enumification of workspace kind --------- Co-authored-by: kdestin <[email protected]>
1 parent 06ccc73 commit bc135cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+907
-901
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@
44

55
### Features Added
66

7+
- Renamed WorkspaceHub class as Hub.
8+
- Added Project entity class and YAML support.
9+
- Project and Hub operations supported by workspace operations.
10+
- workspace list operation supports type filtering.
11+
712
### Bugs Fixed
813

914
### Breaking Changes
1015

16+
- Removed WorkspaceHubConfig entity, and renamed WorkspaceHub to Hub.
17+
- workspace_hub input of Workspace class hidden, renamed to hub_id, and re-surfaced in child class Project.
18+
- Removed Workspace Hub Operations from ML Client.
19+
1120
### Other Changes
1221

1322
## 1.15.0 (2024-03-26)

sdk/ml/azure-ai-ml/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ml/azure-ai-ml",
5-
"Tag": "python/ml/azure-ai-ml_baea630318"
5+
"Tag": "python/ml/azure-ai-ml_cfba1d7771"
66
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
load_registry,
3636
load_workspace,
3737
load_workspace_connection,
38-
load_workspace_hub,
3938
)
4039

4140
module_logger = logging.getLogger(__name__)
@@ -69,7 +68,6 @@
6968
"load_workspace",
7069
"load_registry",
7170
"load_workspace_connection",
72-
"load_workspace_hub",
7371
"load_model_package",
7472
]
7573

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from azure.ai.ml._scope_dependent_operations import OperationConfig, OperationsContainer, OperationScope
4444
from azure.ai.ml._telemetry.logging_handler import get_appinsights_log_handler
4545
from azure.ai.ml._user_agent import USER_AGENT
46-
from azure.ai.ml._utils._experimental import experimental
4746
from azure.ai.ml._utils._http_utils import HttpPipeline
4847
from azure.ai.ml._utils._preflight_utils import get_deployments_operation
4948
from azure.ai.ml._utils._registry_utils import get_registry_client
@@ -82,7 +81,6 @@
8281
OnlineEndpointOperations,
8382
RegistryOperations,
8483
WorkspaceConnectionsOperations,
85-
WorkspaceHubOperations,
8684
WorkspaceOperations,
8785
)
8886
from azure.ai.ml.operations._code_operations import CodeOperations
@@ -658,15 +656,6 @@ def __init__(
658656
**ops_kwargs, # type: ignore[arg-type]
659657
)
660658

661-
self._workspace_hubs = WorkspaceHubOperations(
662-
self._operation_scope,
663-
self._service_client_08_2023_preview,
664-
self._operation_container,
665-
self._credential,
666-
**app_insights_handler_kwargs, # type: ignore[arg-type]
667-
)
668-
self._operation_container.add(AzureMLResourceType.WORKSPACE_HUB, self._workspace_hubs) # type: ignore[arg-type]
669-
670659
self._operation_container.add(AzureMLResourceType.FEATURE_STORE, self._featurestores) # type: ignore[arg-type]
671660
self._operation_container.add(AzureMLResourceType.FEATURE_SET, self._featuresets)
672661
self._operation_container.add(AzureMLResourceType.FEATURE_STORE_ENTITY, self._featurestoreentities)
@@ -811,7 +800,8 @@ def _ml_client_cli(cls, credentials: TokenCredential, subscription_id: Optional[
811800

812801
@property
813802
def workspaces(self) -> WorkspaceOperations:
814-
"""A collection of workspace-related operations.
803+
"""A collection of workspace-related operations. Also manages workspace
804+
sub-classes like projects and hubs.
815805
816806
:return: Workspace operations
817807
:rtype: ~azure.ai.ml.operations.WorkspaceOperations
@@ -854,16 +844,6 @@ def feature_sets(self) -> FeatureSetOperations:
854844
"""
855845
return self._featuresets
856846

857-
@property
858-
@experimental
859-
def workspace_hubs(self) -> WorkspaceHubOperations:
860-
"""A collection of workspace hub-related operations.
861-
862-
:return: Hub Operations
863-
:rtype: HubOperations
864-
"""
865-
return self._workspace_hubs
866-
867847
@property
868848
def feature_store_entities(self) -> FeatureStoreEntityOperations:
869849
"""A collection of feature store entity related operations.

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_workspace_hub/workspace_hub.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_workspace_hub/workspace_hub_config.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/workspace/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
66

77
from .workspace import WorkspaceSchema
8+
from .ai_workspaces.project import ProjectSchema
9+
from .ai_workspaces.hub import HubSchema
810

9-
__all__ = ["WorkspaceSchema"]
11+
__all__ = ["WorkspaceSchema", "ProjectSchema", "HubSchema"]

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_workspace_hub/__init__.py renamed to sdk/ml/azure-ai-ml/azure/ai/ml/_schema/workspace/ai_workspaces/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,3 @@
33
# ---------------------------------------------------------
44

55
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
6-
7-
from .workspace_hub import WorkspaceHubSchema
8-
9-
__all__ = ["WorkspaceHubSchema"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# ---------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# ---------------------------------------------------------
4+
5+
from marshmallow import fields
6+
7+
from azure.ai.ml._schema import StringTransformedEnum
8+
from azure.ai.ml._schema.workspace import WorkspaceSchema
9+
from azure.ai.ml._utils._experimental import experimental
10+
from azure.ai.ml.constants import WorkspaceKind
11+
12+
13+
@experimental
14+
class HubSchema(WorkspaceSchema):
15+
# additional_workspace_storage_accounts This field exists in the API, but is unused, and thus not surfaced yet.
16+
kind = StringTransformedEnum(required=True, allowed_values=WorkspaceKind.HUB)
17+
default_resource_group = fields.Str(required=False)
18+
associated_workspaces = fields.List(fields.Str(), required=False, dump_only=True)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ---------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# ---------------------------------------------------------
4+
5+
from marshmallow import fields
6+
7+
from azure.ai.ml._schema import StringTransformedEnum
8+
from azure.ai.ml._utils._experimental import experimental
9+
from azure.ai.ml._schema.workspace import WorkspaceSchema
10+
from azure.ai.ml.constants import WorkspaceKind
11+
12+
13+
@experimental
14+
class ProjectSchema(WorkspaceSchema):
15+
kind = StringTransformedEnum(required=True, allowed_values=WorkspaceKind.PROJECT)
16+
hub_id = fields.Str(required=True)

sdk/ml/azure-ai-ml/azure/ai/ml/constants/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from azure.ai.ml._restclient.v2023_10_01.models import ListViewType
99

1010
from ._assets import IPProtectionLevel
11-
from ._common import AssetTypes, InputOutputModes, ModelType, Scope, TimeZone
11+
from ._common import AssetTypes, InputOutputModes, ModelType, Scope, TimeZone, WorkspaceKind
1212
from ._component import ParallelTaskType
1313
from ._deployment import BatchDeploymentOutputAction
1414
from ._job import (
@@ -63,4 +63,5 @@
6363
"MonitorTargetTasks",
6464
"IPProtectionLevel",
6565
"ListViewType",
66+
"WorkspaceKind",
6667
]

sdk/ml/azure-ai-ml/azure/ai/ml/constants/_common.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,10 @@ class AzureMLResourceType:
246246
"""Feature store entity resource type."""
247247
FEATURE_STORE = "feature_store"
248248
"""Feature store resource type."""
249-
WORKSPACE_HUB = "workspace_hub"
250-
"""WorkspaceHub resource type."""
249+
HUB = "hub"
250+
"""Hub resource type."""
251+
PROJECT = "project"
252+
"""Project resource type."""
251253

252254
NAMED_TYPES = {
253255
JOB,
@@ -390,6 +392,7 @@ class CommonYamlFields:
390392
"""Name."""
391393
SCHEMA = "$schema"
392394
"""Schema."""
395+
KIND = "kind"
393396

394397

395398
class SchemaUrl:
@@ -490,7 +493,7 @@ class YAMLRefDocLinks:
490493
FEATURE_STORE = "https://aka.ms/ml-cli-v2-featurestore-yaml-reference"
491494
FEATURE_SET = "https://aka.ms/ml-cli-v2-featureset-yaml-reference"
492495
FEATURE_STORE_ENTITY = "https://aka.ms/ml-cli-v2-featurestore-entity-yaml-reference"
493-
WORKSPACEHUB = "https://aka.ms/ml-cli-v2-workspace-hub-entity-yaml-reference"
496+
HUB = "https://aka.ms/ml-cli-v2-workspace-hub-entity-yaml-reference"
494497

495498

496499
class YAMLRefDocSchemaNames:
@@ -910,3 +913,12 @@ class ScheduleType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
910913
class AutoDeleteCondition(str, Enum, metaclass=CaseInsensitiveEnumMeta):
911914
CREATED_GREATER_THAN = "created_greater_than"
912915
LAST_ACCESSED_GREATER_THAN = "last_accessed_greater_than"
916+
917+
918+
class WorkspaceKind():
919+
"""Enum of workspace categories."""
920+
921+
DEFAULT = "default"
922+
HUB = "hub"
923+
PROJECT = "project"
924+
FEATURE_STORE = "featurestore"

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@
220220
from ._workspace.private_endpoint import EndpointConnection, PrivateEndpoint
221221
from ._workspace.serverless_compute import ServerlessComputeSettings
222222
from ._workspace.workspace import Workspace
223+
from ._workspace._ai_workspaces.hub import Hub
224+
from ._workspace._ai_workspaces.project import Project
223225
from ._workspace.workspace_keys import ContainerRegistryCredential, NotebookAccessKeys, WorkspaceKeys
224-
from ._workspace_hub.workspace_hub import WorkspaceHub, WorkspaceHubConfig
225226

226227
__all__ = [
227228
"Resource",
@@ -356,8 +357,8 @@
356357
"AutoScaleSettings",
357358
"AutoPauseSettings",
358359
"WorkspaceModelReference",
359-
"WorkspaceHub",
360-
"WorkspaceHubConfig",
360+
"Hub",
361+
"Project",
361362
"Feature",
362363
"FeatureSet",
363364
"FeatureSetBackfillRequest",

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_feature_store/_constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
ONLINE_MATERIALIZATION_STORE_TYPE = "redis"
1010
ONLINE_STORE_CONNECTION_CATEGORY = "Redis"
1111
DEFAULT_SPARK_RUNTIME_VERSION = "3.2.0"
12-
FEATURE_STORE_KIND = "featurestore"
1312
STORE_REGEX_PATTERN = (
1413
"^/?subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/Microsoft.Storage"
1514
"/storageAccounts/([^/]+)/blobServices/default/containers/([^/]+)"

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_feature_store/feature_store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
from azure.ai.ml.entities._workspace.feature_store_settings import FeatureStoreSettings
2020
from azure.ai.ml.entities._workspace.networking import ManagedNetwork
2121
from azure.ai.ml.entities._workspace.workspace import Workspace
22-
23-
from ._constants import DEFAULT_SPARK_RUNTIME_VERSION, FEATURE_STORE_KIND
22+
from azure.ai.ml.constants._common import WorkspaceKind
23+
from ._constants import DEFAULT_SPARK_RUNTIME_VERSION
2424
from .materialization_store import MaterializationStore
2525

2626

@@ -136,7 +136,7 @@ def __init__(
136136
name=name,
137137
description=description,
138138
tags=tags,
139-
kind=FEATURE_STORE_KIND,
139+
kind=WorkspaceKind.FEATURE_STORE,
140140
display_name=display_name,
141141
location=location,
142142
resource_group=resource_group,

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

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
from azure.ai.ml.entities._validation import PathAwareSchemaValidatableMixin, ValidationResultBuilder
4242
from azure.ai.ml.entities._workspace.connections.workspace_connection import WorkspaceConnection
4343
from azure.ai.ml.entities._workspace.workspace import Workspace
44-
from azure.ai.ml.entities._workspace_hub.workspace_hub import WorkspaceHub
4544
from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, ValidationErrorType, ValidationException
4645

4746
module_logger = logging.getLogger(__name__)
@@ -202,7 +201,8 @@ def load_workspace(
202201
relative_origin: Optional[str] = None,
203202
**kwargs: Any,
204203
) -> Workspace:
205-
"""Load a workspace object from a yaml file.
204+
"""Load a workspace object from a yaml file. This includes workspace sub-classes
205+
like hubs and projects.
206206
207207
:param source: The local yaml source of a workspace. Must be either a
208208
path to a local file, or an already-open file.
@@ -862,45 +862,6 @@ def load_feature_store_entity(
862862
return cast(FeatureStoreEntity, load_common(FeatureStoreEntity, source, relative_origin, **kwargs))
863863

864864

865-
@experimental
866-
def load_workspace_hub(
867-
source: Union[str, PathLike, IO[AnyStr]],
868-
*,
869-
relative_origin: Optional[str] = None,
870-
**kwargs: Any,
871-
) -> WorkspaceHub:
872-
"""Load a WorkspaceHub object from a yaml file.
873-
874-
:param source: The local yaml source of a WorkspaceHub. Must be either a
875-
path to a local file, or an already-open file.
876-
If the source is a path, it will be open and read.
877-
An exception is raised if the file does not exist.
878-
If the source is an open file, the file will be read directly,
879-
and an exception is raised if the file is not readable.
880-
:type source: Union[PathLike, str, io.TextIOWrapper]
881-
:keyword relative_origin: The origin to be used when deducing
882-
the relative locations of files referenced in the parsed yaml.
883-
Defaults to the inputted source's directory if it is a file or file path input.
884-
Defaults to "./" if the source is a stream input with no name value.
885-
:paramtype relative_origin: str
886-
:keyword params_override: Fields to overwrite on top of the yaml file.
887-
Format is [{"field1": "value1"}, {"field2": "value2"}]
888-
:paramtype params_override: List[Dict]
889-
:return: Loaded WorkspaceHub object.
890-
:rtype: WorkspaceHub
891-
892-
.. admonition:: Example:
893-
894-
.. literalinclude:: ../samples/ml_samples_workspace.py
895-
:start-after: [START load_workspace_hub]
896-
:end-before: [END load_workspace_hub]
897-
:language: python
898-
:dedent: 8
899-
:caption: Loading a Workspace Hub from a YAML config file.
900-
"""
901-
return cast(WorkspaceHub, load_common(WorkspaceHub, source, relative_origin, **kwargs))
902-
903-
904865
@experimental
905866
def load_model_package(
906867
source: Union[str, PathLike, IO[AnyStr]],

0 commit comments

Comments
 (0)