Skip to content

Commit 0a9f223

Browse files
committed
Add support for setting per-task user_metadata
1 parent 2795442 commit 0a9f223

File tree

9 files changed

+44
-5
lines changed

9 files changed

+44
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.pm.bak-201*
33
*.py.bak-201*
44
lib/Bio/KBase/AppService/AppConfig.pm
5+
lib/javascript/AppService/Client.js

AppService.spec

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ module AppService
7373
workspace_id workspace;
7474
string base_url;
7575
string container_id;
76+
string user_metaata;
7677
} StartParams;
7778
funcdef start_app2(app_id, task_parameters params, StartParams start_params)
7879
returns (Task task);

lib/Bio/KBase/AppService/SchedulerDB.pm

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ sub create_task
183183
req_runtime => $preflight->{runtime},
184184
req_policy_data => $self->json->encode($preflight->{policy_data} // {}),
185185
req_is_control_task => ($preflight->{is_control_task} ? 1 : 0),
186+
user_metadata => $start_parameters->{user_metadata},
186187
(defined($container_id) ? (container_id => $container_id) : ()),
187188
};
188189

lib/Bio/KBase/AppService/Schema.sql

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ CREATE TABLE Task
134134
hidden BOOLEAN default FALSE,
135135
container_id VARCHAR(255),
136136
base_url VARCHAR(255),
137+
user_metadata TEXT,
137138
FOREIGN KEY (owner) REFERENCES ServiceUser(id),
138139
FOREIGN KEY (state_code) REFERENCES TaskState(code),
139140
FOREIGN KEY (application_id) REFERENCES Application(id),

lib/Bio/KBase/AppService/Schema/Result/SiteDefaultContainer.pm

+16-2
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,27 @@ __PACKAGE__->table("SiteDefaultContainer");
4848
is_nullable: 1
4949
size: 255
5050
51+
=head2 last_modified
52+
53+
data_type: 'timestamp'
54+
datetime_undef_if_invalid: 1
55+
default_value: current_timestamp
56+
is_nullable: 0
57+
5158
=cut
5259

5360
__PACKAGE__->add_columns(
5461
"base_url",
5562
{ data_type => "varchar", is_nullable => 0, size => 255 },
5663
"default_container_id",
5764
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 255 },
65+
"last_modified",
66+
{
67+
data_type => "timestamp",
68+
datetime_undef_if_invalid => 1,
69+
default_value => \"current_timestamp",
70+
is_nullable => 0,
71+
},
5872
);
5973

6074
=head1 PRIMARY KEY
@@ -92,8 +106,8 @@ __PACKAGE__->belongs_to(
92106
);
93107

94108

95-
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-03-10 14:48:58
96-
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:V6EqtIbT76SwZFjX+kEb4A
109+
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-03-25 13:44:04
110+
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QMwEFGWcM+UY+LiYNXFGmw
97111

98112

99113
# You can replace this text with custom code or comments, and it will be preserved on regeneration

lib/Bio/KBase/AppService/Schema/Result/Task.pm

+9-2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ __PACKAGE__->table("Task");
165165
is_nullable: 1
166166
size: 255
167167
168+
=head2 user_metadata
169+
170+
data_type: 'text'
171+
is_nullable: 1
172+
168173
=cut
169174

170175
__PACKAGE__->add_columns(
@@ -227,6 +232,8 @@ __PACKAGE__->add_columns(
227232
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 255 },
228233
"base_url",
229234
{ data_type => "varchar", is_nullable => 1, size => 255 },
235+
"user_metadata",
236+
{ data_type => "text", is_nullable => 1 },
230237
);
231238

232239
=head1 PRIMARY KEY
@@ -389,8 +396,8 @@ __PACKAGE__->has_many(
389396
);
390397

391398

392-
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-03-10 14:48:59
393-
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IF9bnr/uurQeFeJEocy84g
399+
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-03-25 13:44:04
400+
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3855e9g3LybZorgM6ul/nA
394401

395402
__PACKAGE__->many_to_many(cluster_jobs => 'task_executions', 'cluster_job');
396403

lib/javascript/AppService/Client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function AppService(url, auth, auth_cb) {
1818
}
1919

2020
if (typeof(_url) != "string" || _url.length == 0) {
21-
_url = "https://p3.theseed.org/services/app_service";
21+
_url = "https://p3.theseed.org/services_test/app_service_test";
2222
}
2323
var _auth = auth ? auth : { 'token' : '', 'user_id' : ''};
2424
var _auth_cb = auth_cb;

scripts/appserv-start-app.pl

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
["output-file|f=s", "Change the output file"],
1111
["container-id|c=s", "Use the specified container"],
1212
["base-url|b=s", "Submit with the chosen base URL"],
13+
["user-metadata=s", "Tag the job with the given metadata"],
14+
["user-metadata-file=s", "Tag the job with the given metadata from this file"],
1315
["verbose|v", "Show verbose output"],
1416
["url|u=s", "Service URL"],
1517
["help|h", "Show this help message"]);
@@ -25,10 +27,18 @@
2527

2628
my $params = decode_json(scalar read_file($params_data));
2729

30+
my $user_metadata = $opt->user_metadata;
31+
if ($opt->user_metadata_file)
32+
{
33+
$user_metadata = read_file($opt->user_metadata);
34+
}
35+
36+
2837
my $start_params = {
2938
defined($workspace) ? (workspace => $workspace) : (),
3039
$opt->container_id ? (container_id => $opt->container_id) : (),
3140
$opt->base_url ? (base_url => $opt->base_url) : (),
41+
defined($user_metadata) ? (user_metadata => $user_metadata) : (),
3242
};
3343

3444
if ($params->{output_path} && $opt->output_path)

service-scripts/p3x-run-qa.pl

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
["submit|s" => "Submit the job to the scheduler"],
2222
["base|b=s" => "Use this directory as the deployment base for the run (not for use with --submit)"],
2323
["app|a=s" => "Application name"],
24+
["user-metadata=s" => "User metadata for this run"],
2425
['override=s@' => "Override other parameter settings in app parameter file", { default => [] }],
2526
["out|o=s" => "Use this workspace path as the output base",
2627
{ default => '/olson@patricbrc.org/PATRIC-QA/applications' }],
@@ -189,6 +190,7 @@ sub run_in_container
189190
my $exitcode = $?;
190191
write_file("$out_dir/exitcode", "$exitcode\n");
191192
write_file("$out_dir/hostname", "$hostname\n");
193+
write_file("$out_dir/user_metadata", $opt->user_metadata) if $opt->user_metadata;
192194
$ok or die "Error running @cmd\n";
193195

194196
}
@@ -212,6 +214,7 @@ sub run_locally
212214
my $exitcode = $?;
213215
write_file("$out_dir/exitcode", "$exitcode\n");
214216
write_file("$out_dir/hostname", "$hostname\n");
217+
write_file("$out_dir/user_metadata", $opt->user_metadata) if $opt->user_metadata;
215218
$ok or die "Error running @cmd\n";
216219

217220
}
@@ -221,6 +224,7 @@ sub submit_job
221224
my($app, $params, $out_dir, $container) = @_;
222225
my @cmd = ('appserv-start-app');
223226
push(@cmd, '-c', $container) if $container;
227+
push(@cmd, "--user-metadata", $opt->user_metadata) if $opt->user_metadata;
224228
push(@cmd, $app, $params);
225229

226230
my $out;

0 commit comments

Comments
 (0)