Debugging#

Here we would like to describe possible techniques that could help you to find and understand issues in your code.

Show stack trace#

We provide ability to show line of code where the issue happens in case if code is written in onetick.py.

In code your set or otp.config['show_stack_info'] or the OTP_SHOW_STACK_INFO env variable to enable this option (more about it is here)

In tests your could use the --show-stack-trace option.

Dumping ticks#

The .dump() method allows to print out incoming ticks, that might help to find ticks that leads to incorrect behaviour and reproduce it then in tests.

onetick view#

onetick view is a terminal UI for browsing OneTick databases and their content.

This tool is built on the top of the onetick.py and distributed as a separate python package.

After installation a developer just needs to go to a folder with OneTick databases and executes the onetick view command in terminal – it automatically discovers databases and show them.

Usually it’s convenient to use this tool along with the --keep-generated flag in tests, because this flag provides all databases are used in tests with their content.

../../_images/onetick-view.png

Save OTQ#

Any otp.Source object has the .to_otq() method that allows to save a query on the disk with goal to check the OTQ graph. Note that this method has symbols and start/end query interval parameters that’s better to pass there the same as for otp.run because these parameters could change graph calculation.

It’s often useful when you think the onetick.py constructs the wrong calculation or you want to check some details.

Setting name of the query#

Method otp.Source.set_name can be used to set the name of the source. This name will be used as a part of the resulting .otq file name and as the name of the query inside this file.

Graph rendering#

Alternatively we could propose to use the .render() method on the otp.Source that draws a query as the graphviz DAG. It could help with quick investigations because save OTQ requires a running tick server and connected to it OneTick client with necessary context.

Logging symbols#

Configuration parameter otp.config.log_symbol and parameter log_symbol of function otp.run can be used to enable printing of each processed symbol to the standard output.

Note that this method has some limitations:

  • In this case function otp.run is called in callback mode, thus it doesn’t return pandas.DataFrame or other object.

  • This only works with unbound symbols, so it will not work if otp.merge is used to merge symbols into one flow.