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

Collect addional info in mixin #206

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

casparvl
Copy link
Collaborator

@casparvl casparvl commented Nov 14, 2024

Solves #196

Note that the nodenames on which the test is run are already logged by the ReFrame framework, so we don't need to do that.

Discussed on the ReFrame slack channel. The challenge is that we want the variables from the batch nodes, so it has to be printed with postrun_cmds. But then, we need to get it from the output, and into a ReFrame variable so that it is logged. Those need to be initialized in the class body. Then can be updated with the output of the extracted information. We use sanity functions to extract from the output, catching the SanityError that is produced if there is no match (as we don't want the test to fail because of this). Note that SanityError's are actually expected for runs on local software stack, since then the EESSI_* environment variables are not set, and the pattern match fails. That's fine, we just want the variables to read 'None' in those cases.

@casparvl casparvl marked this pull request as ready for review November 14, 2024 21:22
Comment on lines +186 to +189
# Get full modulepath, stripping leading spaces with sed and trailing colon by string substitution
get_full_modpath = f'modpath=$(module show {self.module_name} 2>&1 | '
get_full_modpath += 'grep ".lua" | '
get_full_modpath += 'sed "s/^[[:space:]]*//") && echo "FULL_MODULEPATH: ${modpath%:*}"'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be simplified using the --location option:

Suggested change
# Get full modulepath, stripping leading spaces with sed and trailing colon by string substitution
get_full_modpath = f'modpath=$(module show {self.module_name} 2>&1 | '
get_full_modpath += 'grep ".lua" | '
get_full_modpath += 'sed "s/^[[:space:]]*//") && echo "FULL_MODULEPATH: ${modpath%:*}"'
# Get full modulepath
get_full_modpath = f'echo "FULL_MODULEPATH: $(module --location show {self.module_name})"'

def extract_runtime_info_from_log(self):
"""Extracts the printed runtime info from the job log and logs it as reframe variables"""
# If EESSI_CVMFS_REPO environment variable was set, extract it and store it in self.cvmfs_repo_name
# Try block is needed to surpress sanity error if there is no match
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Try block is needed to surpress sanity error if there is no match
# Try block is needed to suppress sanity error if there is no match

Comment on lines +197 to +203
try:
repo_name = sn.extractsingle(r'EESSI_CVMFS_REPO: /cvmfs/(?P<repo>.*)$', f'{self.stagedir}/{self.stdout}',
'repo', str)
if repo_name:
self.cvmfs_repo_name = f'{repo_name}'
except SanityError:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like to make a distinction between 'None', indicating a failing sanity check, and an empty string, indicating that the EESSI CVMFS repo was not used:

Suggested change
try:
repo_name = sn.extractsingle(r'EESSI_CVMFS_REPO: /cvmfs/(?P<repo>.*)$', f'{self.stagedir}/{self.stdout}',
'repo', str)
if repo_name:
self.cvmfs_repo_name = f'{repo_name}'
except SanityError:
pass
try:
self.cvmfs_repo_name = sn.extractsingle(r'EESSI_CVMFS_REPO: /cvmfs/(?P<repo>.*)$', f'{self.stagedir}/{self.stdout}',
'repo', str)
except SanityError:
pass

Comment on lines +205 to +211
try:
software_subdir = sn.extractsingle(r'EESSI_SOFTWARE_SUBDIR: (?P<subdir>.*)$',
f'{self.stagedir}/{self.stdout}', 'subdir', str)
if software_subdir:
self.cvmfs_software_subdir = f'{software_subdir}'
except SanityError:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment on lines +213 to +220
try:
module_path = sn.extractsingle(r'FULL_MODULEPATH: (?P<modpath>.*)$', f'{self.stagedir}/{self.stdout}',
'modpath', str)
print(f"Full modulepath: {module_path}")
if module_path:
self.full_modulepath = f'{module_path}'
except SanityError:
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants