• Stars
    star
    2,507
  • Rank 18,185 (Top 0.4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Python debugging, redefined.

Cyberbrain: Python debugging, redefined.

support-version PyPI implementation PyPI version shields.io "GitHub Discussions" Discord Twitter

Cyberbrain1(电子脑) aims to free programmers from debugging. It lets you:

  • Backtrace variable changes.

  • See every state of program execution, including variables' values

  • Debug loops with confidence.

Never spend hours stepping through a program, let Cyberbrain tell you what happened.

Read more about existing features, and roadmaps for features to come.

I gave a talk at PyCascades 2021 about Cyberbrain, watch it here.

Install

Cyberbrain consists of a Python library and various editor/IDE integrations. Currently it supports VS Code and Gitpod. See our plan on expanding the support.

To install Cyberbrain:

pip install cyberbrain
code --install-extension laike9m.cyberbrain

You can also install from PyPI , VS Code marketplace or Open VSX .

Or, you can try Cyberbrain online: Open in Gitpod

How to Use

Suppose you want to trace a function foo, just decorate it with @trace:

from cyberbrain import trace

# As of now, you can only have one @trace decorator in the whole program.
# We may change this in version 2.0, see https://github.com/laike9m/Cyberbrain/discussions/73

@trace  # Disable tracing with `@trace(disabled=True)`
def foo():
    ...

Cyberbrain keeps your workflow unchanged. You run a program (from vscode or command line, both work), and a new panel will be opened to visualize how your program executed.

The following gif demonstrates the workflow (click to view the full size image):

usage

Read our documentation to learn more about Cyberbrain's features and limitations.

❗Note on use❗

  • Cyberbrain may conflict with other debuggers. If you set breakpoints and use VSC's debugger, Cyberbrain may not function normally. Generally speaking, prefer "Run Without Debugging" (like shown in the gif).
  • If you have multiple VS Code window opened, the trace graph will always be created in the first one. #72 is tracking this issue.
  • When having multiple decorators, you should put @trace as the innermost one.
    @app.route("/")
    @trace
    def hello_world():
        x = [1, 2, 3]
        return "Hello, World!"

Roadmaps

Updated 2020.11

Cyberbrain is new and under active development, bugs are expected. If you met any, please create an issue. At this point, you should NOT use Cyberbrain in production. We'll release 1.0 when it's ready for production.

Major features planned for future versions are listed below. It may change over time.

Version Features
1.0 Code & trace interaction (#7), API specification
2.0 Multi-frame tracing (👉 I need your feedback for this feature)
3.0 async support, remote debugging
4.0 Fine-grained symbol tracing
5.0 Multi-threading support

Visit the project's kanban to learn more about the current development schedule.

How does it compare to other tools?

PySnooper PySnooper and Cyberbrain share the same goal of reducing programmers' work while debugging, with a fundamental difference: Cyberbrain traces and shows the sources of each variable change, while PySnooper only logs them. The differences should be pretty obvious after you tried both.
Debug Visualizer Debug visualizer and Cyberbrain have different goals. Debug visualizer visualizes data structures, while Cyberbrain visualizes program execution (but also lets you inspect values).
Python Tutor Python Tutor is for education purposes, you can't use it to debug your own programs. It's a brilliant tool for its purpose and I do it like it very much.
Static analysis Cyberbrain is *NOT* static analyis. It's runtime tracing. Static analysis can't provide enough information for debugging.

Community

Interested in Contributing?

See the development guide. This project follows the all-contributors specification. Contributions of ANY kind welcome!

All Contributors

Thanks goes to these wonderful contributors ✨


Alex Hall

🤔

Frost Ming

🐛 📖

Funloading

💻

Ikko Ashimine

💻

Kaustubh Gupta

📝

Ram Rachum

🤔

Siyuan Xu

🐛

Victor Sun

💻 🤔

dingge2016

💵 💻

foo bar

💵

inkuang

🐛

laixintao

📖

yihong

💵 🤔

林玮 (Jade Lin)

🐛 🤔

Support

Cyberbrain is a huge and complicated project that will last for years, but once finished, it will reshape how people think and do debugging. Your support can help sustain it. Let's make it the best Python debugging tool 🤟!

❤️ Sponsor on GitHub

1: The name of this project originates from Ghost in the Shell, quote:

Cyberization is the process whereby a normal brain is physically integrated with electronic components to produce an augmented organ referred to as a cyberbrain.

More Repositories

1

pdir2

Pretty dir() printing with joy🍺
Python
1,325
star
2

Python-Type-Challenges

Master Python typing (type hints) with interactive online exercises!
Python
435
star
3

PyPunchP2P

Python实现NAT穿透+STUN+TURN+P2P聊天 | Python P2P chat
Python
428
star
4

My_Blog

My Django Blog
HTML
209
star
5

Cyberbrain-Deprecated

[Deprecation] This project has been deprecated. Development moved to github.com/laike9m/Cyberbrain
Python
166
star
6

ezcf

Import configuration file for Pythonista
Python
159
star
7

zhihu-card

用卡片在个人网站上展示知乎账户
CSS
121
star
8

rsshub-zhihu-helper

如果你希望通过 RSSHub 浏览知乎,那么这个项目或许可以帮到你。
Python
70
star
9

Bad-Apple-Console

ASCII Art: Bad 🍎 in Windows console
C++
41
star
10

logseq-chatgpt

Talk to ChatGPT directly from Logseq
JavaScript
34
star
11

f

Log to a file without modifying code, with just one line 📝
Python
19
star
12

split_p

漫画图片分割 | split images for manga reading
Python
12
star
13

peerjs-with-nodewebkit-tutorial

How to integrate PeerJs into node-webkit/NW.js app
JavaScript
11
star
14

all_in_utf8

Recursively find and convert files to utf8 encoding
Python
5
star
15

VideoChat

elgg video chat plugin / elgg 视频通话插件
PHP
4
star
16

learn_socket

Learn Python socket programming
Python
3
star
17

CU_login

ChinaUnicom 自动登录断线重连
Python
3
star
18

logseq-twitter-sync

JavaScript
2
star
19

MusicService

读取mp3生成markdown格式的音乐列表
Python
2
star
20

Xylect

TypeScript
2
star
21

DataMining

DataMining Project
Python
1
star
22

spk_cmp2methods

compare 2 methods of speaker change detection
Python
1
star
23

h2-playground

Python
1
star
24

mysite1

My Django Project,consisting of my personal blog and the Mike Hilbert's tutorial things
Python
1
star
25

train

Python
1
star
26

Algorithm_homework_code

Python
1
star
27

pipAlwaysLatest

A wrapper around pip, install/generate requirements with the latest version
Python
1
star
28

Slides

HTML
1
star
29

cyberbrain-examples

Python
1
star
30

DumpRenrenPosts2Markdown

人人日志导出工具/Dump Renren Posts to Markdown
Python
1
star