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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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(LINEAGE_DATA_MANAGER, 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(LINEAGE_DATA_MANAGER, 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(LINEAGE_DATA_MANAGER, 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(LINEAGE_DATA_MANAGER, 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(LINEAGE_DATA_MANAGER, 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(LINEAGE_DATA_MANAGER, 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(LINEAGE_DATA_MANAGER, 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. search_condition
  372. )
  373. # only sorted_type (no sorted_name)
  374. search_condition = {
  375. 'sorted_type': 'descending'
  376. }
  377. self.assertRaisesRegex(
  378. LineageSearchConditionParamError,
  379. 'The sorted_name have to exist when sorted_type exists.',
  380. filter_summary_lineage,
  381. LINEAGE_DATA_MANAGER,
  382. search_condition
  383. )
  384. # search condition is not dict or None
  385. search_condition = []
  386. self.assertRaisesRegex(
  387. LineageSearchConditionParamError,
  388. 'Invalid search_condition type, it should be dict.',
  389. filter_summary_lineage,
  390. LINEAGE_DATA_MANAGER,
  391. search_condition
  392. )
  393. # the condition of limit is invalid
  394. search_condition = {
  395. 'limit': True
  396. }
  397. self.assertRaisesRegex(
  398. LineageSearchConditionParamError,
  399. 'The limit must be int.',
  400. filter_summary_lineage,
  401. LINEAGE_DATA_MANAGER,
  402. search_condition
  403. )
  404. @pytest.mark.level0
  405. @pytest.mark.platform_arm_ascend_training
  406. @pytest.mark.platform_x86_gpu_training
  407. @pytest.mark.platform_x86_ascend_training
  408. @pytest.mark.platform_x86_cpu
  409. @pytest.mark.env_single
  410. def test_filter_summary_lineage_exception_3(self):
  411. """Test the abnormal execution of the filter_summary_lineage interface."""
  412. # the condition of offset is invalid
  413. search_condition = {
  414. 'offset': 1.0
  415. }
  416. self.assertRaisesRegex(
  417. LineageSearchConditionParamError,
  418. 'The offset must be int.',
  419. filter_summary_lineage,
  420. LINEAGE_DATA_MANAGER,
  421. search_condition
  422. )
  423. # the search attribute not supported
  424. search_condition = {
  425. 'dataset_graph': {
  426. 'le': 1
  427. }
  428. }
  429. self.assertRaisesRegex(
  430. LineageSearchConditionParamError,
  431. 'The search attribute not supported.',
  432. filter_summary_lineage,
  433. LINEAGE_DATA_MANAGER,
  434. search_condition
  435. )
  436. @pytest.mark.level0
  437. @pytest.mark.platform_arm_ascend_training
  438. @pytest.mark.platform_x86_gpu_training
  439. @pytest.mark.platform_x86_ascend_training
  440. @pytest.mark.platform_x86_cpu
  441. @pytest.mark.env_single
  442. def test_filter_summary_lineage_exception_4(self):
  443. """Test the abnormal execution of the filter_summary_lineage interface."""
  444. # the sorted_type not supported
  445. search_condition = {
  446. 'sorted_name': 'summary_dir',
  447. 'sorted_type': 'xxx'
  448. }
  449. self.assertRaisesRegex(
  450. LineageSearchConditionParamError,
  451. 'The sorted_type must be ascending or descending',
  452. filter_summary_lineage,
  453. LINEAGE_DATA_MANAGER,
  454. search_condition
  455. )
  456. # the search condition not supported
  457. search_condition = {
  458. 'batch_size': {
  459. 'dd': 30
  460. }
  461. }
  462. self.assertRaisesRegex(
  463. LineageSearchConditionParamError,
  464. 'The compare condition should be in',
  465. filter_summary_lineage,
  466. LINEAGE_DATA_MANAGER,
  467. search_condition
  468. )
  469. # the search condition type error
  470. search_condition = {
  471. 'metric/accuracy': {
  472. 'lt': 'xxx'
  473. }
  474. }
  475. self.assertRaisesRegex(
  476. LineageSearchConditionParamError,
  477. 'The parameter metric/accuracy is invalid.',
  478. filter_summary_lineage,
  479. LINEAGE_DATA_MANAGER,
  480. search_condition
  481. )
  482. @pytest.mark.level0
  483. @pytest.mark.platform_arm_ascend_training
  484. @pytest.mark.platform_x86_gpu_training
  485. @pytest.mark.platform_x86_ascend_training
  486. @pytest.mark.platform_x86_cpu
  487. @pytest.mark.env_single
  488. def test_filter_summary_lineage_exception_5(self):
  489. """Test the abnormal execution of the filter_summary_lineage interface."""
  490. # gt > lt
  491. search_condition1 = {
  492. 'metric/accuracy': {
  493. 'gt': 1,
  494. 'lt': 0.5
  495. }
  496. }
  497. expect_result = {
  498. 'customized': {},
  499. 'object': [],
  500. 'count': 0
  501. }
  502. partial_res1 = filter_summary_lineage(LINEAGE_DATA_MANAGER, search_condition1)
  503. assert expect_result == partial_res1
  504. # the (offset + 1) * limit > count
  505. search_condition2 = {
  506. 'loss': {
  507. 'lt': 1
  508. },
  509. 'limit': 1,
  510. 'offset': 4
  511. }
  512. expect_result = {
  513. 'customized': {},
  514. 'object': [],
  515. 'count': 2
  516. }
  517. partial_res2 = filter_summary_lineage(LINEAGE_DATA_MANAGER, search_condition2)
  518. assert expect_result == partial_res2
  519. @pytest.mark.level0
  520. @pytest.mark.platform_arm_ascend_training
  521. @pytest.mark.platform_x86_gpu_training
  522. @pytest.mark.platform_x86_ascend_training
  523. @pytest.mark.platform_x86_cpu
  524. @pytest.mark.env_single
  525. def test_filter_summary_lineage_exception_6(self):
  526. """Test the abnormal execution of the filter_summary_lineage interface."""
  527. condition_keys = ["summary_dir", "lineage_type", "loss_function", "optimizer", "network", "dataset_mark"]
  528. for condition_key in condition_keys:
  529. # the condition type not supported in summary_dir and lineage_type
  530. search_condition = {
  531. condition_key: {
  532. 'lt': '/xxx'
  533. }
  534. }
  535. self.assertRaisesRegex(
  536. LineageSearchConditionParamError,
  537. f'The parameter {condition_key} is invalid. Its operation should be `eq`, `in` or `not_in`.',
  538. filter_summary_lineage,
  539. LINEAGE_DATA_MANAGER,
  540. search_condition
  541. )
  542. @pytest.mark.level0
  543. @pytest.mark.platform_arm_ascend_training
  544. @pytest.mark.platform_x86_gpu_training
  545. @pytest.mark.platform_x86_ascend_training
  546. @pytest.mark.platform_x86_cpu
  547. @pytest.mark.env_single
  548. def test_filter_summary_lineage_exception_7(self):
  549. """Test the abnormal execution of the filter_summary_lineage interface."""
  550. invalid_lineage_types = ['xxx', None]
  551. for lineage_type in invalid_lineage_types:
  552. search_condition = {
  553. 'lineage_type': {
  554. 'eq': lineage_type
  555. }
  556. }
  557. self.assertRaisesRegex(
  558. LineageSearchConditionParamError,
  559. "The parameter lineage_type is invalid. It should be 'dataset' or 'model'.",
  560. filter_summary_lineage,
  561. LINEAGE_DATA_MANAGER,
  562. search_condition
  563. )
  564. @pytest.mark.level0
  565. @pytest.mark.platform_arm_ascend_training
  566. @pytest.mark.platform_x86_gpu_training
  567. @pytest.mark.platform_x86_ascend_training
  568. @pytest.mark.platform_x86_cpu
  569. @pytest.mark.env_single
  570. def test_filter_summary_lineage_exception_8(self):
  571. """Test the abnormal execution of the filter_summary_lineage interface."""
  572. invalid_sorted_names = ['xxx', 'metric_', 1]
  573. for sorted_name in invalid_sorted_names:
  574. search_condition = {
  575. 'sorted_name': sorted_name
  576. }
  577. self.assertRaisesRegex(
  578. LineageSearchConditionParamError,
  579. 'The sorted_name must be in',
  580. filter_summary_lineage,
  581. LINEAGE_DATA_MANAGER,
  582. search_condition
  583. )
  584. @pytest.mark.level1
  585. @pytest.mark.platform_arm_ascend_training
  586. @pytest.mark.platform_x86_gpu_training
  587. @pytest.mark.platform_x86_ascned_training
  588. @pytest.mark.platform_x86_cpu
  589. @pytest.mark.env_single
  590. def test_get_flattened_lineage(self):
  591. """Test the function of get_flattened_lineage"""
  592. datamanager = data_manager.DataManager(SUMMARY_DIR)
  593. datamanager.register_brief_cache_item_updater(LineageCacheItemUpdater())
  594. datamanager.start_load_data().join()
  595. data = get_flattened_lineage(datamanager)
  596. assert data.get('[U]info') == ['info1']