-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(azure-ai-ml): add subscription_id and resource_group to Azure storage datastores #46067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,6 +52,10 @@ class AzureFileDatastore(Datastore): | |||||||||||||||||||||||
| :param credentials: Credentials to use for Azure ML workspace to connect to the storage. Defaults to None. | ||||||||||||||||||||||||
| :type credentials: Union[~azure.ai.ml.entities.AccountKeyConfiguration, | ||||||||||||||||||||||||
| ~azure.ai.ml.entities.SasTokenConfiguration] | ||||||||||||||||||||||||
| :param subscription_id: Azure subscription ID of the storage account. Defaults to None. | ||||||||||||||||||||||||
| :type subscription_id: Optional[str] | ||||||||||||||||||||||||
| :param resource_group: Azure resource group of the storage account. Defaults to None. | ||||||||||||||||||||||||
| :type resource_group: Optional[str] | ||||||||||||||||||||||||
| :param kwargs: A dictionary of additional configuration parameters. | ||||||||||||||||||||||||
| :type kwargs: dict | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
|
|
@@ -68,6 +72,8 @@ def __init__( | |||||||||||||||||||||||
| protocol: str = HTTPS, | ||||||||||||||||||||||||
| properties: Optional[Dict] = None, | ||||||||||||||||||||||||
| credentials: Optional[Union[AccountKeyConfiguration, SasTokenConfiguration]] = None, | ||||||||||||||||||||||||
| subscription_id: Optional[str] = None, | ||||||||||||||||||||||||
| resource_group: Optional[str] = None, | ||||||||||||||||||||||||
| **kwargs: Any | ||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||
| kwargs[TYPE] = DatastoreType.AZURE_FILE | ||||||||||||||||||||||||
|
|
@@ -78,6 +84,8 @@ def __init__( | |||||||||||||||||||||||
| self.account_name = account_name | ||||||||||||||||||||||||
| self.endpoint = endpoint | ||||||||||||||||||||||||
| self.protocol = protocol | ||||||||||||||||||||||||
| self.subscription_id = subscription_id | ||||||||||||||||||||||||
| self.resource_group = resource_group | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def _to_rest_object(self) -> DatastoreData: | ||||||||||||||||||||||||
| file_ds = RestAzureFileDatastore( | ||||||||||||||||||||||||
|
|
@@ -88,6 +96,8 @@ def _to_rest_object(self) -> DatastoreData: | |||||||||||||||||||||||
| protocol=self.protocol, | ||||||||||||||||||||||||
| description=self.description, | ||||||||||||||||||||||||
| tags=self.tags, | ||||||||||||||||||||||||
| subscription_id=self.subscription_id, | ||||||||||||||||||||||||
| resource_group=self.resource_group, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
| return DatastoreData(properties=file_ds) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -109,6 +119,8 @@ def _from_rest_object(cls, datastore_resource: DatastoreData) -> "AzureFileDatas | |||||||||||||||||||||||
| file_share_name=properties.file_share_name, | ||||||||||||||||||||||||
| description=properties.description, | ||||||||||||||||||||||||
| tags=properties.tags, | ||||||||||||||||||||||||
| subscription_id=properties.subscription_id, | ||||||||||||||||||||||||
| resource_group=properties.resource_group, | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def __eq__(self, other: Any) -> bool: | ||||||||||||||||||||||||
|
|
@@ -152,6 +164,10 @@ class AzureBlobDatastore(Datastore): | |||||||||||||||||||||||
| :param credentials: Credentials to use for Azure ML workspace to connect to the storage. | ||||||||||||||||||||||||
| :type credentials: Union[~azure.ai.ml.entities.AccountKeyConfiguration, | ||||||||||||||||||||||||
| ~azure.ai.ml.entities.SasTokenConfiguration] | ||||||||||||||||||||||||
| :param subscription_id: Azure subscription ID of the storage account. Defaults to None. | ||||||||||||||||||||||||
| :type subscription_id: Optional[str] | ||||||||||||||||||||||||
| :param resource_group: Azure resource group of the storage account. Defaults to None. | ||||||||||||||||||||||||
| :type resource_group: Optional[str] | ||||||||||||||||||||||||
| :param kwargs: A dictionary of additional configuration parameters. | ||||||||||||||||||||||||
| :type kwargs: dict | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
|
|
@@ -168,6 +184,8 @@ def __init__( | |||||||||||||||||||||||
| protocol: str = HTTPS, | ||||||||||||||||||||||||
| properties: Optional[Dict] = None, | ||||||||||||||||||||||||
| credentials: Optional[Union[AccountKeyConfiguration, SasTokenConfiguration]] = None, | ||||||||||||||||||||||||
| subscription_id: Optional[str] = None, | ||||||||||||||||||||||||
| resource_group: Optional[str] = None, | ||||||||||||||||||||||||
| **kwargs: Any | ||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||
| kwargs[TYPE] = DatastoreType.AZURE_BLOB | ||||||||||||||||||||||||
|
|
@@ -179,6 +197,8 @@ def __init__( | |||||||||||||||||||||||
| self.account_name = account_name | ||||||||||||||||||||||||
| self.endpoint = endpoint if endpoint else _get_storage_endpoint_from_metadata() | ||||||||||||||||||||||||
| self.protocol = protocol | ||||||||||||||||||||||||
| self.subscription_id = subscription_id | ||||||||||||||||||||||||
| self.resource_group = resource_group | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
| def __eq__(self, other: object) -> bool: | |
| if not isinstance(other, AzureBlobDatastore): | |
| return NotImplemented | |
| return ( | |
| super().__eq__(other) | |
| and self.subscription_id == other.subscription_id | |
| and self.resource_group == other.resource_group | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AzureFileDatastore now has subscription_id/resource_group fields that affect datastore identity/scope, but eq doesn’t compare them. This can cause two datastores with different ARM scope to compare equal and can hide regressions in round-trip tests. Include subscription_id and resource_group in the eq comparison (alongside endpoint/protocol).