-
Notifications
You must be signed in to change notification settings - Fork 3
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
Calculator api #45
Comments
@James-Crean I'm not clear on this issue if you're waiting for me to take some action, or if you have it under control for the time being. Last time we chatted, I thought this was going to end up being mostly a pass-through functionality in Let me know if this is not the case, or you think we need to discuss a bit more. |
At the end of our last meeting it was undecided if we should use Sam's compute graph or if we should send python strings. Once a solution is agreed upon we can begin to work toward designing the API. You are correct in thinking that vcs-js will be doing most of the work. The core idea is that the frontend should only be storing a set of actions/operations. These actions should be sent with a plot request, and vcs-js will execute these actions and manipulate the data before plotting. The reason we need the series of commands to be executed on the fly is so that the undo/redo functionality works, as well as allowing users the convenience of saving and loading what they are doing. |
@James-Crean you mentioned that we should parse the expression before we eval it for security reasons. I think this is a valid concern and we should do it. Not sure what parser we should use for that. Do you need parsing for anything else in the front-end? What do you need to do for an undo operation? I assume you need to remove the temporary variable created. Anything else? |
The undo/redo library on the frontend is not very flexible. Neither redux nor the undo library provide hooks/events to allow me to run code before/after the undo action is resolved. The general idea is that these state changes should be "pure" (Without side effects). I am still wary of eval'ing python strings. My understanding was that allowing any sort of web service that would run arbitrary python code from users would be almost impossible to get approved by security. It would also defeat the purpose of having a "calculator" since we could just provide a pseudo python interpreter. A cursory glance at stack overflow yields: https://stackoverflow.com/questions/3513292/python-make-eval-safe?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa From what I can tell, there are alternatives and workarounds, but it gets into parsing grammars and abstract syntax trees. Is there a better/simpler method of making it secure that I don't know about? |
We need an api for calculations on variables. To start out we are looking to support '+', '-', '*', '/', 'power', and 'regrid'.
From vCDAT's perspective, the user will be able to select a variable/value, an operation, and another variable/value. They also have the ability to specify a variable name to store the result in.
Here are a few issues I can think of off the top of my head:
u + v
, users need to be able to specify constants as well:u + 100
100 + u
u + print "should not print"
clt2 = clt + 100
clt = clt + 100
. Suppose the following:clt
clt = clt + 100
@scottwittenburg and @doutriaux1 let me know your thoughts and ideas.
The text was updated successfully, but these errors were encountered: