@sasjs/core 6.0.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/mp_assertscope.sas +1 -1
- package/base/mp_init.sas +1 -1
- package/package.json +1 -1
- package/server/ms_runstp.sas +1 -0
- package/xplatform/mx_execute.sas +103 -6
package/base/mp_assertscope.sas
CHANGED
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
%mp_init()
|
|
82
82
|
|
|
83
83
|
%local ds test_result test_comments del add mod ilist;
|
|
84
|
-
%let ilist=%upcase(
|
|
84
|
+
%let ilist=%upcase(_SASJS_FUNCTIONS SYS_PROCHTTP_STATUS_CODE
|
|
85
85
|
SYS_PROCHTTP_STATUS_CODE SYS_PROCHTTP_STATUS_PHRASE &ignorelist);
|
|
86
86
|
|
|
87
87
|
/* get current variables */
|
package/base/mp_init.sas
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
All the system variables this macro creates use the hard-coded `_SASJS_`
|
|
23
23
|
prefix - the same namespace sasjs/server uses in the pre-program it
|
|
24
24
|
generates for each session (`_SASJS_WEBOUT_HEADERS`, `_SASJS_TOKENFILE`,
|
|
25
|
-
`_SASJS_USERNAME` ...).
|
|
25
|
+
`_SASJS_USERNAME` ...).
|
|
26
26
|
|
|
27
27
|
Setting `_SASJS_INIT` before this macro runs skips it, which is how an
|
|
28
28
|
autoexec opts out - a second pass would re-apply the options below.
|
package/package.json
CHANGED
package/server/ms_runstp.sas
CHANGED
package/xplatform/mx_execute.sas
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|stpmacname|some value|
|
|
22
22
|
|mustbevalidname|can be anything, oops, %abort!!|
|
|
23
23
|
|
|
24
|
-
@param [in] debug= (
|
|
24
|
+
@param [in] debug= (131) Provide the _debug value.
|
|
25
25
|
@param [in] mdebug= (0) Set to 1 to provide macro debugging
|
|
26
26
|
@param [in] viyaresult= (WEBOUT_JSON) The Viya result type to return. For
|
|
27
27
|
more info, see mv_getjobresult.sas
|
|
@@ -31,6 +31,17 @@
|
|
|
31
31
|
0 if the service output is not in JSON format.
|
|
32
32
|
@param [out] outref= (0) Output fileref to create, to contain the full _webout
|
|
33
33
|
response.
|
|
34
|
+
@param [out] outlogds= (_null_) Name of a dataset to receive the child's log
|
|
35
|
+
(one column, line). Populated on Viya, from the job log mv_jobflow
|
|
36
|
+
collects, and on SASjs Server, from the log the server appends to the
|
|
37
|
+
response - ms_testservice discards that log unless this is set. Not
|
|
38
|
+
populated on SAS 9, where proc stp returns no child log. On SASjs Server
|
|
39
|
+
it is only populated when debug is 131 or above: the server appends the log
|
|
40
|
+
to the response in debug mode, so a lower value returns an empty dataset.
|
|
41
|
+
@param [out] outstatus= (0) Name of a dataset to receive the outcome of each
|
|
42
|
+
child run - one row per program, with columns STATE, URI, ERRMSG and
|
|
43
|
+
PLATFORM. ERRMSG is only populated on SASjs Server, from the abort block;
|
|
44
|
+
the Viya job flow carries a state but no message, and SAS 9 gives neither.
|
|
34
45
|
|
|
35
46
|
<h4> SAS Macros </h4>
|
|
36
47
|
@li mf_getplatform.sas
|
|
@@ -56,14 +67,16 @@
|
|
|
56
67
|
inputfiles=0,
|
|
57
68
|
inputdatasets=0,
|
|
58
69
|
inputparams=0,
|
|
59
|
-
debug=
|
|
70
|
+
debug=131,
|
|
60
71
|
mdebug=0,
|
|
61
72
|
outlib=0,
|
|
62
73
|
outref=0,
|
|
74
|
+
outlogds=_null_,
|
|
75
|
+
outstatus=0,
|
|
63
76
|
viyaresult=WEBOUT_JSON,
|
|
64
77
|
viyacontext=SAS Job Execution compute context
|
|
65
78
|
);
|
|
66
|
-
%local dbg pcnt fref1 fref2 webref webrefpath i webcount var platform;
|
|
79
|
+
%local dbg pcnt fref1 fref2 webref webrefpath i webcount var platform jobds respref clearmeref;
|
|
67
80
|
%if &mdebug=1 %then %do;
|
|
68
81
|
%put &sysmacroname entry vars:;
|
|
69
82
|
%put _local_;
|
|
@@ -183,6 +196,27 @@ filename &webref "&webrefpath";
|
|
|
183
196
|
%mp_binarycopy(inref=&webref,outref=&outref)
|
|
184
197
|
%end;
|
|
185
198
|
|
|
199
|
+
%if "&outlogds" ne "_null_" %then %do;
|
|
200
|
+
/* SAS 9 returns no child log. Create the dataset all the same, so a caller
|
|
201
|
+
* that reads it gets no rows rather than a missing table. */
|
|
202
|
+
data &outlogds;
|
|
203
|
+
length line $32767;
|
|
204
|
+
stop;
|
|
205
|
+
run;
|
|
206
|
+
%end;
|
|
207
|
+
|
|
208
|
+
/* proc stp gives no job status - say so rather than imply success */
|
|
209
|
+
%if "&outstatus" ne "0" %then %do;
|
|
210
|
+
data &outstatus;
|
|
211
|
+
length state $20 uri $256 errmsg $256 platform $10;
|
|
212
|
+
state='unknown';
|
|
213
|
+
uri='';
|
|
214
|
+
errmsg='proc stp returns no job status';
|
|
215
|
+
platform='SASMETA';
|
|
216
|
+
output;
|
|
217
|
+
run;
|
|
218
|
+
%end;
|
|
219
|
+
|
|
186
220
|
%end;
|
|
187
221
|
%else %if &platform=SASVIYA %then %do;
|
|
188
222
|
|
|
@@ -240,9 +274,11 @@ filename &webref "&webrefpath";
|
|
|
240
274
|
putlog (_all_)(=);
|
|
241
275
|
run;
|
|
242
276
|
|
|
277
|
+
/* the flow table is an internal detail: unique name, thrown away below */
|
|
278
|
+
%let jobds=%mf_getuniquename(prefix=mx_execute_);
|
|
243
279
|
%mv_jobflow(inds=&ds1
|
|
244
280
|
,maxconcurrency=1
|
|
245
|
-
,outds
|
|
281
|
+
,outds=&jobds
|
|
246
282
|
,outref=&fref1
|
|
247
283
|
,mdebug=&mdebug
|
|
248
284
|
)
|
|
@@ -252,12 +288,37 @@ filename &webref "&webrefpath";
|
|
|
252
288
|
input;
|
|
253
289
|
putlog _infile_;
|
|
254
290
|
run;
|
|
291
|
+
/* and keep it, if the caller asked */
|
|
292
|
+
%if "&outlogds" ne "_null_" %then %do;
|
|
293
|
+
data &outlogds;
|
|
294
|
+
infile &fref1 lrecl=32767 end=eof;
|
|
295
|
+
length line $32767;
|
|
296
|
+
do while(not eof);
|
|
297
|
+
input;
|
|
298
|
+
line=_infile_;
|
|
299
|
+
output;
|
|
300
|
+
end;
|
|
301
|
+
run;
|
|
302
|
+
%end;
|
|
255
303
|
/* get the uri to fetch results */
|
|
256
304
|
data _null_;
|
|
257
|
-
set
|
|
305
|
+
set &jobds;
|
|
258
306
|
call symputx('uri',uri);
|
|
259
307
|
putlog "&sysmacroname: fetching results for " uri;
|
|
260
308
|
run;
|
|
309
|
+
/* the outcome, before the flow table goes away */
|
|
310
|
+
%if "&outstatus" ne "0" %then %do;
|
|
311
|
+
data &outstatus;
|
|
312
|
+
length state $20 uri $256 errmsg $256 platform $10;
|
|
313
|
+
platform='SASVIYA';
|
|
314
|
+
errmsg='';
|
|
315
|
+
set &jobds(keep=state uri);
|
|
316
|
+
run;
|
|
317
|
+
%end;
|
|
318
|
+
/* nothing else needs the flow table - do not leave it in the caller's WORK */
|
|
319
|
+
proc datasets lib=work nolist nowarn;
|
|
320
|
+
delete &jobds;
|
|
321
|
+
quit;
|
|
261
322
|
/* fetch results from webout.json */
|
|
262
323
|
%mv_getjobresult(uri=&uri,
|
|
263
324
|
result=&viyaresult,
|
|
@@ -269,6 +330,13 @@ filename &webref "&webrefpath";
|
|
|
269
330
|
%end;
|
|
270
331
|
%else %if &platform=SASJS %then %do;
|
|
271
332
|
|
|
333
|
+
/* the response is needed to judge the outcome, even if not requested -
|
|
334
|
+
* and only a ref we create here may be cleared afterwards */
|
|
335
|
+
%let respref=&outref;
|
|
336
|
+
%if "&respref"="0" and "&outstatus" ne "0" %then %do;
|
|
337
|
+
%let respref=%mf_getuniquefileref();
|
|
338
|
+
%let clearmeref=1;
|
|
339
|
+
%end;
|
|
272
340
|
%ms_testservice(&program
|
|
273
341
|
,inputfiles=&inputfiles
|
|
274
342
|
,inputdatasets=&inputdatasets
|
|
@@ -276,8 +344,37 @@ filename &webref "&webrefpath";
|
|
|
276
344
|
,debug=&debug
|
|
277
345
|
,mdebug=&mdebug
|
|
278
346
|
,outlib=&outlib
|
|
279
|
-
,outref=&
|
|
347
|
+
,outref=&respref
|
|
348
|
+
,outlogds=&outlogds
|
|
280
349
|
)
|
|
350
|
+
%if "&outstatus" ne "0" %then %do;
|
|
351
|
+
data &outstatus;
|
|
352
|
+
length state $20 uri $256 errmsg $256 platform $10;
|
|
353
|
+
retain state 'completed' uri '' errmsg '' platform 'SASJS' abortseen 0;
|
|
354
|
+
infile &respref end=eof lrecl=32767;
|
|
355
|
+
/* scan the whole response - the abort block is not always on the first
|
|
356
|
+
* line - but only take a message from inside that block, so a service
|
|
357
|
+
* with its own MSG field does not look like an abort */
|
|
358
|
+
do while(not eof);
|
|
359
|
+
input;
|
|
360
|
+
if index(_infile_,'"sasjsAbort"')>0 then do;
|
|
361
|
+
state='canceled';
|
|
362
|
+
abortseen=1;
|
|
363
|
+
end;
|
|
364
|
+
if abortseen=1 and errmsg='' and index(_infile_,'"MSG"')>0 then do;
|
|
365
|
+
/* prxchange returns its input untouched when nothing matches, which
|
|
366
|
+
* would put the whole line in errmsg */
|
|
367
|
+
if prxmatch('/"MSG" *: *"([^"]*)"/',_infile_) then
|
|
368
|
+
errmsg=prxchange('s/.*"MSG" *: *"([^"]*)".*/$1/',-1,_infile_);
|
|
369
|
+
end;
|
|
370
|
+
end;
|
|
371
|
+
/* one row, whatever the response contained */
|
|
372
|
+
output;
|
|
373
|
+
run;
|
|
374
|
+
%end;
|
|
375
|
+
%if %length(&clearmeref)>0 %then %do;
|
|
376
|
+
filename &respref clear;
|
|
377
|
+
%end;
|
|
281
378
|
|
|
282
379
|
%end;
|
|
283
380
|
%else %do;
|