-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreateTest.php
360 lines (296 loc) · 18.7 KB
/
createTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<?php
require __DIR__."/../../config/bootstrap.php";
redirectToolDevOutside();
if(!isset($_REQUEST['id'])) {
$_SESSION['errorData']['Error'][] = "Please provide a tool id.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
$toolDevJSON = $GLOBALS['toolsDevMetaCol']->findOne(array('_id' => $_REQUEST['id']));
//vaR_dump($toolDevJSON); die();
if(!isset($toolDevJSON)) {
$_SESSION['errorData']['Error'][] = "The tool id <strong>".$_REQUEST['toolid']."</strong> doesn't exist in our database.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
if($_SESSION['User']['Type'] != 0)
$toolDevMetaJSON = $GLOBALS['toolsDevMetaCol']->findOne(array('_id' => $_REQUEST['id'], 'user_id' => $_SESSION['User']['id']));
else
$toolDevMetaJSON = $GLOBALS['toolsDevMetaCol']->findOne(array('_id' => $_REQUEST['id']));
if(!isset($toolDevMetaJSON) && ($_SESSION['User']['Type'] != 0)) {
$_SESSION['errorData']['Error'][] = "The tool id <strong>".$_REQUEST['toolid']."</strong> you are trying to edit doesn't belong to you.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
if(!$toolDevMetaJSON["step1"]["tool_io_validated"]) {
$_SESSION['errorData']['Error'][] = "Please first insert a valid JSON.";
redirect($GLOBALS['BASEURL'].'admin/myNewTools.php');
}
?>
<?php require "../htmlib/header.inc.php"; ?>
<body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white page-container-bg-solid page-sidebar-fixed">
<div class="page-wrapper">
<?php require "../htmlib/top.inc.php"; ?>
<?php require "../htmlib/menu.inc.php"; ?>
<!-- BEGIN CONTENT -->
<div class="page-content-wrapper">
<!-- BEGIN CONTENT BODY -->
<div class="page-content">
<!-- BEGIN PAGE HEADER-->
<!-- BEGIN PAGE BAR -->
<div class="page-bar">
<ul class="page-breadcrumb">
<li>
<span>Admin</span>
<i class="fa fa-circle"></i>
</li>
<li>
<a href="admin/myNewTools.php">My new tools</a>
<i class="fa fa-circle"></i>
</li>
<li>
<span>Generate test files</span>
</li>
</ul>
</div>
<!-- END PAGE BAR -->
<!-- BEGIN PAGE TITLE-->
<h1 class="page-title"> Generate Test Files
</h1>
<!-- END PAGE TITLE-->
<!-- END PAGE HEADER-->
<div class="row">
<div class="col-md-12">
<?php
$error_data = false;
if ($_SESSION['errorData']){
$error_data = true;
?>
<?php if ($_SESSION['errorData']['Info']) { ?>
<div class="alert alert-info">
<?php } else { ?>
<div class="alert alert-danger">
<?php } ?>
<?php
foreach($_SESSION['errorData'] as $subTitle=>$txts){
print "<strong>$subTitle</strong><br/>";
foreach($txts as $txt){
print "<div>$txt</div>";
}
}
unset($_SESSION['errorData']);
?>
</div>
<?php } ?>
</div>
</div>
<form name="create-test" id="create-test" action="applib/updateToolDevTest.php" method="post" >
<div class="portlet box blue-oleo">
<div class="portlet-title">
<div class="caption">
<div style="float:left;margin-right:20px;"> Test Files Configuration</div>
</div>
</div>
<div class="portlet-body form">
<div class="form-body">
<p>You are to develop your tool code offline, in a local environmet (i.e VM). And to best way to check that your tool is going to be properly called by VRE server when integrated into the cloud, is precisely emulating a VRE execution to you tool code. Fill in this form with the test input files that you have in your development environent, and use the resulting JSON files to create your test script</p>
<!--------------- SETTING LOCAL DIRECTORIES -->
<h4 class="form-section">Local test environment</h4>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Test working directory <i class="icon-question popovers" data-container="body" data-content="Correspond to the local working directory of your tool. In there is where output files and logs are expected." data-html="true" data-original-title="Foo execution folder" data-trigger="hover"></i>
</label>
<?php
$val = $toolDevMetaJSON["step1"]["form_data"]["execution"];
if(!isset($val)) $val = "/test/execution/directory";
?>
<input type="text" name="execution" placeholder="/local/development/env/path/tests/run000" class="form-control input-file-path " value="<?php echo $val; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Tool wrapper <i class="icon-question popovers" data-container="body" data-content="TODO" data-html="true" data-original-title="Foo execution folder" data-trigger="hover"></i>
</label>
<?php
$val = $toolDevMetaJSON["step1"]["form_data"]["tool_executable"];
if(!isset($val)) $val = "/main/mg-tool/executable.py";
?>
<input type="text" name="tool_executable" placeholder="/local/development/env/path/tests/run000" class="form-control" value="<?php echo $val; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label">Workflow type <i class="icon-question popovers" data-container="body" data-content="What is it?." data-html="true" data-original-title="Foo project Id" data-trigger="hover"></i>
</label>
<?php $val = $toolDevMetaJSON["step1"]["form_data"]["workflowtype"]; ?>
<select name="workflowtype" id="workflowtype" class="form-control" >
<option value="single" <?php echo ($val == "single" ? 'selected' : '') ?>>Single</option>
<option value="compss" <?php echo ($val == "compss" ? 'selected' : '') ?>>COMPSs</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group <?php echo ($val != "compss" ? 'display-hide' : '') ?> " id="tool_lib_block">
<label class="control-label">Tool python libraries <i class="icon-question popovers" data-container="body" data-content="TODO" data-html="true" data-original-title="Foo execution folder" data-trigger="hover"></i>
</label>
<?php
$vte = $toolDevMetaJSON["step1"]["form_data"]["tool_lib"];
if(!isset($vte) || $vte === 0) $vte = "/packages/to/add/into/pythonpath";
?>
<input type="text" name="tool_lib" id="tool_lib" placeholder="/local/development/env/path/tests/run000" class="form-control input-file-path " <?php echo ($val != "compss" ? 'disabled' : '') ?> value="<?php echo $vte; ?>">
</div>
</div>
</div>
<!--------------- SETTING INPUT FILES -->
<h4 class="form-section">Local data test</h4>
<?php foreach($toolDevJSON["step1"]["tool_io"]["input_files"] as $inputf) { ?>
<div class="row margin-top-20">
<div class="col-md-12">
<div class="form-group">
<label class="control-label">
<?php echo $inputf["description"] ?>
<i class="icon-question popovers" data-container="body" data-content="<?php echo getInputMetadata($inputf); ?>" data-html="true" data-original-title="Metadata for <?php echo $inputf["description"] ?>" data-trigger="hover"></i>
</label>
<?php $val = $toolDevMetaJSON["step1"]["form_data"]["input_files"]; ?>
<input type="text" name="input_files[<?php echo $inputf["name"] ?>]" value="<?php echo $val[$inputf["name"]]; ?>" class="form-control input-file-path input-files" placeholder="">
</div>
</div>
<?php
if ($inputf['data_type']){
$features =getFeaturesFromDataType($inputf['data_type'][0],$inputf['file_type'][0]);
$c = 0;
foreach ($features as $feature => $required){
if ($required === FALSE) {continue;}
if ($feature === "_id") {continue;}
if($c%2 == 0) $ml = 15;
else $ml = -30;
?>
<div class="col-md-6" style="background:#e9e9e9;margin-left:<?php echo $ml; ?>px;margin-top: -15px;padding-top: 15px;">
<div class="form-group">
<label class="control-label">
<?php echo $feature; ?>
<a href="http://www.multiscalegenomics.eu/MuGVRE/integration-of-tools/test-job-configuration-files/" target="_blank"><i class="icon-question tooltips" data-container="body" data-html="true" data-original-title="Click here to open the Input metadata file help section" data-trigger="hover" data-placement="right"></i></a>
</label>
<?php $val = $toolDevMetaJSON["step1"]["form_data"]["metadata"][$inputf["name"]]; ?>
<input type="text" name="metadata[<?php echo $inputf["name"]; ?>][<?php echo $feature; ?>]" value="<?php echo $val[$feature]; ?>" class="form-control input-files" style="width:95%;">
</div>
</div>
<?php
$c ++;
}
if($c%2 != 0) {
echo '<div class="col-md-6" style="background:#e9e9e9;margin-left:-30px;margin-top: -15px;padding-top: 15px;">
<div class="form-group">
<label class="control-label"> </label>
<input type="text" class="form-control" style="width:95%;opacity:0" disabled>
</div>
</div>';
}
}
echo "</div>";
} ?>
<!--------------- SETTING INPUT FILES FROM PUBLIC DIR -->
<?php if (count($toolDevJSON["step1"]["tool_io"]["input_files_public_dir"])){ ?>
<h4 class="form-section">Local data test - <span style="font-size:14px">hidden input files</span></h4>
<?php foreach($toolDevJSON["step1"]["tool_io"]["input_files_public_dir"] as $inputf) { ?>
<div class="row margin-top-20">
<div class="col-md-12">
<div class="form-group">
<label class="control-label">
<?php echo $inputf["description"] ?>
<i class="icon-question popovers" data-container="body" data-content="<?php echo getInputMetadata($inputf); ?>" data-html="true" data-original-title="Metadata for <?php echo $inputf["description"] ?>" data-trigger="hover"></i>
</label>
<?php $val = $toolDevMetaJSON["step1"]["form_data"]["input_files_public_dir"]; ?>
<!--<input type="text" name="input_files_public_dir[<?php echo $inputf["name"] ?>]" value="<?php echo $val[$inputf["name"]]; ?>" class="form-control input-file-path input-files" placeholder="">-->
<?php echo getArgument($inputf, null, "", "input_files_public_dir"); ?>
</div>
</div>
<?php
if ($inputf['data_type']){
$features =getFeaturesFromDataType($inputf['data_type'][0],$inputf['file_type'][0]);
$c = 0;
foreach ($features as $feature => $required){
if ($required === FALSE) {continue;}
if ($feature === "_id") {continue;}
if($c%2 == 0) $ml = 15;
else $ml = -30;
?>
<div class="col-md-6" style="background:#e9e9e9;margin-left:<?php echo $ml; ?>px;margin-top: -15px;padding-top: 15px;">
<div class="form-group">
<label class="control-label">
<?php echo $feature; ?>
<a href="http://www.multiscalegenomics.eu/MuGVRE/integration-of-tools/test-job-configuration-files/" target="_blank"><i class="icon-question tooltips" data-container="body" data-html="true" data-original-title="Click here to open the Input metadata file help section" data-trigger="hover" data-placement="right"></i></a>
</label>
<?php $val = $toolDevMetaJSON["step1"]["form_data"]["metadata"][$inputf["name"]]; ?>
<input type="text" name="metadata[<?php echo $inputf["name"]; ?>][<?php echo $feature; ?>]" value="<?php echo $val[$feature]; ?>" class="form-control input-files" style="width:95%;">
</div>
</div>
<?php
$c ++;
}
if($c%2 != 0) {
echo '<div class="col-md-6" style="background:#e9e9e9;margin-left:-30px;margin-top: -15px;padding-top: 15px;">
<div class="form-group">
<label class="control-label"> </label>
<input type="text" class="form-control" style="width:95%;opacity:0" disabled>
</div>
</div>';
}
}
echo "</div>";
} } ?>
<!--------------- SETTING ARGUMENTS -->
<h4 class="form-section">Test arguments</h4>
<?php
$c = 0;
foreach($toolDevJSON["step1"]["tool_io"]["arguments"] as $arg) { ?>
<?php if($c%2 == 0) { ?><div class="row"><?php } ?>
<div class="col-md-6">
<div class="form-group">
<label class="control-label">
<?php echo $arg["description"] ?>
<i class="icon-question popovers" data-container="body" data-content="<?php echo getInputMetadata($arg); ?>" data-html="true" data-original-title="Metadata for <?php echo $arg["description"] ?>" data-trigger="hover"></i>
</label>
<?php echo getArgument($arg, null, $toolDevMetaJSON["step1"]["form_data"]["arguments"][$arg["name"]]); ?>
</div>
</div>
<?php if($c%2 != 0) { ?></div><?php } ?>
<?php
$c ++;
}
if($c%2 != 0) echo '</div>';
?>
<!-- foreach d'arguments i input_files amb (?) mostrant les metadades de cadascun amb un popover.
Separar en dos blocs diferenciats. Als arguments, si hi ha default el poso, sinó placeholder.
Als input_files per ara posar strings (mirar si regex path?) -->
</div>
<div class="form-actions">
<input type="hidden" id="base-url" value="<?php echo $GLOBALS['BASEURL']; ?>" />
<input type="hidden" name="toolid" value="<?php echo $_REQUEST['id']; ?>" />
<button type="submit" class="btn blue"><i class="fa fa-check"></i> Submit</button>
<button type="reset" class="btn default">Reset</button>
</div>
</div>
</div>
</form>
<!-- END CONTENT BODY -->
</div>
<!-- END CONTENT -->
<!--<div class="modal fade bs-modal" id="modalJSONSchema" tabindex="-1" role="basic" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">JSON Schema Validation</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn dark btn-outline" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>-->
<?php
require "../htmlib/footer.inc.php";
require "../htmlib/js.inc.php";
?>