Skip to content

Commit

Permalink
updated sls and added runAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
devaKumaraswamy committed Sep 17, 2018
1 parent 8e65572 commit 56c02d6
Show file tree
Hide file tree
Showing 48 changed files with 538 additions and 1,676 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "score",
"program": "${workspaceFolder}\\index.js"
}
]
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Changes

# Version 0.5.0

- Added AWS serverless functions for scroing and sentiment analysis
- cleaned up the examples
- Added an inventory of the examples in the README.md file


# Version 0.5.1

- Added sls-image serverless example

# Version 0.6.0

## Organization of repository
- Moved all nodejs samples into the examples/samples sub-directory. Makes it easier to view the repository

## Serverless functions
- Moved all the common parts of serverless.yml into awsenv.yml in the root directory.
- Added index.js to the root of each serverless functions to export the entries to serverless.yml. Motivation was the next item.
- Added runAPI.js to help with debugging the serverless functions end points(see README file for more information)
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,42 @@ The serverless subdirectory has examples of using restaf to build AWS serverless
- sls-image - display an image for a SAS VA report


### Configuring the serverless.yml

In this version the serverless.yml references the awsenv.yml file to get information that is usually common between all
the serverless functions ( vpc, subnets etc...).


## Poor Man's version of debugging of Serverless functions

IDE's like VSCode have capability to debug serverless functions. But not all users use this IDE.
So I built a very simple way to invoke the API endpoints in nodejs debugger.

### Configuration

In the env file add the following three options (see reataf.env for an example)

```
SLS=<serverless function name in examples dir> <-- ex: sls-scoreAstore
SLSPATH=path <-- the specific sls path ex: score
SLSPAYLOAD=<payload file path> <-- a json file with the payload(if POST or PUT)ex: score.json
```

### Execution

To run with nodejs inspect issue the following command

```
npm run debugAPI <envfile with the information discussed above>
```

Then follow standard nodejs debugging process

To run without debug turned on issue the following command

```
npm run runAPI <envfile with the information discussed above>
16 changes: 16 additions & 0 deletions awsenv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

role: arn:yourrole
vpc:
securityGroupIds:
- sg1
subnetIds:
- subnet1
- subnet2
deploymentBucket:
name: bucket1
environment:
VIYA_SERVER: http://xx.xxx.xx.xx
CLIENTID: raf
CLIENTSECRET: raf
USER: superuser
PASSWORD: superfly
12 changes: 0 additions & 12 deletions change.md

This file was deleted.

Binary file added data/astoreLarge/Simple_CNN.astore
Binary file not shown.
Binary file added data/sasdata/Simple_CNN.sashdat
Binary file not shown.
73 changes: 0 additions & 73 deletions examples/codeTable.js

This file was deleted.

4 changes: 3 additions & 1 deletion examples/addCaslib.js → examples/samples/addCaslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let restaf = require('restaf');
let payload = require('./config')('restaf.env');
let casSetup = require('./lib/casSetup');
let runAction = require('./lib/runAction');
let path = '/u/kumar/casdata/astore'; /* this must be accessible to CAS server */

let store = restaf.initStore();

Expand All @@ -34,12 +35,13 @@ async function example (store, payload, ...actionSets) {
activeOnAdd: true,
dataSource : { srcType: 'path' },
name : 'mycaslib',
path : '/xyz',
path : path,
subdirectories: false
}
}

let r = await runAction(store, session, p, 'Assign caslib')


}
example(store, payload,null)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions examples/serverless/sls-image/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* ------------------------------------------------------------------------------------
* Copyright (c) SAS Institute Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ---------------------------------------------------------------------------------------
*
*/
'use strict';

let app = require('./src/app').app;
let image = require('./src/image').image;

module.exports = { app, image};
1 change: 0 additions & 1 deletion examples/serverless/sls-image/lib/setError.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ module.exports = function setError(data) {
headers : {"Content-Type": "text/plain"},
body : (typeof data === 'object' ) ? JSON.stringify(data) : data
}
console.log(JSON.stringify(err, null, 4));
return err;
}
Loading

0 comments on commit 56c02d6

Please sign in to comment.