Re: [codenode-devel] sagenotebook vs codenode

8 views
Skip to first unread message

William Stein

unread,
Jun 21, 2010, 3:37:05 AM6/21/10
to codenod...@googlegroups.com, sage-notebook
On Mon, Jun 21, 2010 at 12:27 AM, Ralf Hemmecke <hemm...@gmail.com> wrote:
>> OK, but that doesn't fully answer my question. From appearance they
>> look similar. Do they have the same codebase? Was sagenotebook
>> developed from codenode or vice versa?
>>
>> They have different code bases.  I was one of the original creators
>> of the Sage Notebook (which came first) and I'm one of the original
>> creators of Codenode.  Codenode's codebase is more modular, and "much
>> cleaner" IMHO - with the right amount of continued work on it, it
>> could prove to be an awesome project - the "core structure" of it is
>> very good.
>
> OK. It somehow looks as if I could give it a try. Is codenode supposed
> to work?
>
> I've said git clone git://github.com/codenode/codenode.git. What comes
> next to make it run and read documentation?
>
>>sphinx-build doc docbuild
> Making output directory...
> Running Sphinx v0.6.4
>
> Exception occurred:
>  File "/home/hemmecke/scratch/cn/doc/conf.py", line 4, in <module>
>    import codenode
> ImportError: No module named codenode
> The full traceback has been saved in
> /tmp/hemmecke/sphinx-err-5GFhHr.log, if you want to report the issue to
> the developers.
> Please also report this if it was a user error, so that a better error
> message can be provided next time.
> Either send bugs to the mailing list at
> <http://groups.google.com/group/sphinx-dev/>,
> or report them in the tracker at
> <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
>
> I know there is easy_install codenode, but that doesn't seem to work for me.
>
> D=/home/hemmecke/scratch/codenode
> mkdir -p $D
> cd $D
> hg clone http://bitbucket.org/ianb/virtualenv
> cd virtualenv
> python virtualenv.py $D
> export PATH=$D/bin:$PATH
> easy_install codenode
> cd $D
> $D/bin/codenode-admin init -name mycodenode
> cd mycodenode
> $D/bin/codenode-admin run
>
> Now if I go to localhost:8000 and login with the admin account, I get an
> error:
>
>
> Forbidden (403)
>
> CSRF verification failed. Request aborted.
>
> Help
>
> Reason given for failure:
>
>    CSRF cookie not set.
>
> Is there some hint of how I should continue?
>
>> Could someone also comment on another passage from the above thread:
>>
>> "The aim of Codenode is to make a "generalized notebook" that could
>> be used by all these projects, but in practice it turns out that is
>> an *extremely* large amount of work."
>>
>> What exactly is this large amount of work?
>
>> They are so many parts to creating a full-fledged "Online
>> Programming Notebook". Here are the main 3 parts, each one is a
>> significant challenge:
>>
>> 1) Content Management System (Users, Notebooks, folders, tagging,
>> search, managed, upload data)
>> 2) Notebook (Rich Editors, Cells, Worksheets, sharing,
>> multi-user-editing, plots, Interact, etc)
>> 3) Kernel (Let anonymous people run arbitrary code!!)
>
> Since I couldn't yet run codenode I don't really know what would be
> missing for me. In the end I just want a better standalone interface to
> FriCAS.
>
> Is there an easy tutorial of what I would have to do to connect FriCAS
> (or just /bin/sh if that is easiser) to codenode?
>
> Features in (2) would be good (wouldn't that be easy to port from the
> sage notebook?), but in fact, currently I would be content with just
> running the notebook as a single user at localhost:8000.

You can use the Sage notebook separately from Sage.
It includes most of its dependencies. E.g., Ondrej Certik
ships the Sage Notebook with his FEMhub stuff, which
has none of Sage. I don't think the Sage notebook has
much more in dependencies than codenode.

William

--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Ralf Hemmecke

unread,
Jun 21, 2010, 4:05:14 AM6/21/10
to sage-n...@googlegroups.com
> You can use the Sage notebook separately from Sage. It includes most
> of its dependencies.

How do I install it if I don't have sage installed?

> E.g., Ondrej Certik ships the Sage Notebook with his FEMhub stuff,
> which has none of Sage.

True, but, in fact, if I want to do anything it requires me to install
femhub (which for example includes fortran). Even in Ondreij's
femhub-lab there is still a lot of links to some sage code or femhub
code. Nobody hasn't yet told me how to hook in another backend.
"Look at the code" is not a very helpful hint.

> I don't think the Sage notebook has much more in dependencies than
> codenode.

Good. Then how would I install the Sage Notebook (just interested in a
bare minimum)?
And how would I, for example, make the notebook an interface to /bin/sh?

Ralf

William Stein

unread,
Jun 21, 2010, 4:08:42 AM6/21/10
to sage-n...@googlegroups.com
On Mon, Jun 21, 2010 at 1:05 AM, Ralf Hemmecke <hemm...@gmail.com> wrote:
>> You can use the Sage notebook separately from Sage. It includes most
>> of its dependencies.
>
> How do I install it if I don't have sage installed?

Extract the tarball and do

source spkg-install

This will use whatever Python is in your PATH first.

>
>> E.g., Ondrej Certik ships the Sage Notebook with his FEMhub stuff,
>> which has none of Sage.
>
> True, but, in fact, if I want to do anything it requires me to install
> femhub (which for example includes fortran).

That was just an example to prove that the sage notebook does not
depend on sage.

> Even in Ondreij's
> femhub-lab there is still a lot of links to some sage code or femhub
> code.

Sage code? I doubt it.

> Nobody hasn't yet told me how to hook in another backend.
> "Look at the code" is not a very helpful hint.

It might be the only option for now... Hopefully that will change
though. It's good that you're asking good question, since they are
excellent motivation for writing better documentation.

>
>> I don't think the Sage notebook has much more in dependencies than
>> codenode.
>
> Good. Then how would I install the Sage Notebook (just interested in a
> bare minimum)?
> And how would I, for example, make the notebook an interface to /bin/sh?
>
> Ralf
>

--

Ralf Hemmecke

unread,
Jun 21, 2010, 4:49:15 AM6/21/10
to sage-n...@googlegroups.com
>> Even in Ondreij's
>> femhub-lab there is still a lot of links to some sage code or femhub
>> code.
>
> Sage code? I doubt it.

Well, not to get the notebook running, but there is no clear API to how
to hook in anything else than sage or femhub.

http://git.hpfem.org/femhub-lab.git/blob/4897d5bec770c9bc06048a5d865c0e04a546d738:/src/sagenb/notebook/notebook.py#l52

Wouldn't that be the place where I should look for a hook?

>> Nobody hasn't yet told me how to hook in another backend.
>> "Look at the code" is not a very helpful hint.

> It might be the only option for now... Hopefully that will change
> though.

Is someone working on a better documentation right now?

> It's good that you're asking good question, since they are
> excellent motivation for writing better documentation.

Is there already someone who got motivated? ;-)

>> Good. Then how would I install the Sage Notebook (just interested in a
>> bare minimum)?
>> And how would I, for example, make the notebook an interface to /bin/sh?

OK, I did...

D=/home/hemmecke/scratch/sagenb


mkdir -p $D
cd $D
hg clone http://bitbucket.org/ianb/virtualenv
cd virtualenv
python virtualenv.py $D
export PATH=$D/bin:$PATH

cd $D
wget http://www.sagemath.org/packages/standard/sagenb-0.8.p2.spkg
bunzip2 -c sagenb-0.8.p2.spkg |tar xvf -
cd sagenb-0.8.p2
source spkg-install
cd $D

The script $D/sagenb-0.8.p2/src/sagenb/go obviously cannot work. It
starts with "#!/usr/bin/env pynb" and I have no pynb anywhere. So I did
it manually.

>python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sagenb.notebook.notebook_object as n
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/notebook_object.py",
line 17, in <module>
import notebook as _notebook
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/notebook.py",
line 40, in <module>
import js # javascript
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/js.py",
line 38, in <module>
from sage.misc.misc import SAGE_ROOT
ImportError: No module named sage.misc.misc

What am I doing wrong?

Ralf

Ralf Hemmecke

unread,
Jun 21, 2010, 5:03:43 AM6/21/10
to sage-n...@googlegroups.com
Oh, it's a bug. It hit me again... :-(

sagenb-0.8.p2/src/sagenb/sagenb/notebook/js.py

says

try:
from sage.misc.misc import SAGE_ROOT
from pkg_resources import Requirement, working_set
sagenb_path = working_set.find(Requirement.parse('sagenb')).location
debug_mode = SAGE_ROOT not in os.path.realpath(sagenb_path)
except AttributeError, ImportError:
debug_mode = False

But according to what I cite below, it should rather be

except (AttributeError, ImportError):

Ralf

http://docs.python.org/tutorial/errors.html

A try statement may have more than one except clause, to specify
handlers for different exceptions. At most one handler will be executed.
Handlers only handle exceptions that occur in the corresponding try
clause, not in other handlers of the same try statement. An except
clause may name multiple exceptions as a parenthesized tuple, for example:

... except (RuntimeError, TypeError, NameError):
... pass

Ralf Hemmecke

unread,
Jun 21, 2010, 5:17:16 AM6/21/10
to sage-n...@googlegroups.com
> D=/home/hemmecke/scratch/sagenb
> mkdir -p $D
> cd $D
> hg clone http://bitbucket.org/ianb/virtualenv
> cd virtualenv
> python virtualenv.py $D
> export PATH=$D/bin:$PATH
> cd $D
> wget http://www.sagemath.org/packages/standard/sagenb-0.8.p2.spkg
> bunzip2 -c sagenb-0.8.p2.spkg |tar xvf -
> cd sagenb-0.8.p2
> source spkg-install
> cd $D

Now after correcting the bug, I get...

>python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sagenb.notebook.notebook_object as n
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/notebook_object.py",
line 17, in <module>
import notebook as _notebook
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/notebook.py",

line 41, in <module>
import worksheet # individual worksheets (which make up a notebook)
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/worksheet.py",
line 55, in <module>
import sagenb.misc.support as support
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/misc/support.py",
line 23, in <module>
import sageinspect
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/misc/sageinspect.py",
line 153, in <module>
SAGE_ROOT = os.environ["SAGE_ROOT"]
File "/home/hemmecke/scratch/sagenb/lib/python2.6/UserDict.py", line
22, in __getitem__
raise KeyError(key)
KeyError: 'SAGE_ROOT'

So in the hope that sage will not be required and that this is yet
another bug, I say

export SAGE_ROOT=$D

Maybe it would be a good idea to get rid of a SAGE_ROOT reference in the
notebook.

python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sagenb.notebook.notebook_object as n

>>> n.notebook('sage_notebook', server_pool=[])


Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/notebook_object.py",

line 217, in __call__
return self.notebook(*args, **kwds)
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/run_notebook.py",
line 174, in notebook_twisted
nb = notebook.load_notebook(directory)
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/notebook.py",
line 1715, in load_notebook
import sagenb.notebook.twist
File
"/home/hemmecke/scratch/sagenb/lib/python2.6/site-packages/sagenb-0.8-py2.6.egg/sagenb/notebook/twist.py",
line 42, in <module>
from twisted.web2 import server, http, resource, channel
ImportError: No module named web2

OK, let's install twistedweb2.

cd $D
svn co svn://svn.twistedmatrix.com/svn/Twisted/trunk twistedweb2
cd twistedweb2
python setup.py install

After that

python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sagenb.notebook.notebook_object as n

>>> n.notebook('sage_notebook', server_pool=[])

works and I can log into a notebook at http://localhost:8000/.

Fine.

So, please, could now someone point me to the right code place to get
/bin/sh running inside the notebook?

Ralf

Ondrej Certik

unread,
Jun 21, 2010, 3:26:04 PM6/21/10
to sage-n...@googlegroups.com
On Mon, Jun 21, 2010 at 1:08 AM, William Stein <wst...@gmail.com> wrote:
> On Mon, Jun 21, 2010 at 1:05 AM, Ralf Hemmecke <hemm...@gmail.com> wrote:
>>> You can use the Sage notebook separately from Sage. It includes most
>>> of its dependencies.
>>
>> How do I install it if I don't have sage installed?
>
> Extract the tarball and do
>
>   source spkg-install
>
> This will use whatever Python is in your PATH first.
>
>>
>>> E.g., Ondrej Certik ships the Sage Notebook with his FEMhub stuff,
>>> which has none of Sage.
>>
>> True, but, in fact, if I want to do anything it requires me to install
>> femhub (which for example includes fortran).
>
> That was just an example to prove that the sage notebook does not
> depend on sage.
>
>> Even in Ondreij's
>> femhub-lab there is still a lot of links to some sage code or femhub
>> code.
>
> Sage code?  I doubt it.

femhub doesn't contain any sage code. In fact, the latest git version
doesn't even contain any of the sage buildsystem (except 3 little
scripts, like spkg-build)

We do have some (lots of) sage packages, for example the sagenb, and
other stuff, but we don't have anything from the sage library. So this
shows, that the sage notebook runs nicely without any Sage.

If you don't like femhub, you can just install all the dependencies
yourself (see the spkg-install scripts how to do it) and it will just
work.

Ondrej

William Stein

unread,
Jun 22, 2010, 12:38:25 AM6/22/10
to sage-notebook
On Mon, Jun 21, 2010 at 2:03 AM, Ralf Hemmecke <hemm...@gmail.com> wrote:
> Oh, it's a bug. It hit me again... :-(
>
> sagenb-0.8.p2/src/sagenb/sagenb/notebook/js.py
>
> says
>
> try:
>    from sage.misc.misc import SAGE_ROOT
>    from pkg_resources import Requirement, working_set
>    sagenb_path = working_set.find(Requirement.parse('sagenb')).location
>    debug_mode = SAGE_ROOT not in os.path.realpath(sagenb_path)
> except AttributeError, ImportError:
>    debug_mode = False

This is now

http://trac.sagemath.org/sage_trac/ticket/9303

>
> But according to what I cite below, it should rather be
>
> except (AttributeError, ImportError):
>
> Ralf
>
> http://docs.python.org/tutorial/errors.html
>
> A try statement may have more than one except clause, to specify
> handlers for different exceptions. At most one handler will be executed.
> Handlers only handle exceptions that occur in the corresponding try
> clause, not in other handlers of the same try statement. An except
> clause may name multiple exceptions as a parenthesized tuple, for example:
>
> ... except (RuntimeError, TypeError, NameError):
> ...     pass
>

--

Ondrej Certik

unread,
Jun 22, 2010, 12:48:12 AM6/22/10
to sage-n...@googlegroups.com
On Mon, Jun 21, 2010 at 9:38 PM, William Stein <wst...@gmail.com> wrote:
> On Mon, Jun 21, 2010 at 2:03 AM, Ralf Hemmecke <hemm...@gmail.com> wrote:
>> Oh, it's a bug. It hit me again... :-(
>>
>> sagenb-0.8.p2/src/sagenb/sagenb/notebook/js.py
>>
>> says
>>
>> try:
>>    from sage.misc.misc import SAGE_ROOT
>>    from pkg_resources import Requirement, working_set
>>    sagenb_path = working_set.find(Requirement.parse('sagenb')).location
>>    debug_mode = SAGE_ROOT not in os.path.realpath(sagenb_path)
>> except AttributeError, ImportError:
>>    debug_mode = False
>
> This is now
>
>   http://trac.sagemath.org/sage_trac/ticket/9303

What happens if the bug was fixed before the track ticket was reported? :)

http://boxen.math.washington.edu:8100/rev/65d6838cefd8

Ondrej

William Stein

unread,
Jun 22, 2010, 12:57:50 AM6/22/10
to sage-notebook


Do you have a time machine?


-- William --

Ondrej Certik

unread,
Jun 22, 2010, 1:15:42 AM6/22/10
to sage-n...@googlegroups.com

Do you want one too?

Ondrej

Ralf Hemmecke

unread,
Jun 22, 2010, 3:52:58 AM6/22/10
to sage-n...@googlegroups.com
Then maybe you should also close

http://trac.sagemath.org/sage_trac/ticket/9294

Ralf

Ralf Hemmecke

unread,
Jun 22, 2010, 4:08:14 AM6/22/10
to sage-n...@googlegroups.com

You both have. ;-)

http://groups.google.com/group/sage-notebook/msg/8059052e1f4183d4

Note that I took

wget http://www.sagemath.org/packages/standard/sagenb-0.8.p2.spkg

since as I understand there is no central repository that contains the
latest changes that will be in the next release. Everyone points me to
the hg repo that is in the spkg.

Just a suggestion. Bless an "official (read-only) repository of the
release manager", so everyone would be up-to-date with fixes that have
already been incorporated for the new release. (This suggestion should
be applied to all hg repositories that are part of sage.)

Ralf

Ralf Hemmecke

unread,
Jun 23, 2010, 8:50:31 AM6/23/10
to Mateusz Paprocki, fem...@googlegroups.com, sage-n...@googlegroups.com
> Our ideas go a bit further than that, because we would like to have
> three separate layers of codes:

> 1) web user interfaces (originally a part of Codenode's frontend)
> 2) data backends (originally Codenode's frontend)
> 3) computational backends (originally Codenode's backends)

Sounds great.

> This, however, will change in future, because we would like to split
> Codenode into layers (2) and (3) to have tree cleanly separated
> projects, of course, with well defined APIs between layers.

Oh, I'd like to see this happen. Currently, I get a little confused by
files like

http://git.hpfem.org/femhub-lab.git/blob/HEAD:/src/sagenb/data/sage/images/hermes2d_logo.png

lying in a *generic* notebook. So splitting the code would be very much
appreciated.

>>> All I want is a nice web interface, that sends the input string
>>> from the cell to a (registered) process and get's corresponding
>>> output. For something like http://wiki.sagemath.org/interact,
>>> there would have to be a proper API for the backend as well. The
>>> notebook code should not contain anything that is related to the
>>> potential packends (except APIs, of course).

> This is also what we want to have.

But as you said, you basically only let python run inside a notebook
cell. What I want is that, the input is just forwarded to another
application and the output of the application is put back into the
notebook. Should probably be doable, but how would I *currently* do it
with femhub-lab. Can you point me to the code piece that takes an input,
sends it to an (arbitrary (in some way registered) interpreter and then
deals with the output from that interpreter?

I just need an entry point.

Thanks in advance.

Ralf

Ralf Hemmecke

unread,
Jun 23, 2010, 8:51:48 AM6/23/10
to Mateusz Paprocki, fem...@googlegroups.com, sage-n...@googlegroups.com
BTW, is the femhub-lab project pulling patches from sagenb?

Ralf

Reply all
Reply to author
Forward
0 new messages