Difference between revisions of "ICalico"

From IPRE Wiki
Jump to: navigation, search
(Installation)
Line 20: Line 20:
 
# <b>Start IPython with Calico profile</b>
 
# <b>Start IPython with Calico profile</b>
 
#* <code>icalico</code>
 
#* <code>icalico</code>
 +
# To end server, control+break on Windows; control+c on Linux/Mac
  
 
A web page should open up which will allow you to enter scripts and Calico "magic" commands (see below).
 
A web page should open up which will allow you to enter scripts and Calico "magic" commands (see below).

Revision as of 18:06, 18 April 2014

ICalico is a new method of interacting with Calico. In addition, a host of new functionality is available.

What is ICalico? It is a graphical user interface (GUI) to Calico through a web browser. Everything currently runs locally, so it isn't something on the world wide web, but rather a interface to write code using the browser as the GUI. You'll need ipython can Calico 3 or greater to use.

To get an idea of what ICalico is, see the sample notebooks here:

http://nbviewer.ipython.org/urls/bitbucket.org/ipre/calico/raw/master/notebooks/Index.ipynb

Installation

  1. Install IPython version 2.0.0 or greater
    • http://ipython.org/install.html - We suggest using the Anaconda installer for its ease of use
      • If you do not use Anaconda, you may have to build zmq from source
    • Make sure that ipython is in your path (type "ipython" at a console prompt)
      • Anaconda will do this for you. You may have to logout, close/open terminal window, or reboot
      • On Windows, if you need to manually set your path, use something like: PATH=%PATH%;c:\Python27\Scripts
  2. Install Calico version 3.0.0 or greater
  3. Start IPython with Calico profile
    • icalico
  4. To end server, control+break on Windows; control+c on Linux/Mac

A web page should open up which will allow you to enter scripts and Calico "magic" commands (see below).

Trouble shooting

If a webpage opens, you should be able to open a Notebook (either old or make a new one. On the new Notebook page, you should see:

  1. the purple Calico butterfly logo in the upper-left corner
  2. if you type calico in a cell and evaluate it (control+enter) it should respond back with the Calico version number, like <Calico version 3.0.0>

If a webpage does not open, some things to check:

  1. Is IPython in your path?
  2. Do you have a default web browser?
  3. On Linux, is Mono on your path?

Other questions? Please ask on the calico-users mailing list.

NOTE: If you move the Calico folder, you should re-create a new Calico profile:

  1. cd Calico
  2. calico --create-profile

Getting Started

For an introduction to this manner of interacting with programs, please see:

http://nbviewer.ipython.org/urls/bitbucket.org/ipre/calico/raw/master/notebooks/Calico%20Overview.ipynb

Editing

Each cell in a notebook can be one of the following:

  • Code
  • Markdown
  • Raw text
  • Heading 1 through 6

You can change what type of data is in a cell by changing it in the menu selection.

If the cell is marked Code, then you can enter commands (from Python by default). Press shift/control/alt Enter to evaluate.

You can also enter a "magic" command. These are proceeded by:

  • a single-percent sign for magic-line commands
  • two percent signs for magic-cell commands
  • three percent signs for magic sticky, notebook commands

The magic line commands are:

%connect_info        - show ICalico JSON connection information
%download url [file] - download a URL to a file
%edit FILENAME       - edit a file in an external editor
%lang                - get information on current language
%magic               - get information on magic meta-commands
%qtconsole           - start a qtconsole
%run FILENAME        - run a file (language determined by extension)

The magic cell commands are:

%%file FILENAME      - create a filename with contents of cell
%%html               - treat the cell as HTML
%%javascript         - treat the cell as Javascript data
%%latex              - treat the cell as Latex
%%lang LANGUAGE      - change language for just this cell
%%svg                - treat the cell as SVG data
%%time               - time how long it takes to run this cell

The magic notebook commands are:

%%%lang LANGUAGE     - change language for rest of cells (or until another %%%lang command)

If the cell is marked as Markdown, then you can use Markdown syntax, including some LaTeX commands.

Documentation

Technically, ICalico is a "IPython kernel". However, of course ICalico can operate using any of a number of languages.

Editing Notebooks

You can drag and drop images onto a notebook when editing.

Magics

ICalico magics are "meta" commands: commands for the ICalico system, separate from any Calico language.

  • One preceding percent sign indicates a "magic line command" (applies to just the line)
  • Two preceding percent signs indicates a "magic cell command" (applies to just the cell)
  • Three preceding percent sign indicates a "magic notebook command" (applies from here to rest of notebook)

Any cell can have any number of magic commands, but they must all appear first, before any code.

%connect_info        - show ICalico JSON connection information
%download url [file] - download a URL to a file
%edit FILENAME       - edit a file in an external editor
%%file FILENAME      - create a filename with contents of cell
%%html               - treat the cell as HTML
%%javascript         - treat the cell as Javascript data
%lang                - get information on current language
%%lang LANGUAGE      - change language for just this cell
%%%lang LANGUAGE     - change language for rest of cells
%magic               - get information on magic meta-commands
%qtconsole           - start a qtconsole
%run FILENAME        - run a file (language determined by extension)
%%svg                - treat the cell as SVG data
%%time               - time how long it takes to run this cell

Display Functions

These are available from the Calico: calico object:

  • animate(item[, item]*) - redisplay one or more items with little jitter (for animating a display)
  • display(item[, item]*) - display one or more items to the notebook output area
    • display_html(item)
    • display_javascript(item)
    • display_json(item)
    • display_svg(item)
    • display_png(item)
    • display_jpeg(item)
    • display_latex(item)
    • display_pdf(item)

Examples:

for i in range(10):
    calico.animate(image)

calico.display_json(json_data)

Rich Media Objects

All of the rich media objects are available from the Calico: calico object.

  • Audio(URI)
  • HTML(string)
  • Javascript(string)
  • Latex(string)
  • Math(string)
  • Table()
  • Image(URI)
  • YouTubeVideo(id, width, height)
  • IFrame(src)
  • SVG(xml)
  • FileLink(filename)
  • FileLinks(directory)
  • VimeoVideo(id)

Examples:

calico.display(calico.HTML("<b>This is bold!</b>"))

Widgets

Widgets allow for creating interactive interfaces, when connected to an executing kernel. All of the widgets are available from the Calico: calico object.

  • BoundedFloatTextWidget
  • BoundedIntTextWidget
  • ButtonWidget
  • CameraWidget
  • CheckboxWidget
  • ContainerWidget
  • DropdownWidget
  • FloatProgressWidget
  • FloatSliderWidget
  • FloatTextProgressWidget
  • FloatTextWidget
  • HTMLWidget
  • ImageWidget
  • IntProgressWidget
  • IntSliderWidget
  • IntTextWidget
  • LatexWidget
  • PasswordWidget
  • PopupWidget
  • RadioButtonsWidget
  • SelectWidget
  • SelectionWidget
  • TextWidget
  • TextareaWidget
  • ToggleButtonWidget
  • ToggleButtonsWidget

Container widgets:

  • ContainerWidget
  • PopupWidget
  • AccordionWidget
  • TabWidget
Widget().display()

Charts

In addition, there are Javascript-based widgets:

Examples:

from Widgets import Lines

lines = Lines(3) # three lines
for label, line in [["Money", [1, 2, 3]], 
                    ["Power", [5, 6, 7]],
                    ["Wealth", [2, 4, 5]]]:
    lines = Lines(lines, line, label)
calico.LineChart(lines, {"width": 800, "height": 300, "chartArea": {"width": 300}}).display()