session actionstatus

Performance: Orchestrating Multiple Asynchronous Model Scoring Jobs

Scénario de test & Cas d'usage

Business Context

An automated nightly process kicks off several model scoring jobs in parallel to score different customer segments. Each job runs in its own CAS session for isolation. A master script needs to poll all running job sessions to provide a consolidated status report and trigger downstream actions only when all scoring is complete.
About the Set : session

Management of the CAS session state.

Discover all actions of session
Data Preparation

Create a large dataset and a dummy scoring model to simulate a long-running scoring task.

Copied!
1DATA casuser.customer_segments;
2 DO segment_id = 1 to 3;
3 DO customer_id = 1 to 200000;
4 var1 = ranuni(456);
5 var2 = rannor(456);
6 var3 = ranbin(456, 10, 0.5);
7 OUTPUT;
8 END;
9 END;
10RUN;
11 
12PROC CAS;
13 LOADACTIONSET 'aStore';
14 /* Create a dummy model store to simulate scoring */
15 SOURCE myModel;
16 dcl double p_var1;
17 p_var1=0;
18 method score(double var1, double var2, double var3, double p_var1);
19 p_var1 = var1 * 0.5 + var2 * 0.2 + var3 * 0.3;
20 END;
21 ENDSOURCE;
22 ACTION aStore.compile / code=myModel, name='dummy_scorer', caslib='casuser';
23RUN;

Étapes de réalisation

1
Launch three separate, named sessions and start an asynchronous scoring job in each.
Copied!
1PROC CAS;
2 SESSION casauto name='ScoringJob_Seg1';
3 SESSION casauto name='ScoringJob_Seg2';
4 SESSION casauto name='ScoringJob_Seg3';
5 
6 cas ScoringJob_Seg1;
7 ACTION aStore.score / TABLE={name='customer_segments', where='segment_id=1'}, rstore={name='dummy_scorer', caslib='casuser'}, out={name='scored_seg1', caslib='casuser', replace=true}, async='job_seg1';
8 
9 cas ScoringJob_Seg2;
10 ACTION aStore.score / TABLE={name='customer_segments', where='segment_id=2'}, rstore={name='dummy_scorer', caslib='casuser'}, out={name='scored_seg2', caslib='casuser', replace=true}, async='job_seg2';
11 
12 cas ScoringJob_Seg3;
13 ACTION aStore.score / TABLE={name='customer_segments', where='segment_id=3'}, rstore={name='dummy_scorer', caslib='casuser'}, out={name='scored_seg3', caslib='casuser', replace=true}, async='job_seg3';
14RUN;
2
From the main session, loop through all sessions prefixed with 'ScoringJob_' and check their status.
Copied!
1PROC CAS;
2 SESSION;
3 ACTION SESSION.listSessions RESULT=r;
4 DO row over r.SESSION;
5 IF starts(row['Session Name'], 'ScoringJob_') THEN DO;
6 PRINT '--- Checking Status for Session: ' || row['Session Name'] || ' (' || row['Session UUID'] || ') ---';
7 ACTION SESSION.actionstatus / uuid=row['Session UUID'];
8 END;
9 END;
10RUN;
3
Clean up all scoring sessions.
Copied!
1PROC CAS;
2 SESSION ScoringJob_Seg1 terminate;
3 SESSION ScoringJob_Seg2 terminate;
4 SESSION ScoringJob_Seg3 terminate;
5RUN;

Expected Result


The log will show three distinct blocks of output, one for each scoring session. Each block will contain a status table for that session's 'aStore.score' action. This demonstrates the action's effectiveness in a concurrent, multi-session monitoring scenario, which is typical for batch orchestration.