mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 15:12:25 +00:00 
			
		
		
		
	fw/target_info: Prevent multiple parses of the target_info_cache
Instead of parsing the target_info_cache multiple times,allow for it to be read it once and passed as a paramter to the coresponding methods.
This commit is contained in:
		| @@ -292,7 +292,8 @@ def write_target_info_cache(cache): | |||||||
|         write_pod(cache, settings.target_info_cache_file) |         write_pod(cache, settings.target_info_cache_file) | ||||||
|  |  | ||||||
|  |  | ||||||
| def get_target_info_from_cache(system_id): | def get_target_info_from_cache(system_id, cache=None): | ||||||
|  |     if cache is None: | ||||||
|         cache = read_target_info_cache() |         cache = read_target_info_cache() | ||||||
|     pod = cache.get(system_id, None) |     pod = cache.get(system_id, None) | ||||||
|  |  | ||||||
| @@ -307,7 +308,8 @@ def get_target_info_from_cache(system_id): | |||||||
|     return TargetInfo.from_pod(pod) |     return TargetInfo.from_pod(pod) | ||||||
|  |  | ||||||
|  |  | ||||||
| def cache_target_info(target_info, overwrite=False): | def cache_target_info(target_info, overwrite=False, cache=None): | ||||||
|  |     if cache is None: | ||||||
|         cache = read_target_info_cache() |         cache = read_target_info_cache() | ||||||
|     if target_info.system_id in cache and not overwrite: |     if target_info.system_id in cache and not overwrite: | ||||||
|         raise ValueError('TargetInfo for {} is already in cache.'.format(target_info.system_id)) |         raise ValueError('TargetInfo for {} is already in cache.'.format(target_info.system_id)) | ||||||
|   | |||||||
| @@ -24,7 +24,8 @@ from wa.framework.plugin import Parameter | |||||||
| from wa.framework.target.descriptor import (get_target_description, | from wa.framework.target.descriptor import (get_target_description, | ||||||
|                                             instantiate_target, |                                             instantiate_target, | ||||||
|                                             instantiate_assistant) |                                             instantiate_assistant) | ||||||
| from wa.framework.target.info import get_target_info, get_target_info_from_cache, cache_target_info | from wa.framework.target.info import (get_target_info, get_target_info_from_cache, | ||||||
|  |                                       cache_target_info, read_target_info_cache) | ||||||
| from wa.framework.target.runtime_parameter_manager import RuntimeParameterManager | from wa.framework.target.runtime_parameter_manager import RuntimeParameterManager | ||||||
| from wa.utils.types import module_name_set | from wa.utils.types import module_name_set | ||||||
|  |  | ||||||
| @@ -92,18 +93,19 @@ class TargetManager(object): | |||||||
|  |  | ||||||
|     @memoized |     @memoized | ||||||
|     def get_target_info(self): |     def get_target_info(self): | ||||||
|         info = get_target_info_from_cache(self.target.system_id) |         cache = read_target_info_cache() | ||||||
|  |         info = get_target_info_from_cache(self.target.system_id, cache=cache) | ||||||
|  |  | ||||||
|         if info is None: |         if info is None: | ||||||
|             info = get_target_info(self.target) |             info = get_target_info(self.target) | ||||||
|             cache_target_info(info) |             cache_target_info(info, cache=cache) | ||||||
|         else: |         else: | ||||||
|             # If module configuration has changed form when the target info |             # If module configuration has changed form when the target info | ||||||
|             # was previously cached, it is possible additional info will be |             # was previously cached, it is possible additional info will be | ||||||
|             # available, so should re-generate the cache. |             # available, so should re-generate the cache. | ||||||
|             if module_name_set(info.modules) != module_name_set(self.target.modules): |             if module_name_set(info.modules) != module_name_set(self.target.modules): | ||||||
|                 info = get_target_info(self.target) |                 info = get_target_info(self.target) | ||||||
|                 cache_target_info(info, overwrite=True) |                 cache_target_info(info, overwrite=True, cache=cache) | ||||||
|  |  | ||||||
|         return info |         return info | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user