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
7 changes: 7 additions & 0 deletions src/aimanager/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Release History
===============

2.0.1b2
+++++++
* ``az aimanager create/update``, ``az aimanager namespace create/update``, ``az aimanager
modelsource create/update/show/list`` and ``az aimanager namespace modeldeployment
Comment thread
circy9 marked this conversation as resolved.
Outdated
create/update``: ``-o table`` output now uses the same columns as ``show``/``list``, including
``ProvisioningState``.

2.0.1b1
+++++++
* ``az aimanager create``, ``az aimanager namespace create``, ``az aimanager modelsource
Expand Down
16 changes: 16 additions & 0 deletions src/aimanager/azext_aimanager/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ def namespace_list_table_format(results):
return [namespace_table_format(r) for r in results]


def modelsource_table_format(result):
"""Format a single model source resource for display with "-o table"."""
properties = result.get('properties') or {}
return OrderedDict([
('Name', result.get('name', '')),
('ProvisioningState', properties.get('provisioningState', '')),
('SourceType', properties.get('sourceType', '')),
('Description', properties.get('description', '')),
Comment thread
circy9 marked this conversation as resolved.
Outdated
])


def modelsource_list_table_format(results):
"""Format a list of model source resources for display with "-o table"."""
return [modelsource_table_format(r) for r in results]


def _replica_display(value):
"""Render a replica count, using '-' when the count is not yet reported."""
return str(value) if value is not None else '-'
Expand Down
30 changes: 20 additions & 10 deletions src/aimanager/azext_aimanager/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
aimanager_list_table_format,
namespace_table_format,
namespace_list_table_format,
modelsource_table_format,
modelsource_list_table_format,
modeldeployment_table_format,
modeldeployment_list_table_format,
calculate_cost_table_format,
Expand Down Expand Up @@ -54,8 +56,10 @@ def load_command_table(self, _):

# aimanager command group
with self.command_group("aimanager", ai_managers_sdk, client_factory=cf_ai_managers, is_preview=True) as g:
g.custom_command("create", "create_aimanager", supports_no_wait=True)
g.custom_command("update", "update_aimanager", supports_no_wait=True)
g.custom_command("create", "create_aimanager", supports_no_wait=True,
table_transformer=aimanager_table_format)
g.custom_command("update", "update_aimanager", supports_no_wait=True,
table_transformer=aimanager_table_format)
g.custom_show_command("show", "show_aimanager", table_transformer=aimanager_table_format)
g.custom_command("list", "list_aimanager", table_transformer=aimanager_list_table_format)
g.custom_command("delete", "delete_aimanager", supports_no_wait=True, confirmation=True)
Expand All @@ -64,8 +68,10 @@ def load_command_table(self, _):

# aimanager namespace command group
with self.command_group("aimanager namespace", ai_manager_namespaces_sdk, client_factory=cf_ai_manager_namespaces, is_preview=True) as g:
g.custom_command("create", "create_aimanager_namespace", supports_no_wait=True)
g.custom_command("update", "update_aimanager_namespace", supports_no_wait=True)
g.custom_command("create", "create_aimanager_namespace", supports_no_wait=True,
table_transformer=namespace_table_format)
g.custom_command("update", "update_aimanager_namespace", supports_no_wait=True,
table_transformer=namespace_table_format)
g.custom_show_command("show", "show_aimanager_namespace", table_transformer=namespace_table_format)
g.custom_command("list", "list_aimanager_namespace", table_transformer=namespace_list_table_format)
g.custom_command("delete", "delete_aimanager_namespace", supports_no_wait=True, confirmation=True)
Expand All @@ -82,18 +88,22 @@ def load_command_table(self, _):

# aimanager modelsource command group
with self.command_group("aimanager modelsource", model_sources_sdk, client_factory=cf_model_sources) as g:
g.custom_command("create", "create_modelsource", supports_no_wait=True)
g.custom_command("update", "update_modelsource", supports_no_wait=True)
g.custom_show_command("show", "show_modelsource")
g.custom_command("list", "list_modelsource")
g.custom_command("create", "create_modelsource", supports_no_wait=True,
table_transformer=modelsource_table_format)
g.custom_command("update", "update_modelsource", supports_no_wait=True,
table_transformer=modelsource_table_format)
g.custom_show_command("show", "show_modelsource", table_transformer=modelsource_table_format)
g.custom_command("list", "list_modelsource", table_transformer=modelsource_list_table_format)
g.custom_command("delete", "delete_modelsource", supports_no_wait=True, confirmation=True)
g.custom_wait_command("wait", "show_modelsource")

# aimanager namespace modeldeployment command group
with self.command_group("aimanager namespace modeldeployment", model_deployments_sdk,
client_factory=cf_model_deployments, is_preview=True) as g:
g.custom_command("create", "create_modeldeployment", supports_no_wait=True)
g.custom_command("update", "update_modeldeployment", supports_no_wait=True)
g.custom_command("create", "create_modeldeployment", supports_no_wait=True,
Comment thread
circy9 marked this conversation as resolved.
table_transformer=modeldeployment_table_format)
g.custom_command("update", "update_modeldeployment", supports_no_wait=True,
table_transformer=modeldeployment_table_format)
g.custom_show_command("show", "show_modeldeployment", table_transformer=modeldeployment_table_format)
g.custom_command("list", "list_modeldeployment", table_transformer=modeldeployment_list_table_format)
g.custom_command("delete", "delete_modeldeployment", supports_no_wait=True, confirmation=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
aimanager_list_table_format,
namespace_table_format,
namespace_list_table_format,
modelsource_table_format,
modelsource_list_table_format,
modeldeployment_table_format,
modeldeployment_list_table_format,
calculate_cost_table_format,
Expand Down Expand Up @@ -117,6 +119,53 @@ def test_list_table_format_namespace(self):
self.assertEqual(results[0]["Name"], "ns1")


class TestModelSourceTableFormat(unittest.TestCase):
Comment thread
circy9 marked this conversation as resolved.
"""Test cases for model source table output formatting."""

def _sample(self):
return {
"id": (
"/subscriptions/26fe00f8-0000-0000-0000-bb1d2e00343a"
"/resourceGroups/yiralirg"
"/providers/Microsoft.ContainerService/aiManagers/aimbyo"
"/modelSources/hf1"
),
"name": "hf1",
"eTag": "ff459bfb-b983-436f-b55b-afe701d1c896",
"properties": {
"provisioningState": "Succeeded",
"sourceType": "HuggingFace",
"description": "gated models",
},
}

def test_table_format_columns_modelsource(self):
result = modelsource_table_format(self._sample())
self.assertEqual(
list(result.keys()),
["Name", "ProvisioningState", "SourceType", "Description"],
)

def test_table_format_values_modelsource(self):
result = modelsource_table_format(self._sample())
self.assertEqual(result["Name"], "hf1")
self.assertEqual(result["ProvisioningState"], "Succeeded")
self.assertEqual(result["SourceType"], "HuggingFace")
self.assertEqual(result["Description"], "gated models")

def test_table_format_null_properties_modelsource(self):
result = modelsource_table_format({"name": "hf1", "properties": None})
self.assertEqual(result["Name"], "hf1")
self.assertEqual(result["ProvisioningState"], "")
self.assertEqual(result["SourceType"], "")
self.assertEqual(result["Description"], "")

def test_list_table_format_modelsource(self):
results = modelsource_list_table_format([self._sample(), self._sample()])
self.assertEqual(len(results), 2)
self.assertEqual(results[0]["Name"], "hf1")


class TestModelDeploymentTableFormat(unittest.TestCase):
"""Test cases for model deployment table output formatting."""

Expand Down
2 changes: 1 addition & 1 deletion src/aimanager/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from distutils import log as logger
logger.warn("Wheel is not available, disabling bdist_wheel hook")

VERSION = '2.0.1b1'
VERSION = '2.0.1b2'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
Loading