cli icon indicating copy to clipboard operation
cli copied to clipboard

Can't deploy .sas programs

Open ccastillo232 opened this issue 4 years ago • 3 comments

I've found that when I cbd I can't actually specify a location of .sas files. I can only define jobs and services. For both, the assets are nested under a "jobs" or "services" folder. And both are deployed as job definitions, not as .sas files.

Is there a way I don't see to define a place for .sas files to be uploaded?

ccastillo232 avatar Sep 16 '21 12:09 ccastillo232

Hi Chuck - correct, we support three categories of "job" - regular jobs (/jobs), web services (/services) and tests (/tests), all of which are deployed as "jobs" in Viya. We haven't built a feature for deploying SAS programs. We're happy to accept this as a feature request though. Would need to think about how we fit that into the framework - perhaps by having a sasFiles array, and deploying under /sasfiles in the appLoc root.

A short term workaround might be to deploy as Jobs, then write an additional job (using SAS code) to read the content and deploy as a ".sas" program.

This macro will list the jobs in a folder: https://core.sasjs.io/mv__getfoldermembers_8sas.html

This macro will grab the code from a job: https://core.sasjs.io/mv__getjobcode_8sas.html

And this macro can be used to create a SAS file (will also create any parent folders if needed): https://core.sasjs.io/mv__createfile_8sas.html

allanbowe avatar Sep 16 '21 12:09 allanbowe

Understood, thanks Allan.

ccastillo232 avatar Sep 16 '21 13:09 ccastillo232

@ccastillo232 - we found a workaround for this (credit to @mblauw-sas) which would give you the functionality at the cost of a slightly longer deployment process.

Basically, you create a jobs/admin/rebuild.sas program (as a Job) which converts every deployed job to a SAS Program in Drive. You can then call this job in the deployConfig.deployScripts array by pointing to sasjsbuild/jobs/admin/rebuild.sas. This will execute the code as "code" (rather than as a job) and so there will be no _program variable, so you must provide the appLoc. This can be a jobConfig.macroVars value.

Example config as follows:

{
  "$schema": "https://raw.githubusercontent.com/sasjs/utils/main/src/types/sasjsconfig-schema.json",
  "targets": [
    {
      "name": "demo",
      "serverUrl": "https://my.server",
      "serverType": "SASVIYA",
      "appLoc": "/My/Drive/Folder",
      "jobConfig": {
        "jobFolders": [
          "jobs/admin"
        ],
        "macroVars": {
          "tgtAppLoc": "/My/Drive/Folder"
        }
      },
      "deployConfig": {
        "deployScripts": [
          "sasjsbuild/jobs/admin/rebuild.sas"
        ]
      }
    }
  ]
}

To do the translation from Job to Studio Program you can make use of the following macros:

  • https://core.sasjs.io/mv__getjobcode_8sas.html
  • https://core.sasjs.io/mv__getfoldermembers_8sas.html
  • https://core.sasjs.io/mv__deletejes_8sas.html

Creating the actual program is quite simple - just set up the fileref using the filesrvc engine, eg:

filename outref filesrvc  folderPath="&tgtappLoc/jobs/load" filename="jobx.sas";

Happy to jump on a call to assist with setup.

allanbowe avatar Sep 04 '22 11:09 allanbowe