BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AllanBowe
Barite | Level 11

The documentation refers to an additional property called `stateDetails` that can indicate the job state according to the log (warning, info, error etc)

 

However this never appears for us in the API response.  Is it set automatically?  Or is it just a placeholder that customers should populate themselves after performing log analysis?

 

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
1 ACCEPTED SOLUTION

Accepted Solutions
joeFurbee
Community Manager

Hi @AllanBowe

Your reasoning is correct. The stateDetails ONLY returns a value when the job /state is "completed". If you then run a GET /jobExecution/jobs/{{jobID}} and more info is available you'll see the state details. For example, I submitted a job (with SAS code that I know would produce a warning message. Then I sent the call referenced above and I see the following in the response:

"state": "completed",
"stateDetails": "warning",

 

I hope this clears things up.


Join us for SAS Community Trivia
SAS Bowl XL, SAS Innovate 2024 Recap
Wednesday, May 15, 2024, at 10 a.m. ET | #SASBowl

View solution in original post

6 REPLIES 6
joeFurbee
Community Manager

Hi @AllanBowe ,

I got this back from a colleague:

stateDetails is a field the job execution provider (NOT the user) sets - in other words it would get set automatically and is only applicable to the "completed" state.

 

I'm working on getting some more info.

 

To investigate the "completed" state when the job fails, the first way to troubleshoot is to run a get on the job:

GET: {{sasserver}}/reportImages/jobs/{{jobid}}

 

That should provide more info on what happened during the job execution.

 

Additionally, in the response from the call above, you can locate the log from this endpoint:

 "logLocation": "/files/files/49b70680-c318-471d-bac9-889bff80a8bc"
 
Append this endpoint with /content and you can see the contents of the Compute session:
{{sasserver}}/files/files/49b70680-c318-471d-bac9-889bff80a8bc/content
yields
{
    "version": 2,
    "name": "items",
    "accept": "application/vnd.sas.compute.log.line",
    "start": 0,
    "items": [
        {
            "version": 1,
            "type": "source",
            "line": "1    proc sql;"...........
 
Thanks,
Joe

Join us for SAS Community Trivia
SAS Bowl XL, SAS Innovate 2024 Recap
Wednesday, May 15, 2024, at 10 a.m. ET | #SASBowl

AllanBowe
Barite | Level 11

Thanks Joe!

To give some context, we're using this to determine job status when interfacing with the Viya APIs as part of the SASjs CLI, the command looks like this:

 

sasjs job execute /path/to/my/job -l path/to/job.log --status status.txt

My guess, based on responses, is that the `completed` status is _replaced_ with the `stateDetails` value when errors or warnings are found.  Be good to confirm this though.

 

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
joeFurbee
Community Manager

Hi @AllanBowe

Your reasoning is correct. The stateDetails ONLY returns a value when the job /state is "completed". If you then run a GET /jobExecution/jobs/{{jobID}} and more info is available you'll see the state details. For example, I submitted a job (with SAS code that I know would produce a warning message. Then I sent the call referenced above and I see the following in the response:

"state": "completed",
"stateDetails": "warning",

 

I hope this clears things up.


Join us for SAS Community Trivia
SAS Bowl XL, SAS Innovate 2024 Recap
Wednesday, May 15, 2024, at 10 a.m. ET | #SASBowl

AllanBowe
Barite | Level 11
would it be possible to get a complete list of values for the /state endpoint?
/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs
joeFurbee
Community Manager

Here is a complete list of /state values:

Path: /jobs/{jobId}/state
Returns the following states: pending, running, canceled, completed, or failed.

 

Also, I meant to mention (you may have seen it already) when "stateDetails" returns in the response, the "error" object should return in the response as well with the message. Something like:

    },
    "state": "completed",
    "stateDetails": "warning",
    "endTimeStamp": "2020-12-10T14:12:39.506Z",
    "heartbeatTimeStamp": "2020-12-10T14:12:34.094Z",
    "submittedByApplication": "jobExecution",
    "heartbeatInterval": 600,
    "elapsedTime": 6114,
    "results": {
        "COMPUTE_CONTEXT": "SAS Job Execution compute context",
        "COMPUTE_JOB": "EA965EB3-DF9D-EB41-A990-6FF54791EE06",
        "EA965EB3-DF9D-EB41-A990-6FF54791EE06.log.txt": "/files/files/f650a15e-97ab-4aab-bb77-f0f88eda0e06",
        "COMPUTE_SESSION": "8566c785-a142-47f9-b941-f65e256dbd09-ses0000 Ended."
    },
    "logLocation": "/files/files/ad14e8d0-5e88-45e4-9af5-2564fa052d48",
    "error": {
        "errorCode": 5710,
        "message": "Apparent symbolic reference Y not resolved.",
        "links": [],
        "version": 2,
        "httpStatusCode": 0
    },

 

IOW, the "warning" generated when my code ran in SAS is returned in the "error" "message" object.


Join us for SAS Community Trivia
SAS Bowl XL, SAS Innovate 2024 Recap
Wednesday, May 15, 2024, at 10 a.m. ET | #SASBowl

AllanBowe
Barite | Level 11
nice!

fyi, we also see "idle" being returned from this endpoint.
/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2329 views
  • 2 likes
  • 2 in conversation