Skip to content

Commit 50f8a1b

Browse files
authored
Merge pull request #123 from olsonanl/master
Rollup of mods for binning
2 parents 3d9de92 + 16244d3 commit 50f8a1b

15 files changed

+696
-364
lines changed

AppService.spec

+8
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module AppService
3131

3232
typedef structure {
3333
task_id id;
34+
task_id parent_id;
3435
app_id app;
3536
workspace_id workspace;
3637
task_parameters parameters;
@@ -66,6 +67,13 @@ module AppService
6667
funcdef start_app(app_id, task_parameters params, workspace_id workspace)
6768
returns (Task task);
6869

70+
typedef structure {
71+
task_id parent_id;
72+
workspace_id workspace;
73+
} StartParams;
74+
funcdef start_app2(app_id, task_parameters params, StartParams start_params)
75+
returns (Task task);
76+
6977
funcdef query_tasks(list<task_id> task_ids)
7078
returns (mapping<task_id, Task task> tasks);
7179

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ DATA_API_URL = https://p3.theseed.org/services/data_api
2929
GITHUB_ISSUE_REPO_OWNER = olsonanl
3030
GITHUB_ISSUE_REPO_NAME = app_service
3131

32-
SEEDTK = /disks/patric-common/seedtk
32+
SEEDTK = /disks/patric-common/seedtk-2018-0820
3333

3434
REFERENCE_DATA_DIR = /tmp
3535

app_specs/MetagenomeBinning.json

+16
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@
7272
"desc":"Name of genome group into whcih the generated genome ids will be placed. ",
7373
"type":"string"
7474
},
75+
{
76+
"id": "skip_indexing",
77+
"required": 0,
78+
"default": false,
79+
"label": "Don't index bins",
80+
"desc": "If set, don't index the generated bins solr. They will not be available for analysis through the PATRIC site.",
81+
"type": "bool"
82+
},
83+
{
84+
"id": "recipe",
85+
"label": "Annotation recipe",
86+
"required": 0,
87+
"default": null,
88+
"desc": "Specifies a non-default annotation recipe for annotation of bins",
89+
"type": "string"
90+
},
7591
{
7692
"id":"output_path",
7793
"label":"Output Folder",

lib/Bio/KBase/AppService/AppServiceImpl.pm

+147-90
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ sub _awe_to_task
207207

208208
my $task = {
209209
id => $id,
210+
parent_id => $u->{parent_task},
210211
app => $u->{app_id},
211212
workspace => $u->{workspace},
212213
parameters => decode_json($u->{parameters}),
@@ -368,7 +369,7 @@ sub service_status
368369
my($return);
369370
#BEGIN service_status
370371

371-
my($stat, $txt) = $self->{util}->service_status();
372+
my($stat, $txt) = $self->{util}->service_status($ctx);
372373
$return = [$stat, $txt];
373374

374375
#END service_status
@@ -494,6 +495,7 @@ task_parameters is a reference to a hash where the key is a string and the value
494495
workspace_id is a string
495496
Task is a reference to a hash where the following keys are defined:
496497
id has a value which is a task_id
498+
parent_id has a value which is a task_id
497499
app has a value which is an app_id
498500
workspace has a value which is a workspace_id
499501
parameters has a value which is a task_parameters
@@ -523,6 +525,7 @@ task_parameters is a reference to a hash where the key is a string and the value
523525
workspace_id is a string
524526
Task is a reference to a hash where the following keys are defined:
525527
id has a value which is a task_id
528+
parent_id has a value which is a task_id
526529
app has a value which is an app_id
527530
workspace has a value which is a workspace_id
528531
parameters has a value which is a task_parameters
@@ -568,111 +571,127 @@ sub start_app
568571
my($task);
569572
#BEGIN start_app
570573

571-
if (!$self->{util}->submissions_enabled($app_id))
572-
{
573-
die "App service submissions are disabled\n";
574+
$task = $self->{util}->start_app($ctx, $app_id, $params, { workspace => $workspace });
575+
#END start_app
576+
my @_bad_returns;
577+
(ref($task) eq 'HASH') or push(@_bad_returns, "Invalid type for return variable \"task\" (value was \"$task\")");
578+
if (@_bad_returns) {
579+
my $msg = "Invalid returns passed to start_app:\n" . join("", map { "\t$_\n" } @_bad_returns);
580+
die $msg;
574581
}
582+
return($task);
583+
}
575584

576-
my $json = JSON::XS->new->ascii->pretty(1);
577585

578-
#
579-
# Create a new workflow for this task.
580-
#
581586

582-
my $app = $self->{util}->find_app($app_id);
583587

584-
if (!$app)
585-
{
586-
die "Could not find app for id $app_id\n";
587-
}
588+
=head2 start_app2
588589
589-
my $awe = Bio::KBase::AppService::Awe->new($self->{awe_server}, $ctx->token);
590+
$task = $obj->start_app2($app_id, $params, $start_params)
590591
591-
my $param_str = $json->encode($params);
592+
=over 4
592593
593-
#
594-
# Create an identifier we can use to match the Shock nodes we create for this
595-
# job with the job itself.
596-
#
594+
=item Parameter and return types
597595
598-
my $gen = Data::UUID->new;
599-
my $task_file_uuid = $gen->create();
600-
my $task_file_id = lc($gen->to_string($task_file_uuid));
596+
=begin html
601597
602-
my $userattr = {
603-
app_id => $app_id,
604-
parameters => $param_str,
605-
workspace => $workspace,
606-
task_file_id => $task_file_id,
607-
};
598+
<pre>
599+
$app_id is an app_id
600+
$params is a task_parameters
601+
$start_params is a StartParams
602+
$task is a Task
603+
app_id is a string
604+
task_parameters is a reference to a hash where the key is a string and the value is a string
605+
StartParams is a reference to a hash where the following keys are defined:
606+
parent_id has a value which is a task_id
607+
workspace has a value which is a workspace_id
608+
task_id is a string
609+
workspace_id is a string
610+
Task is a reference to a hash where the following keys are defined:
611+
id has a value which is a task_id
612+
parent_id has a value which is a task_id
613+
app has a value which is an app_id
614+
workspace has a value which is a workspace_id
615+
parameters has a value which is a task_parameters
616+
user_id has a value which is a string
617+
status has a value which is a task_status
618+
awe_status has a value which is a task_status
619+
submit_time has a value which is a string
620+
start_time has a value which is a string
621+
completed_time has a value which is a string
622+
stdout_shock_node has a value which is a string
623+
stderr_shock_node has a value which is a string
624+
task_status is a string
608625
609-
my $clientgroup = $self->{awe_clientgroup};
626+
</pre>
610627
611-
if ($app_id eq 'MetagenomeBinning' && $params->{contigs})
612-
{
613-
# Hack to send contigs-only jobs to a different clientgroup
614-
$clientgroup .= "-fast";
615-
print STDERR "Redirecting job to fast queue\n" . Dumper($params);
616-
}
617-
if ($params->{_clientgroup})
618-
{
619-
$clientgroup = $params->{_clientgroup};
628+
=end html
629+
630+
=begin text
631+
632+
$app_id is an app_id
633+
$params is a task_parameters
634+
$start_params is a StartParams
635+
$task is a Task
636+
app_id is a string
637+
task_parameters is a reference to a hash where the key is a string and the value is a string
638+
StartParams is a reference to a hash where the following keys are defined:
639+
parent_id has a value which is a task_id
640+
workspace has a value which is a workspace_id
641+
task_id is a string
642+
workspace_id is a string
643+
Task is a reference to a hash where the following keys are defined:
644+
id has a value which is a task_id
645+
parent_id has a value which is a task_id
646+
app has a value which is an app_id
647+
workspace has a value which is a workspace_id
648+
parameters has a value which is a task_parameters
649+
user_id has a value which is a string
650+
status has a value which is a task_status
651+
awe_status has a value which is a task_status
652+
submit_time has a value which is a string
653+
start_time has a value which is a string
654+
completed_time has a value which is a string
655+
stdout_shock_node has a value which is a string
656+
stderr_shock_node has a value which is a string
657+
task_status is a string
658+
659+
660+
=end text
661+
662+
663+
664+
=item Description
665+
666+
667+
668+
=back
669+
670+
=cut
671+
672+
sub start_app2
673+
{
674+
my $self = shift;
675+
my($app_id, $params, $start_params) = @_;
676+
677+
my @_bad_arguments;
678+
(!ref($app_id)) or push(@_bad_arguments, "Invalid type for argument \"app_id\" (value was \"$app_id\")");
679+
(ref($params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument \"params\" (value was \"$params\")");
680+
(ref($start_params) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument \"start_params\" (value was \"$start_params\")");
681+
if (@_bad_arguments) {
682+
my $msg = "Invalid arguments passed to start_app2:\n" . join("", map { "\t$_\n" } @_bad_arguments);
683+
die $msg;
620684
}
621-
622-
my $job = $awe->create_job_description(pipeline => 'AppService',
623-
name => $app_id,
624-
project => 'AppService',
625-
user => $ctx->user_id,
626-
clientgroups => $clientgroup,
627-
userattr => $userattr,
628-
priority => 2,
629-
);
630-
631-
my $shock = Bio::KBase::AppService::Shock->new($self->{shock_server}, $ctx->token);
632-
$shock->tag_nodes(task_file_id => $task_file_id,
633-
app_id => $app_id);
634-
my $params_node_id = $shock->put_file_data($param_str, "params");
635-
636-
my $app_node_id = $shock->put_file_data($json->encode($app), "app");
637-
638-
my $app_file = $awe->create_job_file("app", $shock->server, $app_node_id);
639-
my $params_file = $awe->create_job_file("params", $shock->server, $params_node_id);
640-
641-
# my $stdout_file = $awe->create_job_file("stdout.txt", $shock->server);
642-
# my $stderr_file = $awe->create_job_file("stderr.txt", $shock->server);
643-
644-
my $awe_stdout_file = $awe->create_job_file("awe_stdout.txt", $shock->server);
645-
my $awe_stderr_file = $awe->create_job_file("awe_stderr.txt", $shock->server);
646-
647-
my $appserv_info_url = "$self->{service_url}/task_info";
648-
649-
my $task_userattr = {};
650-
my $task_id = $job->add_task($app->{script},
651-
$app->{script},
652-
join(" ",
653-
$appserv_info_url,
654-
$app_file->in_name, $params_file->in_name,
655-
# $stdout_file->name, $stderr_file->name,
656-
),
657-
[],
658-
[$app_file, $params_file],
659-
[$awe_stdout_file, $awe_stderr_file],
660-
# [$stdout_file, $stderr_file, $awe_stdout_file, $awe_stderr_file],
661-
undef,
662-
undef,
663-
$task_userattr,
664-
);
665-
666-
# print STDERR Dumper($job);
667-
668-
my $task_id = $awe->submit($job);
669-
670-
$task = $self->_lookup_task($awe, $task_id);
671-
#END start_app
685+
686+
my $ctx = $Bio::KBase::AppService::Service::CallContext;
687+
my($task);
688+
#BEGIN start_app2
689+
$task = $self->{util}->start_app($ctx, $app_id, $params, $start_params);
690+
#END start_app2
672691
my @_bad_returns;
673692
(ref($task) eq 'HASH') or push(@_bad_returns, "Invalid type for return variable \"task\" (value was \"$task\")");
674693
if (@_bad_returns) {
675-
my $msg = "Invalid returns passed to start_app:\n" . join("", map { "\t$_\n" } @_bad_returns);
694+
my $msg = "Invalid returns passed to start_app2:\n" . join("", map { "\t$_\n" } @_bad_returns);
676695
die $msg;
677696
}
678697
return($task);
@@ -697,6 +716,7 @@ $tasks is a reference to a hash where the key is a task_id and the value is a Ta
697716
task_id is a string
698717
Task is a reference to a hash where the following keys are defined:
699718
id has a value which is a task_id
719+
parent_id has a value which is a task_id
700720
app has a value which is an app_id
701721
workspace has a value which is a workspace_id
702722
parameters has a value which is a task_parameters
@@ -724,6 +744,7 @@ $tasks is a reference to a hash where the key is a task_id and the value is a Ta
724744
task_id is a string
725745
Task is a reference to a hash where the following keys are defined:
726746
id has a value which is a task_id
747+
parent_id has a value which is a task_id
727748
app has a value which is an app_id
728749
workspace has a value which is a workspace_id
729750
parameters has a value which is a task_parameters
@@ -1001,6 +1022,7 @@ $count is an int
10011022
$return is a reference to a list where each element is a Task
10021023
Task is a reference to a hash where the following keys are defined:
10031024
id has a value which is a task_id
1025+
parent_id has a value which is a task_id
10041026
app has a value which is an app_id
10051027
workspace has a value which is a workspace_id
10061028
parameters has a value which is a task_parameters
@@ -1029,6 +1051,7 @@ $count is an int
10291051
$return is a reference to a list where each element is a Task
10301052
Task is a reference to a hash where the following keys are defined:
10311053
id has a value which is a task_id
1054+
parent_id has a value which is a task_id
10321055
app has a value which is an app_id
10331056
workspace has a value which is a workspace_id
10341057
parameters has a value which is a task_parameters
@@ -1561,6 +1584,7 @@ a string
15611584
<pre>
15621585
a reference to a hash where the following keys are defined:
15631586
id has a value which is a task_id
1587+
parent_id has a value which is a task_id
15641588
app has a value which is an app_id
15651589
workspace has a value which is a workspace_id
15661590
parameters has a value which is a task_parameters
@@ -1581,6 +1605,7 @@ stderr_shock_node has a value which is a string
15811605
15821606
a reference to a hash where the following keys are defined:
15831607
id has a value which is a task_id
1608+
parent_id has a value which is a task_id
15841609
app has a value which is an app_id
15851610
workspace has a value which is a workspace_id
15861611
parameters has a value which is a task_parameters
@@ -1650,6 +1675,38 @@ output_files has a value which is a reference to a list where each element is a
16501675
16511676
16521677
1678+
=head2 StartParams
1679+
1680+
=over 4
1681+
1682+
1683+
1684+
=item Definition
1685+
1686+
=begin html
1687+
1688+
<pre>
1689+
a reference to a hash where the following keys are defined:
1690+
parent_id has a value which is a task_id
1691+
workspace has a value which is a workspace_id
1692+
1693+
</pre>
1694+
1695+
=end html
1696+
1697+
=begin text
1698+
1699+
a reference to a hash where the following keys are defined:
1700+
parent_id has a value which is a task_id
1701+
workspace has a value which is a workspace_id
1702+
1703+
1704+
=end text
1705+
1706+
=back
1707+
1708+
1709+
16531710
=head2 TaskDetails
16541711
16551712
=over 4

0 commit comments

Comments
 (0)