sasjs / cli

Command line interface for creating, compiling, and building SAS® projects
https://cli.sasjs.io
MIT License
37 stars 5 forks source link

Difference termprogram json and sas build output #1379

Closed mblauw-sas closed 1 year ago

mblauw-sas commented 1 year ago

Currently we do not have the possibility yet of authenticating to one of our SAS environments, so we run the .sas build output and run that in SAS Studio. We have a postbuild job included that creates .sas files from the job definitions.

Snippet from our sasjsconfig.json

"buildConfig": {
  "termProgram": "sasjs/admin/postbuild.sas"
},

And our target definition

{
   "name": "XX",
   "serverUrl": "https://XX",
   "serverType": "XX",
   "httpsAgentOptions": {
     "allowInsecureRequests": false
   },
   "appLoc": "XX",
   "jobConfig": {
     "jobFolders": [
       "XX",
           [...]
       "sasjs/admin"
     ],
     "initProgram": "_shared/jobs/jobinit.sas",
     "termProgram": "_shared/jobs/jobterm.sas",
     "macroVars": {
       "_apploc": "XX"
     }
   },
   "contextName": "SAS Job Execution compute context"
}

Our postbuild.sas program

/**
  @file
  @brief <Your brief here>
  <h4> SAS Macros </h4>
  @li m_sasjobinitwrite.sas
**/

%m_sasjobinitwrite(root=&_appLoc.);

Snippet of how this is included in the .sas build output

%global appLoc serverName;
%let compiled_apploc=XX;

%let appLoc=%sysfunc(coalescec(&appLoc,&compiled_apploc));

[...]

* BuildTerm start;
/**
  @file
  @brief <Your brief here>
  <h4> SAS Macros </h4>
  @li m_sasjobinitwrite.sas
**/

%m_sasjobinitwrite(root=&_appLoc.);
* BuildTerm end;

Snippet of how this is included in the .json build output

"name": "admin",
"type": "folder",
"members": [
 {
  "name": "postbuild",
  "type": "service",
  "code": "* Job Variables start;\n\n%let _apploc= XXX
      [...]
   %m_sasjobinitwrite(root=&_appLoc.);
      [...]
 }
]

It seems that using sasjs deploy, sasjs triggers the deployed job on the server. This deployed job is aware of the &_appLoc variable. However, the .sas job output seems to use the "open code" deployscript, which is only aware of &appLoc and not of &_appLoc. Thus resulting in an error.

allanbowe commented 1 year ago

Thanks @mblauw-sas! To summarise the conversation we had:

Good luck with the project, and keep in touch!