Introducing DI-toolkit
DI-toolkit is a versatile and user-friendly utility package designed for the OpenDILab projects. It offers several helpful tools that enhance the functionalities for developers who work with data, logging, and documentation generation. This toolkit is widely beneficial for those who require a straightforward yet efficient toolkit to boost their project productivity.
Core Utilities
-
ditk.logging: This module offers an easy-to-use logging system. It has a similar interface to Python's native logging module. This means developers can adapt it into their existing projects by simply changing the import statement from
import logging
tofrom ditk import logging
. -
ditk.annotated: This is a script for generating annotated documentation, making it easier for developers to create clear and well-documented codebases. It can automatically generate HTML documents from Python source code.
-
ditk.tensorboard: A utility designed to extract and visualize data from TensorBoard log files. It includes a plotting utility,
ditk.tensorboard.plot
, which developers can use to create comprehensive visual reports from their data.
Installation
DI-toolkit is conveniently available via PyPI, allowing users to install it directly using pip:
pip install DI-toolkit
Alternatively, users can install it from the latest source code on GitHub:
git clone https://github.com/opendilab/DI-toolkit.git
cd di-toolkit
pip install . --user
Getting Started
Logging with ditk.logging: Its functionality is nearly identical to Python's built-in logging, making it intuitive to use. For example:
from ditk import logging
if __name__ == '__main__':
logging.try_init_root(logging.INFO)
logging.info('This is info')
logging.warning('This is a warning with integer 233')
logging.error('This is an error with string \'233\'.')
try:
_ = 1 / 0
except ZeroDivisionError as err:
logging.exception(err)
Generating Documentation with ditk.annotated: This script facilitates the creation of detailed and stylistic HTML documentation directly from Python files. Users can utilize command line options to specify input files, output directories, and even document language:
python -m ditk.doc.annotated create -i ditk/doc/annotated/ppo.py -o my_doc/index.html -L zh
Plotting with ditk.tensorboard: Easily generate multi-seed multi-algorithm benchmark plots:
import matplotlib.pyplot as plt
import seaborn as sns
from ditk.tensorboard.plots import tb_create_range_plots
sns.set()
tb_create_range_plots(
'test/testfile/pong_tb', # directory of tensorboard log
xname='step',
yname='evaluator_step/reward_mean',
)
plt.show()
Contribution and License
DI-toolkit is open to contributions which are welcomed to enhance its logic and system designs. Contributors can refer to the project's CONTRIBUTING.md
for guidance. The toolkit is released under the Apache 2.0 license, ensuring it is free and open to use by the community.
This toolkit is an excellent resource for developers looking to streamline their workflow and improve the efficiency of their projects. Its simple installation process and set of easy-to-learn utilities make it a must-have for data scientists and developers alike.