Skip to content

Commit

Permalink
davai from bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreMary committed Jan 25, 2024
1 parent f87e709 commit 9e2496b
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 12 deletions.
97 changes: 97 additions & 0 deletions bin/davai-new_xp_from_bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
# -*- coding:Utf-8 -*-
"""
Create a new Davai experiment, from a bundle.
"""
from __future__ import print_function, absolute_import, unicode_literals, division

import os
import argparse
import sys

# Automatically set the python path for davai_cmd
repo_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
sys.path.insert(0, os.path.join(repo_path, 'src'))
from davai_env import guess_host, config
from davai_env.experiment import XPmaker
from davai_env.util import expandpath

DAVAI_HOST = guess_host()


def main(sources_to_test,
davai_tests_version,
davai_tests_origin=config['defaults']['davai_tests_origin'],
usecase=config['defaults']['usecase'],
host=DAVAI_HOST):
"""
Setup an XP.
:param sources_to_test: information about the sources to be tested, provided as a dict
:param davai_tests_version: version of the test bench to be used
:param davai_tests_origin: URL of the DAVAI-tests origin repository to be cloned in XP
:param usecase: among NRV, ELP, PC, ...
:param host: name of host machine, to link necessary packages and get according config file
(otherwise guessed)
"""
xp = XPmaker.new_xp(sources_to_test=sources_to_test,
davai_tests_version=davai_tests_version,
davai_tests_origin=davai_tests_origin,
usecase=usecase,
host=host)
xp.write_genesis(" ".join(sys.argv))


if __name__ == '__main__':

parser = argparse.ArgumentParser(description='Create a Davai experiment based on a Git reference.')
parser.add_argument('bundle',
help="An IAL-bundle, either as a local file or " +
"a git ref (tag, commit) in the IAL-bundle repository " +
"(repo URL to be specified via arg -r in this case).")
parser.add_argument('-r', '--IAL_bundle_repo',
default=None,
dest='IAL_bundle_repository',
help="URL (or path) of IAL-bundle repository in which to find the bundle in the given reference. " +
"E.g. 'https://github.com/ACCORD-NWP/IAL-bundle' or '~/repositories/IAL-bundle'.")
parser.add_argument('-v', '--tests_version',
dest='davai_tests_version',
help="Version of the Davai test bench to be used.",
required=True)
parser.add_argument('-c', '--comment',
default=None,
help="Comment about experiment. Defaults to bundle.")
parser.add_argument('-u', '--usecase',
default=config['defaults']['usecase'],
help="Usecase: NRV (restrained set of canonical tests) or ELP (extended elementary tests); " +
"More (PC, ...) to come. Defaults to: '{}'".format(config['defaults']['usecase']))
parser.add_argument('--origin', '--davai_tests_origin',
default=config['defaults']['davai_tests_origin'],
dest='davai_tests_origin',
help=("URL of the DAVAI-tests origin repository to be cloned in XP. " +
"Default ({}) can be set through section [defaults] " +
"of user config file").format(config['defaults']['davai_tests_origin']))
parser.add_argument('--host',
default=DAVAI_HOST,
help="Generic name of host machine, in order to find paths to necessary packages. " +
("Default is guessed ({}), or can be set through " +
"section 'hosts' of user config file").format(DAVAI_HOST))
args = parser.parse_args()

if args.IAL_bundle_repository is not None:
if any([args.IAL_bundle_repository.startswith(p) for p in ['https://', 'ssh://', 'git://']]):
IAL_bundle_repository = args.IAL_bundle_repository
else:
IAL_bundle_repository = os.path.abspath(args.IAL_bundle_repository)
assert os.path.isdir(IAL_bundle_repository)
sources_to_test = dict(IAL_bundle_ref=args.bundle,
IAL_bundle_repository=IAL_bundle_repository)
else:
sources_to_test = dict(IAL_bundle_file=os.path.abspath(args.bundle))
sources_to_test['comment'] = args.comment

main(sources_to_test,
args.davai_tests_version,
davai_tests_origin=args.davai_tests_origin,
usecase=args.usecase,
host=args.host)
2 changes: 1 addition & 1 deletion conf/atos_bologna.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ vortex = ~sos/vortex/vortex-olive-dev
epygram = ~acrd/public/EPyGrAM/1.4.16
# for others, the path has to lead to the python package
ial_expertise = ~acrd/public/IAL-expertise/1.1.5/src/ial_expertise
ial_build = ~acrd/public/IAL-build/1.2.4/src/ial_build
ial_build = ~acrd/public/IAL-build/1.2.5/src/ial_build
ecbundle = ~acrd/public/ecbundle/2.0.0/ecbundle
2 changes: 1 addition & 1 deletion conf/base.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ usecase = NRV
davai_tests_origin = https://github.com/ACCORD-NWP/DAVAI-tests.git
davai_alias_user = mary
davai_alias_arch_subdir = davai
IAL_bundle_repository = https://github.com/ACCORD-NWP/IAL-bundle

[paths]
IAL_repository = ~/repositories/IAL
IAL_bundle_repository = ~/repositories/IAL-bundle
experiments = ~/davai/experiments
logs = ~/davai/logs

Expand Down
2 changes: 1 addition & 1 deletion conf/belenos.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ vortex = ~verolive/vortex/vortex-olive-dev
epygram = ~mary/public/EPyGrAM/1.4.17
# for others, the path has to lead to the python package
ial_expertise = ~mary/public/IAL-expertise/1.1.5/src/ial_expertise
ial_build = ~mary/public/IAL-build/1.2.4/src/ial_build
ial_build = ~mary/public/IAL-build/1.2.5/src/ial_build
ecbundle = ~mary/public/ecbundle/2.0.0/ecbundle
20 changes: 11 additions & 9 deletions src/davai_env/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ThisXP(object):
davai_tests_dir = 'DAVAI-tests'
sources_to_test_file = os.path.join('conf', 'sources.yaml')
sources_to_test_minimal_keys = (set(('IAL_git_ref',)),
set(('IAL_bundle',)),
set(('IAL_bundle_ref', 'IAL_bundle_repository')),
set(('IAL_bundle_file',))
)

Expand Down Expand Up @@ -278,13 +278,15 @@ def sources_to_test(self):
c['comment'] = c['IAL_git_ref']
repo = c.get('IAL_repository', config['paths']['IAL_repository'])
c['IAL_repository'] = expandpath(repo)
elif 'IAL_bundle' in c:
# sources to be tested taken from IAL_bundle@IAL_bundle_repository
elif 'IAL_bundle_file' in c:
# sources to be tested taken from an IAL bundle file
if c.get('comment', None) is None:
c['comment'] = c['IAL_bundle']
if c['IAL_bundle'].startswith('tag:'):
repo = c.get('IAL_bundle_repository', config['paths']['IAL_bundle_repository'])
c['IAL_bundle_repository'] = expandpath(repo)
c['comment'] = c['IAL_bundle_file']
elif 'IAL_bundle_ref' in c:
# sources to be tested taken from IAL_bundle_ref@IAL_bundle_repository
if c.get('comment', None) is None:
c['comment'] = c['IAL_bundle_ref']
c['IAL_bundle_repository'] = c.get('IAL_bundle_repository', config['default']['IAL_bundle_repository'])
self._sources_to_test = c
return self._sources_to_test

Expand Down Expand Up @@ -348,11 +350,11 @@ def launch_build(self,
if 'IAL_git_ref' in self.sources_to_test:
# build from a single IAL Git reference
build_job = 'build.gmkpack.build_from_gitref'
elif 'IAL_bundle' in self.sources_to_test:
elif any([k in self.sources_to_test for k in ['IAL_bundle_ref', 'IAL_bundle_file']]):
# build from a bundle
build_job = 'build.gmkpack.build_from_bundle'
else:
raise KeyError("Particular config should contain one of: ('IAL_git_ref', 'IAL_bundle_tag', 'IAL_bundle_file')")
raise KeyError("Particular config should contain one of: ('IAL_git_ref', 'IAL_bundle_ref', 'IAL_bundle_file')")
self._launch(build_job, 'build',
drymode=drymode,
preexisting_pack=preexisting_pack,
Expand Down

0 comments on commit 9e2496b

Please sign in to comment.