line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HPC::Runner::Command::Logger::JSON; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1542
|
use MooseX::App::Role; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
9
|
|
4
|
1
|
|
|
1
|
|
7868
|
use MooseX::Types::Path::Tiny qw/File Path Paths AbsPath AbsFile/; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
16
|
|
5
|
1
|
|
|
1
|
|
5779
|
use File::Spec; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
37
|
|
6
|
1
|
|
|
1
|
|
468
|
use Data::UUID; |
|
1
|
|
|
|
|
638
|
|
|
1
|
|
|
|
|
77
|
|
7
|
1
|
|
|
1
|
|
9
|
use DateTime; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
8
|
1
|
|
|
1
|
|
8
|
use File::Path qw(make_path remove_tree); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
77
|
|
9
|
1
|
|
|
1
|
|
494
|
use HPC::Runner::Command::Logger::JSON::Archive; |
|
1
|
|
|
|
|
34
|
|
|
1
|
|
|
|
|
656
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'BioSAILs::Utils::Files::CacheDir'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'data_dir' => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
isa => AbsPath, |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
coerce => 1, |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
documentation => q{Data directory for hpcrunner}, |
20
|
|
|
|
|
|
|
predicate => 'has_data_dir', |
21
|
|
|
|
|
|
|
default => sub { |
22
|
|
|
|
|
|
|
my $self = shift; |
23
|
|
|
|
|
|
|
return File::Spec->catdir( $self->cache_dir, '.hpcrunner-data' ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
option 'data_tar' => ( |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
isa => Path, |
30
|
|
|
|
|
|
|
coerce => 1, |
31
|
|
|
|
|
|
|
required => 0, |
32
|
|
|
|
|
|
|
predicate => 'has_data_tar', |
33
|
|
|
|
|
|
|
documentation => 'Location of tar file for hpcrunner logging data.', |
34
|
|
|
|
|
|
|
lazy => 1, |
35
|
|
|
|
|
|
|
trigger => sub { |
36
|
|
|
|
|
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
$self->data_tar->touchpath; |
38
|
|
|
|
|
|
|
my $tar = $self->set_archive; |
39
|
|
|
|
|
|
|
$self->archive($tar); |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
default => sub { |
42
|
|
|
|
|
|
|
my $self = shift; |
43
|
|
|
|
|
|
|
$self->create_data_archive; |
44
|
|
|
|
|
|
|
}, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has 'archive' => ( |
48
|
|
|
|
|
|
|
is => 'rw', |
49
|
|
|
|
|
|
|
required => 0, |
50
|
|
|
|
|
|
|
lazy => 1, |
51
|
|
|
|
|
|
|
predicate => 'has_archive', |
52
|
|
|
|
|
|
|
clearer => 'clear_archive', |
53
|
|
|
|
|
|
|
default => sub { |
54
|
|
|
|
|
|
|
my $self = shift; |
55
|
|
|
|
|
|
|
# return $self->set_archive; |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub set_archive { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my $tar = HPC::Runner::Command::Logger::JSON::Archive->new( dirs => 1 ); |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ( $self->has_data_tar ) { |
64
|
0
|
|
|
|
|
|
$self->data_tar->touchpath; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
|
|
|
|
|
|
#Create a UID and a tar |
68
|
0
|
|
|
|
|
|
my $archive = $self->create_data_archive; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$ENV{HPC_DATA_TAR} = $self->data_tar->stringify; |
72
|
0
|
|
|
|
|
|
return $tar; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub create_data_archive { |
76
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $project = "NULL_PROJECT"; |
79
|
0
|
0
|
|
|
|
|
$project = $self->project if $self->has_project; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
##Create initial document |
82
|
0
|
|
|
|
|
|
my $dt = DateTime->now( time_zone => 'local' ); |
83
|
0
|
|
|
|
|
|
$dt = "$dt"; |
84
|
0
|
|
|
|
|
|
$dt =~ s/:/-/g; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $ug = Data::UUID->new; |
87
|
0
|
|
|
|
|
|
my $uuid = $ug->create(); |
88
|
0
|
|
|
|
|
|
$uuid = $ug->to_string($uuid); |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$self->submission_uuid($uuid); |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $path = File::Spec->catdir( $self->data_dir, $project ); |
93
|
0
|
|
|
|
|
|
make_path($path); |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
if ( $self->has_project ) { |
96
|
0
|
|
|
|
|
|
$path = |
97
|
|
|
|
|
|
|
File::Spec->catdir( $self->data_dir, $project, |
98
|
|
|
|
|
|
|
$dt . '__PR_' . $project . '__UID_' . $uuid ); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
0
|
|
|
|
|
|
$path = |
102
|
|
|
|
|
|
|
File::Spec->catdir( $self->data_dir, $project, |
103
|
|
|
|
|
|
|
$dt . '__UID_' . $uuid ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$self->data_dir($path); |
107
|
0
|
|
|
|
|
|
my $archive = $path . '.tar.gz'; |
108
|
0
|
|
|
|
|
|
$self->data_tar($archive); |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return $archive; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |