@sasjs/core 5.2.2 → 5.2.4
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_abort.sas +7 -1
- package/package.json +1 -1
- package/viya/mv_getjoblog.sas +45 -1
- package/viya/mv_jobflow.sas +2 -2
- package/viya/mv_jobwaitfor.sas +18 -8
package/base/mp_abort.sas
CHANGED
|
@@ -215,7 +215,13 @@ and %superq(SYSPROCESSNAME) ne %str(Compute Server)
|
|
|
215
215
|
put ',"_DEBUG":' debug ;
|
|
216
216
|
if symexist('_metauser') then do;
|
|
217
217
|
_METAUSER=quote(trim(symget('_METAUSER')));
|
|
218
|
-
put
|
|
218
|
+
put ',"_METAUSER": ' _METAUSER;
|
|
219
|
+
end;
|
|
220
|
+
/* _METAPERSON is not always set when _METAUSER is (e.g. Viya JES
|
|
221
|
+
sessions provide only _METAUSER) - guard it separately or SYMGET
|
|
222
|
+
raises "Invalid argument" and pollutes SYSERRORTEXT inside the
|
|
223
|
+
very abort JSON we are writing here. */
|
|
224
|
+
if symexist('_metaperson') then do;
|
|
219
225
|
_METAPERSON=quote(trim(symget('_METAPERSON')));
|
|
220
226
|
put ',"_METAPERSON": ' _METAPERSON;
|
|
221
227
|
end;
|
package/package.json
CHANGED
package/viya/mv_getjoblog.sas
CHANGED
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
|
|
85
85
|
<h4> SAS Macros </h4>
|
|
86
86
|
@li mp_abort.sas
|
|
87
|
+
@li mf_existvar.sas
|
|
87
88
|
@li mf_getplatform.sas
|
|
88
89
|
@li mf_existfileref.sas
|
|
89
90
|
@li mf_getuniquefileref.sas
|
|
@@ -96,7 +97,8 @@
|
|
|
96
97
|
,grant_type=sas_services
|
|
97
98
|
,mdebug=0
|
|
98
99
|
);
|
|
99
|
-
%local dbg libref1 libref2 loglocation fname1 fname2
|
|
100
|
+
%local dbg libref1 libref2 loglocation fname1 fname2 jobstate err_httpcode
|
|
101
|
+
err_msg abortmsg;
|
|
100
102
|
%if &mdebug=1 %then %do;
|
|
101
103
|
%put &sysmacroname entry vars:;
|
|
102
104
|
%put _local_;
|
|
@@ -182,7 +184,49 @@ libname &libref1 JSON fileref=&fname1;
|
|
|
182
184
|
data _null_;
|
|
183
185
|
set &libref1..root;
|
|
184
186
|
call symputx('loglocation',loglocation,'l');
|
|
187
|
+
%if %mf_existvar(&libref1..root,state) %then %do;
|
|
188
|
+
call symputx('jobstate',state,'l');
|
|
189
|
+
%end;
|
|
190
|
+
%else %do;
|
|
191
|
+
call symputx('jobstate','unknown','l');
|
|
192
|
+
%end;
|
|
185
193
|
run;
|
|
194
|
+
/* If root had zero observations, jobstate was never set - fall back to
|
|
195
|
+
"unknown" so the abort message below reads cleanly. */
|
|
196
|
+
%if %str(&jobstate)= %then %let jobstate=unknown;
|
|
197
|
+
|
|
198
|
+
/* A real loglocation is always a /files/files/<uuid> URI (48+ chars), so
|
|
199
|
+
length<2 unambiguously means the job has no log (empty or SAS missing
|
|
200
|
+
value) - the job likely failed before a compute session was created
|
|
201
|
+
(e.g. 403 on session creation). Read the error details from the job
|
|
202
|
+
response so the actual failure reason is reported instead of the
|
|
203
|
+
opaque "URI is too short" message. */
|
|
204
|
+
%if &mdebug=1 %then %do;
|
|
205
|
+
%put &sysmacroname: jobstate=[&jobstate] loglocation=[&loglocation];
|
|
206
|
+
%end;
|
|
207
|
+
%if %length(&loglocation)<2 %then %do;
|
|
208
|
+
%let err_httpcode=;
|
|
209
|
+
%let err_msg=;
|
|
210
|
+
%if %sysfunc(exist(&libref1..error)) %then %do;
|
|
211
|
+
data _null_;
|
|
212
|
+
set &libref1..error;
|
|
213
|
+
call symputx('err_httpcode',httpStatusCode,'l');
|
|
214
|
+
call symputx('err_msg',message,'l');
|
|
215
|
+
putlog "&sysmacroname: Job &jobstate - error " httpStatusCode ": " message;
|
|
216
|
+
stop;
|
|
217
|
+
run;
|
|
218
|
+
%end;
|
|
219
|
+
/* Build the abort message so it reads cleanly whether or not error
|
|
220
|
+
details were available (err_msg stays empty if the table is absent
|
|
221
|
+
or has zero observations). Include the job URI so the full JSON
|
|
222
|
+
response can be fetched directly via a GET to &base_uri&uri. */
|
|
223
|
+
%let abortmsg=Job &jobstate, no log available. GET &uri;
|
|
224
|
+
%if %length(&err_msg)>0 %then %let abortmsg=Job &jobstate, no log available. Error &err_httpcode: &err_msg. GET &uri;
|
|
225
|
+
%mp_abort(iftrue=(1=1)
|
|
226
|
+
,mac=&sysmacroname
|
|
227
|
+
,msg=%str(&abortmsg)
|
|
228
|
+
)
|
|
229
|
+
%end;
|
|
186
230
|
|
|
187
231
|
/* validate log path*/
|
|
188
232
|
%let errflg=1;
|
package/viya/mv_jobflow.sas
CHANGED
|
@@ -273,7 +273,7 @@ data;run;%let jdswaitfor=&syslast;
|
|
|
273
273
|
%let _vnm=%scan(&cvars,&ii,%str( ));
|
|
274
274
|
if _param ne '' then _param=cats(_param,',');
|
|
275
275
|
_param=cats(_param,'"'
|
|
276
|
-
,"
|
|
276
|
+
,"&_vnm"
|
|
277
277
|
,'":'
|
|
278
278
|
,quote(trim(&_vnm))
|
|
279
279
|
);
|
|
@@ -282,7 +282,7 @@ data;run;%let jdswaitfor=&syslast;
|
|
|
282
282
|
%let _vnm=%scan(&nvars,&ii,%str( ));
|
|
283
283
|
if _param ne '' then _param=cats(_param,',');
|
|
284
284
|
_param=cats(_param,'"'
|
|
285
|
-
,"
|
|
285
|
+
,"&_vnm"
|
|
286
286
|
,'":"'
|
|
287
287
|
,strip(put(&_vnm,best32.))
|
|
288
288
|
,'"'
|
package/viya/mv_jobwaitfor.sas
CHANGED
|
@@ -68,8 +68,10 @@
|
|
|
68
68
|
@param [in] action=Either ALL (to wait for every job) or ANY (if one job
|
|
69
69
|
completes, processing will continue). Default=ALL.
|
|
70
70
|
@param [in] inds= The input dataset containing the list of job uris, in the
|
|
71
|
-
following format: `/jobExecution/jobs/&JOBID
|
|
72
|
-
|
|
71
|
+
following format: `/jobExecution/jobs/&JOBID.` (a trailing `/state`
|
|
72
|
+
suffix, as returned by the mv_jobexecute state link, is also
|
|
73
|
+
accepted and will be stripped) and the corresponding job name.
|
|
74
|
+
The uri should be in a `uri` variable, and the job path/name
|
|
73
75
|
should be in a `_program` variable.
|
|
74
76
|
@param [in] raise_err=0 Set to 1 to raise SYSCC when a job does not complete
|
|
75
77
|
succcessfully
|
|
@@ -151,7 +153,15 @@ options noquotelenmax;
|
|
|
151
153
|
data _null_;
|
|
152
154
|
length jobparams $32767;
|
|
153
155
|
set &inds end=last;
|
|
154
|
-
|
|
156
|
+
/* strip any trailing /state suffix - the poll below GETs the plain
|
|
157
|
+
job uri (whose root object carries the state field), and
|
|
158
|
+
downstream consumers (mv_getjoblog, the outds) expect the plain
|
|
159
|
+
job uri. Do not truncate: job uris are not a fixed length (a
|
|
160
|
+
definition uri passed in error must fail loudly, not be silently
|
|
161
|
+
corrupted into a 404). */
|
|
162
|
+
if length(strip(uri))>6 and substr(strip(uri),length(strip(uri))-5)='/state'
|
|
163
|
+
then uri=substr(strip(uri),1,length(strip(uri))-6);
|
|
164
|
+
call symputx(cats('joburi',_n_),strip(uri),'l');
|
|
155
165
|
call symputx(cats('jobname',_n_),_program,'l');
|
|
156
166
|
call symputx(cats('jobparams',_n_),jobparams,'l');
|
|
157
167
|
if last then call symputx('uricnt',_n_,'l');
|
|
@@ -205,21 +215,21 @@ run;
|
|
|
205
215
|
libname &libref1 clear;
|
|
206
216
|
|
|
207
217
|
%if &status=completed or &status=failed or &status=canceled %then %do;
|
|
208
|
-
|
|
209
|
-
|
|
218
|
+
/* &&joburi&i is already the plain job uri (any /state suffix was
|
|
219
|
+
stripped on input) - use it as-is. */
|
|
210
220
|
proc sql;
|
|
211
221
|
insert into &outds set
|
|
212
222
|
_program="&&jobname&i",
|
|
213
|
-
uri="&
|
|
223
|
+
uri="&&joburi&i",
|
|
214
224
|
state="&status",
|
|
215
225
|
stateDetails=symget("stateDetails"),
|
|
216
226
|
timestamp=datetime(),
|
|
217
227
|
jobparams=symget("jobparams&i");
|
|
218
|
-
%let joburi&i=0; /* do not re-check */
|
|
219
228
|
/* fetch log */
|
|
220
229
|
%if %str(&outref) ne 0 %then %do;
|
|
221
|
-
%mv_getjoblog(uri
|
|
230
|
+
%mv_getjoblog(uri=&&joburi&i,outref=&outref,mdebug=&mdebug)
|
|
222
231
|
%end;
|
|
232
|
+
%let joburi&i=0; /* do not re-check */
|
|
223
233
|
%end;
|
|
224
234
|
%else %if &status=idle or &status=pending or &status=running %then %do;
|
|
225
235
|
data _null_;
|