Skip to content
Snippets Groups Projects
Commit 78c6dbd5 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Subcommand to setup repo combinations

parents
Branches
No related tags found
No related merge requests found
#!/usr/bin/python2
from __future__ import print_function
import sys
import argparse
from xml.etree import ElementTree
import osc
import osc.conf
import osc.core
import osc.cmdln
all_compilers = "gcc_4_9 gcc_5 gcc_6 gcc_7 intel_16_0 intel_17_0"
all_mpis = "openmpi_1_10 impi_5_1_3 impi_2017_3"
all_cudas = "cuda_8"
default_distribution = "SLE_12_SP1"
default_architectures = "x86_64"
def valid_mpi(compiler, mpi):
if compiler == "intel_17_0":
if mpi.startswith("impi"):
return mpi == "impi_2017_3"
if compiler == "intel_16_0":
if mpi.startswith("impi"):
return mpi == "impi_5_1_3"
return True
@osc.cmdln.option('--distribution',
default=default_distribution,
help="Base distribution [default: %default]")
@osc.cmdln.option('--architectures',
default=default_architectures,
help="Architectures [default: %default]")
@osc.cmdln.option('--compilers',
default=all_compilers,
help="List of compilers, [default: %default]")
@osc.cmdln.option('--mpis',
default=all_mpis,
help="List of MPI libraries, [default: %default]")
@osc.cmdln.option('--cudas',
default=all_cudas,
help="List of CUDA versions, [default: %default]")
@osc.cmdln.option('--parent', metavar="PARENT",
help="Setup the repositories to be based on the upstream project PARENT (e.g. for home: projects)")
@osc.cmdln.option('-n', '--dry-run', action="store_true",
help="Do not actually run anything but output the resulting XML configuration")
def do_mpcdf_repositories(self, subcmd, opts, *args):
"""${cmd_name}: Create all repository combinations for an MPCDF project
Given a list of compilers, MPI libraries, and possibly CUDA versions, this command
creates repositories for all the resulting combinations
Usage:
osc ${cmd_name} [PROJECT]
${cmd_option_list}
"""
if len(args) == 0:
if is_project_dir(os.curdir) or is_package_dir(os.curdir):
project = osc.core.store_read_project(os.curdir)
else:
raise oscerr.WrongArgs('Specify PROJECT or run command in an osc checkout directory')
elif len(args) == 1:
project, = args
else:
raise oscerr.WrongArgs("Too many arguments")
compilers = opts.compilers.split()
architectures = opts.architectures.split()
mpis = opts.mpis.split()
cudas = opts.cudas.split()
project_meta = osc.core.show_project_meta(osc.conf.config["apiurl"], project)
root = ElementTree.fromstringlist(project_meta)
# Remove existing repositories
for repo in root.findall("./repository"):
root.remove(repo)
def repo(name, *dependencies):
r = ElementTree.SubElement(root, "repository")
r.set("name", name)
r.text="\n "
def path(project, repo):
p = ElementTree.SubElement(r, "path")
p.set("project", project)
p.set("repository", repo)
p.tail="\n "
if opts.parent:
path(opts.parent, name)
for dep_project, dep_repo in dependencies:
path(dep_project, dep_repo)
for arch in architectures:
a = ElementTree.SubElement(r, "arch")
a.text = arch
a.tail = "\n "
a.tail = "\n "
r.tail = "\n "
repo("System", ("distributions", opts.distribution))
for compiler in sorted(compilers):
repo(compiler, (project, "System"))
for mpi in sorted(mpis):
for compiler in sorted(compilers):
if not valid_mpi(compiler, mpi):
continue
repo(mpi + "_" + compiler, (project, compiler))
for cuda in sorted(cudas):
repo(cuda, (project, "System"))
for compiler in sorted(compilers):
repo(cuda + "_" + compiler, (project, cuda), (project, compiler))
for mpi in sorted(mpis):
for compiler in sorted(compilers):
if not valid_mpi(compiler, mpi):
continue
repo(cuda + "_" + mpi + "_" + compiler,
(project, cuda + "_" + compiler),
(project, mpi + "_" + compiler))
root.getchildren()[-1].tail = "\n"
meta = ET.tostring(root, encoding=osc.core.ET_ENCODING)
if opts.dry_run:
print(meta)
else:
osc.core.edit_meta("prj", project, data=meta)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment