Code Monkey home page Code Monkey logo

openwhisk-workshop's Introduction

OpenWhisk Workshop

๐ŸŽ‰ Welcome to the OpenWhisk workshop! ๐ŸŽ‰

OpenWhisk is a cloud-first distributed event-based programming service. It provides a programming model to upload event handlers to a cloud service, and register the handlers to respond to various events. Learn more at https://developer.ibm.com/openwhisk or try it on IBM Bluemix OpenWhisk.

This workshop provides a series of exercises to help you understand how to use OpenWhisk to build serverless applications.

Developers are introduced to each feature of the platform through these exercises. After reading the exercise documentation, they are presented with a challenge to test their skills. The tool automatically verifies whether they have passed that test and records their progress.

overview

installation

Please ensure you are running Node version 6 or above.

$ npm install -g openwhisk-workshop 

This tool needs the OpenWhisk command-line utility to be installed and authenticated against an instance of the platform. For more details on getting this environment setup, see the following documentation for a cloud setup here, or a local setup here.

usage

Once the tool is installed, developers can open the application by running the following command.

$ openwhisk-workshop

challenges

The list of exercises will be displayed, along with current completion progress. Using the arrow keys (โ†‘โ†“) to navigate the menu, press RETURN to open an exercise.

On selecting an exercise, the problem challenge will be printed to the terminal.

exercise

documentation

Each exercise comes with a documentation page which explains the concepts behind the challenge. Use the following command to display the exercise documentation in the terminal.

$ openwhisk-workshop more

Developers may need to write sample serverless functions and set up triggers and rules to implement the solutions.

verification

Once the developer has solved the challenge, they can verify their solution with the following command.

$ openwhisk-workshop verify

If their solution is correct, that task will be marked as completed and the utility returns to the list of exercises. Developers can continue working through the exercises until they have completed them all.

verify

exercises

Exercises are located in the exercises folder. The more.md file contains the documentation for the feature being introduced. The problem.md file contains the test for this exercise. The exercise.js file contains the JavaScript run to verify the exercise solution.

support

If you have problems with the workshop, please raise an issue in the repository.

Need more general help with OpenWhisk?

credits

This workshop tool uses the NodeSchool project.

openwhisk-workshop's People

Contributors

jthomas avatar jumapico avatar markusthoemmes avatar mrutkows avatar shazron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openwhisk-workshop's Issues

"Kind" value check fails in Creating NodeJS Actions

For the CREATING NODEJS ACTIONS:

https://github.com/openwhisk/openwhisk-workshop/blob/master/exercises/creating_nodejs_actions/exercise.js#L9
https://github.com/openwhisk/openwhisk-workshop/blob/master/exercises/creating_nodejs_actions/exercise.js#L41
https://github.com/openwhisk/openwhisk-workshop/blob/master/exercises/creating_nodejs_actions/exercise.js#L79

Three lines check for the kind value of nodejs:6.

const uses_nodejs = (stdout.match('"kind": "nodejs:6"'))

The returned value for kind is nodejs (using an older version of wsk CLI?), not nodejs:6 (see below):

wsk action get hello-world-nodejs-delay
ok: got action hello-world-nodejs-delay
{
    "annotations": [],
    "exec": {
        "code": "function main() {\n\treturn new Promise(function(resolve, reject) {\n\t\tsetTimeout(function() {\n\t\t\tresolve({message: \"Hello World\"});\n\t\t}, 3000);\n\t});\n}\n",
        "kind": "nodejs"
    },
    "limits": {
        "logs": 10,
        "memory": 256,
        "timeout": 60000
    },
    "name": "hello-world-nodejs-delay",
    "namespace": "------------------",
    "parameters": [],
    "publish": false,
    "version": "0.0.1"
}

Possible bug in task "Using Action Sequences"

When I select the task "Using Action Sequences" I get the following error:

/usr/local/lib/node_modules/openwhisk-workshop/exercises/using_action_sequences/exercise.js:35
    let found_message = false
    ^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:374:25)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Workshopper.loadExercise (/usr/local/lib/node_modules/openwhisk-workshop/node_modules/workshopper/workshopper.js:484:14)
    at Workshopper.onselect (/usr/local/lib/node_modules/openwhisk-workshop/node_modules/workshopper/workshopper.js:501:23)
    at emitThree (events.js:97:13)

I'm on an updated Ubuntu 16.04 64bit Desktop with NodeJS 4.2.6 and OpenWhisk Workshop 0.1.0.

PS:
This also doesn't switch the task, so even when I look at the Markdown file instead I cannot verify my solution with openwhisk-workshop verify.

PPS:
I just noticed that the same problem occurs for me for all following tasks as well - the previous ones work, but the ones afterwards break. This is unfortunate - I solved the sequence task on my own, but I really liked the verification to know my solution meets the requirements.

Workshop one fails due to namespace

I've been using wsk for a week or so now, but when I tried the first exercise I got a failure for:

OpenWhisk namespace set incorrectly

I know for a fact its setup right.

Ex7 typo

(Btw, I'm filing this, but will try to fix it myself too to help out - just depends on my available time today. :)

Ex 7 typo:

"This challenges involes"

should be

"This challenge involves"

Instructions with links are coming through in Markdown

For the parameters task, the help text prints this:

Request parameters are passed as an object through the first function parameter
for the runtime interface. Here's an example of using this with the NodeJS
runtime
https://github.com/openwhisk/openwhisk/blob/master/docs/actions.md#passing-parameters-to-an-action.

Default parameters for Actions can bound using the wsk command-line utility
https://github.com/openwhisk/openwhisk/blob/master/docs/actions.md#setting-default-parameters

Hopefully GitHub won't replace the Markdown...

Remove Geocoding API task

I already suggested breaking out that task into multiple, but I'd suggest removing the Geocoding task completely as it requires a dev to go out and get a key before using the API. That's not terribly difficult, but it is a process and it's a hassle a dev doesn't want to worry about when learning OpenWhisk.

Ex 7 typo

In the instructions:

string parameter (text) containing asentence

No space between "a" and "sentence".

Consider breaking up the actions task

The task for writing actions in NodeJS has you writing 3 actions, and while the first one is extremely trivial, the second and third are not. (Ok, the second is pretty easy too, but for a new user, it will be something they have to look up.) I really think they should be separate tasks.

Even if they were all really easy, my gut says NodeSchool tasks should do one thing at a time.

Missing start and end properties in hello-world-nodejs-delay response

For the second exercise in Creating NodeJS Actions, response is missing the start and end properties.

$openwhisk-workshop verify
โœ“ OpenWhisk Action hello-world-nodejs exists
โœ“ OpenWhisk Action hello-world-nodejs returns correct message
โœ“ OpenWhisk Action hello-world-nodejs-delay exists
/usr/local/lib/node_modules/openwhisk-workshop/exercises/creating_nodejs_actions/exercise.js:61
      const start_time = parseInt(stdout.match(/start": (\d+)/)[1], 10)
                                                               ^

TypeError: Cannot read property '1' of null
    at /usr/local/lib/node_modules/openwhisk-workshop/exercises/creating_nodejs_actions/exercise.js:61:64
    at /usr/local/lib/node_modules/openwhisk-workshop/node_modules/shelljs/src/exec.js:180:7
    at ChildProcess.exithandler (child_process.js:194:7)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:817:16)
    at Socket.<anonymous> (internal/child_process.js:319:11)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Pipe._onclose (net.js:469:12)

Running it manually to get response:

wsk action invoke hello-world-nodejs-delay -b
ok: invoked hello-world-nodejs-delay with id -----------------
response:
{
    "result": {
        "message": "Hello World"
    },
    "status": "success",
    "success": true
}

Add documentation on level of Node.js (4) and NPM required

I ran this on a Ubuntu 14.04 VM that I use as my wsk workstation. Installation worked, and I got the initial blue menu box, but when making a selection it died on the following error when choosing an exercise:

/usr/lib/node_modules/openwhisk-workshop/exercises/setting_up_cli/exercise.js:18
exec('wsk property get --apihost', {silent: true}, (code, stdout, stderr) => {
                                                                          ^^
SyntaxError: Unexpected token =>
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Workshopper.loadExercise (/usr/lib/node_modules/openwhisk-workshop/node_modules/workshopper/workshopper.js:484:14)
    at Workshopper.onselect (/usr/lib/node_modules/openwhisk-workshop/node_modules/workshopper/workshopper.js:501:23)
    at EventEmitter.emit (events.js:107:17)

I was able to work around the problem by manually upgrading to Node 4, which wasn't evident on the first VM I tried, but it was when the packaged failed to install at all on another Ubuntu 14.04 box.

Minor correction: Timeout in second task explanation is 2s, not 20s

You write "The setTimeout() JavaScript function in this case waits for twenty seconds
before calling the callback function.", but your code is

setTimeout(function() {
             resolve({ done: true });
             }, 2000);

setTimeout() takes milliseconds, so imho it should be 2s, not twenty.

NodeJS Delay Action failing

The task for the delay test says this:

Create an Action (hello-world-delay-nodejs) that returns the same message after an artificial delay of one second.

This to me means it should take, AT LEAST, 1000ms, so I used this:

function main() {
return new Promise(function(resolve,reject) {
setTimeout(resolve({"message":"Hello World"}),1000);
});
}

When I tried to verify, I got:

โœ— OpenWhisk Action hello-world-nodejs-delay returned response within 1000ms.

Which seems to imply it wants to return in less than 1000ms. So I changed my timeout to 100, and it didn't help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.