[IPython-dev] How to preconfigure notebook environment in v1.1?

Adam Sadovsky asadovsky at gmail.com
Thu Nov 14 15:32:09 EST 2013


For the record, I ended up achieving this by modifying KernelManager to
invoke the original script in a subprocess (rather than just calling zmq
main), and then configuring that binary, when called in kernel mode (i.e.
with "kernel" argument), to call IPython.start_kernel with the desired
user_ns passed in.

Is there any documentation for developers who want to better understand the
internal IPython APIs, specifically around kernels, applications, etc.? I
felt myself digging around somewhat blindly in order to figure this out,
and I'm sure there are better ways to do it (that don't require modifying
IPython internals).


--Adam


On Wed, Oct 30, 2013 at 10:32 PM, Adam Sadovsky <asadovsky at gmail.com> wrote:

> Hi Paul,
>
> Thanks for the reply! The reason I'd like to avoid startup files is that
> I'm trying to provide a library for others to use. As part of this library,
> I want it to be possible for people to start a notebook server where any
> new notebook has a certain set of things pre-imported for convenience. I
> suppose I could provide a startup file for users to place in their own
> startup dirs, but I'd like to avoid making users do any extra work. Ideally
> I'd like an option similar to what's offered in the interactive shell API,
> which allows users to pass in a user_ns object. Does that make sense?
>
> I should say, I'm relatively new to IPython/notebook and not very familiar
> with its architecture, so I certainly may be missing something obvious. :)
>
>
> --Adam
>
>
> On Wed, Oct 30, 2013 at 9:11 PM, Paul Ivanov <pi at berkeley.edu> wrote:
>
>> Adam Sadovsky, on 2013-10-30 20:28,  wrote:
>> > I recently upgraded from IPython 0.13 to 1.1.
>> > In 0.13, I was able to execute code in each notebook at startup, but the
>> > kernel code has changed and I can't figure out how to do it anymore.
>> Could
>> > someone point me in the right direction?
>>
>> Hi Adam,
>>
>> why not just use a file in the startup directory?
>>
>> $ echo `ipython locate profile`/startup/
>> /home/pi/.ipython/profile_default/startup/
>> $ cat `ipython locate profile`/startup/README
>> This is the IPython startup directory
>>
>> .py and .ipy files in this directory will be run *prior* to any
>> code or files specified
>> via the exec_lines or exec_files configurables whenever you load
>> this profile.
>>
>> Files will be run in lexicographical order, so you can control
>> the execution order of files
>> with a prefix, e.g.::
>>
>>   00-first.py
>>   50-middle.py
>>   99-last.ipy
>>
>> best,
>> --
>>                    _
>>                   / \
>>                 A*   \^   -
>>              ,./   _.`\\ / \
>>             / ,--.S    \/   \
>>            /  `"~,_     \    \
>>      __o           ?
>>    _ \<,_         /:\
>> --(_)/-(_)----.../ | \
>> --------------.......J
>> Paul Ivanov
>> http://pirsquared.org
>> _______________________________________________
>> 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/20131114/b46e1d6a/attachment.html>


More information about the IPython-dev mailing list