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

Clyde Fare clyde.fare at gmail.com
Tue May 13 06:39:53 EDT 2014


"since python logic code will be in javascript files."

You can leave the python as a .py file and load it as text before passing
it to the kernel:

 $.get('/static/custom/my_file.py', function(python_code){
...
kernel.execute(python_code, callbacks)
}


Which can then be passed to the kernel.


On 12 May 2014 21:48, John Gill <jgill at tokiomillennium.com> wrote:

>  You can also use pythonnet to embed python in .NET
>
>
>
> *From:* ipython-dev-bounces at scipy.org [mailto:
> ipython-dev-bounces at scipy.org] *On Behalf Of *Roman Max.
> *Sent:* Monday, May 12, 2014 4:18 PM
>
> *To:* IPython developers list
> *Subject:* Re: [IPython-dev] is it possible to pass parameters to IPython
> notebook via URL?
>
>
>
> Hi, John,
>
>
>
> thanks for the suggestion, will have a look into the project. Although my
> use case assumes interaction the other way -- from .NET to Python.
>  ------------------------------
>
> From: jgill at tokiomillennium.com
> To: ipython-dev at scipy.org
> Date: Mon, 12 May 2014 13:14:23 +0000
> Subject: Re: [IPython-dev] is it possible to pass parameters to IPython
> notebook via URL?
>
> If you are working with python and .NET you should take a look at
> pythonnet:
>
>
>
> https://github.com/pythonnet/pythonnet
>
>
>
> It allows you to work seamlessly with .NET objects from python.
>
>
>
> John
>
>
>
> *From:* ipython-dev-bounces at scipy.org [mailto:
> ipython-dev-bounces at scipy.org] *On Behalf Of *Roman Max.
> *Sent:* Sunday, May 11, 2014 3:51 AM
> *To:* IPython developers list
> *Subject:* Re: [IPython-dev] is it possible to pass parameters to IPython
> notebook via URL?
>
>
>
> 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.
>
>
>
> 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
>
> This communication and any attachments contain information which is
> confidential and may also be legally privileged. It is for the exclusive
> use of the intended recipient(s). If you are not the intended recipient(s)
> please note that any form of disclosure, distribution, copying, printing or
> use of this communication or the information in it or in any attachments is
> strictly prohibited and may be unlawful. If you have received this
> communication in error, please return it with the title "received in error"
> to postmaster at tokiomillennium.com and then permanently delete the email
> and any attachments from your system.
>
>
>
> E-mail communications cannot be guaranteed to be secure or error free, as
> information could be intercepted, corrupted, amended, lost, destroyed,
> arrive late or incomplete, or contain viruses. It is the recipient's
> responsibility to ensure that e-mail transmissions and any attachments are
> virus free. We do not accept liability for any damages or other
> consequences caused by information that is intercepted, corrupted, amended,
> lost, destroyed, arrives late or incomplete or contains viruses.
>
> ******************************************
>
>
> _______________________________________________ IPython-dev mailing list
> IPython-dev at scipy.org http://mail.scipy.org/mailman/listinfo/ipython-dev
>
> This communication and any attachments contain information which is
> confidential and may also be legally privileged. It is for the exclusive
> use of the intended recipient(s). If you are not the intended recipient(s)
> please note that any form of disclosure, distribution, copying, printing or
> use of this communication or the information in it or in any attachments is
> strictly prohibited and may be unlawful. If you have received this
> communication in error, please return it with the title "received in error"
> to postmaster at tokiomillennium.com and then permanently delete the email
> and any attachments from your system.
>
>
>
> E-mail communications cannot be guaranteed to be secure or error free, as
> information could be intercepted, corrupted, amended, lost, destroyed,
> arrive late or incomplete, or contain viruses. It is the recipient's
> responsibility to ensure that e-mail transmissions and any attachments are
> virus free. We do not accept liability for any damages or other
> consequences caused by information that is intercepted, corrupted, amended,
> lost, destroyed, arrives late or incomplete or contains viruses.
>
> ******************************************
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140513/dc84fbbf/attachment.html>


More information about the IPython-dev mailing list