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

[feat] Import past results to DB #3275

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions reframe/frontend/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def add_argument(self, *flags, **kwargs):

if flags and opt_name is None:
# A positional argument
opt_name = flags[-1]
opt_name, flags = flags[-1], flags[:-1]

if opt_name is None:
raise ValueError('could not infer a dest name: no flags defined')
Expand Down Expand Up @@ -230,7 +230,8 @@ def add_argument(self, *flags, **kwargs):
except KeyError:
self._defaults.__dict__[opt_name] = None

if not flags:
positional = kwargs.pop('positional', False)
if not flags and not positional:
return None

return self._holder.add_argument(*flags, **kwargs)
Expand Down
34 changes: 34 additions & 0 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
import time
import traceback
import yaml

import reframe.core.config as config
import reframe.core.exceptions as errors
Expand Down Expand Up @@ -479,6 +480,10 @@ def main():
action_options.add_argument(
'-V', '--version', action='version', version=osext.reframe_version()
)
action_options.add_argument(
'--import-results', action='store', metavar='SPECFILE',
help='Import results to the database'
)

# Run options
run_options.add_argument(
Expand Down Expand Up @@ -831,6 +836,7 @@ def main():
action='store_true',
help='Use a login shell for job scripts'
)
argparser.add_argument('args', metavar='ARGS', nargs='*', positional=True)

def restrict_logging():
'''Restrict logging to errors only.
Expand Down Expand Up @@ -1066,6 +1072,34 @@ def restrict_logging():
)
sys.exit(0)

if options.import_results:
with exit_gracefully_on_error('failed to import results', printer):
with open(options.import_results) as fp:
spec = yaml.load(fp, yaml.Loader)

if spec['import']['from'] == 'perflog':
kwargs = spec['import']
del kwargs['from']
reports = reporting.RunReport.create_from_perflog(
*options.args, **kwargs
)
elif spec['import']['from'] == 'sqlite':
kwargs = spec['import']
del kwargs['from']
reports = reporting.RunReport.create_from_sqlite_db(
*options.args, **kwargs
)

for rpt in reports:
uuid = rpt.store()
printer.verbose(f'Successfully imported session {uuid}')

printer.info(f'Successfully imported {len(reports)} sessions')
if not reports:
printer.warning('No sessions have been imported')

sys.exit(0)

# Show configuration after everything is set up
if options.show_config:
# Restore logging level
Expand Down
Loading
Loading