Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MPI-BugBench
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
High Performance Computing - Public
MPI-BugBench
Commits
15b41b5f
Commit
15b41b5f
authored
1 year ago
by
Jammer, Tim
Browse files
Options
Downloads
Patches
Plain Diff
added Insert after and before capability in Template Manager
parent
c8fccc8c
No related branches found
No related tags found
2 merge requests
!13
Infrasructure patch 1
,
!12
More improvements to Infrastructure
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/Infrastructure/Template.py
+20
-6
20 additions, 6 deletions
scripts/Infrastructure/Template.py
with
20 additions
and
6 deletions
scripts/Infrastructure/Template.py
+
20
−
6
View file @
15b41b5f
...
@@ -187,20 +187,25 @@ class TemplateManager:
...
@@ -187,20 +187,25 @@ class TemplateManager:
raise
ValueError
(
"
Neither Both block name nor index is given
"
)
raise
ValueError
(
"
Neither Both block name nor index is given
"
)
def
insert_block
(
self
,
new_block
:
InstructionBlock
,
after_block_name
:
str
=
None
,
after_idx
:
int
=
None
):
def
insert_block
(
self
,
new_block
:
InstructionBlock
,
after_block_name
:
str
=
None
,
after_idx
:
int
=
None
,
before_block_name
:
str
=
None
,
before_idx
:
int
=
None
):
"""
"""
inserts the given Instruction Block
AFTER
the one specified Either by name or by index
inserts the given Instruction Block
after/before
the one specified Either by name or by index
Raises IndexError if the specified block is not found
Raises IndexError if the specified block is not found
Raises IndexError if multiple Blocks with the given name are found
Raises IndexError if multiple Blocks with the given name are found
Raises ValueError if Both a block name and index are given (or none is given)
Raises ValueError if Both a block name and index are given (or none is given)
Raises ValueError if Both a before and an after block is given (or none is given)
Args:
Args:
new_block (InstructionBlock): the block to insert
new_block (InstructionBlock): the block to insert
after_block_name (str): The name of the InstructionBlock to receive
after_block_name (str): The name of the InstructionBlock to receive
after_idx (int): index of the InstructionBlock to retrieve
after_idx (int): index of the InstructionBlock to retrieve
"""
"""
# assert only one param is not None
parameters
=
[
after_block_name
,
after_idx
,
before_block_name
,
before_idx
]
if
parameters
.
count
(
None
)
!=
3
:
raise
ValueError
(
"
Only one parameter is allowed to be specified
"
)
if
after_block_name
is
not
None
:
if
after_block_name
is
not
None
:
if
after_idx
is
not
None
:
raise
ValueError
(
"
Both block name and index are given
"
)
to_return
=
[
b
for
b
in
self
.
_blocks
if
b
.
name
==
after_block_name
]
to_return
=
[
b
for
b
in
self
.
_blocks
if
b
.
name
==
after_block_name
]
if
len
(
to_return
)
==
0
:
if
len
(
to_return
)
==
0
:
raise
IndexError
(
"
Block Not Found
"
)
raise
IndexError
(
"
Block Not Found
"
)
...
@@ -208,12 +213,21 @@ class TemplateManager:
...
@@ -208,12 +213,21 @@ class TemplateManager:
raise
IndexError
(
"
Multiple Blocks Found
"
)
raise
IndexError
(
"
Multiple Blocks Found
"
)
self
.
_blocks
.
insert
(
self
.
_blocks
.
index
(
to_return
[
0
])
+
1
,
new_block
)
self
.
_blocks
.
insert
(
self
.
_blocks
.
index
(
to_return
[
0
])
+
1
,
new_block
)
return
return
if
before_block_name
is
not
None
:
to_return
=
[
b
for
b
in
self
.
_blocks
if
b
.
name
==
before_block_name
]
if
len
(
to_return
)
==
0
:
raise
IndexError
(
"
Block Not Found
"
)
if
len
(
to_return
)
>
1
:
raise
IndexError
(
"
Multiple Blocks Found
"
)
self
.
_blocks
.
insert
(
self
.
_blocks
.
index
(
to_return
[
0
]),
new_block
)
return
if
after_idx
is
not
None
:
if
after_idx
is
not
None
:
if
after_block_name
is
not
None
:
raise
ValueError
(
"
Both block name and index are given
"
)
self
.
_blocks
.
insert
(
after_idx
+
1
,
new_block
)
self
.
_blocks
.
insert
(
after_idx
+
1
,
new_block
)
return
return
if
before_idx
is
not
None
:
self
.
_blocks
.
insert
(
before_idx
,
new_block
)
return
raise
ValueError
(
"
Neither Both block name nor index is given
"
)
raise
ValueError
(
"
Neither Both block name nor index is given
"
)
...
...
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