8 Star 54 Fork 12

Gitee 极速下载 / baserow

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://gitlab.com/bramw/baserow.git
克隆/下载
debugging.md 2.19 KB
一键复制 编辑 原始数据 按行查看 历史
Petr Stribny 提交于 2022-02-21 13:03 . Add dev dependencies for debugging

Debugging Tools

Baserow development dependencies include some useful tools for debugging that you can use.

snoop

snoop is a powerful set of Python debugging tools.

Automatic tracing

One of the common things to do is to use the @snoop decorator or the snoop context manager to trace the execution of a piece of Python code and show how variable values change over time:

@snoop
def test():
    for i in range(5):
        a = i*2

# or

with snoop:
    for i in range(5):
        a = i*2

The depth can be controlled with depth parameter, e.g. @snoop(depth=2) for tracing functions that go deep.

Objects and dictionaries can be expanded automatically to show all their items or attributes using the watch_explode parameter taking a list of watched variable names:

@snoop(watch_explode=['d'])
def test():
    d = {'key1': 0, 'key2': 1}
    for i in range(5):
        d["key1"] += 1

Pretty printing

Besides automatic tracing, variables can be pretty printed manually with pp function:

d = {'key1': 0, 'key2': 1}
pp(d)

Note that import snoop or from snoop import pp is not necessary as snoop is installed and available automatically.

django-extensions

django-extensions is available to provide a variety of features like a shell with auto-imported Django models or a command to list all registered urls.

You can use django-extensions commands inside backend docker containers:

  • django-admin shell_plus starts an interactive Python shell with loaded Django contexts and imported models.
  • django-admin show_urls lists all registered urls in the Baserow.

django-silk

django-silk is a live profiling and inspection tool for executed requests and database queries.

The interface can be accessed at http://localhost:8000/silk/ after Baserow is started in the debug mode. Every request is logged and can be analyzed, including the list of performed database queries.

django-silk can be also configured and used for profiling using the Python's built-in profiler, see the official documentation for details.

Python
1
https://gitee.com/mirrors/baserow.git
git@gitee.com:mirrors/baserow.git
mirrors
baserow
baserow
develop

搜索帮助