Skip to content

Commit

Permalink
target/manager: Allow specifying usage of target_info cache
Browse files Browse the repository at this point in the history
Allow disabling of the usage of the target_info cache. This is
useful when running on a one-off target and there is no benefit
of using caching the target information.
  • Loading branch information
marcbonnici committed Jun 23, 2020
1 parent c0c213f commit e20c254
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions wa/framework/target/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class TargetManager(object):
Specifies whether the target should be disconnected from
at the end of the run.
"""),
Parameter('cache_target_info', kind=bool, default=True,
description="""
Configure whether the cache should be used when collecting
target information.
"""),
]

def __init__(self, name, parameters, outdir):
Expand All @@ -50,6 +55,7 @@ def __init__(self, name, parameters, outdir):
self.rpm = None
self.parameters = parameters
self.disconnect = parameters.get('disconnect')
self.cache_target_info = parameters.get('cache_target_info')

def initialize(self):
self._init_target()
Expand Down Expand Up @@ -89,18 +95,21 @@ def extract_results(self, context):

@memoized
def get_target_info(self):
info = get_target_info_from_cache(self.target.system_id)
if self.cache_target_info:
info = get_target_info_from_cache(self.target.system_id)

if info is None:
info = get_target_info(self.target)
cache_target_info(info)
else:
# If module configuration has changed form when the target info
# was previously cached, it is possible additional info will be
# available, so should re-generate the cache.
if module_name_set(info.modules) != module_name_set(self.target.modules):
if info is None:
info = get_target_info(self.target)
cache_target_info(info, overwrite=True)
cache_target_info(info)
else:
# If module configuration has changed form when the target info
# was previously cached, it is possible additional info will be
# available, so should re-generate the cache.
if module_name_set(info.modules) != module_name_set(self.target.modules):
info = get_target_info(self.target)
cache_target_info(info, overwrite=True)
else:
info = get_target_info(self.target)

return info

Expand Down

0 comments on commit e20c254

Please sign in to comment.