Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
254e3bf3
Commit
254e3bf3
authored
Jul 31, 2012
by
Leo Gordon
Browse files
made it possible for a standaloneJob to provide Runnables with a functional worker_temp_directory()
parent
1ef3199a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
23 deletions
+41
-23
modules/Bio/EnsEMBL/Hive/Process.pm
modules/Bio/EnsEMBL/Hive/Process.pm
+27
-3
modules/Bio/EnsEMBL/Hive/Worker.pm
modules/Bio/EnsEMBL/Hive/Worker.pm
+8
-19
scripts/standaloneJob.pl
scripts/standaloneJob.pl
+6
-1
No files found.
modules/Bio/EnsEMBL/Hive/Process.pm
View file @
254e3bf3
...
...
@@ -534,11 +534,35 @@ sub debug {
=cut
sub
worker_temp_directory
{
my
$self
=
shift
;
return
undef
unless
(
$self
->
worker
);
return
$self
->
worker
->
worker_process_temp_directory
;
my
$self
=
shift
@_
;
# TODO: simplify $holding_object=$self when -compile_module_once becomes the only option:
my
$holding_object
=
$self
->
worker
?
$self
->
worker
:
$self
;
unless
(
defined
(
$holding_object
->
{'
_tmp_dir
'})
and
(
-
e
$holding_object
->
{'
_tmp_dir
'}))
{
my
$username
=
$ENV
{'
USER
'};
my
$worker_id
=
$self
->
worker
?
$self
->
worker
->
dbID
:
'
standalone
';
$holding_object
->
{'
_tmp_dir
'}
=
"
/tmp/worker_
${username}
.
${worker_id}
/
";
mkdir
(
$holding_object
->
{'
_tmp_dir
'},
0777
);
throw
("
unable to create a writable directory
"
.
$holding_object
->
{'
_tmp_dir
'})
unless
(
-
w
$holding_object
->
{'
_tmp_dir
'});
}
return
$holding_object
->
{'
_tmp_dir
'};
}
sub
cleanup_worker_temp_directory
{
my
$self
=
shift
@_
;
# TODO: simplify $holding_object=$self when -compile_module_once becomes the only option:
my
$holding_object
=
$self
->
worker
?
$self
->
worker
:
$self
;
if
(
$holding_object
->
{'
_tmp_dir
'})
{
my
$cmd
=
"
rm -r
"
.
$holding_object
->
{'
_tmp_dir
'};
system
(
$cmd
);
}
}
#################################################
#
# methods to make porting from RunnableDB easier
...
...
modules/Bio/EnsEMBL/Hive/Worker.pm
View file @
254e3bf3
...
...
@@ -454,21 +454,6 @@ sub toString {
}
sub
worker_process_temp_directory
{
my
$self
=
shift
;
unless
(
defined
(
$self
->
{'
_tmp_dir
'})
and
(
-
e
$self
->
{'
_tmp_dir
'}))
{
#create temp directory to hold fasta databases
my
$username
=
$ENV
{'
USER
'};
my
$worker_id
=
$self
->
dbID
;
$self
->
{'
_tmp_dir
'}
=
"
/tmp/worker_
${username}
.
${worker_id}
/
";
mkdir
(
$self
->
{'
_tmp_dir
'},
0777
);
throw
("
unable to create a writable directory
"
.
$self
->
{'
_tmp_dir
'})
unless
(
-
w
$self
->
{'
_tmp_dir
'});
}
return
$self
->
{'
_tmp_dir
'};
}
sub
cleanup_worker_process_temp_directory
{
my
$self
=
shift
;
if
(
$self
->
{'
_tmp_dir
'})
{
...
...
@@ -589,10 +574,14 @@ sub run {
}
while
(
!
$self
->
cause_of_death
);
# /Worker's lifespan loop
if
(
$self
->
perform_cleanup
)
{
#have runnable cleanup any global/process files/data it may have created
$self
->
cleanup_worker_process_temp_directory
;
}
# have runnable clean up any global/process files/data it may have created
if
(
$self
->
perform_cleanup
)
{
if
(
my
$runnable_object
=
$self
->
runnable_object
())
{
# if -compile_module_once is 1, keep _tmp_dir in the Process object:
$runnable_object
->
cleanup_worker_temp_directory
();
}
else
{
# otherwise keep _tmp_dir in the Worker object, so it needs its own cleanup method:
$self
->
cleanup_worker_process_temp_directory
();
# TODO: remove this method when -compile_module_once becomes the only option
}
}
$self
->
queen
->
register_worker_death
(
$self
);
...
...
scripts/standaloneJob.pl
View file @
254e3bf3
...
...
@@ -10,7 +10,7 @@ use Bio::EnsEMBL::Hive::Utils ('script_usage', 'load_file_or_module', 'parse_cmd
use
Data::
Dumper
;
my
(
$reg_conf
,
$help
,
$debug
,
$no_write
,
$flow_into
,
$input_id
);
my
(
$reg_conf
,
$help
,
$debug
,
$no_write
,
$no_cleanup
,
$flow_into
,
$input_id
);
my
$module_or_file
=
shift
@ARGV
or
script_usage
();
...
...
@@ -19,6 +19,7 @@ GetOptions(
'
debug=i
'
=>
\
$debug
,
'
reg_conf|regfile=s
'
=>
\
$reg_conf
,
'
no_write|nowrite
'
=>
\
$no_write
,
'
no_cleanup
'
=>
\
$no_cleanup
,
'
flow_into|flow=s
'
=>
\
$flow_into
,
'
input_id=s
'
=>
\
$input_id
,
);
...
...
@@ -64,6 +65,10 @@ $runnable_object->execute_writes( not $no_write );
$runnable_object
->
life_cycle
();
unless
(
$no_cleanup
)
{
$runnable_object
->
cleanup_worker_temp_directory
();
}
__DATA__
=pod
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment