|
11 | 11 | def test_store_output_file(env): |
12 | 12 | # setup variables |
13 | 13 | filename = "test_output_file.json" |
14 | | - results, _ = tune_kernel(*env, cache=cache_filename, simulation_mode=True) |
15 | | - tune_params = env[-1] |
16 | 14 |
|
17 | | - # run store_output_file |
18 | | - store_output_file(filename, results, tune_params) |
| 15 | + try: |
| 16 | + results, _ = tune_kernel(*env, cache=cache_filename, simulation_mode=True) |
| 17 | + tune_params = env[-1] |
| 18 | + |
| 19 | + # run store_output_file |
| 20 | + store_output_file(filename, results, tune_params) |
19 | 21 |
|
20 | | - # retrieve output file |
21 | | - _, schema = output_file_schema("results") |
22 | | - with open(filename) as json_file: |
23 | | - output_json = json.load(json_file) |
| 22 | + # retrieve output file |
| 23 | + _, schema = output_file_schema("results") |
| 24 | + with open(filename) as json_file: |
| 25 | + output_json = json.load(json_file) |
24 | 26 |
|
25 | | - # validate |
26 | | - validate(output_json, schema=schema) |
| 27 | + # validate |
| 28 | + validate(output_json, schema=schema) |
27 | 29 |
|
28 | | - # clean up |
29 | | - delete_temp_file(filename) |
| 30 | + finally: |
| 31 | + # clean up |
| 32 | + delete_temp_file(filename) |
30 | 33 |
|
31 | 34 |
|
32 | 35 | def test_store_metadata_file(): |
33 | 36 | # setup variables |
34 | 37 | filename = "test_metadata_file.json" |
35 | 38 |
|
36 | | - # run store_metadata_file |
37 | 39 | try: |
38 | | - store_metadata_file(filename, target="nvidia") |
39 | | - except FileNotFoundError: |
40 | | - pytest.skip("'lshw' or 'nvidia-smi' not present on this system") |
41 | | - |
42 | | - # retrieve metadata file |
43 | | - _, schema = output_file_schema("metadata") |
44 | | - with open(filename) as json_file: |
45 | | - metadata_json = json.load(json_file) |
46 | | - |
47 | | - # validate |
48 | | - validate(metadata_json, schema=schema) |
49 | | - |
50 | | - # clean up |
51 | | - delete_temp_file(filename) |
| 40 | + # run store_metadata_file |
| 41 | + try: |
| 42 | + store_metadata_file(filename) |
| 43 | + except FileNotFoundError: |
| 44 | + pytest.skip("'lshw' not present on this system") |
| 45 | + |
| 46 | + # retrieve metadata file |
| 47 | + _, schema = output_file_schema("metadata") |
| 48 | + with open(filename) as json_file: |
| 49 | + metadata_json = json.load(json_file) |
| 50 | + |
| 51 | + # validate |
| 52 | + validate(metadata_json, schema=schema) |
| 53 | + |
| 54 | + finally: |
| 55 | + # clean up |
| 56 | + delete_temp_file(filename) |
0 commit comments