Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support deprecation of attributes and attribute values #390

Open
wants to merge 7 commits into
base: unstable
Choose a base branch
from
13 changes: 13 additions & 0 deletions packages/taucmdr/cf/software/tau_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ def install(self, force_reinstall=False):
LOGGER.info(f'Installing {self.title} to:\n {self.install_prefix}')
try:
shutil.move(self._prepare_src(), self.install_prefix)
self.tau_version = self.get_version(os.path.join(self.install_prefix, 'include/TAU.h.default'))
except Exception as err:
LOGGER.debug("Exception thrown by shutil.move, attempting to continue.")
# On some docker fuse mounted file systems shutil.move was failing with symlinks
Expand Down Expand Up @@ -1932,3 +1933,15 @@ def get_python_version(self, python_path):
pattern = re.compile(r'\d+\.\d+\.\d+')
match = pattern.search(out)
return match.group()

def get_version(self):
header_path = os.path.join(self.install_prefix, 'include/TAU.h.default')
with open(header_path) as f:
for line in f:
if line.startswith("#define TAU_VERSION"):
verline = line
break
verstr = re.findall('"([^"]*)"', verline)[0]
if verstr.endswith('-git'):
ver = verstr[:-len('-git')]
return ver
49 changes: 49 additions & 0 deletions packages/taucmdr/model/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ def attributes():
'type': 'string',
'description': 'TAU Makefile used during this experiment, if any.'
},
'tau_version': {
'type': 'string',
'description': 'TAU version used during this experiment'
},
'record_output': {
'type': 'boolean',
'default': False,
Expand Down Expand Up @@ -233,6 +237,49 @@ def verify(self):
for rhs in [targ, app, meas]:
lhs.check_compatibility(rhs)

# Check for deprecated attributes
if 'tau_version' in self.controller(self.storage).search(self.eid)[0]:
tau_version_str = self.controller(self.storage).search(self.eid)[0]['tau_version']
tau_version = [int(i) for i in tau_version_str.split('.')]
tau_version.extend([0]*(3-len(tau_version)))
else:
return
for comp in [targ, app, meas]:
for attr, props in comp.attributes.iteritems():
if 'deprecated' in props:
if comp.controller(self.storage).search(self.eid)[0][attr] in props['deprecated']:
deprecated_option = comp.controller(self.storage).search(self.eid)[0][attr]
dep = props['deprecated'][targ[attr]]
if isinstance(dep, list):
if len(dep) == 2 and dep[1] != '':
rem_str = dep[1]
rem = [int(i) for i in rem_str.split('.')]
rem.extend([0]*(3-len(rem)))
is_removed = tau_version >= rem
else:
is_removed = False

if is_removed:
is_deprecated = False
else:
depr_str = dep[0]
depr = [int(i) for i in depr_str.split('.')]
depr.extend([0]*(3-len(depr)))
is_deprecated = tau_version >= depr
else:
depr_str = dep
depr = [int(i) for i in depr_str.split('.')]
depr.extend([0]*(3-len(depr)))
is_deprecated = tau_version >= depr
is_removed = False

if is_deprecated:
LOGGER.warning(
"The \"--%s %s\" option has been deprecated in TAU version %s and will be removed in a future release." %(attr, deprecated_option, depr_str)
)
elif is_removed:
raise ConfigurationError(f'The \"--{attr} {deprecated_option}\" option was removed in TAU version {rem_str}.')

def on_create(self):
self.verify()
try:
Expand Down Expand Up @@ -348,6 +395,8 @@ def configure(self):
tau.install()
if not baseline:
self.controller(self.storage).update({'tau_makefile': os.path.basename(tau.get_makefile())}, self.eid)
self.controller(self.storage).update({'tau_version': tau.get_version()}, self.eid)
self.verify()
return tau

def managed_build(self, compiler_cmd, compiler_args):
Expand Down
4 changes: 4 additions & 0 deletions packages/taucmdr/model/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ def attributes():
'group': 'software package',
'metavar': '(<path>|<url>|download|download-tr4|download-tr6|None)',
'action': ParsePackagePathAction},
'deprecated': {'download-tr4' : ['2.29.1',''], 'download-tr6' : ['2.29.1','']},
'rebuild_required': True
},
'libotf2_source': {
Expand Down Expand Up @@ -744,6 +745,9 @@ def papi_metrics(self, event_type="PRESET", include_modifiers=False):
def tau_metrics(self):
return self.get_installation('tau').tau_metrics()

def tau_version(self):
return self.get_installation('tau').tau_version()

def cupti_metrics(self):
if not self.get('cuda'):
return []
Expand Down