Giter VIP home page Giter VIP logo

discovery-nodejs's Introduction

# DEPRECATED

This demo and repo is no longer supported. You can find the newly supported Discovery demo here.

๐Ÿ”Ž Discovery Demo

Use the IBM Watson Discovery service to add a cognitive search and content analytics engine to your applications to identify patterns, trends and actionable insights that drive better decision-making.

Travis semantic-release

demo

Demo: https://discovery-news-demo.ng.bluemix.net/

Prerequisites

  1. Sign up for an IBM Cloud account.
  2. Download the IBM Cloud CLI.
  3. Create an instance of the Discovery service and get your credentials:
    • Go to the Discovery page in the IBM Cloud Catalog.
    • Log in to your IBM Cloud account.
    • Click Create.
    • Click Show to view the service credentials.
    • Copy the apikey value, or copy the username and password values if your service instance doesn't provide an apikey.
    • Copy the url value.

Configuring the application

  1. In the application folder, copy the .env.example file and create a file called .env

    cp .env.example .env
    
  2. Open the .env file and add the service credentials that you obtained in the previous step.

    Example .env file that configures the apikey and url for a Discovery service instance hosted in the US East region:

    DISCOVERY_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
    DISCOVERY_URL=https://gateway-wdc.watsonplatform.net/discovery/api
    
    • If your service instance uses username and password credentials, add the DISCOVERY_USERNAME and DISCOVERY_PASSWORD variables to the .env file.

    Example .env file that configures the username, password, and url for a Discovery service instance hosted in the Sydney region:

    DISCOVERY_USERNAME=522be-7b41-ab44-dec3-g1eab2ha73c6
    DISCOVERY_PASSWORD=A4Z5BdGENrwu8
    DISCOVERY_URL=https://gateway-syd.watsonplatform.net/discovery/api
    

Running locally

  1. Install the dependencies

    npm install
    
  2. Build the application

    npm run build
    
  3. Run the application

    npm start
    
  4. View the application in a browser at localhost:3000

Deploying to IBM Cloud as a Cloud Foundry Application

  1. Build the application

    npm run build
    
  2. Login to IBM Cloud with the IBM Cloud CLI

    ibmcloud login
    
  3. Target a Cloud Foundry organization and space.

    ibmcloud target --cf
    
  4. Edit the manifest.yml file. Change the name field to something unique. For example, - name: my-app-name.

  5. Deploy the application

    ibmcloud app push
    
  6. View the application online at the app URL, for example: https://my-app-name.mybluemix.net

Tests

Unit tests

Run unit tests with npm run test-unit, then a to run all tests. See the output for more info.

Integration tests

First you have to make sure your code is built: npm run build

Then run integration tests with: npm run test-integration-runner

Directory structure

.
โ”œโ”€โ”€ app.js                      // express routes
โ”œโ”€โ”€ config                      // express configuration
โ”‚   โ”œโ”€โ”€ error-handler.js
โ”‚   โ”œโ”€โ”€ express.js
โ”‚   โ””โ”€โ”€ security.js
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ public                      // static resources
โ”œโ”€โ”€ server.js                   // entry point
โ”œโ”€โ”€ test                        // integration tests
โ””โ”€โ”€ src                         // react client
    โ”œโ”€โ”€ __test__                // unit tests
    โ””โ”€โ”€ index.js                // app entry point

License

This sample code is licensed under the MIT License.

Contributing

See CONTRIBUTING.

Open Source @ IBM

Find more open source projects on the IBM Github Page

discovery-nodejs's People

Contributors

apaparazzi0329 avatar atambo avatar dependabot[bot] avatar ehdsouza avatar germanattanasio avatar jeanlange avatar jsstylos avatar kognate avatar mamoonraja avatar maniax89 avatar savitanagaraj avatar sirspidey avatar zachary-dernar 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  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

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

discovery-nodejs's Issues

Add telium

We need to make sure the demo loads

function loadAnalytics() {
  var idaScript = document.createElement('script');
  idaScript.src = '//www.ibm.com/common/stats/ida_stats.js';
  document.head.appendChild(idaScript);
}

window.addEventListener('load', loadAnalytics);

Trying to Deploy on BlueMix by Pressing button on ReadMe fails with the following errors

By pressing the "Deploy to Bluemix" button in the readme and making no changes to the code. The following is my log file.

Also REACT_APP_BLUEMIX_ANALYICS: is not in my manifest.yml file, but DEMO_DEPLOY apprears to be in it place.

My intention is to get this to run on one of my Discovery collections... Does the discovery collection have to be a standard collection?

Thanks in advance for the Feedback.

Jon
--------------------------------------------------------------- Log file
Preparing to start the job...
Preparing the build artifacts...
Target: https://api.ng.bluemix.net
FAILED
Service instance Discovery-Demo not found
Creating service instance Discovery-Demo in org [email protected] / space dev as [email protected]...
OK

Create in progress. Use 'cf services' or 'cf service Discovery-Demo' to check operation status.

Attention: The plan standard of service discovery is not free. The instance Discovery-Demo will incur a cost. Contact your administrator if you think this is in error.

Writing manifest.yml...
Manifest file written
name: watson-discovery-service-news-demo-JonD-1
instances: 5
memory: 512M
command: node server.js
services:

  • Discovery-Demo
    env:
    REACT_APP_BLUEMIX_ANALYICS:

Pushing new app:watson-discovery-service-news-demo-JonD-1
FAILED
Error reading manifest file:
env var 'REACT_APP_BLUEMIX_ANALYICS' should not be null

Finished: FAILED

Pain points with "View Query"

  • Queries for each insight pane (Top Stories, Top Entities, etc) are all the same, but the responses are different.
  • It is difficult to understand how to construct an API request from the queries.
  • Query should be called "Request", because in the Query pane there is a field called "query"

Right now:

  • Demo makes a single API call and uses sections of the response for different insights
  • "View Query" Query tab is identical for each pane
  • Response tab is different for each pane

image

image

What should happen:

  • Separate requests for each pane to facilitate easy understanding. When someone views the request for the Top Entities pane, they should learn how to get Top Entities alone, not Top Entities, Concepts, Sentiment, etc.
  • Or the app should more clearly explain that the response in each section is a subset of the single large response
  • "View Query" button and "Query" tab should be called "View Request" / "Request", because Discovery has a specific parameter called "query" that is shown in the "Query" tab

can't deploy app to cloud

Hi!

At the time of doing the deployment, i have this error:

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 crashed
FAILED
Error restarting application: Start unsuccessful

The application log error shows the following:

2018-08-30T16:23:33.02-0300 [APP/PROC/WEB/0] OUT > @ibm-watson/[email protected] start /home/vcap/app
2018-08-30T16:23:33.02-0300 [APP/PROC/WEB/0] OUT > node scripts/start.js
2018-08-30T16:23:33.71-0300 [APP/PROC/WEB/0] OUT Server running on port: 8080
2018-08-30T16:23:34.19-0300 [CELL/0] OUT Container became healthy
2018-08-30T16:23:36.39-0300 [APP/PROC/WEB/0] OUT Something is already running on port 8080.
2018-08-30T16:23:36.49-0300 [APP/PROC/WEB/0] OUT Exit status 0

Change titles for consistency

The hosted demo is at a URL that contains: discovery-news-demo.

Let's change the repo name to: watson-developer-cloud/discovery-news-demo.

And change the main readme title to: "Discovery News Demo".

Can't deploy to cloud

@germanattanasio - this works fine when running locally, but I'm running into an issue when trying to deploy to cloud. Note that there is no other app in my space with this name, and that there are no log errors in the app log from the IBM Cloud UI.

rhagarty@Richs-MBP-15 discovery-nodejs (master) $ ibmcloud app push
Invoking 'cf push'...

Pushing from manifest to org IBM Cloud Storage / space dev as [email protected]...
Using manifest file /Users/rhagarty/journeys/discovery-nodejs/manifest.yml

Deprecation warning: Specifying app manifest attributes at the top level is deprecated. Found: command, env, instances, memory, name, services.
Please see http://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#deprecated for alternatives and other app manifest deprecations. This feature will be removed in the future.

Using manifest file /Users/rhagarty/journeys/discovery-nodejs/manifest.yml

Creating app discovery-news-demo-crawl-date in org IBM Cloud Storage / space dev as [email protected]...
OK

Creating route discovery-news-demo-crawl-date.mybluemix.net...
OK

FAILED
Server error, status code: 400, error code: 210003, message: The host is taken: discovery-news-demo-crawl-date

react-scripts ENOENT

Error from logs:

[email protected] start C:\GitHub\discovery-nodejs
node scripts/start.js

Server running on port: 5000
ERROR: Error: spawn ./node_modules/.bin/react-scripts ENOENT
events.js:160
throw er; // Unhandled 'error' event
^

Error: spawn pkill ENOENT
at exports._errnoException (util.js:1018:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3

After debugging for a long time, I eventually had to modify scripts/start.js to use 'exec' instead of 'spawn' to make it work. Here is the page that talks about the issue with spawn on Windows machines and cross-platform executions:

https://nodejs.org/api/child_process.html#child_process_spawning_bat_and_cmd_files_on_windows

Please let me know if you happen to know a better way to solve this issue. Thanks.

Demo code fails to start on IBM Cloud

Hi
Steps:

  1. Cloned github 'discovery-nodejs' code to local machine.
  2. Created .env file and edited to include required 'Discovery service' elements.
  3. Edited manifest.yml file to include my discovery service, and application name, etc.
  4. ran "cf push" to upload code into my ibm cloud space.
  5. Application starts then crash with following error;
2018-10-31T07:36:33.45+0000 [APP/PROC/WEB/0]OUT Server running on port: 8080
2018-10-31T07:36:33.45+0000 [APP/PROC/WEB/0]OUT ERROR: Error: spawn ./node_modules/react-scripts/bin/react-scripts.js ENOENT
2018-10-31T07:36:33.56+0000 [APP/PROC/WEB/0]OUT Exit status 0
2018-10-31T07:36:33.58+0000 [CELL/SSHD/0]OUT Exit status 0
2018-10-31T07:36:33.61+0000 [CELL/0]     OUT Cell a7187c69-5c2d-412a-960d-687d643f9e53 stopping instance 9c569aa7-1d9f-4d57-7e85-5a71
2018-10-31T07:36:33.61+0000 [CELL/0]     OUT Cell a7187c69-5c2d-412a-960d-687d643f9e53 destroying container for instance 9c569aa7-1d9f-4d57-7e85-5a71
2018-10-31T07:36:33.66+0000 [API/7]      OUT App instance exited with guid 5cbabf15-a6ea-4bbe-8ed0-9798a3df4229 payload: {"instance"=>"9c569aa7-1d9f-4d57-7e85-5a71", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"Codependent step exited", "crash_count"=>61, "crash_timestamp"=>1540971393597529186, "version"=>"9f76e2e9-7d63-4800-ac43-c09ea0de71d0"}
2018-10-31T07:36:40.24+0000 [CELL/0]     OUT Cell a7187c69-5c2d-412a-960d-687d643f9e53 successfully destroyed container for instance 9c569aa7-1d9f-4d57-7e85-5a71
2018-10-31T07:52:39.45+0000 [CELL/0]     OUT Cell 38493bb6-b0fc-4c81-a0ef-05c0416d2c3e creating container for instance f101cfcd-e4cb-
  1. Tried some of the fixes detailed in #89 issue, but these also failed.

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.