mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 12:06:08 +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:
parent
1425a6f6c9
commit
615cbbc94d
@ -292,8 +292,9 @@ 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):
|
||||||
cache = read_target_info_cache()
|
if cache is None:
|
||||||
|
cache = read_target_info_cache()
|
||||||
pod = cache.get(system_id, None)
|
pod = cache.get(system_id, None)
|
||||||
|
|
||||||
if not pod:
|
if not pod:
|
||||||
@ -307,8 +308,9 @@ 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):
|
||||||
cache = read_target_info_cache()
|
if cache is None:
|
||||||
|
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))
|
||||||
cache[target_info.system_id] = target_info.to_pod()
|
cache[target_info.system_id] = target_info.to_pod()
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user