Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mkexp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esmenv
mkexp
Commits
e3004481
Commit
e3004481
authored
6 years ago
by
Karl-Hermann Wieners
Browse files
Options
Downloads
Patches
Plain Diff
mkexp: added creation of config dump to mkexp, add multi-group identifiers as comment
parent
b4cd2c23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGES.txt
+6
-0
6 additions, 0 deletions
CHANGES.txt
mkexp
+14
-2
14 additions, 2 deletions
mkexp
test.py
+41
-3
41 additions, 3 deletions
test.py
with
61 additions
and
5 deletions
CHANGES.txt
+
6
−
0
View file @
e3004481
...
...
@@ -9,6 +9,12 @@ Release Changes
Release 1.0.1
=============
Global
------
* Added creation of config dump to mkexp (including backup)
* Changed mkexp namelist formatting to add multi-group identifiers as comment
Release 1.0.0
=============
...
...
This diff is collapsed.
Click to expand it.
mkexp
+
14
−
2
View file @
e3004481
...
...
@@ -164,8 +164,11 @@ def format_namelist(section):
if
not
any
(
map
(
lambda
x
:
re
.
match
(
x
,
group_id
),
black_list
)):
# Create list of removed keys
remove_keys
=
cut_remove_list
(
contents
,
'
.remove
'
)
group_name
=
re
.
sub
(
r
'
.*$
'
,
''
,
group_id
)
lines
.
write
(
'
&
'
+
group_name
+
'
\n
'
)
group_names
=
group_id
.
split
(
'
'
,
1
)
if
len
(
group_names
)
==
1
:
lines
.
write
(
'
&
'
+
group_names
[
0
]
+
'
\n
'
)
else
:
lines
.
write
(
'
&
'
+
group_names
[
0
]
+
"
!
'"
+
group_names
[
1
]
+
"'
\n
"
)
for
key
,
value
in
contents
.
iteritems
():
if
key
not
in
remove_keys
:
key
=
key
.
lower
()
...
...
@@ -534,3 +537,12 @@ update_file.write('exec ' + ' '.join(map(quote, sys.argv)) + ' "$@"\n')
update_file
.
close
()
chmod_plus_x
(
os
.
path
.
join
(
script_dir
,
'
update
'
))
# Create config dump for reference
dump_name
=
config
.
experiment_id
+
'
.dump
'
move_file_to_backup
(
os
.
path
.
join
(
script_dir
,
dump_name
),
os
.
path
.
join
(
backup_dir
,
dump_name
))
dump_file
=
open
(
os
.
path
.
join
(
script_dir
,
dump_name
),
'
w
'
)
config
.
indent_type
=
'
'
config
.
write
(
dump_file
)
dump_file
.
close
()
This diff is collapsed.
Click to expand it.
test.py
+
41
−
3
View file @
e3004481
...
...
@@ -50,11 +50,11 @@ class MkexpTestCase(unittest.TestCase):
"""
)
def
setUp
(
self
):
os
.
system
(
self
.
script_clean
)
pass
#
os.system(self.script_clean)
@classmethod
def
tearDownClass
(
cls
):
os
.
system
(
cls
.
script_clean
)
pass
#
os.system(cls.script_clean)
class
MkexpSimpleTestCase
(
MkexpTestCase
):
...
...
@@ -156,7 +156,7 @@ class CommandLineTestCase(MkexpTestCase):
result
=
readfile
(
'
test/experiments/test0001/test0001.run
'
)
self
.
assertMultiLineEqual
(
expected
,
result
)
class
ContentTestCase
(
MkexpTestCase
):
class
ContentTestCase
(
Mkexp
Simple
TestCase
):
def
test_job_override
(
self
):
exp_id
=
"
test_job_override
"
...
...
@@ -407,6 +407,44 @@ class ContentTestCase(MkexpTestCase):
result
=
align
(
result
)
self
.
assertMultiLineEqual
(
expected
,
result
)
def
test_namelist_multi_groups
(
self
):
self
.
run_test
(
"""
%{NAMELIST}
"""
,
"""
&group !
'
1
'
/
&group !
'
1
'
/
&group !
'
2
'
/
&group !
'
i i i
'
/
"""
,
"""
[namelists]
[[namelist]]
[[[group 1]]]
[[[group 1]]]
[[[group 2]]]
[[[group i i i]]]
"""
)
def
test_namelist_case_twist
(
self
):
self
.
run_test
(
"""
%{NAMELIST}
"""
,
"""
&group
value = 41
value = 42
/
"""
,
"""
[namelists]
[[namelist]]
[[[group]]]
value = 41
VALUE = 42
"""
)
class
JinjaTemplateTestCase
(
MkexpSimpleTestCase
):
def
test_ignore_blocks
(
self
):
...
...
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