Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63094482
mvRuns.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, May 17, 18:05
Size
2 KB
Mime Type
text/x-python
Expires
Sun, May 19, 18:05 (2 d)
Engine
blob
Format
Raw Data
Handle
17731582
Attached To
R3127 blackdynamite
mvRuns.py
View Options
#!/usr/bin/env python
################################################################
from
__future__
import
print_function
################################################################
import
BlackDynamite
as
BD
import
os
import
subprocess
import
socket
################################################################
def
move_run
(
r
,
machine_src
,
machine_dst
,
path_src
,
path_dst
):
if
path_src
==
path_dst
and
machine_dst
==
machine_src
:
return
if
not
os
.
path
.
exists
(
path_dst
):
os
.
makedirs
(
path_dst
)
# print(machine_src, machine_dst)
# print(path_src, path_dst)
url_src
=
machine_src
+
':'
+
path_src
if
url_src
[
-
1
]
==
'/'
:
url_src
=
url_src
[:
-
1
]
print
(
'mv run,job:'
,
r
.
id
,
j
.
id
)
url_dst
=
path_dst
if
machine_src
==
machine_dst
:
url_src
=
path_src
else
:
url_src
=
machine_src
+
':'
+
path_src
if
url_src
[
-
1
]
==
'/'
:
url_src
=
url_src
[:
-
1
]
if
url_dst
[
-
1
]
==
'/'
:
url_dst
=
url_dst
[:
-
1
]
rsync_command
=
'rsync --remove-source-files -auP {0} {1}'
.
format
(
url_src
,
url_dst
)
print
(
rsync_command
)
if
params
[
'truerun'
]
is
True
:
ret
=
subprocess
.
call
(
rsync_command
,
shell
=
True
)
else
:
ret
=
True
if
ret
:
return
r
[
'run_path'
]
=
path_dst
r
[
'machine_name'
]
=
machine_dst
r
.
update
()
if
params
[
'truerun'
]
is
True
:
mybase
.
commit
()
################################################################
parser
=
BD
.
BDParser
()
parser
.
register_params
(
group
=
"mvRuns"
,
params
=
{
"path"
:
str
},
mandatory
=
{
'path'
:
True
},
help
=
{
"path"
:
"Path to the local machine where to store the run outputs"
})
params
=
parser
.
parseBDParameters
()
mybase
=
BD
.
Base
(
**
params
)
runSelector
=
BD
.
RunSelector
(
mybase
)
run_list
=
runSelector
.
selectRuns
(
params
,
params
,
quiet
=
True
)
for
r
,
j
in
run_list
:
machine_dst
=
socket
.
gethostname
()
machine_src
=
r
[
'machine_name'
]
path_src
=
r
[
'run_path'
]
if
path_src
is
None
:
continue
f
,
p
=
os
.
path
.
split
(
path_src
)
while
p
==
''
:
f
,
p
=
os
.
path
.
split
(
f
)
run_subdir
=
p
path_dst
=
os
.
path
.
join
(
params
[
'path'
],
"BD-"
+
params
[
"study"
]
+
"-runs"
,
run_subdir
)
move_run
(
r
,
machine_src
,
machine_dst
,
path_src
,
path_dst
)
Event Timeline
Log In to Comment