Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osc-plugins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpcdf
obs
osc-plugins
Commits
78c6dbd5
Commit
78c6dbd5
authored
7 years ago
by
Lorenz Huedepohl
Browse files
Options
Downloads
Patches
Plain Diff
Subcommand to setup repo combinations
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mpcdf-repositories.py
+138
-0
138 additions, 0 deletions
mpcdf-repositories.py
with
138 additions
and
0 deletions
mpcdf-repositories.py
0 → 100755
+
138
−
0
View file @
78c6dbd5
#!/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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment