Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't deploy .sas programs #991

Open
ccastillo232 opened this issue Sep 16, 2021 · 3 comments
Open

Can't deploy .sas programs #991

ccastillo232 opened this issue Sep 16, 2021 · 3 comments
Labels
enhancement New feature or request sponsorship needed

Comments

@ccastillo232
Copy link

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?

@allanbowe
Copy link
Member

allanbowe commented Sep 16, 2021

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 allanbowe added the enhancement New feature or request label Sep 16, 2021
@ccastillo232
Copy link
Author

Understood, thanks Allan.

@allanbowe
Copy link
Member

allanbowe commented Sep 4, 2022

@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:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sponsorship needed
Projects
None yet
Development

No branches or pull requests

2 participants