Cookbook
The cookbook contains recipes for common or useful tasks.
PyCell Template
PyCell is a plugin included with Quantum. It provides the ability to author new
cells in Python. We provide a general template to provide a quick start to
building new cell types in native Python.
Create the Python file that will define your cell.
You should put this file in your PyCell user directory. This is located at
/Users/[username]/.kivy/mods/UDPyCell
.
Attention
This process will change in the future. Instead of creating
the file in a specific location, you will be able to browse to the file
from Quantum and choose to install the file for either all users or only
for the current user.
Copy and paste the following template into your new file:
import PyCell
from PyCell.custom_cell import Custom
class MyCell(Custom):
"""
Provide your docstring for MyCell here.
"""
def __init__(self):
self.inputs = {} # add your own input variables
self.outputs = {} # add your own output variables
self.inflows = ['>>'] # remove this line if the cell doesn't require token-based execution
self.outflows = {} # add any token outputs here, remove if you don't need it
# Add any additional initialization you might need
def process(self):
# Add your process code here
return super().process() # this return line is required
# Be sure to add your new cell to the registry so that it will be
# available to Quantum:
PyCell.registry.append({
'name': 'MyCell',
'module': 'UDPyCell.my_cell',
'categories': ['Category1','Category2','MyCell']
})
To make sure your cell appears in Quantum, you need to make sure it is added
to PyCell’s registry. You see this code in the last 5 lines. Here’s an
explanation of the dictionary items:
- name: This should match the name of your class exactly.
- module: The format is
UDPyCell.[filename]
. Replace [filename]
with
the name of your python file.
- categories: This list determines the contextual menu path to take in order
to reach your cell. This is how the user will navigate the right click to
use your cell.
Graph Database
The underlying graph database uses the TinkerPop API, which means you can use
you own tools of choice to manipulate the application data.
Attention
Our current graph database provider is TitanDB 0.5.4, but this
will change in the future. Regardless what data provider we may use in the
future, it will use the TinkerPop API so you can continue to rely on having
the Gremlin query language as the method of interaction with the underlying
data.
Titan DB, our current graph database, exposes a Gremlin console through a
website that you can access. You can find this console at
http://localhost:8182
. From here you can execute Gremlin queries to
manipulate the data. For example, you can clear out the entire database:
gremlin> g.V.remove()
==> null
gremlin> g.commit()
==> null
If you have Quantum running, the graph database will be running and you will be
able to connect to it. However, if you do not have Quantum open, then the graph
database server may not be running and in this situation, you may need to
manually start the server.
$ /Applications/Quantum.app/Contents/Frameworks/titan-0.5.4-hadoop2/titan.sh start
Generate an Eclipse Project
Quantum projects uses cmake as the build system. Cmake can generate eclipse
project files if you use that as your IDE. As an example, this section will
provide a recipe for creating an eclipse project with PyCell:
$ git clone https://github.com/QuantumActuary/Quantum-PyCell.git
$ cd Quantum-PyCell
$ cmake -G"Eclipse CDT4 - Unix Makefiles"
Now you can import this project in eclipse by going to File
> Import
>
Existing Project
.
Pip Install Python Modules
For developers, you may wish to install python modules into Quantum’s Python
environment. You can do this like so:
$ quantum -m pip install <package name>