-
Notifications
You must be signed in to change notification settings - Fork 10
Executing a cas action
This section discusses how to use restaf and restaflib methods to execute any cas action.
The two key methods of restaflib are:
- casSetup - creates a cas session.The only argument to this method is restaf store
- casActionRun - execute a specified cas action
This method runs a specified action.
let actionResult = await restaflib.casActionRun(store, session, payload);
The arguments to this method are:
- store - the store object for restaf
- session - the session object from the casSetup method
- payload - An object with the schema describe below
The payload is:
{
action : name of the action - actionset.actionname,
data : The parameters(if any) for this action,
headers: Any special http headers for this action -
the table.upload action is the only action I am aware of that needs special headers
}
An typical payload for a datastep action is shown below
let p = {
action: "datastep.runCode",
data : {
code: "data casuser.score; x1=10;x2=20;x3=30; score1 = x1+x2+x3;run; "
}
};
The code to execute this action is:
let result = await restaflib.casActionRun(store, session, p);
... process results...
The result from the action is the json returned by the Cas for any action. The content of the output will vary based on the action. See the documentation for the specific action for the details.
This action is one of actions that requires information to be passed in the header. Below is an example for uploading a cars.csv file to casuser.cars:
let JSON\_Parameters = {
casout: {
caslib: 'casuser' /\* a valid caslib \*/,
name : 'cars' /\* name of output file on cas server \*/
},
importOptions: {
fileType: 'csv' /\* type of the file being uploaded \*/
}
};
let p = {
headers: { 'JSON-Parameters': JSON\_Parameters },
data : readFile(filename, fileType), /\* read file from a local csv file \*/
action : 'table.upload'
};
let actionResult = await restaflib.casActionRun(store, session, p);
... process results ...
See https://github.com/sassoftware/restaf/tree/gen2/packages/viyacaddy/src for information on how to upload
- sas7bdat
- sashdat
- astore
- csv
- ds2 scoring code to a model table
- datastep scoring to a model table
Include the following two script tags.
<script src="https://unpkg.com/@sassoftware/restaf/dist/restaf.min.js"></script>
<script src="https://unpkg.com/@sassoftware/restaflib/dist/restaflib.min.js"></script>
Two globals restaf and restaflib will be available for use in your script tags.
Install restaf and restaflib using the following command
npm install @sassoftware/restaf @sassoftware/restaflib
.... Under construction...
-
restaf
-
restaflib
-
Examples:
- Cas Server
- Compute Server
- Scoring with MAS
- Scoring with CAS
- Utility
-
CAS Related Functions
-
MAS Related Functions
-
Compute Server Related Functions
-
Reports Related Functions
-
Interactive CLI
-
Special Topic