From 7396fc849727c937148cdc73920622f2627ce03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCdepohl?= <lorenz.huedepohl@rzg.mpg.de> Date: Wed, 4 Apr 2018 14:34:07 +0200 Subject: [PATCH] Add temptative python repository support --- mpcdf_common.py | 12 ++++++++++++ mpcdf_enable_repositories.py | 8 ++++++-- mpcdf_info.py | 4 +++- mpcdf_setup_repositories.py | 5 +++-- mpcdf_sync_projects.py | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/mpcdf_common.py b/mpcdf_common.py index 31a7d68..2a240c6 100644 --- a/mpcdf_common.py +++ b/mpcdf_common.py @@ -125,6 +125,7 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False): all_compilers = get_attribute_values(api_url, project, None, "MPCDF:compiler_modules") mpis = get_attribute_values(api_url, project, package, "MPCDF:mpi_modules", with_project=True) cudas = get_attribute_values(api_url, project, package, "MPCDF:cuda_modules", with_project=True) + pythons = get_attribute_values(api_url, project, package, "MPCDF:python_modules", with_project=True) def enable(name): node = ElementTree.Element("enable") @@ -169,6 +170,9 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False): for mpi in mpis: if valid_mpi(compiler, mpi): enable(cuda + "_" + mpi + "_" + compiler) + if flag == "python": + for python in pythons: + enable(python) if len(build.getchildren()) > 0: build.getchildren()[-1].tail = "\n " @@ -188,6 +192,7 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p compilers = list(get_attribute_values(api_url, project, None, "MPCDF:compiler_modules")) mpis = list(get_attribute_values(api_url, project, None, "MPCDF:mpi_modules")) cudas = list(get_attribute_values(api_url, project, None, "MPCDF:cuda_modules")) + pythons = list(get_attribute_values(api_url, project, None, "MPCDF:python_modules")) if distribution is None: # Get existing value from project meta @@ -231,10 +236,12 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p is_mpi = kwargs.pop("mpi", False) is_cuda = kwargs.pop("cuda", False) is_cuda_mpi = kwargs.pop("cuda_mpi", False) + is_python = kwargs.pop("python", False) have_compiler = is_compiler or is_mpi or is_cuda or is_cuda_mpi have_mpi = is_mpi or is_cuda_mpi have_cuda = is_cuda or is_cuda_mpi + have_python = is_python if kwargs: raise Exception("Invalid argument") @@ -267,10 +274,12 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p prjconf.append("%is_mpi_repository {0}".format(1 if is_mpi else 0)) prjconf.append("%is_cuda_repository {0}".format(1 if is_cuda else 0)) prjconf.append("%is_cuda_mpi_repository {0}".format(1 if is_cuda_mpi else 0)) + prjconf.append("%is_python_repository {0}".format(1 if is_python else 0)) prjconf.append("%have_mpcdf_compiler {0}".format(1 if have_compiler else 0)) prjconf.append("%have_mpcdf_mpi {0}".format(1 if have_mpi else 0)) prjconf.append("%have_mpcdf_cuda {0}".format(1 if have_cuda else 0)) + prjconf.append("%have_mpcdf_python {0}".format(1 if have_python else 0)) prjconf.append(":Macros") prjconf.append("%endif") @@ -296,6 +305,9 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p (project, mpi + "_" + compiler), cuda_mpi=True) + for python in pythons: + repo(python, (project, "System"), python=True) + # Remove build configuration build = root.find("./build") if build is None: diff --git a/mpcdf_enable_repositories.py b/mpcdf_enable_repositories.py index 239b28d..0f47f4e 100644 --- a/mpcdf_enable_repositories.py +++ b/mpcdf_enable_repositories.py @@ -18,9 +18,11 @@ import osc.cmdln help="Restrict the set of MPI implementations to use") @osc.cmdln.option('--cuda-modules', nargs=1, help="Restrict the set of CUDA implementations to use") +@osc.cmdln.option('--python-modules', nargs=1, + help="Restrict the set of Python implementations to use") @osc.cmdln.option('--set', nargs=1, metavar="FLAGS", help="Modify the set of enabled repositories, without this the current setup is displayed. " - "FLAGS is a comma-separated list of a subset of 'system', 'compilers', 'mpi', 'cuda_mpi'") + "FLAGS is a comma-separated list of a subset of 'system', 'compilers', 'mpi', 'cuda_mpi', 'python'") @osc.cmdln.alias("mpcdf_enable_repos") def do_mpcdf_enable_repositories(self, subcmd, opts, *args): """${cmd_name}: Select all appropriate repositories for an MPCDF package @@ -78,11 +80,12 @@ def do_mpcdf_enable_repositories(self, subcmd, opts, *args): set_or_remove(opts.mpi_modules, "MPCDF:mpi_modules") set_or_remove(opts.cuda_modules, "MPCDF:cuda_modules") + set_or_remove(opts.python_modules, "MPCDF:python_modules") set_or_remove(opts.compiler_modules, "MPCDF:compiler_modules") if opts.recreate or opts.set: mpcdf_common.mpcdf_enable_repositories(api_url, project, package, verbose=True) - elif (opts.compiler_modules or opts.mpi_modules or opts.cuda_modules): + elif (opts.compiler_modules or opts.mpi_modules or opts.cuda_modules or opts.python_modules): print("ERROR: Invalid arguments, try --help") else: try: @@ -102,3 +105,4 @@ def do_mpcdf_enable_repositories(self, subcmd, opts, *args): print_attr("- Subset of compiler modules set to:", "MPCDF:compiler_modules") print_attr("- Subset of MPI modules set to:", "MPCDF:mpi_modules") print_attr("- Subset of CUDA modules set to:", "MPCDF:cuda_modules") + print_attr("- Subset of Python modules set to:", "MPCDF:python_modules") diff --git a/mpcdf_info.py b/mpcdf_info.py index f945212..12a68f3 100644 --- a/mpcdf_info.py +++ b/mpcdf_info.py @@ -45,6 +45,7 @@ def do_mpcdf_info(self, subcmd, opts, *args): print_attribute("Compilers", "MPCDF:compiler_modules") print_attribute("MPI libraries", "MPCDF:mpi_modules") print_attribute("CUDA versions", "MPCDF:cuda_modules") + print_attribute("Python versions", "MPCDF:python_modules") unmanaged = [] @@ -73,7 +74,8 @@ def do_mpcdf_info(self, subcmd, opts, *args): print(" " + pkg_name_fmt.format(package), ", ".join(enabled_repos), subset("compiler subset", "MPCDF:compiler_modules") + subset("MPI subset", "MPCDF:mpi_modules") + - subset("CUDA subet", "MPCDF:cuda_modules")) + subset("CUDA subset", "MPCDF:cuda_modules") + + subset("Python subset", "MPCDF:python_modules")) print() if unmanaged: diff --git a/mpcdf_setup_repositories.py b/mpcdf_setup_repositories.py index b9725e7..d6f1e9c 100644 --- a/mpcdf_setup_repositories.py +++ b/mpcdf_setup_repositories.py @@ -20,8 +20,9 @@ import osc.cmdln def do_mpcdf_setup_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 + Given a list of compilers, MPI libraries, and possibly CUDA and python + versions from the project attributes, this command creates repositories for + all the resulting combinations Usage: osc ${cmd_name} [PROJECT] diff --git a/mpcdf_sync_projects.py b/mpcdf_sync_projects.py index 6d36b62..bb00bcf 100644 --- a/mpcdf_sync_projects.py +++ b/mpcdf_sync_projects.py @@ -42,7 +42,7 @@ def do_mpcdf_sync_projects(self, subcmd, opts, *args): from_packages = [package] to_packages = osc.core.meta_get_packagelist(api_url, to_project) - project_attributes = ["MPCDF:compiler_modules", "MPCDF:cuda_modules", "MPCDF:mpi_modules"] + project_attributes = ["MPCDF:compiler_modules", "MPCDF:cuda_modules", "MPCDF:mpi_modules", "MPCDF:python_modules"] package_attributes = ["MPCDF:enable_repositories"] + project_attributes for attribute in project_attributes: -- GitLab