BookmarkSubscribeRSS Feed
elisehoo1
Obsidian | Level 7
hi there, 
for the jobs that i have scheduled, is it a way to show what was the code inside ? does it have any job code for refer back?
thanks

 

elisehoo1_0-1627216010145.png

 

9 REPLIES 9
gwootton
SAS Super FREQ
If the job definition is saved to a path in the content server you could go the URL /SASJobExecution and locate the job definition, right-click and select View -> Source Code.

If not, you could access the endpoint for the job definition itself (/jobDefinitions/definition/<id>) and one of the fields returned is the code.
--
Greg Wootton | Principal Systems Technical Support Engineer
elisehoo1
Obsidian | Level 7

thank you @gwootton  , i will explore on it . but i didn't use job definition ,i checked it is more like a stored process . 

 

below are my use case which hope you can provide me some ideas how to refresh the latest changes into the "deployed" jobs 

 

 

1.  job created in jsf and pointing to a code (abc.sas) in one of project folder under sas content tree

 

elisehoo1_1-1627361497238.png

 

elisehoo1_0-1627360422325.png

 

2. added the job into a flow 

elisehoo1_2-1627361777574.png

 

3. if i change the code (abc.sas) , how do i reflect the change to the "deployed" job which i have embedded in the job flow itself? 

 

4. if i can trace the job path/file.sas on those jobs that i seen from flows ? 

 

Thanks

 

gwootton
SAS Super FREQ

When you create a new job from a saved program, the code of the program is copied into the job request. You can see that code by pulling /jobExecution/jobRequests/<id> (the ID is found in the "general" tab of the job properties) in the "code" attribute. This means any changes to the source code (abc.sas) would not carry over to the job, so you would need to delete the existing job and create a new one with the updated code. If you have jq installed, these commands would fairly quickly show you the stored code, just need to update the user, job id and baseurl with what is correct for your environment.

baseurl=https://viya.demo.sas.com
user=<user_id>
read -s -p "Enter password: " pass
id=<job_id>
token=$(curl -s -L -X POST "$baseurl/SASLogon/oauth/token" -H 'Accept: application/json' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Authorization: Basic c2FzLmNsaTo=' -d 'grant_type=password' -d "username=$user" -d "password=$pass" | sed "s/{.*\"access_token\":\"\([^\"]*\).*}/\1/g")
curl -s -L $baseurl/jobExecution/jobRequests/$id -H "Authorization: Bearer $token" | jq -r '.jobDefinition.code'
--
Greg Wootton | Principal Systems Technical Support Engineer
elisehoo1
Obsidian | Level 7
sorry, may i know what is JQ ? thanks
gwootton
SAS Super FREQ
jq is a command-line application that can process JSON.
https://stedolan.github.io/jq/
--
Greg Wootton | Principal Systems Technical Support Engineer
Quentin
Super User

Just curious, is there no option to "redeploy" an existing job?  With SAS 9.4 / DI studio there is a "redeploy."

 

Another option, which I use in 9.4 / DI studio is to have your deployed job just be a singe %INCLUDE statement which includes the real program.  So the deployed job foo is just %include foo.sas.  Then you can update foo.sas any time you want, and the deployed job doesn't need to change.

 

I haven't tried Viya yet, but it works well on 9.4 BI server.  Typically I try to write my SAS code (foo.sas) in a way that it will run when called from DI studio or EG or as a batch submission or whatever.  I only create a "job" when I want to schedule something.  The job is just a wrapper object that points to existing code.  In fact, most of my jobs are exactly the same, because they just %include /&project/Code/&jobname..sas /source2.    The value for &project and &jobname come from the name of the job and metadata path.

BASUG is hosting free webinars ! Check out recordings of our past webinars: https://www.basug.org/videos. Save the date for our in person SAS Blowout on Oct 18 in Cambridge, MA. Registration opens in September.
gwootton
SAS Super FREQ
I'm not aware of any redeploy functionality as exists in SAS 9.4. The solution of using an include statement would work in Viya, assuming the path to the program is present on all the compute server hosts. I'm not sure about the ability to use macro variables in the include statement as the job name / path isn't known to the program.
--
Greg Wootton | Principal Systems Technical Support Engineer
Quentin
Super User

Gotcha, thanks.  I would think redeploy would be a handy feature for the backlog.

 

In 9.4, looks like there were macro variables  &ETLS_JOBNAME and &JOBID but for the path I had to use the &JOBID to crawl the metadata.

BASUG is hosting free webinars ! Check out recordings of our past webinars: https://www.basug.org/videos. Save the date for our in person SAS Blowout on Oct 18 in Cambridge, MA. Registration opens in September.
gwootton
SAS Super FREQ
These variables are not present in Viya. I created a job with %put _all_ and executed it and found these variables set. I also didn't see any in the environment variables.

normal: GLOBAL SYS_COMPUTE_DATA /opt/sas/viya/config/data/compsrv/default
normal: GLOBAL SYS_COMPUTE_JOB_ID 64FC27DA-E57D-7E44-BAA3-187CE2220F8C
normal: GLOBAL SYS_COMPUTE_SESSION_ID f027c925-2d8c-4d90-b8a0-8fd6e2769cc7-ses0000
normal: GLOBAL SYS_COMPUTE_SESSION_OWNER grwoot
normal: GLOBAL SYS_JES_JOB_URI /jobExecution/jobs/5d52283b-028d-4eac-a2b7-1186d3af6b43
normal: GLOBAL _CONTEXTNAME SAS Job Execution compute context
--
Greg Wootton | Principal Systems Technical Support Engineer

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Discussion stats
  • 9 replies
  • 1974 views
  • 4 likes
  • 3 in conversation