Browse Source

[MNT] Modify illegal semantic_spec check

tags/v0.3.2
xiey 3 years ago
parent
commit
6a07e3808f
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      learnware/market/easy.py

+ 20
- 0
learnware/market/easy.py View File

@@ -89,6 +89,26 @@ class EasyMarket(BaseMarket):
if not os.path.exists(zip_path):
logger.warning("Zip Path NOT Found! Fail to add learnware.")
return None, False
try:
if len(semantic_spec["Data"]["Values"]) == 0:
logger.warning("Illegal semantic specification, please choose Data.")
return None, False
if len(semantic_spec["Task"]["Values"]) == 0:
logger.warning("Illegal semantic specification, please choose Task.")
return None, False
if len(semantic_spec["Device"]["Values"]) == 0:
logger.warning("Illegal semantic specification, please choose Device.")
return None, False
if len(semantic_spec["Name"]["Values"]) == 0:
logger.warning("Illegal semantic specification, please provide Name.")
return None, False
if len(semantic_spec["Description"]["Values"]) == 0 and len(semantic_spec["Scenario"]["Values"]) == 0:
logger.warning("Illegal semantic specification, please provide Scenario or Description.")
return None, False
except:
logger.warning("Illegal semantic specification, some keys are missing.")
return None, False

logger.info("Get new learnware from %s" % (zip_path))
id = "%08d" % (self.count)


Loading…
Cancel
Save