You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_model.py 22 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. # Copyright 2019 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """
  16. Function:
  17. Test the query module about lineage information.
  18. Usage:
  19. The query module test should be run after lineagemgr/collection/model/test_model_lineage.py
  20. pytest lineagemgr
  21. """
  22. import os
  23. from unittest import TestCase
  24. import pytest
  25. from mindinsight.lineagemgr.model import filter_summary_lineage
  26. from mindinsight.datavisual.data_transform import data_manager
  27. from mindinsight.lineagemgr.cache_item_updater import LineageCacheItemUpdater
  28. from mindinsight.lineagemgr.common.exceptions.exceptions import LineageSearchConditionParamError
  29. from mindinsight.lineagemgr.model import get_flattened_lineage
  30. from .conftest import BASE_SUMMARY_DIR, DATASET_GRAPH, SUMMARY_DIR, SUMMARY_DIR_2, LINEAGE_DATA_MANAGER
  31. from ....ut.lineagemgr.querier import event_data
  32. from ....utils.tools import assert_equal_lineages, get_relative_path
  33. LINEAGE_INFO_RUN1 = {
  34. 'summary_dir': './run1',
  35. 'metric': {
  36. 'accuracy': 0.78
  37. },
  38. 'hyper_parameters': {
  39. 'optimizer': 'Momentum',
  40. 'learning_rate': 0.12,
  41. 'loss_function': 'SoftmaxCrossEntropyWithLogits',
  42. 'epoch': 14,
  43. 'parallel_mode': 'stand_alone',
  44. 'device_num': 2,
  45. 'batch_size': 32
  46. },
  47. 'algorithm': {
  48. 'network': 'ResNet'
  49. },
  50. 'train_dataset': {
  51. 'train_dataset_size': 1024
  52. },
  53. 'valid_dataset': {
  54. 'valid_dataset_size': 1024
  55. },
  56. 'model': {
  57. 'path': '{"ckpt": "'
  58. + BASE_SUMMARY_DIR + '/run1/CKPtest_model.ckpt"}',
  59. 'size': 64
  60. },
  61. 'dataset_graph': DATASET_GRAPH
  62. }
  63. LINEAGE_FILTRATION_EXCEPT_RUN = {
  64. 'summary_dir': './except_run',
  65. 'model_lineage': {
  66. 'loss_function': 'SoftmaxCrossEntropyWithLogits',
  67. 'train_dataset_path': None,
  68. 'train_dataset_count': 1024,
  69. 'test_dataset_path': None,
  70. 'test_dataset_count': None,
  71. 'user_defined': {},
  72. 'network': 'ResNet',
  73. 'optimizer': 'Momentum',
  74. 'learning_rate': 0.12,
  75. 'epoch': 10,
  76. 'batch_size': 32,
  77. 'device_num': 2,
  78. 'loss': 0.03,
  79. 'model_size': 64,
  80. 'metric': {},
  81. 'dataset_mark': 2
  82. },
  83. 'dataset_graph': DATASET_GRAPH,
  84. 'added_info': {}
  85. }
  86. LINEAGE_FILTRATION_RUN1 = {
  87. 'summary_dir': './run1',
  88. 'model_lineage': {
  89. 'loss_function': 'SoftmaxCrossEntropyWithLogits',
  90. 'train_dataset_path': None,
  91. 'train_dataset_count': 1024,
  92. 'test_dataset_path': None,
  93. 'test_dataset_count': 1024,
  94. 'user_defined': {
  95. 'info': 'info1',
  96. 'version': 'v1',
  97. 'eval_version': 'version2'
  98. },
  99. 'network': 'ResNet',
  100. 'optimizer': 'Momentum',
  101. 'learning_rate': 0.12,
  102. 'epoch': 14,
  103. 'batch_size': 32,
  104. 'device_num': 2,
  105. 'loss': None,
  106. 'model_size': 64,
  107. 'metric': {
  108. 'accuracy': 0.78
  109. },
  110. 'dataset_mark': 2
  111. },
  112. 'dataset_graph': DATASET_GRAPH,
  113. 'added_info': {}
  114. }
  115. LINEAGE_FILTRATION_RUN2 = {
  116. 'summary_dir': './run2',
  117. 'model_lineage': {
  118. 'loss_function': "SoftmaxCrossEntropyWithLogits",
  119. 'train_dataset_path': None,
  120. 'train_dataset_count': 1024,
  121. 'test_dataset_path': None,
  122. 'test_dataset_count': 1024,
  123. 'user_defined': {},
  124. 'network': "ResNet",
  125. 'optimizer': "Momentum",
  126. 'learning_rate': 0.12,
  127. 'epoch': 10,
  128. 'batch_size': 32,
  129. 'device_num': 2,
  130. 'loss': 0.03,
  131. 'model_size': 10,
  132. 'metric': {
  133. 'accuracy': 2.78
  134. },
  135. 'dataset_mark': 3
  136. },
  137. 'dataset_graph': DATASET_GRAPH,
  138. 'added_info': {}
  139. }
  140. @pytest.mark.usefixtures("create_summary_dir")
  141. class TestModelApi(TestCase):
  142. """Test lineage information query interface."""
  143. @classmethod
  144. def setup_class(cls):
  145. """The initial process."""
  146. cls._dir_with_empty_lineage = os.path.join(
  147. BASE_SUMMARY_DIR, 'dir_with_empty_lineage'
  148. )
  149. os.makedirs(cls._dir_with_empty_lineage)
  150. ms_file = os.path.join(
  151. cls._dir_with_empty_lineage, 'empty.summary.1581499502.bms_MS'
  152. )
  153. lineage_file = ms_file + '_lineage'
  154. with open(ms_file, mode='w'):
  155. pass
  156. with open(lineage_file, mode='w'):
  157. pass
  158. empty_dir = os.path.join(BASE_SUMMARY_DIR, 'empty_dir')
  159. os.makedirs(empty_dir)
  160. cls._empty_train_id = get_relative_path(empty_dir, LINEAGE_DATA_MANAGER.summary_base_dir)
  161. LINEAGE_DATA_MANAGER.start_load_data().join()
  162. @pytest.mark.level0
  163. @pytest.mark.platform_arm_ascend_training
  164. @pytest.mark.platform_x86_gpu_training
  165. @pytest.mark.platform_x86_ascend_training
  166. @pytest.mark.platform_x86_cpu
  167. @pytest.mark.env_single
  168. def test_filter_summary_lineage(self):
  169. """Test the interface of filter_summary_lineage."""
  170. expect_result = {
  171. 'customized': event_data.CUSTOMIZED__1,
  172. 'object': [
  173. LINEAGE_FILTRATION_EXCEPT_RUN,
  174. LINEAGE_FILTRATION_RUN1,
  175. LINEAGE_FILTRATION_RUN2
  176. ],
  177. 'count': 3
  178. }
  179. search_condition = {
  180. 'sorted_name': 'summary_dir'
  181. }
  182. res = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition)
  183. expect_objects = expect_result.get('object')
  184. for idx, res_object in enumerate(res.get('object')):
  185. expect_objects[idx]['model_lineage']['dataset_mark'] = res_object['model_lineage'].get('dataset_mark')
  186. assert_equal_lineages(expect_result, res, self.assertDictEqual)
  187. @pytest.mark.level0
  188. @pytest.mark.platform_arm_ascend_training
  189. @pytest.mark.platform_x86_gpu_training
  190. @pytest.mark.platform_x86_ascend_training
  191. @pytest.mark.platform_x86_cpu
  192. @pytest.mark.env_single
  193. def test_filter_summary_lineage_with_condition_1(self):
  194. """Test the interface of filter_summary_lineage with condition."""
  195. search_condition = {
  196. 'summary_dir': {
  197. 'in': [
  198. get_relative_path(SUMMARY_DIR, LINEAGE_DATA_MANAGER.summary_base_dir),
  199. get_relative_path(SUMMARY_DIR_2, LINEAGE_DATA_MANAGER.summary_base_dir)
  200. ]
  201. },
  202. 'metric/accuracy': {
  203. 'lt': 3.0,
  204. 'gt': 0.5
  205. },
  206. 'sorted_name': 'metric/accuracy',
  207. 'sorted_type': 'descending',
  208. 'limit': 3,
  209. 'offset': 0
  210. }
  211. expect_result = {
  212. 'customized': event_data.CUSTOMIZED__1,
  213. 'object': [
  214. LINEAGE_FILTRATION_RUN2,
  215. LINEAGE_FILTRATION_RUN1
  216. ],
  217. 'count': 2
  218. }
  219. partial_res = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition)
  220. expect_objects = expect_result.get('object')
  221. for idx, res_object in enumerate(partial_res.get('object')):
  222. expect_objects[idx]['model_lineage']['dataset_mark'] = res_object['model_lineage'].get('dataset_mark')
  223. assert_equal_lineages(expect_result, partial_res, self.assertDictEqual)
  224. @pytest.mark.level0
  225. @pytest.mark.platform_arm_ascend_training
  226. @pytest.mark.platform_x86_gpu_training
  227. @pytest.mark.platform_x86_ascend_training
  228. @pytest.mark.platform_x86_cpu
  229. @pytest.mark.env_single
  230. def test_filter_summary_lineage_with_condition_2(self):
  231. """Test the interface of filter_summary_lineage with condition."""
  232. search_condition = {
  233. 'summary_dir': {
  234. 'in': [
  235. './run1',
  236. './run2'
  237. ]
  238. },
  239. 'metric/accuracy': {
  240. 'lt': 3.0,
  241. 'gt': 0.5
  242. },
  243. 'sorted_name': 'metric/accuracy',
  244. 'sorted_type': 'descending',
  245. 'limit': 3,
  246. 'offset': 0
  247. }
  248. expect_result = {
  249. 'customized': event_data.CUSTOMIZED__1,
  250. 'object': [
  251. LINEAGE_FILTRATION_RUN2,
  252. LINEAGE_FILTRATION_RUN1
  253. ],
  254. 'count': 2
  255. }
  256. partial_res = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition)
  257. expect_objects = expect_result.get('object')
  258. for idx, res_object in enumerate(partial_res.get('object')):
  259. expect_objects[idx]['model_lineage']['dataset_mark'] = res_object['model_lineage'].get('dataset_mark')
  260. assert_equal_lineages(expect_result, partial_res, self.assertDictEqual)
  261. @pytest.mark.level0
  262. @pytest.mark.platform_arm_ascend_training
  263. @pytest.mark.platform_x86_gpu_training
  264. @pytest.mark.platform_x86_ascend_training
  265. @pytest.mark.platform_x86_cpu
  266. @pytest.mark.env_single
  267. def test_filter_summary_lineage_with_condition_3(self):
  268. """Test the interface of filter_summary_lineage with condition."""
  269. search_condition1 = {
  270. 'batch_size': {
  271. 'ge': 30
  272. },
  273. 'sorted_name': 'metric/accuracy',
  274. }
  275. expect_result = {
  276. 'customized': event_data.CUSTOMIZED__1,
  277. 'object': [
  278. LINEAGE_FILTRATION_EXCEPT_RUN,
  279. LINEAGE_FILTRATION_RUN1,
  280. LINEAGE_FILTRATION_RUN2
  281. ],
  282. 'count': 3
  283. }
  284. partial_res1 = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition1)
  285. expect_objects = expect_result.get('object')
  286. for idx, res_object in enumerate(partial_res1.get('object')):
  287. expect_objects[idx]['model_lineage']['dataset_mark'] = res_object['model_lineage'].get('dataset_mark')
  288. assert_equal_lineages(expect_result, partial_res1, self.assertDictEqual)
  289. search_condition2 = {
  290. 'batch_size': {
  291. 'lt': 30
  292. },
  293. 'lineage_type': {
  294. 'eq': 'model'
  295. },
  296. }
  297. expect_result = {
  298. 'customized': {},
  299. 'object': [],
  300. 'count': 0
  301. }
  302. partial_res2 = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition2)
  303. assert expect_result == partial_res2
  304. @pytest.mark.level0
  305. @pytest.mark.platform_arm_ascend_training
  306. @pytest.mark.platform_x86_gpu_training
  307. @pytest.mark.platform_x86_ascend_training
  308. @pytest.mark.platform_x86_cpu
  309. @pytest.mark.env_single
  310. def test_filter_summary_lineage_condition_4(self):
  311. """Test the abnormal execution of the filter_summary_lineage interface."""
  312. expect_result = {
  313. 'customized': {},
  314. 'object': [],
  315. 'count': 0
  316. }
  317. search_condition = {
  318. 'summary_dir': {
  319. 'eq': self._empty_train_id
  320. }
  321. }
  322. res = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition)
  323. assert expect_result == res
  324. @pytest.mark.level0
  325. @pytest.mark.platform_arm_ascend_training
  326. @pytest.mark.platform_x86_gpu_training
  327. @pytest.mark.platform_x86_ascend_training
  328. @pytest.mark.platform_x86_cpu
  329. @pytest.mark.env_single
  330. def test_filter_summary_lineage_with_lineage_type(self):
  331. """Test the interface of filter_summary_lineage with lineage_type."""
  332. train_id = './except_run'
  333. search_condition = {
  334. 'summary_dir': {
  335. 'in': [train_id]
  336. },
  337. 'lineage_type': {
  338. 'eq': 'dataset'
  339. },
  340. }
  341. expect_result = {
  342. 'customized': {},
  343. 'object': [
  344. {
  345. 'summary_dir': train_id,
  346. 'dataset_graph': DATASET_GRAPH,
  347. 'added_info': {}
  348. }
  349. ],
  350. 'count': 1
  351. }
  352. res = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition)
  353. assert expect_result == res
  354. @pytest.mark.level0
  355. @pytest.mark.platform_arm_ascend_training
  356. @pytest.mark.platform_x86_gpu_training
  357. @pytest.mark.platform_x86_ascend_training
  358. @pytest.mark.platform_x86_cpu
  359. @pytest.mark.env_single
  360. def test_filter_summary_lineage_exception_2(self):
  361. """Test the abnormal execution of the filter_summary_lineage interface."""
  362. # search_condition type error
  363. search_condition = {
  364. 'summary_dir': 1.0
  365. }
  366. self.assertRaisesRegex(
  367. LineageSearchConditionParamError,
  368. 'The search_condition element summary_dir should be dict.',
  369. filter_summary_lineage,
  370. LINEAGE_DATA_MANAGER,
  371. None,
  372. search_condition
  373. )
  374. # only sorted_type (no sorted_name)
  375. search_condition = {
  376. 'sorted_type': 'descending'
  377. }
  378. self.assertRaisesRegex(
  379. LineageSearchConditionParamError,
  380. 'The sorted_name must exist when sorted_type exists.',
  381. filter_summary_lineage,
  382. LINEAGE_DATA_MANAGER,
  383. None,
  384. search_condition
  385. )
  386. # search condition is not dict or None
  387. search_condition = []
  388. self.assertRaisesRegex(
  389. LineageSearchConditionParamError,
  390. 'Invalid search_condition type, it should be dict.',
  391. filter_summary_lineage,
  392. LINEAGE_DATA_MANAGER,
  393. None,
  394. search_condition
  395. )
  396. # the condition of limit is invalid
  397. search_condition = {
  398. 'limit': True
  399. }
  400. self.assertRaisesRegex(
  401. LineageSearchConditionParamError,
  402. 'The limit must be int.',
  403. filter_summary_lineage,
  404. LINEAGE_DATA_MANAGER,
  405. None,
  406. search_condition
  407. )
  408. @pytest.mark.level0
  409. @pytest.mark.platform_arm_ascend_training
  410. @pytest.mark.platform_x86_gpu_training
  411. @pytest.mark.platform_x86_ascend_training
  412. @pytest.mark.platform_x86_cpu
  413. @pytest.mark.env_single
  414. def test_filter_summary_lineage_exception_3(self):
  415. """Test the abnormal execution of the filter_summary_lineage interface."""
  416. # the condition of offset is invalid
  417. search_condition = {
  418. 'offset': 1.0
  419. }
  420. self.assertRaisesRegex(
  421. LineageSearchConditionParamError,
  422. 'The offset must be int.',
  423. filter_summary_lineage,
  424. LINEAGE_DATA_MANAGER,
  425. None,
  426. search_condition
  427. )
  428. # the search attribute not supported
  429. search_condition = {
  430. 'dataset_graph': {
  431. 'le': 1
  432. }
  433. }
  434. self.assertRaisesRegex(
  435. LineageSearchConditionParamError,
  436. 'The search attribute not supported.',
  437. filter_summary_lineage,
  438. LINEAGE_DATA_MANAGER,
  439. None,
  440. search_condition
  441. )
  442. @pytest.mark.level0
  443. @pytest.mark.platform_arm_ascend_training
  444. @pytest.mark.platform_x86_gpu_training
  445. @pytest.mark.platform_x86_ascend_training
  446. @pytest.mark.platform_x86_cpu
  447. @pytest.mark.env_single
  448. def test_filter_summary_lineage_exception_4(self):
  449. """Test the abnormal execution of the filter_summary_lineage interface."""
  450. # the sorted_type not supported
  451. search_condition = {
  452. 'sorted_name': 'summary_dir',
  453. 'sorted_type': 'xxx'
  454. }
  455. self.assertRaisesRegex(
  456. LineageSearchConditionParamError,
  457. 'The sorted_type must be ascending or descending',
  458. filter_summary_lineage,
  459. LINEAGE_DATA_MANAGER,
  460. None,
  461. search_condition
  462. )
  463. # the search condition not supported
  464. search_condition = {
  465. 'batch_size': {
  466. 'dd': 30
  467. }
  468. }
  469. self.assertRaisesRegex(
  470. LineageSearchConditionParamError,
  471. 'The compare condition should be in',
  472. filter_summary_lineage,
  473. LINEAGE_DATA_MANAGER,
  474. None,
  475. search_condition
  476. )
  477. # the search condition type error
  478. search_condition = {
  479. 'metric/accuracy': {
  480. 'lt': 'xxx'
  481. }
  482. }
  483. self.assertRaisesRegex(
  484. LineageSearchConditionParamError,
  485. 'The parameter metric/accuracy is invalid.',
  486. filter_summary_lineage,
  487. LINEAGE_DATA_MANAGER,
  488. None,
  489. search_condition
  490. )
  491. @pytest.mark.level0
  492. @pytest.mark.platform_arm_ascend_training
  493. @pytest.mark.platform_x86_gpu_training
  494. @pytest.mark.platform_x86_ascend_training
  495. @pytest.mark.platform_x86_cpu
  496. @pytest.mark.env_single
  497. def test_filter_summary_lineage_exception_5(self):
  498. """Test the abnormal execution of the filter_summary_lineage interface."""
  499. # gt > lt
  500. search_condition1 = {
  501. 'metric/accuracy': {
  502. 'gt': 1,
  503. 'lt': 0.5
  504. }
  505. }
  506. expect_result = {
  507. 'customized': {},
  508. 'object': [],
  509. 'count': 0
  510. }
  511. partial_res1 = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition1)
  512. assert expect_result == partial_res1
  513. # the (offset + 1) * limit > count
  514. search_condition2 = {
  515. 'loss': {
  516. 'lt': 1
  517. },
  518. 'limit': 1,
  519. 'offset': 4
  520. }
  521. expect_result = {
  522. 'customized': {},
  523. 'object': [],
  524. 'count': 2
  525. }
  526. partial_res2 = filter_summary_lineage(data_manager=LINEAGE_DATA_MANAGER, search_condition=search_condition2)
  527. assert expect_result == partial_res2
  528. @pytest.mark.level0
  529. @pytest.mark.platform_arm_ascend_training
  530. @pytest.mark.platform_x86_gpu_training
  531. @pytest.mark.platform_x86_ascend_training
  532. @pytest.mark.platform_x86_cpu
  533. @pytest.mark.env_single
  534. def test_filter_summary_lineage_exception_6(self):
  535. """Test the abnormal execution of the filter_summary_lineage interface."""
  536. condition_keys = ["summary_dir", "lineage_type", "loss_function", "optimizer", "network", "dataset_mark"]
  537. for condition_key in condition_keys:
  538. # the condition type not supported in summary_dir and lineage_type
  539. search_condition = {
  540. condition_key: {
  541. 'lt': '/xxx'
  542. }
  543. }
  544. self.assertRaisesRegex(
  545. LineageSearchConditionParamError,
  546. f'The parameter {condition_key} is invalid. Its operation should be `eq`, `in` or `not_in`.',
  547. filter_summary_lineage,
  548. LINEAGE_DATA_MANAGER,
  549. None,
  550. search_condition
  551. )
  552. @pytest.mark.level0
  553. @pytest.mark.platform_arm_ascend_training
  554. @pytest.mark.platform_x86_gpu_training
  555. @pytest.mark.platform_x86_ascend_training
  556. @pytest.mark.platform_x86_cpu
  557. @pytest.mark.env_single
  558. def test_filter_summary_lineage_exception_7(self):
  559. """Test the abnormal execution of the filter_summary_lineage interface."""
  560. invalid_lineage_types = ['xxx', None]
  561. for lineage_type in invalid_lineage_types:
  562. search_condition = {
  563. 'lineage_type': {
  564. 'eq': lineage_type
  565. }
  566. }
  567. self.assertRaisesRegex(
  568. LineageSearchConditionParamError,
  569. "The parameter lineage_type is invalid. It should be 'dataset' or 'model'.",
  570. filter_summary_lineage,
  571. LINEAGE_DATA_MANAGER,
  572. None,
  573. search_condition
  574. )
  575. @pytest.mark.level0
  576. @pytest.mark.platform_arm_ascend_training
  577. @pytest.mark.platform_x86_gpu_training
  578. @pytest.mark.platform_x86_ascend_training
  579. @pytest.mark.platform_x86_cpu
  580. @pytest.mark.env_single
  581. def test_filter_summary_lineage_exception_8(self):
  582. """Test the abnormal execution of the filter_summary_lineage interface."""
  583. invalid_sorted_names = ['xxx', 'metric_', 1]
  584. for sorted_name in invalid_sorted_names:
  585. search_condition = {
  586. 'sorted_name': sorted_name
  587. }
  588. self.assertRaisesRegex(
  589. LineageSearchConditionParamError,
  590. 'The sorted_name must be in',
  591. filter_summary_lineage,
  592. LINEAGE_DATA_MANAGER,
  593. None,
  594. search_condition
  595. )
  596. @pytest.mark.level1
  597. @pytest.mark.platform_arm_ascend_training
  598. @pytest.mark.platform_x86_gpu_training
  599. @pytest.mark.platform_x86_ascned_training
  600. @pytest.mark.platform_x86_cpu
  601. @pytest.mark.env_single
  602. def test_get_flattened_lineage(self):
  603. """Test the function of get_flattened_lineage"""
  604. datamanager = data_manager.DataManager(SUMMARY_DIR)
  605. datamanager.register_brief_cache_item_updater(LineageCacheItemUpdater())
  606. datamanager.start_load_data().join()
  607. data = get_flattened_lineage(datamanager)
  608. assert data.get('[U]info') == ['info1']