Skip to content

Commit 54bc2fd

Browse files
committed
Checkpoint.
1 parent c97eb33 commit 54bc2fd

11 files changed

+528
-34
lines changed

AppService.spec

+2
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,6 @@ module AppService
8080

8181
funcdef enumerate_tasks(int offset, int count)
8282
returns (list<Task>);
83+
84+
funcdef kill_task(task_id id) returns (int killed);
8385
};

lib/Bio/KBase/AppService/AppServiceImpl.pm

+92
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ sub new
276276
$self->{awe_mongo_user} = $cfg->setting("awe-mongo-user");
277277
$self->{awe_mongo_pass} = $cfg->setting("awe-mongo-pass");
278278
$self->{awe_clientgroup} = $cfg->setting("awe-clientgroup") || "";
279+
$self->{awe_admin_token_file} = $cfg->setting("awe-admin-token-file") || "";
279280

280281
$self->{task_status_dir} = $cfg->setting("task-status-dir");
281282
$self->{service_url} = $cfg->setting("service-url");
@@ -1080,6 +1081,97 @@ sub enumerate_tasks
10801081

10811082

10821083

1084+
=head2 kill_task
1085+
1086+
$killed = $obj->kill_task($id)
1087+
1088+
=over 4
1089+
1090+
=item Parameter and return types
1091+
1092+
=begin html
1093+
1094+
<pre>
1095+
$id is a task_id
1096+
$killed is an int
1097+
task_id is a string
1098+
1099+
</pre>
1100+
1101+
=end html
1102+
1103+
=begin text
1104+
1105+
$id is a task_id
1106+
$killed is an int
1107+
task_id is a string
1108+
1109+
1110+
=end text
1111+
1112+
1113+
1114+
=item Description
1115+
1116+
1117+
1118+
=back
1119+
1120+
=cut
1121+
1122+
sub kill_task
1123+
{
1124+
my $self = shift;
1125+
my($id) = @_;
1126+
1127+
my @_bad_arguments;
1128+
(!ref($id)) or push(@_bad_arguments, "Invalid type for argument \"id\" (value was \"$id\")");
1129+
if (@_bad_arguments) {
1130+
my $msg = "Invalid arguments passed to kill_task:\n" . join("", map { "\t$_\n" } @_bad_arguments);
1131+
Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg,
1132+
method_name => 'kill_task');
1133+
}
1134+
1135+
my $ctx = $Bio::KBase::AppService::Service::CallContext;
1136+
my($killed);
1137+
#BEGIN kill_task
1138+
1139+
#
1140+
# Given the task ID, invoke AWE to nuke it.
1141+
#
1142+
# This requires an AWE administrative account.
1143+
#
1144+
my $token = read_file($self->{awe_admin_token_file}, err_mode => 'quiet');
1145+
if (!$token)
1146+
{
1147+
die "Cannot read AWE administrative token\n";
1148+
}
1149+
1150+
GAH. Can one delete one's own job in awe?
1151+
#
1152+
# This is an AWE instance with the user's access. We use this to
1153+
# lookup the job and verify ownership (with limited privileges).
1154+
#
1155+
my $user_awe = Bio::KBase::AppService::Awe->new($self->{awe_server}, $ctx->token);
1156+
#
1157+
# This is an AWE instance with administrative access used to
1158+
#
1159+
my $admin_awe = Bio::KBase::AppService::Awe->new($self->{awe_server}, $token);
1160+
1161+
#END kill_task
1162+
my @_bad_returns;
1163+
(!ref($killed)) or push(@_bad_returns, "Invalid type for return variable \"killed\" (value was \"$killed\")");
1164+
if (@_bad_returns) {
1165+
my $msg = "Invalid returns passed to kill_task:\n" . join("", map { "\t$_\n" } @_bad_returns);
1166+
Bio::KBase::Exceptions::ArgumentValidationError->throw(error => $msg,
1167+
method_name => 'kill_task');
1168+
}
1169+
return($killed);
1170+
}
1171+
1172+
1173+
1174+
10831175
=head2 version
10841176
10851177
$return = $obj->version()

lib/Bio/KBase/AppService/BinningReport.pm

+3-5
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,12 @@ sub write_report
7272
# Scan the bins to find the reference genome.
7373
#
7474
my($bin) = grep { $_->{name} eq $gpkg->{genome_name} } @$bins;
75+
$gpkg->{reference_genomes} = [];
7576
if ($bin)
7677
{
77-
$gpkg->{reference_genome} = $bin->{refGenomes}->[0];
78-
}
79-
if ($gpkg->{reference_genome})
80-
{
81-
$gpkg->{reference_url} = "$url_base/" . uri_escape($gpkg->{reference_genome});
78+
push(@{$gpkg->{reference_genomes}}, @{$bin->{refGenomes}});
8279
}
80+
$gpkg->{reference_urls} = [ map { { reference_genome => $_, reference_url => "$url_base/" . uri_escape($_) } } @{$gpkg->{reference_genomes}} ];
8381
}
8482

8583
#

lib/Bio/KBase/AppService/BinningReport.tt

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ The following roles in the bins have been flagged as potentially problematic.
9898
<td><a target="_blank" href="[% g.genome_url %]">[% g.genome_id %]</a></td>
9999
<td>[% g.genome_name %]</td>
100100
<td>
101-
[% IF g.reference_genome -%]
102-
<a target="_blank" href="[% g.reference_url %]">[% g.reference_genome %]</a>
101+
[% FOR rg IN g.reference_genomes %]
102+
<a target="_blank" href="[% rg.reference_url %]">[% rg.reference_genome %]</a>
103103
[% END -%]
104104
</td>
105105
<td>[% g.scikit_coarse %]</td>

lib/javascript/AppService/Client.js

+10
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ function AppService(url, auth, auth_cb) {
9393
deprecationWarning();
9494
return json_call_ajax("AppService.enumerate_tasks", [offset, count], 1, _callback, _error_callback);
9595
};
96+
97+
this.kill_task = function (id, _callback, _errorCallback) {
98+
return json_call_ajax("AppService.kill_task",
99+
[id], 1, _callback, _errorCallback);
100+
};
101+
102+
this.kill_task_async = function (id, _callback, _error_callback) {
103+
deprecationWarning();
104+
return json_call_ajax("AppService.kill_task", [id], 1, _callback, _error_callback);
105+
};
96106

97107

98108
/*

scripts/appserv-debug-task.pl

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323
# TODO get this from configs
2424
#
25-
my $awe_server = "http://redwood.mcs.anl.gov:7080";
25+
my $awe_server = "http://walnut.mcs.anl.gov:7080";
2626
my $awe_root = "/disks/awe";
2727
my $awe_logs = "$awe_root/logs";
2828

scripts/gather-stats.pl

+38-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212

1313
my $impl = Bio::KBase::AppService::AppServiceImpl->new();
1414

15-
my $mongo = MongoDB::MongoClient->new(host => $impl->{awe_mongo_host}, port => $impl->{awe_mongo_port});
15+
print STDERR "Connect to $impl->{awe_mongo_host} $impl->{awe_mongo_port}\n";
16+
my $mongo = MongoDB::MongoClient->new(host => $impl->{awe_mongo_host},
17+
port => $impl->{awe_mongo_port},
18+
db_name => $impl->{awe_mongo_db},
19+
(defined($impl->{awe_mongo_user}) ? (username => $impl->{awe_mongo_user}) : ()),
20+
(defined($impl->{awe_mongo_pass}) ? (password => $impl->{awe_mongo_pass}) : ()),
21+
);
1622
my $db = $mongo->get_database($impl->{awe_mongo_db});
1723
my $col = $db->get_collection("Jobs");
1824

@@ -27,18 +33,19 @@
2733
'fangfang@patricbrc.org' ,
2834
'PATRIC@patricbrc.org',
2935
'rastuser25@patricbrc.org',
30-
# 'KPNs_4_Houston@patricbrc.org',
3136
);
3237
my %staff_users = map { $_ => 1 } @staff_users;
33-
34-
38+
39+
my %collab_users = map { $_ => 1 } qw(KPNs_4_Houston@patricbrc.org
40+
Salmonella_FDA@patricbrc.org
41+
);
3542

3643
my @q = (state => 'completed');
3744
#@q = ();
3845

3946
#my $begin = DateTime->new(year => 2015, month => 10, day => 1)->set_time_zone( 'America/Chicago' );
40-
my $end = DateTime->new(year => 2017, month => 5, day => 1)->set_time_zone( 'America/Chicago' );
41-
my $begin = DateTime->new(year => 2013, month => 10, day => 1)->set_time_zone( 'America/Chicago' );
47+
my $end = DateTime->new(year => 2017, month => 11, day => 1)->set_time_zone( 'America/Chicago' );
48+
my $begin = DateTime->new(year => 2013, month => 1, day => 1)->set_time_zone( 'America/Chicago' );
4249
my @end;
4350
@end = ('$lt' => $end );
4451

@@ -51,6 +58,7 @@
5158
my %total_by_app;
5259
my %user;
5360
my %allusers;
61+
my %user_app;
5462
while (my $job = $jobs->next)
5563
{
5664
my $id = $job->{id};
@@ -67,10 +75,12 @@
6775
$elap /= 60;
6876

6977
next if $staff_users{$user};
78+
$colkey .= "-collab" if $collab_users{$user};
7079

7180
$allusers{$user}++;
7281
# print STDERR join("\t", $id, $start, $finish, $elap, $app), "\n";
7382

83+
$user_app{$user}->{$app}++;
7484
$user{$colkey}++;
7585

7686
# my $dkey = sprintf("%d-%02d", $submit->week_year, $submit->week_number);
@@ -82,10 +92,25 @@
8292

8393
$total_by_app{$app}++;
8494
}
85-
95+
#for my $user (sort { $allusers{$b} cmp $allusers{$a} } keys (%allusers))
96+
if (0)
97+
{
98+
for my $user (sort { $user_app{$b}->{GenomeAnnotation} <=> $user_app{$a}->{GenomeAnnotation} } keys (%allusers))
99+
{
100+
# print join("\t", $user, $allusers{$user}), "\n";
101+
print join("\t", $user, $user_app{$user}->{GenomeAnnotation}), "\n" if $user_app{$user}->{GenomeAnnotation};
102+
next;
103+
my $alist = $user_app{$user};
104+
for my $app (sort { $alist->{$b} <=> $alist->{$a} } keys %$alist)
105+
{
106+
print join("\t", $user, $app, $alist->{$app}), "\n";
107+
}
108+
}
109+
}
110+
#exit;
86111
#die Dumper(\%allusers);
87112

88-
my @applist = qw(GenomeAssembly GenomeAnnotation GenomeAnnotationGenbank GenomeComparison RunProbModelSEEDJob ModelReconstruction GapfillModel RNASeq DifferentialExpression Variation);
113+
my @applist = qw(GenomeAssembly GenomeAnnotation GenomeAnnotationGenbank GenomeComparison RunProbModelSEEDJob ModelReconstruction GapfillModel RNASeq DifferentialExpression Variation TnSeq PhylogeneticTree);
89114
for my $app (@applist)
90115
{
91116
print "$app\t$total_by_app{$app}\n";
@@ -96,7 +121,11 @@
96121

97122
my @users = sort { $a cmp $b } keys %user;
98123

99-
my @users = qw(GenomeAssembly GenomeAnnotationGenbank GenomeAnnotation GenomeComparison ModelReconstruction GapfillModel RNASeq DifferentialExpression RunProbModelSEEDJob Variation);
124+
my %apps_for_collab = (GenomeAnnotation => 1, GenomeAssembly => 1);
125+
126+
my @users1 = qw(GenomeAssembly GenomeAnnotationGenbank GenomeAnnotation GenomeComparison ModelReconstruction GapfillModel RNASeq DifferentialExpression RunProbModelSEEDJob Variation TnSeq PhylogeneticTree);
127+
128+
my @users = map { $_, ($apps_for_collab{$_} ? "$_-collab" : ()) } @users1;
100129

101130
print join("\t", "Week", "Date", @users), "\n";
102131

scripts/inspect-PhylogeneticTree.pl

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
#
3+
# Inspect input to PhylogeneticTree and emit analysis for choosing
4+
# a client group.
5+
#
6+
7+
use strict;
8+
9+

0 commit comments

Comments
 (0)