-
-
Notifications
You must be signed in to change notification settings - Fork 31
FAQ
-
General
- May I use SageMathCloud for commercial purposes?
- How can I create public projects on SageMathCloud?
- I would like to use SageMathCloud with my 300+ Calculus Students
- I want to categorize my projects
- How can I download a whole directory?
- If I "share" a file, does it become public to everyone and/or searchable? Or is the only way to get to it via a link and a SageMath account?
-
Computations
-
Storage
-
Sage Worksheets
- I would like to edit files (with sync) that are on some remote server that I have ssh access to
- Can you tell me how to insert HTML, LaTeX or simple text between two cells in a Sage worksheet?
- How do I turn on typesetting of math output in SageMathCloud?
- How can I tell if my code is running in a SageMathCloud Worksheet (a sagews file)?
- How do I access functionality specific to SageMathCloud Worksheets (sagews files)?
- How to fix an exception related to Sage's Integer(...) vs. Python ints?
- I would like to use R in a Sage Worksheet
- I would like to use Julia in a Sage Worksheet
- I would like to nicely display a combinatorial object in a worksheet
-
IPython Notebook
-
LaTeX
-
Software
- How can I install Python packages from PyPi using pip?
- I would like to install new R packages.
- I would like that all of my worksheets know where to find a given module that I write or install
- I want to use my own Sage binary
- I want to use my own custom built-from-source copy of Sage
- I would like to use Octave
- I would like to develop a webserver in Python
- I would like to create, compile and run a C program.
- I would like to create, compile and run a Fortran F90 program.
- I would like to create, compile and run a Java program.
- I want to install Python3 and use it as my default.
- Is Scilab broken?
-
Terminal
-
Network/SSH
-
Misc
Yes, you are allowed to use SMC for commercial purposes for free subject to terms of usage. I would very much appreciate it if you report bugs and share ideas for improvements to SMC that you might have, since at present that is the best way for you to contribute back (email: [email protected]). Similar commercial use of SMC by a broader community could help in the long run to provide a source of more longterm sustainability for SMC, and I greatly value your feedback. Please note that this permission could change in the future, since I don't know exactly what will happen longterm regarding the resources I have available. But for now, definitely go for it!
Question: I want to start long-running numerically intensive computations on SageMathCloud. What are the current limitations?
Open your project and click on Settings. The default limitations are listed under "Quotas" in the lower left. These can be raised, as mentioned there. Notes:
-
The Virtual Machines get rebooted regularly -- probably about once per week. You can check if a VM rebooted by typing "uptime". crontab files are persistent, unless your project moves from one machine to another, which can happen in case of machine failure.
-
If a project isn't used (via the web-based UI) for the idle time (by default 3 hours), then all processes in that project are terminated. It's easy for me to raise this idle timeout if necessary -- email me at [email protected].
Type exactly the following in a full terminal (+New--> Terminal) to see all processing running in a project (note the back ticks!):
top -u `whoami`
You can kill things, etc. See http://linux.die.net/man/1/top
Type exactly the following in a full terminal (+New--> Terminal):
smem -tk
It lists all processes and the bottom line shows the total sum.
The last RSS
column is probably the most interesting one, for more consult man smem
.
The directory /scratch
is a ZFS filesystem (at least 64GB) that is never snapshotted. You can write files there if you need some extra space, and there is insufficient quota in your project. However, if your project moves to another host (e.g., if this host goes down) then the scratch that you were using is no longer accessible. If you type this in a terminal, you will get a clickable link in the file browser that lets you navigate to /scratch:
ln -s /scratch .
The Quota pane in project settings list how much quota space you have in /scratch.
You can make individual files and folders public. Pull up information for a file (click the info icon), and click on "Share Publicly". Once you do this, simply share the URL that is displayed in the top of your browser when you look at the file (or directory). Anybody else who views that link will see the file, and can create an account and copy it to their own project.
You can also publish IPython notebooks via a Publish button -- see this video.
Go for it! We have substantial excess capacity. For example, UCLA used SMC in their 400+ Calculus class, and dozens of other 100+ courses are using SMC. See https://github.com/sagemath/cloud/wiki/Teaching
You can put #foo
in the title or description of any project. When you view your list of projects a button will appear for each hashtag, which you can click to show only projects with that tag. There is also excellent support for hashtags in task lists (SageMathCloud's todo list functionality).
There is currently no provision to download an entire directory.
To accomplish this, you can easily create a .zip
-archive.
Above the files view, on the right, there is a command-box.
For a directory called "My Homework", type in:
zip download-homework.zip "My Homework"
The directory name needs to be exactly the same, including upper and lowercase letters, and any space characters need to be protected by quoting the entire name.
If successful, a new file download-homework.zip
should appear.
Question: If I "share" a file, does it become public to everyone and/or searchable? Or is the only way to get to it via a link and a SageMath account?
When you click "Share Publicly" in the info dialog for a file or directory, then yes, it does become public to everyone (as the name "publicly" suggests). It is NOT searchable (via Google, say) right now, but may become searchable later, when I implement something to encourage that. The only way to get it today is via a link, after you share it publicly. But that is temporary. The person getting the link does not need a SageMath account -- try opening the link in private browsing mode to see.
import sage_server
sage_server.MAX_OUTPUT_MESSAGES=100000
See this published worksheet for more details.
Also, type sage_server.[tab key]
to see information about other limitations.
Question: I would like to edit files (with sync) or manipulate data files that are on some remote server that I have ssh access to
WARNING: The following will only work if your project has outgoing network access, i.e., it says "Network access: true" under project settings. (Outgoing network access is blocked by default due to people using SageMathCloud as a platform to attack other computers. If you don't have it, email [email protected] and convince him you should, and he'll enable it.)
Suppose you have an account on some computer that you can ssh to, e.g, so this works for you:
To temporarily make the files at [email protected] available in a cloud project, open a Terminal and type
mkdir foo # make any directory you want
sshfs [email protected]:path/to/files/ foo/
and type your password to login to [email protected]. You'll find that you can now use the files at path/to/files in [email protected] as if they were in the directory foo in your project. You can edit files (with sync), open and output data files, etc. When you're done, type
fusermount -u foo
to unmount foo. Whenever the project server is restarted, foo/ will also be unmounted. So you'll have to type sshfs [email protected]: foo/
to mount foo every once in a while.
(Alternatively, you can type crontab -e
in a terminal, and add a line like this */2 * * * * sshfs [email protected]: foo/
, but that would require setting up ssh keys for passwordless connections to [email protected]
, which you may or may not want to do.)
NOTE: The files in foo/ will not be included in snapshots, because they are part of another filesystem, and the snapshot system is configured to not cross filesystem boundaries.
I've put an example IPython octave notebook and a Sage octave worksheet here:
Unfortunately, neither IPython nor Sage worksheets in Octave mode are "rock solid". For something that is rock solid, type "+New", click terminal, and type "octave" on the command line, and this should work well. You can type "+New", enter a filename that ends with .m, and edit it, then load it into the command line (by typing the filename without the extension).
You might also find this useful: https://github.com/sagemath/cloud/issues/97
Here's a simple example of an HTTP server written using the Python SimpleHTTPServer class. Open a project and click "+New" then paste in this link, then click the "From Web" button:
https://gist.github.com/certik/7031075/raw/fe9eb600946e8b3a94b752a50f0ace9d5641354f/browser
Then in a terminal type
chmod +x browser
./browser
You'll see a URL in a box that looks something like this
https://cloud.sagemath.com/4a5f0542-5873-4eed-a85c-a18c706e8bcd/port/22273/
Just paste it into your browser.
IMPORTANT: This web server is visible exactly to collaborators on your project and nobody else, and all communication is SSL encrypted. Thus you can't use this method to create a general purpose webserver available to the world. On the other hand, this is a good way to collaborate with a controlled group of people on development, without having to worry about security.
If you just want an http view of your files, use the raw servers, which is already available by default at https://cloud.sagemath.com/project_id/raw/
. The point of the above script is that you could modify it to provide all sorts of interesting functionality.
Question: How can I install Python packages from https://pypi.python.org/pypi using pip?
NOTE: Temporarily, due to people launching attacks from SMC, using pip install --user
is unlikely to work, unless you get network access turned on for your project. Email [email protected] if you need anything installed, or have a good reason to need network access (include project's id).
Let's suppose the package is called ggplot
. Create a new Terminal in a project (+New-->Terminal) and type
sage -sh
pip install --user ggplot
Open the project's settings (the gear icon) and click "Restart Sage Worksheet Server" in the Restart section. If you're using IPython Notebook you may also have to click "Restart Project Server". Now ggplot should be available in any (restarted) worksheet (click the red restart icon in a worksheet to restart it). The restart is necessary, since the worksheet server uses forking to reduce startup time of worksheets from 5 seconds to 0.1 seconds.
To directly install your Python dependencies for your local user account,
you can place your packages here: $HOME/.local/lib/python2.7/site-packages/
.
The $HOME/.local/
path is the "canonical" root for some overlay directories
of linux's standard directory layout (For more information, type $ man hier
in a terminal).
Question: Can you tell me how to insert HTML, LaTeX or simple text between two cells in a Sage worksheet?
Put
%md
at the top of a cell to use markdown formatting (which fully supports LaTeX formulas). See http://daringfireball.net/projects/markdown/ about markdown. When you press shift-enter, the output is displayed. Double click to edit.
You can also use %html in a similar way to the above, which also supports LaTeX.
No graphical editor is available yet to edit %html cells, but I hope to change that soon.
You can install any version of Python you want into your own project -- just download and build it locally, and install IPython (and whatever you want) into it. Then, make a directory "bin" in the home directory of your project and put a symlink to your ipython there, e.g.,
cd ~/bin/
ln -s /path/to/your/ipython .
In project settings, restart your project server (just to be sure), then make sure that when you type "ipython" on the command line, you get your ipython. Then clicking on existing IPython notebooks or creating new ones (through the gui) should use your copy of ipython. It just uses the "IPython" that is in the path, since ipython-notebook just sets up some options and runs "ipython notebook" (look at ~/.sagemathcloud/ipython-notebook).
Whenever you save the LaTeX document, it will run a spell checker and underling the words that are not spelled correctly. By default, it uses the language you've set in your web browser.
You can change the autosave interval to be very short in account settings (under editor) if you need the spell checking to update frequently.
Seeing a list of alternative words (correct spellings) isn't supported directly in the editor yet https://github.com/sagemath/cloud/issues/50. For now, a workaround is to run LaTeX-aware aspell
, e.g.
1. open a terminal
2. aspell -t -c <filename.tex>
Suppose, your LaTeX project is composed of one master.tex
file and several chapter-1.tex
, chapter-2.tex
, etc. SageMathCloud's LaTeX editor only knows about the currently opened file, and using \import{}
doesn't work, because the chapter-*.tex
parts are not proper documents.
To solve this, use the subfiles package instead. It does not only collect the partial documents into one, but also extracts the preamble of the master.tex
file for each chapter-*.tex
in order to create valid subdocuments.
Following the documentation, do this:
-
\usepackage{subfiles}
inmaster.tex
-
\subfile{⟨subfile name ⟩}
for each subfile inmaster.tex
'sdocument
environment (i.e. instead of\include
or\import
). -
For each
chapter-*.tex
subfile:\documentclass[⟨master.tex file-name⟩]{subfiles} \begin{document} ⟨text, graphics, etc.⟩ \end{document}
After that, all *.tex
files can be compiled and all other features like forward/inverse search work, too.
Question: I would like that all of my worksheets know where to find a given module that I write or install.
Put an executable file with this content in $HOME/bin/sage:
#!/usr/bin/env bash
SAGE_PATH=$HOME/NEW_MODULE /usr/local/bin/sage "$@"
You could do this by making a new directory called bin, then a new file in there called "sage". Then in the terminal type the following to make "sage" executable.
cd; cd bin; chmod +x sage
This is also the file "sage" attached to this message.
Then restart the worksheet server by going project settings and clicking "Restart --> Worksheet server".
Now any newly (re-)started worksheet will run with the above modified SAGE_PATH. Since SAGE_PATH is added to PYTHONPATH when Sage starts, this does what you want.
Obviously, I plan to add a simple way to do something equivalent to the above, by filling in some settings box in the UI. I'll update this FAQ entry once I do that.
(From Nathan Dunfield) Another approach, which also works now and doesn't require the custom "$HOME/bin/sage", is to use http://docs.python.org/2/install/#alternate-installation-the-user-scheme
That is, one installs a module with "sage -python setup.py install --user" and it's dumped into
$HOME/.local/lib/python2.7/site-packages
This is location is searched automatically by Sage's Python without any intervention on the part of the user. (However, I did have to restart the worksheet server to access newly installed modules from a worksheet.) One can also put modules into the user's site-packages by hand and Sage will find them.
Question: In the standard Sage notebook there is a checkbox to switch on the typesetting of math. How do I turn on typesetting of math output in SageMathCloud?
Turn it on with
typeset_mode(True)
and off with
typeset_mode(False)
Putting
%auto
typeset_mode(True)
at the top of a worksheet will make this automatic.
The Pentadactyl plugin is not compatible with the Codemirror editor in SageMathCloud. You can disable Pentadactyl for a particular page, perhaps by pressing Control+Z. SagemMathCloud has it's own Vim bindings for worksheets and editing files; to enable it, go to setting (click the gear by your name in the upper right), then select Vim next to Editor --> Bindings.
You can make a symbolic link to the root of the filesystem by typing
ln -s / root
Now you can explore the complete filesystem. Note that there many files that you can only read and not write.
Chrome absolutely doesn't allow normal web applications to intercept certain keystrokes, which
makes Emacs-in-a-terminal painful on some operating systems (esp. Linux/Windows). E.g., Ctrl-N brings up a new window, instead of going
to the next line! (It is possible to eventually get around this by creating a Chrome extension,
but I haven't done this yet.) In the meantime, you can install the SageMathCloud
chrome app from the app store or on Linux, type
google-chrome --app=https://cloud.sagemath.com
to local the website as an app (if you use chromium instead, type
chromium-browser --app=https://cloud.sagemath.com
).
This is not a completely solution since in some cases, control-shift-minus and control-shift-plus still zoom in and out (on ChromeOS they zoom the entire desktop -- every window, all icons, the time, etc., in and out!). This is a major problem, because control-shift-minus is "undo" in emacs. The workaround I currently use is to put this in my .emacs file, and instead type "alt-u" for undo:
(define-key esc-map "u" 'undo)
Note that undo is also available by default through other key bindings, like C-x u and C-/. (Execute "M-x where-is undo".) So there are other options available.
~/.bashrc
is run on startup and ~/.bash_profile
is not!
Hence, use ~/.bashrc
to customize your setup,
and you can also use ~/.bash_aliases
for your aliases (see ~/.bashrc
).a
Get the link address for the latest Ubuntu 14.04 64-bit binary from http://boxen.math.washington.edu/home/sagemath/sage-mirror/linux/64bit/ and do this in a Terminal (for Sage-5.11 right now), which should take less than 10 seconds:
wget http://boxen.math.washington.edu/home/sagemath/sage-mirror/linux/64bit/sage-6.4.1-x86_64-Linux-Ubuntu_14.04_x86_64.tar.lzma
Then do this, which should take about 2 minutes (since it extracts over 70,000 files!):
time tar xf sage-6.4.1-x86_64-Linux-Ubuntu_14.04_x86_64.tar.lzma
mv sage-6.4.1-x86_64-Linux-Ubuntu_14.04_x86_64 sage-6.4.1
Finally, type
cd; mkdir -p bin; cd bin; ln -sf ~/sage-6.4.1/sage .
See the discussion about worksheet servers in the next FAQ question below. Also, now that you have your own copy of Sage, you can change anything in Sage! Do so, send us patches, etc. See http://www.sagemath.org/doc/developer/ for step-by-step instructions.
Open a Terminal. Grab the source tarball (which takes maybe 5 seconds to download). For example, to get a recent beta
wget http://sage.math.washington.edu/home/release/sage-6.4.rc1.tar.gz
You can browse http://sage.math.washington.edu/home/release/ to find recent releases and testing versions. To build, do the following in your terminal (no need to worry about screen or tmux, of course, since sessions are persistent even if your browser leaves), and check back in about 2 hours:
tar xvf sage-6.4.rc1.tar.gz; cd sage-6.4.rc1; export MAKE="make -j8"; make
WARNING: In fact, building can easily take more than 2 hours. However, by default SageMathCloud projects have an idle timeout that is about 2 hours. If you aren't editing files in the project, your build will get killed part of the way through. If you're doing legit Sage development, email [email protected] and he'll increase the idle timeout so you can easily build Sage.
After doing that, do this in the terminal:
cd; mkdir -p bin; cd bin; ln -s ~/sage-6.4.rc1/sage .
Then restart your worksheet server (in project settings). Then for that project, you'll have your own 100% customizable copy of Sage; and moreover, when I upgrade the system-wide Sage, your project isn't impacted at all -- that sort of stability is a major win for some people. This also uses little extra disk space in my backups/snapshots, because of de-duplication. You can of course also install any custom packages you want into this copy of Sage. You can also help improve Sage: http://www.sagemath.org/doc/developer/
If you want to do Sage development see http://mathandhats.blogspot.com/2014/06/how-to-develop-for-sage-using-sage-math.html.
Important: Whenever you change Python code installed in that copy of Sage, you may have to restart the worksheet server and any running worksheets. This is inconvenient, but is necessary because the worksheet server starts one copy of Sage, then forks off additional copies each time you open a new worksheet, which greatly reduces the time from when you open a worksheet until it actually starts computing things.
Also Important: If your copy of Sage is messed up in some way, then the worksheet server can't start, hence worksheets won't open. To debug this, open a terminal and do this:
~$ cd .sagemathcloud
~/.sagemathcloud$ sage sage_server.py
you should see an error here, e.g.,
and fix whatever error you see.
Click "+New", then enter a filename and click IPython Notebook
. This is IPython, but enhanced with realtime synchronization. You can also just run a standard IPython notebook server by typing ipython-notebook start
in the Terminal and pointing your browser at the link that is displayed. More precisely, the above command will output something like this
~/tmp$ ipython-notebook start
{"base": "/3702651d-9fbc-4e4e-b7ab-c10a79e34d3b/port/26686/", "pid": 6707, "port": 26686}
This would mean that you should visit the url
https://cloud.sagemath.com/3702651d-9fbc-4e4e-b7ab-c10a79e34d3b/port/26686/
If you want to make IPython Sage-friendly, so the Sage preparser and library are available, type
%load_ext sage
Note: nobody has added support for displaying plots yet to this mode (but Volker Braun just did a lot of work on this and it is coming soon!). As a temporary workaround, this function will display a Sage plot:
def showplot(g):
import IPython.display
save(g, 'a.png')
display(IPython.display.Image('a.png'))
For example, this will now work:
g = plot(sin,(0,5)) + plot(cos, (0,5), color='red')
showplot(g)
The global variable __SAGEWS__
will be defined.
Type salvus.[tab key]
.
If you type ssh-keygen
in a terminal, then you'll generate an ssh key, which you might use with github (say) or sage's trac to easily push and pull to repositories. To copy this ssh key, you could type cat .ssh/id_rsa.pub
and copy in the terminal, but you'll have to manually delete a bunch of newlines. Alternatively, do the following:
-
In the project file list, click on the icon that looks like an eye in the middle on the right side of the screen to reveal hidden files (those that start with a dot).
-
Click on the
.ssh
directory -- you can easily find it by typing "ssh" in the search box labeled "choose files..." on the left. -
Click on
id_rsa.pub
, then highlight everything and copy as usual. -
Click the eye again to turn off viewing hidden files.
Alternatively, type this into the small "terminal command" box in "files": cat ~/.ssh/*.pub
. Below the box, you can conveniently copy/paste it!
You can also type the following into a full terminal: open ~/.ssh/id_rsa.pub
By default, Sage parses the input commands and replaces some elements with its own parts and also adds some syntactic sugar. For example, an integer like 234
is translated to Integer(234)
in order to be more powerful and live as a part of Sage. To avoid this behaviour, either append an r
to the number, like 234r
or change the mode of the cell to Python by adding %python
at the top. You can also switch to pure Python mode by default via %default_mode python
. Alternatively, you can type Integer=int
and possibly also RealNumber=float
.
Under "Status" in project settings, you'll find a section labeled "SSH into your project", with the ssh command line that you can type (on any computer anywhere) to ssh to your project.
For this to work, you MUST add an ssh public key to your project. There is a link "add a public key to ~/.ssh/authorized_keys" right there, so click on it, and paste an ssh public key into that file, then save it. Now you can ssh to your project.
Open a terminal windows and type
`sage -R`
Then you can install packages as usual
`install.packages('packagename')`
Note that you may need to request that network access be enabled for your project (email: [email protected]).
-
Click +New, type a filename, then click the "Sage Worksheet" button.
-
To evaluate code using R, begin the cell with
%r
, type the code, then press shift+enter. -
Type
%default_mode r
in a cell and press shift+enter; now all cells will be evaluated using R by default. If you need to switch back, use%default_mode sage
.
-
Click +New, type a filename, then click the "Sage Worksheet" button.
-
To evaluate code using Julia, begin the cell with
%julia
, type the code, then press shift+enter. -
Type
%default_mode julia
in a cell and press shift+enter; now all cells will be evaluated using Julia by default. If you need to switch back, use%default_mode sage
(or%sage
to just switch back for one cell).
-
Click +New, type a filename ending in ".c", e.g.,
foo.c
, and click "Create File" (or just press return). -
Paste this code into the file:
#include<stdio.h>
int main(void) {
printf("Hello World\n");
printf("this is SageMathCloud!\n");
}
- Open a terminal by clicking +New, clicking "Command Line Terminal" (or typing a filename ending in .term), and type
gcc foo.c
. Finally, run the program by typing./a.out
.
-
Create a file
sum.f90
by clicking +New, which I copy and paste from http://en.wikibooks.org/wiki/Fortran/Fortran_examples#Area_Of_a_Triangle_program -
Create a terminal and type
gfortran sum.f90
-
Run the program by typing
./a.out
- Create a file
HelloWorld.java
containing
public class HelloWorld {
public static void main (String[] args) {
System.out.println ("Hello World!");
}
}
-
Create a terminal and run
javac HelloWorld.java
to compile your program. -
Run
java HelloWorld
to see the output.
With full network access enabled, you can download and compile Python 3 this way. Last line sets a symlink to make it your default!
apt-get source python3.4-dev
cd python3.4-3.4.0/
./configure --prefix=$HOME
make
make install
cd ..
pip3 install numpy
pip3 install scipy
pip3 install matplotlib
pip3 install ipython
pip3 install pyzmq
pip3 install jinja2
pip3 install tornado
ln -s ~/bin/python3 ~/bin/python
No, the Java stacktrace only happens because there is no graphical interface available due to the fact that there is no graphical interface ;-)
Type
scilab-adv-cli
or
scilab-cli
or
scilab -nw
How to draw nice latex/tikz-based combinatorial objects in a SageMathCloud worksheet:
bt = BinaryTree([[None, [[],[[], None]]],[[],[]]])
_=latex.eval(latex(bt))
Why? The (awesome) rendering the combinatorics people have implemented for their objects depends on the tikz latex package. Tikz is not at all supported by Mathjax, which is the web-based latex renderer used by the show command. Tikz-using rendering will not work with any web based renderer yet, until somebody implements a tikz package for mathjax. What the above does is instead run latex on the server, convert the result to an image, and display it.
Do not hesitate to email [email protected] or https://groups.google.com/forum/?fromgroups#!forum/sage-cloud