[IPython-dev] is it possible to pass parameters to IPython notebook via URL?

Mark Voorhies mark.voorhies at ucsf.edu
Sun May 11 17:27:26 EDT 2014


On 05/10/2014 11:51 PM, Roman Max. wrote:
> Many thanks for following up on this thread. I would like to use IPython notebook to perform and present some analytics in a .NET application. I've got a CefSharp (chrome) component integrated and can display notebook's output. Now trying to figure out how to pass parameters, so notebook calculates some analytics per selected object. E.g. depending on a selected object .NET prepares a CSV data input file, then the path of this file would need to be passed to an IPython notebook for further processing. After looking at your Singlecell.py code I think I start to understand where you are heading with giving hints with respect to JavaScript. Essentially .NET app could prepare HTML/Javascrpit part each time a new object is selected and pass it then over to IPython kernel for execution? Porbably will work, just doesn't look so clean, since python logic code will be in javascript files.
> would be still nice to have a way to communicate with the IPython only via URL, as not always client side presentation part(Javascript) can be involved.

Will the presented notebook result be interactive, or will all user interaction be via your .NET interface?

If the latter, is there any disadvantage to just executing numpy/matplotlib/etc. code directly in a CPython or IronPython interpreter?

--Mark

> RM
>
> From: benjaminrk at gmail.com
> Date: Fri, 9 May 2014 13:43:07 -0700
> To: ipython-dev at scipy.org
> Subject: Re: [IPython-dev] is it possible to pass parameters to IPython notebook via URL?
>
> On Fri, May 9, 2014 at 1:25 PM, Roman Max. <rmx555 at hotmail.com> wrote:
>
>
>
>
>
>
>
>
> OK, thanks for clarifying it once again. Javascript API means user needs to interact with the page once it's already loaded?
>
>
>
> Yes. Or you can add custom javascript to the page to take action based on the parameters once the page is loaded.  But again, I wouldn’t recommend doing this, because it may conflict with server changes in the future. If you go this route, I would suggest using # instead of ?, since it would really be client-side only information.
>
>
>
>
>
>
> do you plan for such an enhancement (passing parameters via URL to notebooks)?
>
>
> No. The HTML/Javascript context of the page and notebook server are strongly decoupled from the Python environment of the Kernel. We have no plan to change this.
>
>
>
> or which class would I need to modify to implement support for this?
>
>
> At least a few:
>
> the NotebookHandler, which renders the notebook page, which will receive the URL with parameters, but is not the URL that starts the kernel.
> the KernelManager, which starts the kernel, which would need to be told about these parameters
> possibly the Kernel itself, for taking the actual actions you wish these parameters to imply in the kernel process.
>
> Depending on how much javascript you customize, there are probably a few combinations of classes to modify.
> Can we back up a bit, and ask what you want to accomplish by passing these parameters? There may be a simpler solution than subclassing the entire notebook server.
> -MinRK
>
>
>
> From: benjaminrk at gmail.com
> Date: Thu, 8 May 2014 16:03:15 -0700
> To: ipython-dev at scipy.org
>
>
> Subject: Re: [IPython-dev] is it possible to pass parameters to IPython notebook via URL?
>
>
>
>
> On Thu, May 8, 2014 at 11:51 AM, Roman Max. <rmx555 at hotmail.com> wrote:
>
>
>
>
>
>
>
> Many thanks for the reply, I see. Indeed I am looking for a way to pass parameters to the Python code on the kernel, e.g. .NET app calling out a notebook with parameters and displaying output.So, essentially the notebook server doesn't support this sort of interaction at the moment? I assume I could do it by cloning and modifying .ipynb template file before each request, still hoping there is a better way than that.
>
>
>
>
>
> No, the server definitely doesn't support URLs affecting the kernel. If you want to execute code on the Kernel, you would do this via the Javascript APIs.
>
>
>
>
> -MinRK
>
> From: benjaminrk at gmail.com
>
>
>
>
> Date: Thu, 8 May 2014 10:47:16 -0700
> To: ipython-dev at scipy.org
> Subject: Re: [IPython-dev] is it possible to pass parameters to IPython notebook via URL?
>
>
>
>
>
> You can do this, but I wouldn't recommend it. The parameters will only be available to the HTML/JS in the notebook page, and not the Python code on the kernel.  Plus, there is a chance that it would conflict with any future use of url parameters by the notebook server.
>
>
>
>
>
>
> -MinRK
>
> On Thu, May 8, 2014 at 10:11 AM, Roman Max. <rmx555 at hotmail.com> wrote:
>
>
>
>
>
>
>
>
>
>
>
> is it possible to pass parameters to IPython notebook via URL?
>
>
>
>
>
> How to reference/use those parameters in a notebook?
>
>
>
>
>
> e.g. http://xxxyyzz.org:8888/mynotebook.ipynb?d1=20140101&d2=20140401
>
>
>
>
>
>
>
>
>
>
> Did not find an answer after searching around. Thanks! 		 	   		
>
> _______________________________________________
>
> IPython-dev mailing list
>
> IPython-dev at scipy.org
>
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev 		 	   		
>
> _______________________________________________
>
> IPython-dev mailing list
>
> IPython-dev at scipy.org
>
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev 		 	   		
>
> _______________________________________________
>
> IPython-dev mailing list
>
> IPython-dev at scipy.org
>
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
>
>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev 		 	   		
>
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>





More information about the IPython-dev mailing list