mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 07:04:17 +00:00 
			
		
		
		
	workload/rt-app: Better JSON processing error reporting
The rt-app workload parses the rt-app JSON file in order to override some options (specifically duration). Previously, if the JSON was syntactically incorrect, an uninformative ValueError was raised. Now we raise a ConfigError with appropriate message prompting the user to fix the file.
This commit is contained in:
		
				
					committed by
					
						 Marc Bonnici
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							b8343e545b
						
					
				
				
					commit
					7c1ed6487b
				
			| @@ -21,7 +21,7 @@ from collections import OrderedDict | ||||
| from subprocess import CalledProcessError | ||||
|  | ||||
| from wa import Workload, Parameter, Executable, File | ||||
| from wa.framework.exception import WorkloadError, ResourceError | ||||
| from wa.framework.exception import WorkloadError, ResourceError, ConfigError | ||||
| from wa.utils.misc import check_output | ||||
| from wa.utils.exec_control import once | ||||
|  | ||||
| @@ -231,7 +231,13 @@ class RtApp(Workload): | ||||
|         config_file = self._generate_workgen_config(user_config_file, | ||||
|                                                     context.output_directory) | ||||
|         with open(config_file) as fh: | ||||
|             config_data = json.load(fh, object_pairs_hook=OrderedDict) | ||||
|             try: | ||||
|                 config_data = json.load(fh, object_pairs_hook=OrderedDict) | ||||
|             except ValueError: | ||||
|                 # We were not able to parse the JSON file. Raise an informative error. | ||||
|                 msg = "Failed to parse {}. Please make sure it is valid JSON." | ||||
|                 raise ConfigError(msg.format(user_config_file)) | ||||
|  | ||||
|         self._update_rt_app_config(config_data) | ||||
|         self.duration = config_data['global'].get('duration', 0) | ||||
|         self.task_count = len(config_data.get('tasks', [])) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user