IBM/acme-freight-recommendation

Name: acme-freight-recommendation

Owner: International Business Machines

Description: null

Created: 2017-04-06 20:37:33.0

Updated: 2017-06-09 20:35:56.0

Pushed: 2017-07-10 15:52:05.0

Homepage: null

Size: 1647

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

| master | Build Status Coverage Status | | —– | —– | | dev | Build Status Coverage Status|

Acme Freight - Weather Recommendation

This service is part of the larger Acme Freight project.

Overview

This service monitors the weather conditions around retail stores and makes recommendations on additional shipments of goods.

It is built with OpenWhisk highlighting how OpenWhisk can be used to implement a backend API. The OpenWhisk actions are:

Simulating weather events

For demo purpose, the Recommend action can be called interactively to inject a weather event into the system.

Running the app on Bluemix
  1. If you do not already have a Bluemix account, sign up here

  2. The recommendation service depends on the Controller and ERP microservices. Make sure to deploy them first.

  3. In Bluemix, create an instance of the Weather Company Data service

    reate-service weatherinsights Free-v2 acme-freight-weatherinsights
    
  4. Create a set of credentials for this service

    reate-service-key acme-freight-weatherinsights for-openwhisk
    
  5. View the credentials and take note of the url value

    ervice-key acme-freight-weatherinsights for-openwhisk
    
  6. Create an instance of Cloudant to store the recommendations

    reate-service cloudantNoSQLDB Lite acme-freight-recommendation-db
    
  7. Create a set of credentials for this service

    reate-service-key acme-freight-recommendation-db for-openwhisk
    
  8. View the credentials and take note of the url value

    ervice-key acme-freight-recommendation-db for-openwhisk
    
  9. Clone the app to your local environment from your terminal using the following command:

    clone https://github.com/ibm/acme-freight-recommendation.git
    
  10. cd into the checkout directory

  11. Copy the file named template-local.env into local.env

    emplate-local.env local.env
    
  12. In local.env, update the location of the CONTROLLER_SERVICE, the url of the Weather Company Data service, the url of the Cloudant database.

  13. Get the dependencies, and use webpack module bundler to create our final .js actions in the dist folder.

    install
    run build
    
  14. Ensure your OpenWhisk command line interface is property configured with:

    list
    

    This shows the packages, actions, triggers and rules currently deployed in your OpenWhisk namespace.

  15. Deploy the OpenWhisk artifacts

    ploy.sh --install
    

    Note: the script can also be used to –uninstall the OpenWhisk artifacts to –update the artifacts if you change the action code, or simply with –env to show the environment variables set in local.env.

Code Structure

| File | Description | | —- | ———– | |deploy.sh|Helper script to create the recommendations database, install, uninstall, update the OpenWhisk trigger, actions, rules.| |template-local.env|Contains environment variables used by the deployment script. Duplicate this file into local.env to customize it for your environment.| |package.json|List dependencies used by the actions and the build process.| |webpack.config.js|Webpack configuration used to build OpenWhisk actions. This allows the actions to use modules (module versions) not packaged natively by OpenWhisk. Make sure to add explicit dependencies in the package.json for specific module versions used by the actions. The webpack build will look at the “dependencies” and webpack them. If a module is not listen in “dependencies” it is assumed to be provided by OpenWhisk.| |recommend.js|Entry point for the Recommend action.| |prepare-for-slack.js|Entry point for the Notify action. It formats newly added recommendations into a text suitable for a Slack post message.| |retrieve.js|Entry point for the Retrieve action.| |acknowledge.js|Entry point for the Acknowledge action.| |observations.js|Entry point for the Observations action.| |test|Unit test for the actions to be executed outside of OpenWhisk.|

Troubleshooting

Polling activations is good start to debug the OpenWhisk action execution. Run

activation poll

and invoke actions.

License

See LICENSE for license information.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.