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

Add a reloader to restart the controller #37

Open
ba11b0y opened this issue Dec 27, 2018 · 11 comments
Open

Add a reloader to restart the controller #37

ba11b0y opened this issue Dec 27, 2018 · 11 comments

Comments

@ba11b0y
Copy link

ba11b0y commented Dec 27, 2018

This issue extends #137 in the hydrus repository.

Add a reloader which upon receiving the updated vocabulary from the UI, restarts the controller with the updated vocabulary.

@ba11b0y
Copy link
Author

ba11b0y commented Dec 28, 2018

@Mec-iS for the front end to send a request to the server to reload the docs, I will need a POST method on /api/#vocab/(while I am using GET to retrieve the docs). So should I add a supportedOperation on the URI or create a new endpoint?

@Mec-iS
Copy link
Contributor

Mec-iS commented Dec 28, 2018

I don't know if this is in-line with the spec, likely not. I suppose that creating a custom non-REST resource for the sake of the demo would be more appropriate. Probably finding a way to inject a /api/demo endpoint on the server and POST there the changed vocabulary would be more appropriate. This makes sense as it is a demo-related functionality, not something that has a general use. In the general use-case we would have some cloud-level tool that reboot the machine with the new vocabulary or re-route the URI to a new machine with a new vocabulary.

@ba11b0y
Copy link
Author

ba11b0y commented Dec 28, 2018

I wrote a patch for the Flask app instance, which still will have to be called in sim_controller.flock_controller.main. Not sure how to accomplish this without disturbing main.py, since it belongs to a different repo and is cloned before running the server.
I have pushed the code on my fork here

Also I am really not sure how to update the vocabulary because:

  • Replacing changed values in doc and writing it to doc.py. Not sure if this approach is good.

  • Making a call to doc_gen but it generates the same old vocabulary.

@Mec-iS Any help?

@Mec-iS
Copy link
Contributor

Mec-iS commented Dec 29, 2018

@xadahiya Please give a hint for the implementation ^

@xadahiya
Copy link
Member

The main point here is we need a way to change the controller API structure efficiently ( can be done by the user or by autonomously after some time for the sake of the demo).
The issue is restarting the central controller server cannot be done without using some external tool ( not via some POST request) but do we really need to restart the server? I don't think so.
See hydrus uses the API doc file to create a HydraDoc object which stays in memory until the server is stopped. We can directly modify the HydraDoc object then the API structure should change without restarting the server (Not entirely sure this will work but it's worth giving a shot). If we're able to do this then there will be the following benefits -

  • no need to modify doc.py
  • simply restarting the controller will reset the demo ( which is currently scheduled after every 2-3 hours) so even if someone brraks the API structure it'll fix itself after some time.

We'll need to modify hydrus a bit but since this is for the sake of demonstration and not the generic use case, it shouldn't be a problem.
Obviously there are a lot of other parts involved like we'll need to revamp the entire UI to demonstrate the interaction in a better way but once we're done, this would be a really cool project to show off.

@Mec-iS thoughts?

@vddesai1871
Copy link
Collaborator

do we really need to restart the server? I don't think so.
See hydrus uses the API doc file to create a HydraDoc object which stays in memory until the server is stopped. We can directly modify the HydraDoc object then the API structure should change without restarting the server

Sounds like a very neat and interesting approach.

Not entirely sure this will work but it's worth giving a shot

I think it will work perfectly fine for some apiDoc changes (ie. Change in the path(@id).

For some other changes relating to class title and labels, property names ( or removal of classes or properties) besides changing the HydraDoc we will have to make changes in hydrus to modify the values stored in the database (Right now, these values are stored when we start the server and then remains unchanged).
@xadahiya Correct me if I have misinterpreted your idea.

@xadahiya
Copy link
Member

I don't think we need to modify class names and properties for this demo.

@ba11b0y
Copy link
Author

ba11b0y commented Dec 30, 2018

@xadahiya I agree with not restarting the server via a POST request, but anyways you might want to have a look at this.
Also, since we are looking at making some changes in both hydrus and the central controller, does that mean we include these(a different version/branch just for the sake of demo) in the demo repository?

I had submitted a PR modifying the UI to include an Edit Controller Vocabulary button.

Obviously there are a lot of other parts involved like we'll need to revamp the entire UI to demonstrate the interaction in a better way but once we're done, this would be a really cool project to show off.

A related discussion here.

@Mec-iS
Copy link
Contributor

Mec-iS commented Dec 30, 2018

For sure we don't want to restart the machine, so possibly reloading the app or doing something with Python internals or even Python interpreter is the way to go.

@ba11b0y
Copy link
Author

ba11b0y commented Jan 1, 2019

@xadahiya Ping #37 (comment)

@xadahiya
Copy link
Member

xadahiya commented Jan 1, 2019

@xadahiya I agree with not restarting the server via a POST request, but anyways you might want to have a look at this.

@invinciblycool This might work as well. The main thing to focus is we want to modify hydrus as minimum as possible for demo.

Also, since we are looking at making some changes in both hydrus and the central controller, does that mean we include these(a different version/branch just for the sake of demo) in the demo repository?

The central controller is just hydrus with a different vocab. Keep the main idea in mind i.e we need to demonstrate how powerful hydrus and semantic web is. For that, keeping the number of changes to the generic hydrus version is of utmost importance. Let's take some time to explore our options before we proceed with this else it'll just be a waste of time and we'll need to start over.

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

No branches or pull requests

4 participants