Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions sdk/ai/azure-ai-projects/apiview-properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"azure.ai.projects.models.AzureAISearchIndex": "Azure.AI.Projects.AzureAISearchIndex",
"azure.ai.projects.models.TargetConfig": "Azure.AI.Projects.TargetConfig",
"azure.ai.projects.models.AzureOpenAIModelConfiguration": "Azure.AI.Projects.AzureOpenAIModelConfiguration",
"azure.ai.projects.models.BlobReferenceForConsumption": "Azure.AI.Projects.BlobReferenceForConsumption",
"azure.ai.projects.models.BlobReference": "Azure.AI.Projects.BlobReference",
"azure.ai.projects.models.Connection": "Azure.AI.Projects.Connection",
"azure.ai.projects.models.CosmosDBIndex": "Azure.AI.Projects.CosmosDBIndex",
"azure.ai.projects.models.CustomCredential": "Azure.AI.Projects.CustomCredential",
Expand All @@ -39,7 +39,6 @@
"azure.ai.projects.models.ConnectionType": "Azure.AI.Projects.ConnectionType",
"azure.ai.projects.models.CredentialType": "Azure.AI.Projects.CredentialType",
"azure.ai.projects.models.DatasetType": "Azure.AI.Projects.DatasetType",
"azure.ai.projects.models.ListViewType": "Azure.AI.Projects.ListViewType",
"azure.ai.projects.models.PendingUploadType": "Azure.AI.Projects.PendingUploadType",
"azure.ai.projects.models.IndexType": "Azure.AI.Projects.IndexType",
"azure.ai.projects.models.DeploymentType": "Azure.AI.Projects.DeploymentType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,31 +792,15 @@ def __init__(self, *args, **kwargs) -> None:

@distributed_trace
def list_versions(
self,
name: str,
*,
top: Optional[int] = None,
skip: Optional[str] = None,
tags: Optional[str] = None,
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
**kwargs: Any
self, name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any
) -> AsyncIterable["_models.DatasetVersion"]:
"""List all versions of the given DatasetVersion.

:param name: The name of the resource. Required.
:type name: str
:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
> page size, results with be default page size count will be returned. Default value is None.
:paramtype top: int
:keyword skip: Continuation token for pagination. Default value is None.
:paramtype skip: str
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
tag1,tag2=value2. Default value is None.
:paramtype tags: str
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
View type for including/excluding (for example) archived entities. Known values are:
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
:paramtype list_view_type: str or ~azure.ai.projects.models.ListViewType
:keyword continuation_token_parameter: Continuation token for pagination. Default value is
None.
:paramtype continuation_token_parameter: str
:return: An iterator like instance of DatasetVersion
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion]
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -839,10 +823,7 @@ def prepare_request(next_link=None):

_request = build_datasets_list_versions_request(
name=name,
top=top,
skip=skip,
tags=tags,
list_view_type=list_view_type,
continuation_token_parameter=continuation_token_parameter,
api_version=self._config.api_version,
headers=_headers,
params=_params,
Expand Down Expand Up @@ -902,28 +883,13 @@ async def get_next(next_link=None):

@distributed_trace
def list(
self,
*,
top: Optional[int] = None,
skip: Optional[str] = None,
tags: Optional[str] = None,
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
**kwargs: Any
self, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any
) -> AsyncIterable["_models.DatasetVersion"]:
"""List the latest version of each DatasetVersion.

:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
> page size, results with be default page size count will be returned. Default value is None.
:paramtype top: int
:keyword skip: Continuation token for pagination. Default value is None.
:paramtype skip: str
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
tag1,tag2=value2. Default value is None.
:paramtype tags: str
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
View type for including/excluding (for example) archived entities. Known values are:
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
:paramtype list_view_type: str or ~azure.ai.projects.models.ListViewType
:keyword continuation_token_parameter: Continuation token for pagination. Default value is
None.
:paramtype continuation_token_parameter: str
:return: An iterator like instance of DatasetVersion
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion]
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -945,10 +911,7 @@ def prepare_request(next_link=None):
if not next_link:

_request = build_datasets_list_request(
top=top,
skip=skip,
tags=tags,
list_view_type=list_view_type,
continuation_token_parameter=continuation_token_parameter,
api_version=self._config.api_version,
headers=_headers,
params=_params,
Expand Down Expand Up @@ -1412,7 +1375,7 @@ async def pending_upload(
async def get_credentials(
self, name: str, version: str, body: Any, **kwargs: Any
) -> _models.AssetCredentialResponse:
"""Get download sas for dataset version.
"""Get the SAS credential to access the storage account associated with a Dataset version.

:param name: The name of the resource. Required.
:type name: str
Expand Down Expand Up @@ -1500,31 +1463,15 @@ def __init__(self, *args, **kwargs) -> None:

@distributed_trace
def list_versions(
self,
name: str,
*,
top: Optional[int] = None,
skip: Optional[str] = None,
tags: Optional[str] = None,
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
**kwargs: Any
self, name: str, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any
) -> AsyncIterable["_models.Index"]:
"""List all versions of the given Index.

:param name: The name of the resource. Required.
:type name: str
:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
> page size, results with be default page size count will be returned. Default value is None.
:paramtype top: int
:keyword skip: Continuation token for pagination. Default value is None.
:paramtype skip: str
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
tag1,tag2=value2. Default value is None.
:paramtype tags: str
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
View type for including/excluding (for example) archived entities. Known values are:
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
:paramtype list_view_type: str or ~azure.ai.projects.models.ListViewType
:keyword continuation_token_parameter: Continuation token for pagination. Default value is
None.
:paramtype continuation_token_parameter: str
:return: An iterator like instance of Index
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index]
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -1547,10 +1494,7 @@ def prepare_request(next_link=None):

_request = build_indexes_list_versions_request(
name=name,
top=top,
skip=skip,
tags=tags,
list_view_type=list_view_type,
continuation_token_parameter=continuation_token_parameter,
api_version=self._config.api_version,
headers=_headers,
params=_params,
Expand Down Expand Up @@ -1610,28 +1554,13 @@ async def get_next(next_link=None):

@distributed_trace
def list(
self,
*,
top: Optional[int] = None,
skip: Optional[str] = None,
tags: Optional[str] = None,
list_view_type: Optional[Union[str, _models.ListViewType]] = None,
**kwargs: Any
self, *, continuation_token_parameter: Optional[str] = None, **kwargs: Any
) -> AsyncIterable["_models.Index"]:
"""List the latest version of each Index.

:keyword top: Top count of results, top count cannot be greater than the page size. If topCount
> page size, results with be default page size count will be returned. Default value is None.
:paramtype top: int
:keyword skip: Continuation token for pagination. Default value is None.
:paramtype skip: str
:keyword tags: Comma-separated list of tag names (and optionally values). Example:
tag1,tag2=value2. Default value is None.
:paramtype tags: str
:keyword list_view_type: [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All]
View type for including/excluding (for example) archived entities. Known values are:
"ActiveOnly", "ArchivedOnly", and "All". Default value is None.
:paramtype list_view_type: str or ~azure.ai.projects.models.ListViewType
:keyword continuation_token_parameter: Continuation token for pagination. Default value is
None.
:paramtype continuation_token_parameter: str
:return: An iterator like instance of Index
:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index]
:raises ~azure.core.exceptions.HttpResponseError:
Expand All @@ -1653,10 +1582,7 @@ def prepare_request(next_link=None):
if not next_link:

_request = build_indexes_list_request(
top=top,
skip=skip,
tags=tags,
list_view_type=list_view_type,
continuation_token_parameter=continuation_token_parameter,
api_version=self._config.api_version,
headers=_headers,
params=_params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ async def _create_dataset_and_get_its_container_client(
pending_upload_response: PendingUploadResponse = await self.pending_upload(
name=name,
version=input_version,
body=PendingUploadRequest(pending_upload_type=PendingUploadType.TEMPORARY_BLOB_REFERENCE),
body=PendingUploadRequest(pending_upload_type=PendingUploadType.BLOB_REFERENCE),
)
output_version: str = input_version

if not pending_upload_response.blob_reference_for_consumption:
if not pending_upload_response.blob_reference:
raise ValueError("Blob reference for consumption is not present")
if not pending_upload_response.blob_reference_for_consumption.credential.type:
if not pending_upload_response.blob_reference.credential.type:
raise ValueError("Credential type is not present")
if pending_upload_response.blob_reference_for_consumption.credential.type != CredentialType.SAS:
if pending_upload_response.blob_reference.credential.type != CredentialType.SAS:
raise ValueError("Credential type is not SAS")
if not pending_upload_response.blob_reference_for_consumption.blob_uri:
if not pending_upload_response.blob_reference.blob_uri:
raise ValueError("Blob URI is not present or empty")

if logger.getEffectiveLevel() == logging.DEBUG:
Expand All @@ -69,22 +69,22 @@ async def _create_dataset_and_get_its_container_client(
logger.debug(
"[_create_dataset_and_get_its_container_client] pending_upload_response.pending_upload_type = %s.",
pending_upload_response.pending_upload_type,
) # == PendingUploadType.TEMPORARY_BLOB_REFERENCE
) # == PendingUploadType.BLOB_REFERENCE
logger.debug(
"[_create_dataset_and_get_its_container_client] pending_upload_response.blob_reference_for_consumption.blob_uri = %s.",
pending_upload_response.blob_reference_for_consumption.blob_uri,
"[_create_dataset_and_get_its_container_client] pending_upload_response.blob_reference.blob_uri = %s.",
pending_upload_response.blob_reference.blob_uri,
) # Hosted on behalf of (HOBO) not visible to the user. If the form of: "https://<account>.blob.core.windows.net/<container>?<sasToken>"
logger.debug(
"[_create_dataset_and_get_its_container_client] pending_upload_response.blob_reference_for_consumption.storage_account_arm_id = %s.",
pending_upload_response.blob_reference_for_consumption.storage_account_arm_id,
"[_create_dataset_and_get_its_container_client] pending_upload_response.blob_reference.storage_account_arm_id = %s.",
pending_upload_response.blob_reference.storage_account_arm_id,
) # /subscriptions/<>/resourceGroups/<>/Microsoft.Storage/accounts/<>
logger.debug(
"[_create_dataset_and_get_its_container_client] pending_upload_response.blob_reference_for_consumption.credential.sas_uri = %s.",
pending_upload_response.blob_reference_for_consumption.credential.sas_uri,
"[_create_dataset_and_get_its_container_client] pending_upload_response.blob_reference.credential.sas_uri = %s.",
pending_upload_response.blob_reference.credential.sas_uri,
)
logger.debug(
"[_create_dataset_and_get_its_container_client] pending_upload_response.blob_reference_for_consumption.credential.type = %s.",
pending_upload_response.blob_reference_for_consumption.credential.type,
"[_create_dataset_and_get_its_container_client] pending_upload_response.blob_reference.credential.type = %s.",
pending_upload_response.blob_reference.credential.type,
) # == CredentialType.SAS

# For overview on Blob storage SDK in Python see:
Expand All @@ -94,7 +94,7 @@ async def _create_dataset_and_get_its_container_client(
# See https://learn.microsoft.com/python/api/azure-storage-blob/azure.storage.blob.containerclient?view=azure-python#azure-storage-blob-containerclient-from-container-url
return (
await ContainerClient.from_container_url(
container_url=pending_upload_response.blob_reference_for_consumption.blob_uri, # Of the form: "https://<account>.blob.core.windows.net/<container>?<sasToken>"
container_url=pending_upload_response.blob_reference.blob_uri, # Of the form: "https://<account>.blob.core.windows.net/<container>?<sasToken>"
),
output_version,
)
Expand Down Expand Up @@ -148,8 +148,7 @@ async def upload_file(self, *, name: str, version: str, file: str, **kwargs: Any
body=FileDatasetVersion(
# See https://learn.microsoft.com/python/api/azure-storage-blob/azure.storage.blob.blobclient?view=azure-python#azure-storage-blob-blobclient-url
# Per above doc the ".url" contains SAS token... should this be stripped away?
dataset_uri=blob_client.url, # "<account>.blob.windows.core.net/<container>/<file_name>"
open_ai_purpose="what-should-this-be", # TODO: What is the purpose of this field?
data_uri=blob_client.url, # "<account>.blob.windows.core.net/<container>/<file_name>"
),
)

Expand Down Expand Up @@ -211,7 +210,7 @@ async def upload_folder(self, *, name: str, version: str, folder: str, **kwargs:
body=FolderDatasetVersion(
# See https://learn.microsoft.com/python/api/azure-storage-blob/azure.storage.blob.blobclient?view=azure-python#azure-storage-blob-blobclient-url
# Per above doc the ".url" contains SAS token... should this be stripped away?
dataset_uri=container_client.url, # "<account>.blob.windows.core.net/<container> ?"
data_uri=container_client.url, # "<account>.blob.windows.core.net/<container> ?"
),
)

Expand Down
6 changes: 2 additions & 4 deletions sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
AzureAISearchIndex,
AzureOpenAIModelConfiguration,
BaseCredentials,
BlobReferenceForConsumption,
BlobReference,
Connection,
CosmosDBIndex,
CustomCredential,
Expand Down Expand Up @@ -58,7 +58,6 @@
DatasetType,
DeploymentType,
IndexType,
ListViewType,
PendingUploadType,
RiskCategory,
)
Expand All @@ -77,7 +76,7 @@
"AzureAISearchIndex",
"AzureOpenAIModelConfiguration",
"BaseCredentials",
"BlobReferenceForConsumption",
"BlobReference",
"Connection",
"CosmosDBIndex",
"CustomCredential",
Expand Down Expand Up @@ -108,7 +107,6 @@
"DatasetType",
"DeploymentType",
"IndexType",
"ListViewType",
"PendingUploadType",
"RiskCategory",
]
Expand Down
15 changes: 2 additions & 13 deletions sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,24 +138,13 @@ class IndexType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""Managed Azure Search"""


class ListViewType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""List View Type Definition."""

ACTIVE_ONLY = "ActiveOnly"
"""List only active items."""
ARCHIVED_ONLY = "ArchivedOnly"
"""List only archived items."""
ALL = "All"
"""List all items."""


class PendingUploadType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
"""The type of pending upload."""

NONE = "None"
"""No pending upload."""
TEMPORARY_BLOB_REFERENCE = "TemporaryBlobReference"
"""Temporary Blob Reference is the only supported type."""
BLOB_REFERENCE = "BlobReference"
"""Blob Reference is the only supported type."""


class RiskCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta):
Expand Down
Loading
Loading