Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ess-python-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
ESS Beam Physics
ess-python-tools
Commits
661bac65
Commit
661bac65
authored
5 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
fix script to make sure always getting output files back from error study
replaced several string.format with f-strings
parent
5a95f611
No related branches found
No related tags found
No related merge requests found
Pipeline
#31651
passed with warnings
5 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/tracewin_errorstudy
+40
-16
40 additions, 16 deletions
scripts/tracewin_errorstudy
with
40 additions
and
16 deletions
scripts/tracewin_errorstudy
+
40
−
16
View file @
661bac65
...
@@ -96,16 +96,10 @@ def create_extra_folder(calc_dir, f0, f1):
...
@@ -96,16 +96,10 @@ def create_extra_folder(calc_dir, f0, f1):
if
not
os
.
path
.
exists
(
p1
):
if
not
os
.
path
.
exists
(
p1
):
# hard link
# hard link
os
.
link
(
p0
,
p1
)
os
.
link
(
p0
,
p1
)
delete_output_files
(
calc_dir
,
f1
)
def
delete_output_files
(
args
,
folder
):
def
get_output_files_list
():
"""
Remove all output files in a folder
(clean it for a re-run)
"""
import
os
output_files
=
[
output_files
=
[
"
ENV_diag1.dat
"
,
"
ENV_diag1.dat
"
,
"
part_dtl1.dst
"
,
"
part_dtl1.dst
"
,
...
@@ -116,9 +110,23 @@ def delete_output_files(args, folder):
...
@@ -116,9 +110,23 @@ def delete_output_files(args, folder):
"
PAR_diag1.dat
"
,
"
PAR_diag1.dat
"
,
"
Density_PAR.dat_9
"
,
"
Density_PAR.dat_9
"
,
"
lattice.par
"
,
"
lattice.par
"
,
"
tracelx64
"
,
"
tracemac64
"
,
]
]
return
output_files
def
delete_output_files
(
calc_dir
,
folder
):
"""
Remove all output files in a folder
(clean it for a re-run)
full_path
=
os
.
path
.
join
(
args
.
calc_dir
,
folder
)
"""
import
os
output_files
=
get_output_files_list
()
full_path
=
os
.
path
.
join
(
calc_dir
,
folder
)
for
f
in
os
.
listdir
(
full_path
):
for
f
in
os
.
listdir
(
full_path
):
for
of
in
output_files
:
for
of
in
output_files
:
if
of
in
f
:
if
of
in
f
:
...
@@ -137,16 +145,15 @@ def setup_multi(args):
...
@@ -137,16 +145,15 @@ def setup_multi(args):
num_jobs
=
0
num_jobs
=
0
new_folders
=
[]
new_folders
=
[]
for
njob
in
range
(
args
.
num_jobs
):
for
njob
in
range
(
args
.
num_jobs
):
folder
=
"
Local_TraceWin_{
}
"
.
format
(
njob
)
folder
=
f
"
Local_TraceWin_
{
njob
}
"
if
os
.
path
.
isfile
(
os
.
path
.
join
(
args
.
calc_dir
,
folder
,
"
Error_Datas.txt
"
)):
if
os
.
path
.
isfile
(
os
.
path
.
join
(
args
.
calc_dir
,
folder
,
"
Error_Datas.txt
"
)):
for
mjob
in
range
(
args
.
multi
):
for
mjob
in
range
(
args
.
multi
):
num_jobs
+=
1
num_jobs
+=
1
if
mjob
==
int
(
folder
.
split
(
"
_
"
)[
-
1
]):
if
mjob
==
int
(
folder
.
split
(
"
_
"
)[
-
1
]):
continue
continue
newfolder
=
"
{
}_{}
"
.
format
(
folder
,
mjob
)
newfolder
=
f
"
{
folder
}
_
{
mjob
}
"
new_folders
.
append
(
newfolder
)
new_folders
.
append
(
newfolder
)
create_extra_folder
(
args
.
calc_dir
,
folder
,
newfolder
)
create_extra_folder
(
args
.
calc_dir
,
folder
,
newfolder
)
delete_output_files
(
args
,
newfolder
)
create_and_copy_lattice
(
create_and_copy_lattice
(
args
,
args
,
os
.
path
.
join
(
args
.
calc_dir
,
newfolder
),
os
.
path
.
join
(
args
.
calc_dir
,
newfolder
),
...
@@ -173,7 +180,7 @@ def setup_multi(args):
...
@@ -173,7 +180,7 @@ def setup_multi(args):
j
=
int
(
job_folder
.
split
(
"
_
"
)[
-
1
])
j
=
int
(
job_folder
.
split
(
"
_
"
)[
-
1
])
# Get file list:
# Get file list:
input_files
=
os
.
listdir
(
os
.
path
.
join
(
args
.
calc_dir
,
job_folder
))
input_files
=
listdir
(
os
.
path
.
join
(
args
.
calc_dir
,
job_folder
))
input_files
=
"
,
"
.
join
(
input_files
)
input_files
=
"
,
"
.
join
(
input_files
)
q_priority
=
args
.
priority
q_priority
=
args
.
priority
...
@@ -187,6 +194,21 @@ def setup_multi(args):
...
@@ -187,6 +194,21 @@ def setup_multi(args):
args
.
num_jobs
=
num_jobs
args
.
num_jobs
=
num_jobs
def
listdir
(
path
):
"""
List all input files in path
(ie all files not defined as output files or executables)
"""
import
os
input_files
=
[]
output_files
=
get_output_files_list
()
for
f
in
os
.
listdir
(
path
):
if
f
not
in
output_files
:
input_files
.
append
(
f
)
return
input_files
def
setup
(
args
):
def
setup
(
args
):
import
os
import
os
import
random
import
random
...
@@ -206,7 +228,7 @@ def setup(args):
...
@@ -206,7 +228,7 @@ def setup(args):
# Create extra folders if needed..
# Create extra folders if needed..
if
args
.
num_jobs
>
num_jobs
:
if
args
.
num_jobs
>
num_jobs
:
for
n
in
range
(
num_jobs
,
args
.
num_jobs
):
for
n
in
range
(
num_jobs
,
args
.
num_jobs
):
folder_name
=
"
Local_TraceWin_{n}
"
.
format
(
**
locals
())
folder_name
=
f
"
Local_TraceWin_
{
n
}
"
create_extra_folder
(
args
.
calc_dir
,
"
Local_TraceWin_0
"
,
folder_name
)
create_extra_folder
(
args
.
calc_dir
,
"
Local_TraceWin_0
"
,
folder_name
)
num_jobs
=
args
.
num_jobs
num_jobs
=
args
.
num_jobs
...
@@ -224,7 +246,7 @@ def setup(args):
...
@@ -224,7 +246,7 @@ def setup(args):
# rand_lst=file('rand.dat','r').read().split()
# rand_lst=file('rand.dat','r').read().split()
# Get file list:
# Get file list:
input_files
=
os
.
listdir
(
os
.
path
.
join
(
args
.
calc_dir
,
"
Local_TraceWin_0
"
))
input_files
=
listdir
(
os
.
path
.
join
(
args
.
calc_dir
,
"
Local_TraceWin_0
"
))
for
i
in
range
(
len
(
input_files
)):
for
i
in
range
(
len
(
input_files
)):
if
input_files
[
i
][
-
2
:]
==
"
_0
"
:
if
input_files
[
i
][
-
2
:]
==
"
_0
"
:
input_files
[
i
]
=
input_files
[
i
][:
-
2
]
+
"
_$(Process)
"
input_files
[
i
]
=
input_files
[
i
][:
-
2
]
+
"
_$(Process)
"
...
@@ -242,12 +264,14 @@ def setup(args):
...
@@ -242,12 +264,14 @@ def setup(args):
def
ask
(
args
):
def
ask
(
args
):
print
(
"
You have now set up an error study running {} jobs in folder {
}
"
.
format
(
args
.
num_jobs
,
args
.
calc_dir
)
)
print
(
f
"
You have now set up an error study running
{
args
.
num_jobs
}
jobs in folder
{
args
.
calc_dir
}
"
)
if
args
.
multi
>
1
:
if
args
.
multi
>
1
:
print
(
"
This is a multi-error study
"
)
print
(
"
This is a multi-error study
"
)
answer
=
input
(
"
Do you want to submit the jobs immediately? (yes/no)
"
)
answer
=
input
(
"
Do you want to submit the jobs immediately? (yes/no)
"
)
if
answer
==
"
yes
"
:
if
answer
==
"
yes
"
:
return
0
return
0
else
:
print
(
f
"
To run, execute command
'
condor_submit
{
args
.
calc_dir
}
/submit.job
'"
)
import
sys
import
sys
...
...
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