package HPC::Runner::Command::Logger::JSON;
use MooseX::App::Role;
use MooseX::Types::Path::Tiny qw/File Path Paths AbsPath AbsFile/;
use File::Spec;
use Data::UUID;
use DateTime;
use File::Path qw(m
ake_path remove_tree);
use HPC::Runner::Command::Logger::JSON::Archive;
with 'BioSAILs::Utils::Files::CacheDir';
option 'data_dir' => (
is => 'rw',
isa => AbsPath,
l
PC::Runner::Command::execute_job::Logger::JSON;
use Moose::Role;
use namespace::autoclean;
with 'HPC::Runner::Command::execute_job::Logger::Lock';
use JSON;
use File::Spec;
use DateTime;
use Try::T
;
use File::Path qw(make_path remove_tree);
use File::Slurp;
use Cwd;
use Time::HiRes;
has 'task_json' => (
is => 'rw',
isa => 'Str',
default => '',
required => 0,
);
has
my $self = shift;
my $job_meta = {};
if ( $self->metastr ) {
$job_meta = decode_json( $self->metastr );
}
if ( !$job_meta || !exists $job_meta->{jobname} ) {
##TO ac
:Runner::Command::stats::Logger::JSON::Summary::JSONOutput;
use Moose::Role;
use namespace::autoclean;
use JSON;
with 'HPC::Runner::Command::stats::Logger::JSON::JSONOutput';
sub iter_jobs_summary
n_id}->{jobs}->{$jobname} = $summary;
$self->task_data( {} );
}
push( @{ $self->json_data }, $submission_obj );
}
sub gen_job_tasks_summary {
my $self = shift;
my $jobnam
package HPC::Runner::Command::stats::Logger::JSON::TableOutput;
use Moose::Role;
use namespace::autoclean;
use Text::ASCIITable;
## TODO This one is mostly the same
sub build_table {
my $self =
ge HPC::Runner::Command::stats::Logger::JSON::Summary::TableOutput;
use Moose::Role;
use namespace::autoclean;
with 'HPC::Runner::Command::stats::Logger::JSON::TableOutput';
sub iter_jobs_summary {
package HPC::Runner::Command::stats::Logger::JSON::JSONOutput;
use Moose::Role;
use namespace::autoclean;
use JSON;
has 'json_data' => (
is => 'rw',
isa => 'ArrayRef',
default =
> sub { return [] }
);
after 'iter_submissions' => sub {
my $self = shift;
my $json = encode_json( $self->json_data );
print $json;
print "\n";
};
1;
ckage HPC::Runner::Command::stats::Logger::JSON::Utils;
use Moose::Role;
use namespace::autoclean;
use JSON;
use Try::Tiny;
use File::Slurp;
sub read_json_files {
my $self = shift;
shift;
my @json_files =
glob( File::Spec->catdir( $self->data_dir, $jobname, '*json' ) );
my $running = {};
foreach my $file (@json_files) {
my $running_json = read_file($f
ile);
my $trun = decode_json($running_json);
foreach my $key ( keys %{$trun} ) {
$running->{$key} = $trun->{$key};
}
}
return $running;
}
1;
e HPC::Runner::Command::stats::Logger::JSON::Long;
use Moose::Role;
use namespace::autoclean;
with 'HPC::Runner::Command::stats::Logger::JSON::Utils';
use JSON;
use File::Glob;
use File::Slurp;
su
ift;
my $submission_id = shift;
my $jobname = shift;
my $running = $self->read_json_files($submission_id, $jobname);
my $total_tasks = [];
foreach ( sort { $a <=> $b } keys
ner::Command::stats::Logger::JSON::Long::TableOutput;
use Moose::Role;
use namespace::autoclean;
with 'HPC::Runner::Command::stats::Logger::JSON::TableOutput';
use JSON;
use Text::ASCIITable;
sub
PC::Runner::Command::submit_jobs::Logger::JSON;
use Moose::Role;
use namespace::autoclean;
with 'HPC::Runner::Command::execute_job::Logger::Lock';
use JSON;
use File::Spec;
use Data::UUID;
use File
lurp;
use DateTime;
use Capture::Tiny ':all';
=head3 create_json_submission
Create the data for the json submission
=cut
sub create_json_submission {
my $self = shift;
make_path($self->da
_meta;
# my $json_text = encode_json $hpc_meta;
# write_file(File::Spec->catdir($self->data_dir, 'submission.json'), $json_text);
return $hpc_meta;
}
=head3 update_json_submission
Take
package HPC::Runner::Command::Logger::JSON::Archive;
use Moose;
use MooseX::NonMoose;
use File::Spec;
use File::Slurp;
use Try::Tiny;
use Path::Tiny;
use Data::Dumper;
use Capture::Tiny ':all';
use
HPC::Runner::Command::stats::Logger::JSON::Summary;
use Moose::Role;
use namespace::autoclean;
with 'HPC::Runner::Command::stats::Logger::JSON::Utils';
use JSON;
use Try::Tiny;
use File::Slurp;
##
shift;
my $submission_id = shift;
my $jobname = shift;
my $tasks = $self->read_json_files( $submission_id, $jobname );
my $running =
$self->count_running_tasks( $submissio
JSON::Long::JSONOutput;
use Moose::Role;
use namespace::autoclean;
use JSON;
with 'HPC::Runner::Command::stats::Logger::JSON::Summary';
with 'HPC::Runner::Command::stats::Logger::JSON::Summary::JSON
$submission_id, $jobname );
$submission_obj->{$submission_id}->{jobs}->{$jobname}->{tasks_running}
= $running;
push( @{ $self->json_data }, $submission_obj );
}
}
1;
no_log_json' => (
traits => ['Bool'],
is => 'rw',
isa => 'Bool',
default => 0,
documentation => 'Opt out of writing the tar archive of JSON stats.
HPC::Runner::Command::submit_jobs::Utils::Scheduler::JobStats;
#use Moose::Role;
use Moose;
use JSON;
use List::MoreUtils 0.428 qw(firstidx);
=head1 HPC::Runner::Command::submit_jobs::Utils::Schedu
my $json = JSON->new->allow_nonref;
my $json_text = $json->encode($batch);
# $batch->{meta_str} = $json_text;
# delete $batch->{meta_str};
$json_text = "--metastr \'$json_text\
'";
return $json_text;
}
=head3 collect_stats
Collect job stats
=cut
sub collect_stats {
my $self = shift;
my $batch_counter = shift;
my $cmd_counter = shift;
my $cu
$self->log_table( $cmdpid, $exitcode, $format->format_duration($duration) );
$self->update_json_task;
return $exitcode;
}
=head3 name_log
Default is dt, jobname, counter
=cut
#TODO mov
h->autoflush();
# Start Command Log
$self->start_command_log($cmdpid);
$self->create_json_task($cmdpid);
##IF we have an exitcode the job failed with a command not found
return (
st;
}
}
if ( $x >= $max_retries ) {
$self->{$self->logger}->warn('Logger::JSON Error: We exited the lock!');
}
return $ret;
}
sub write_lock {
my $self = shift;
>lock_file->touchpath;
}
catch {
$self->{$self->logger}->warn(
'Logger::JSON Error: We were not able to write '
. $self->lock_file->stringify );
};
}
1;
,
);
=head3 process_table
We also want to write all cmds and exit codes to a table
#TODO add a json format also
=cut
option 'process_table' => (
isa => Path,
is => 'rw',
lazy
b {
my $self = shift;
$self->process_table->touchpath;
},
);
=head3 metastr
JSON string passed from HPC::Runner::App::Scheduler. It describes the total number of jobs, processes,
'HPC::Runner::Command::execute_job::Utils::Log';
with 'HPC::Runner::Command::execute_job::Logger::JSON';
use Sys::Hostname;
use Archive::Tar;
=head2 Command Line Options
=cut
=head2 Internal Attr
nd::Logger::JSON';
with 'HPC::Runner::Command::stats::Logger::JSON::Summary';
with 'HPC::Runner::Command::stats::Logger::JSON::Long';
with 'HPC::Runner::Command::Logger::Loggers';
use JSON;
use File:
cmd_aliases => ['l'],
);
option 'json' => (
is => 'rw',
isa => 'Bool',
default => 0,
documentation => 'Output data in json instead of a table. '
. 'Th
=> 'Str',
default => 'JSON',
documentation => 'hpcrunner.pl stats JSON/Sqlite/Elasticsearch .',
);
sub BUILD {
my $self = shift;
if ( $self->json && $self->summary ) {