• Stars
    star
    313
  • Rank 129,163 (Top 3 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 10 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quantopian Remote Debugger for Python

qdb

build status Gitter

Remote Debugger for Python

qdb powers the in-browser debugger at Quantopian

Overview

qdb is a debugger for python that allows users to debug code executing on remote machine. qdb is split into three main components that may all be running on separate hardware:

  • The client
  • The tracer
  • The server

The client is the user's interface to the debugger. All communication here is through a websocket connected to the server. This client could be any type of application. qdb provides a terminal client and emacs mode for this.

The tracer is the main debugging process. This is the actual code that the user wishes to debug. Communication here is through a socket sending json objects representing only the valid messages sent to the server from the client. A single tracer may have multiple clients connected to it.

The server is the main routing station for messages between the clients and the tracer. The server is responsible for validating that the messages from the clients are well formed and routing them to the tracer. A single server may manage multiple tracers, so it is responsible for making sure that connections are routed to the proper place. The server can clean up tracer processes whose clients have become inactive if the server manager decides. The server may also impose authentication rules to allow or disallow some connections.

Getting started

To debug a process with qdb locally, first you must start the server process.

The easiest way to do this is to execute:

$ python -m qdb.server

which will start up a server that accepts tracer connections on port 8001, and client connections on port 8002. There are a few options that may be passed to the server from the command line, to see a full list, run:

$ python -m qdb.server --help

Now that you have a server running, you may run a process under qdb. As an example, try saving the following as qdb_test.py:

from qdb import set_trace, RemoteCommandManager


def f():
    in_f = True
    return 'getting out of f'


def main():
    set_trace(
        uuid='qdb',
        host='localhost',
        port=8001,
        cmd_manager=RemoteCommandManager(),
    )
    mutable_object = {}
    print 'Hello world!'
    f()
    print mutable_object


if __name__ == '__main__':
    main()

Then, invoke the program as you normally would with:

$ python qdb_test.py

Finally, you will need to connect your client to the server so that you can actually debug the program. To connect, run the provided client found in the client directory with:

$ qdb-cli

Before you are finished, you will need to get the output from the program, in a seperate terminal, run:

$ tail -f /tmp/qdb/.qdb

This will be the realtime output from the debugger.

You are now ready to debug your process, issue the help command in the repl to see a list of available commands and functions, or begin evaluating python code in the context of the other process.

Contributions

If you would like to contribute, please see our Contribution Requests.

Requirements

To download the requirements, you can simply issue:

$ make requirements

assuming you have pip installed. You will most likely want to install into a virtualenv.

To view the development and normal requirements, see etc/requirements_dev.txt and etc/requirements.txt.

Style

To ensure that changes and patches are focused on behavior changes, the qdb codebase adheres to both PEP-8, http://www.python.org/dev/peps/pep-0008/, and pyflakes, https://launchpad.net/pyflakes/.

The maintainers check the code using the flake8 script, https://bitbucket.org/tarek/flake8/wiki/Home, which is included in the etc/requirements_dev.txt.

Before submitting patches or pull requests, please ensure that running make style and make test both pass.

Source

The source for qdb is hosted at: https://github.com/quantopian/qdb

Contact

For other questions, please contact [email protected].

More Repositories

1

zipline

Zipline, a Pythonic Algorithmic Trading Library
Python
16,969
star
2

pyfolio

Portfolio and risk analytics in Python
Jupyter Notebook
5,379
star
3

alphalens

Performance analysis of predictive (alpha) stock factors
Jupyter Notebook
3,094
star
4

qgrid

An interactive grid for sorting, filtering, and editing DataFrames in Jupyter notebooks
Python
3,018
star
5

research_public

Quantitative research and educational materials
Jupyter Notebook
2,301
star
6

empyrical

Common financial risk and performance metrics. Used by zipline and pyfolio.
Python
1,210
star
7

trading_calendars

Calendars for various securities exchanges.
Python
602
star
8

quantopian-algos

Library of algorithm scripts for Quantopian
Python
171
star
9

pgcontents

A Postgres-backed ContentsManager implementation for Jupyter
Python
149
star
10

coal-mine

Coal Mine - Periodic task execution monitor
Python
110
star
11

bayesalpha

Bayesian models to compute performance and uncertainty of returns and alpha.
Python
100
star
12

algorithm-component-library

A collection of code snippets that can be constructed into larger trading algorithms.
Python
100
star
13

PenguinDome

Simple Linux Mobile Device Management
Python
87
star
14

libpy

Utilities for writing C++ extension modules.
C++
79
star
15

warp_prism

Quickly move data from postgres to numpy or pandas.
C
63
star
16

qgrid-notebooks

Notebooks which will provide a demo of Qgrid functionality
Jupyter Notebook
20
star
17

serializable-traitlets

JSON-Serializable IPython Traitlets
Python
13
star
18

metautils

Utilities for writing metaclasses.
Python
8
star
19

DockORM

An object-relational mapper for docker containers.
Python
8
star
20

quantopian-drafts

Drafts for new Quantopian features.
6
star
21

aqueduct-client

Python wrapper for Quantopian's Aqueduct API
Python
2
star
22

nose_xunit_gevent

Xunit for the nose_gevented_multiprocess plugin
Python
2
star
23

quantopian.github.io

CSS
1
star
24

camo-client

A python client for Github's Camo image proxy
Python
1
star