@sasjs/core 5.2.5 → 5.2.7
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/package.json +1 -1
- package/viya/mv_getjoblog.sas +13 -0
- package/viya/mv_getjobresult.sas +30 -0
- package/viya/mv_jobflow.sas +13 -2
package/package.json
CHANGED
package/viya/mv_getjoblog.sas
CHANGED
|
@@ -222,6 +222,19 @@ run;
|
|
|
222
222
|
response can be fetched directly via a GET to &base_uri&uri. */
|
|
223
223
|
%let abortmsg=Job &jobstate, no log available. GET &uri;
|
|
224
224
|
%if %length(&err_msg)>0 %then %let abortmsg=Job &jobstate, no log available. Error &err_httpcode: &err_msg. GET &uri;
|
|
225
|
+
/* A canceled job does not always provide a loglocation (eg a job
|
|
226
|
+
that was aborted by design, or canceled by the server before a
|
|
227
|
+
compute session was created). Aborting here would terminate the
|
|
228
|
+
calling program, so instead record the reason in the outref and
|
|
229
|
+
return - the caller can decide how to handle the missing log. */
|
|
230
|
+
%if &jobstate=canceled %then %do;
|
|
231
|
+
%put &sysmacroname: &abortmsg;
|
|
232
|
+
data _null_;
|
|
233
|
+
file &outref mod;
|
|
234
|
+
put "&sysmacroname: &abortmsg";
|
|
235
|
+
run;
|
|
236
|
+
%return;
|
|
237
|
+
%end;
|
|
225
238
|
%mp_abort(iftrue=(1=1)
|
|
226
239
|
,mac=&sysmacroname
|
|
227
240
|
,msg=%str(&abortmsg)
|
package/viya/mv_getjobresult.sas
CHANGED
|
@@ -186,6 +186,36 @@ data _null_;
|
|
|
186
186
|
call symputx('resuri',_&result,'l');
|
|
187
187
|
&dbg putlog "&sysmacroname results: " (_all_)(=);
|
|
188
188
|
run;
|
|
189
|
+
%if "&resuri"="." %then %do;
|
|
190
|
+
/* The requested result was not registered - typical for a canceled
|
|
191
|
+
* job whose session ended before the result file was created (eg a
|
|
192
|
+
* job aborted by design, or a job that failed on session creation).
|
|
193
|
+
* Aborting here would terminate the calling program, so write an
|
|
194
|
+
* empty payload and return - the caller can check the job state
|
|
195
|
+
* (from the outds of the wait macro) and decide what to do. */
|
|
196
|
+
%put &sysmacroname: _&result not found in job results -;
|
|
197
|
+
%put &sysmacroname: use mv_getjoblog to fetch the job log instead;
|
|
198
|
+
%if &outref ne 0 %then %do;
|
|
199
|
+
data _null_;
|
|
200
|
+
file &outref;
|
|
201
|
+
put "&sysmacroname: no &_result result available for job &uri";
|
|
202
|
+
run;
|
|
203
|
+
%end;
|
|
204
|
+
%if &outlib ne 0 %then %do;
|
|
205
|
+
%local fname3;
|
|
206
|
+
%let fname3=%mf_getuniquefileref();
|
|
207
|
+
data _null_;
|
|
208
|
+
file &fname3;
|
|
209
|
+
put '{}';
|
|
210
|
+
run;
|
|
211
|
+
libname &outlib JSON fileref=&fname3;
|
|
212
|
+
%end;
|
|
213
|
+
%if &mdebug=0 %then %do;
|
|
214
|
+
filename &fname1 clear;
|
|
215
|
+
libname &lib1 clear;
|
|
216
|
+
%end;
|
|
217
|
+
%return;
|
|
218
|
+
%end;
|
|
189
219
|
%mp_abort(iftrue=("&resuri"=".")
|
|
190
220
|
,mac=&sysmacroname
|
|
191
221
|
,msg=%str(Variable _&result did not exist in the response json)
|
package/viya/mv_jobflow.sas
CHANGED
|
@@ -272,10 +272,21 @@ data;run;%let jdswaitfor=&syslast;
|
|
|
272
272
|
%if %length(&cvars)>0 %then %do ii=1 %to %sysfunc(countw(&cvars,%str( )));
|
|
273
273
|
%let _vnm=%scan(&cvars,&ii,%str( ));
|
|
274
274
|
if _param ne '' then _param=cats(_param,',');
|
|
275
|
+
/* The keys are V7 SAS names (from mf_getvarlist) so need no
|
|
276
|
+
* escaping. The values are free-form data - eg SASJS-formatted
|
|
277
|
+
* CSV payloads with embedded doubled quotes and CRLF row
|
|
278
|
+
* separators - so must be json escaped. The sas quote() function
|
|
279
|
+
* doubles any embedded double quotes (csv convention) which is
|
|
280
|
+
* invalid json and makes the jobExecution request fail with a
|
|
281
|
+
* 400 response. Raw control characters (CR/LF) are also invalid
|
|
282
|
+
* json - viya silently replaces them with spaces, corrupting
|
|
283
|
+
* multi-line CSV payloads. Escape backslashes first, then CR,
|
|
284
|
+
* LF, and finally double quotes. */
|
|
275
285
|
_param=cats(_param,'"'
|
|
276
286
|
,"&_vnm"
|
|
277
|
-
,'":'
|
|
278
|
-
,
|
|
287
|
+
,'":"'
|
|
288
|
+
,tranwrd(tranwrd(tranwrd(tranwrd(trim(&_vnm),'\','\\'),'0D'x,'\r'),'0A'x,'\n'),'"','\"')
|
|
289
|
+
,'"'
|
|
279
290
|
);
|
|
280
291
|
%end;
|
|
281
292
|
%if %length(&nvars)>0 %then %do ii=1 %to %sysfunc(countw(&nvars,%str( )));
|