Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI service MVP #95

Closed
wants to merge 19 commits into from
Closed

UI service MVP #95

wants to merge 19 commits into from

Conversation

damienkilgannon
Copy link
Contributor

Pull request to provide the first steps to satisfying #25.

A simple angularjs + Flask UI provides a UI to the user to check status of the Scrapy Cluster and submit crawl requests easily.

The status checks and crawl requests are provided via the rest service.

@damienkilgannon damienkilgannon changed the title Dev UI service MVP Feb 2, 2017
@coveralls
Copy link

coveralls commented Feb 2, 2017

Coverage Status

Coverage increased (+0.02%) to 67.237% when pulling 08d09bc on damienkilgannon:dev into 3f20ea1 on istresearch:dev.

@damienkilgannon
Copy link
Contributor Author

Screen grab of the UI as it is currently ...

image

@madisonb
Copy link
Collaborator

madisonb commented Feb 4, 2017

@damienkilgannon This is an awesome start, great job! Here is what I have done:

  1. Started up scrapy cluster with docker-compose up -d, the Rest service returns
$ curl localhost:5343
{
  "kafka_connected": true,
  "my_id": "fc6c7bc9ae7e",
  "node_health": "GREEN",
  "redis_connected": true,
  "uptime_sec": 249
}
  1. Installed the python reqs from the /ui folder, and then ran the ui service
$ python ui_service.py
2017-02-04 11:00:05,013 [ui_service] INFO: Running main flask method on port 5000
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
  1. When I hit the main ui in my browser at localhost:5000, I get the following:

screen shot 2017-02-04 at 10 58 22 am

and the logs say
2017-02-04 11:00:09,587 [ui_service] INFO: 'index' endpoint called
127.0.0.1 - - [04/Feb/2017 11:00:09] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [04/Feb/2017 11:00:09] "GET /static/js/app.js HTTP/1.1" 200 -
127.0.0.1 - - [04/Feb/2017 11:00:09] "GET /static/angular_settings.js HTTP/1.1" 200 -
127.0.0.1 - - [04/Feb/2017 11:00:09] "GET /static/css/style.css HTTP/1.1" 200 -
127.0.0.1 - - [04/Feb/2017 11:00:09] "GET /static/img/logo.png HTTP/1.1" 200 -
127.0.0.1 - - [04/Feb/2017 11:00:10] "GET /static/partials/overview.html HTTP/1.1" 200 -
127.0.0.1 - - [04/Feb/2017 11:00:10] "GET /favicon.ico HTTP/1.1" 404 -

I don't think the 404 is the issue here, but perhaps it is.

  1. I clicked through the other pages, but I see they are blank (as far as I can tell). The form submission for a crawl request also doesnt work, but again I am not sure if it is because of my initial error above.

Regardless, I think we should work on this with the goal of it being released with v1.3, given that Milestone 1.2 is so close. I would like to actually merge this into a new branch ui and then create a bunch of tasks/tickets/checkboxes for things we need to do.

Off the top of my head I can think of the following:

  • Documentation
  • Unit Testing
  • Figuring out why Travis CI wants 'python path' set in run_tests.sh
  • Filling out
    • Crawlers
    • Kafka
    • Redis (do we rename these to "Redis/Kafka Monitor")
  • Cluster Debug
  • Docker (main and alpine python images)
  • Travis Testing
    etc from our discussions on UI for displaying information about Cluster #25

From there, you/I can work and make PR's onto the ui branch and then when we are happy with it, merge into dev -> master to be included in an official release.

Thoughts? Really nice initial work!

@damienkilgannon
Copy link
Contributor Author

Sounds, good ... i would think that error is as a result of making request to the rest service at the wrong IP:PORT. The ui is running javascript in your browser which makes GET/POST requests to the rest service, its defaults to localhost and as the ui is running on your browser (not the same host as the rest service) it fails. Need to change to edit ui/static/angular_settings.js to reflect the IP of the virtual machine which the rest service is running on.
Will I move the UI stuff to a new branch on the pull request or do you want to create a new branch first?

@madisonb
Copy link
Collaborator

madisonb commented Feb 12, 2017

Do you have any suggestions for the 404 error? I can hit http://localhost:5343/(which is what my angular settings say) and get a return value, but the UI still doesn't quite function.

EDIT: In the console the following error occurs:

XMLHttpRequest cannot load http://localhost:5343/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5000' is therefore not allowed access.

EDIT 2: Everything returns 200 in the network inspector, except for the minified angular js which is a 307

@@ -142,6 +143,7 @@ def __init__(self, settings_name):
self.wrapper = SettingsWrapper()
self.logger = None
self.app = Flask(__name__)
CORS(self.app)
Copy link
Contributor Author

@damienkilgannon damienkilgannon Feb 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madisonb the CORS module adds support for cross origin requests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 'No 'Access-Control-Allow-Origin'' should be not be an issue as the CORS modules adds the required HTTP headers to the HTTP messages to allow cross origin requests.

Following your second EDIT .... are you still getting that error?

@damienkilgannon
Copy link
Contributor Author

image

@madisonb if you have a look at the above screenshot you will see that my client browser connecting to the UI service, note that the request to the REST service from the UI is not via 'localhost' but the IP of the vagrant machine at 'http://192.168.33.99:5343/'.
On your local machine is the REST and UI service running on your localhost or the vagrant? If they are running on the vagrant you need to edit the 'angular_settings' to reflect the IP of the vagrant machine.

@damienkilgannon
Copy link
Contributor Author

@madisonb does that make sense? I think as the IP of the Vagrant machine is set in the 'Vagrantfile' as 192.168.33.99, I should change the default from localhost -> 192.168.33.99.

@madisonb
Copy link
Collaborator

madisonb commented Feb 15, 2017

@damienkilgannon ah ok, I typically just use docker or run the scripts on my host os in order to test/debug stuff. Can you check to see if the problem works with the following setup (and how do we resolve it)?

  • run docker-compose up -d, make sure curl from your host os your can curl localhost:5343
  • Run the ui server from your local machine

This is my setup which ends up complaining.

@damienkilgannon
Copy link
Contributor Author

I will try with that setup later this evening and see how it can be fixed

@damienkilgannon
Copy link
Contributor Author

@madisonb I have replicated the issue and its a CORS problem but unsure why its on issue with docker environment on not vagrant. Will revert back when I have fix.

@madisonb
Copy link
Collaborator

madisonb commented Mar 4, 2017

@damienkilgannon I haven't forgotten about this, would like to get the CORS issue fixed and then can merge this into a ui branch so we can do more work. Any help needed?

@damienkilgannon
Copy link
Contributor Author

@madisonb never got a chance to resolve the problem .... I have time this weekend so going to look at it now.

@damienkilgannon
Copy link
Contributor Author

@madisonb so I made some changes, created a route decorator for the rest service which adds the CORS headers to response in a better way than I had set up before. However that wasn't the problem. The reason it doesn't work with docker is due to the fact that docker pulls the 'rest service' image from the repo which doesn't have the changes I added to allow cross origin requests. For you to run it locally you need to run the rest service and the UI service as they are in my pull request. Does that make sense?

@damienkilgannon
Copy link
Contributor Author

Sorry didn't mean to create that merge request!

@damienkilgannon
Copy link
Contributor Author

@madisonb not sure what is causing two of the builds to fail, can you have a look?

@coveralls
Copy link

coveralls commented Mar 20, 2017

Coverage Status

Coverage increased (+0.1%) to 65.844% when pulling 71e790a on damienkilgannon:dev into 2956780 on istresearch:dev.

@damienkilgannon
Copy link
Contributor Author

@madisonb I just ran that build job again and all passed. What else would you like me to add in before starting a new branch and merging the pull request into that branch? Is it your plan to have a separate branch for the UI ?

@madisonb
Copy link
Collaborator

@damienkilgannon My plan of attack is as follows:

  • Wrap up this PR testing for the 👍
  • Merge it into a new ui branch where we can continue to add features/unit tests/docs/etc
  • When ready, merge it into dev to be included as part of 1.3

I have been working hard on wrapping up milestone 1.2 so once that is completed that opens up a lot more time to work on this. However, if you would like to continue adding features to this PR my workflow will not change

@damienkilgannon
Copy link
Contributor Author

Sounds good with me. I will continue working on the PR for the time been.

@madisonb
Copy link
Collaborator

Closing as I have merged this branch into a new ui branch. All subsequent PR's for UI activity should go there until that branch is merged into dev

Please see #116 for remaining checklist to get the UI merged into dev.

@madisonb madisonb closed this Apr 13, 2017
@madisonb madisonb mentioned this pull request Jul 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants