Switch off generating prompt asset type (#1464)

* Switch off generating prompt asset type

* Use SUPPORTED_ASSET_TYPES for warning & create TYPE_TO_DOC_FUNCS mapping

* Update spacing for scripts-syntax

---------

Co-authored-by: Kelly Ly <kellyly@microsoft.com>
This commit is contained in:
Kelly 2023-10-17 11:33:33 -04:00 коммит произвёл GitHub
Родитель 4dbc7c2274
Коммит 5275919a82
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 18 добавлений и 15 удалений

Просмотреть файл

@ -9,8 +9,9 @@ import snakemd
import re
from pathlib import Path
from azureml.assets.config import AssetConfig, AssetType
import warnings
SUPPORTED_ASSET_TYPES = [AssetType.ENVIRONMENT, AssetType.COMPONENT, AssetType.MODEL, AssetType.DATA, AssetType.PROMPT]
SUPPORTED_ASSET_TYPES = [AssetType.ENVIRONMENT, AssetType.COMPONENT, AssetType.MODEL, AssetType.DATA]
DEFAULT_CATEGORY = "Uncategorized"
PLURALIZED_ASSET_TYPE = {"environment": "environments", "component": "components", "model": "models", "data": "data",
"prompt": "prompts"}
@ -94,18 +95,11 @@ class AssetInfo:
@staticmethod
def create_asset_info(asset_config):
"""Instantiate an asset info class."""
if asset_config.type == AssetType.ENVIRONMENT:
return EnvironmentInfo(asset_config)
if asset_config.type == AssetType.COMPONENT:
return ComponentInfo(asset_config)
if asset_config.type == AssetType.MODEL:
return ModelInfo(asset_config)
if asset_config.type == AssetType.DATA:
return DataInfo(asset_config)
if asset_config.type == AssetType.PROMPT:
return PromptInfo(asset_config)
if asset_config.type not in TYPE_TO_DOC_FUNCS:
warnings.warn(f"Not supported asset type {asset_config.type}. Use {SUPPORTED_ASSET_TYPES}")
return None
raise Exception(f"Not supported asset type {asset_config.type}. Use {SUPPORTED_ASSET_TYPES}")
return TYPE_TO_DOC_FUNCS[asset_config.type](asset_config)
# region Doc Formatting
def _add_doc_name(self, doc):
@ -375,6 +369,14 @@ class PromptInfo(AssetInfo):
return _doc
TYPE_TO_DOC_FUNCS = {
AssetType.ENVIRONMENT: EnvironmentInfo,
AssetType.COMPONENT: ComponentInfo,
AssetType.MODEL: ModelInfo,
AssetType.DATA: DataInfo
}
class Categories:
"""Categories structured by type."""

Просмотреть файл

@ -28,9 +28,10 @@ def parse_assets(input_dirs: List[Path],
for asset_config in util.find_assets(input_dirs, asset_config_filename, pattern=pattern):
asset_info = AssetInfo.create_asset_info(asset_config)
categories.classify_asset(asset_info)
# Save asset info. Revisit to save all docs after
asset_info.save()
if asset_info:
categories.classify_asset(asset_info)
# Save asset info. Revisit to save all docs after
asset_info.save()
categories.save()