Statistics collection extension for Dialog Flow Framework
dff_node_stats is package, that extends basic dialog_flow_engine by adding statistic collection and dashboard for visualization.
Installation
Installation:
# install dialog flow framework
pip install dff
# Install dff_node_stats
pip install dff-node-stats #basic
# the default version is only capable of saving stats to a csv file.
# However, you can use any combination of the listed extras that give you much more
# freedom in saving and analyzing your data.
# pip install dff-node-stats[api] # extra for rest-api interface
# pip install dff-node-stats[streamlit] # extra for streamlit-based dashboard
# pip install dff-node-stats[jupyter] # extra for jupyter-based dashboard
# pip install dff-node-stats[pg] # extra for postgresql backend
# pip install dff-node-stats[clickhouse] # extra for clickhouse backend
# pip install dff-node-stats[all] # extra for all options
Code snippets
Insert stats in your dff code:
# import dependencies
from df_engine.core.plot import Plot
from df_engine.core.actor import Actor
from dff_node_stats import Stats, Saver
# ....
# Define a plot and an actor
plot = Plot(foo)
actor = Actor(bar, baz)
# Define file for stats saving
stats = Stats(
saver=Saver("csv://examples/stats.csv")
)
# As an alternative, you can use a database. Currently, Clickhouse and Postgreql are supported
stats = Stats(
saver=Saver("postgresql://user:password@localhost:5432/default")
)
# You can optionally add predefined Collectors to gather additional data
from dff_node_stats import collectors as DSC
from dff_node_stats import Stats, Saver
stats = Stats(
saver=Saver("csv://examples/stats.csv"),
collectors=[
DSC.NodeLabelCollector()
]
)
# Or define your own Collector.
# It should implement methods and properties, defined in the Collector protocol,
# which will make it compatible with multiple databackends.
# For more information see dff_node_stats.collectors
# Add handlers to actor
stats.update_actor_handlers(actor, auto_save=False)
# ....
# Handle user requests
# ....
Dashboard on stored data ([streamlit] extra required!):
from dff_node_stats import Stats, Saver
from dff_node_stats.widgets.streamlit import StreamlitDashboard
stats = Stats(
saver=Saver("csv://examples/stats.csv")
)
streamlit_dashboard = StreamlitDashboard(df)
streamlit_dashboard()
http-api on stored data ([api] extra required!om dff_node_stats import Stats, Saver
from dff_node_stats.api import api_run
from dff_node_stats import Stats, Saver
stats = Stats(
saver=Saver("csv://examples/stats.csv"),
collectors=[
DSC.NodeLabelCollector()
]
)
api_run(stats.dataframe)
Run Examples:
# run dff dialog bot and collect stats
python examples/1.collect_stats.py
# or this one, they have differences only in a dialog scripts
python examples/1.collect_stats_vscode_demo.py
# run dashboard (make sure you installed the lib with [streamlit] extra)
streamlit run examples/2.run_dashboard_for_stats.py
# run api and follow to swagger by http://localhost:8000/docs
# note that [api] install option is required.
python examples/2.get_stats_by_api.py
# jupyter version of the dashboard can be launched by:
jupyter notebook examples/run_dashboard.ipynb
# you need to have [jupyter] option installed.
Metadata
Release files for dff-node-stats 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dff_node_stats-0.1.2.tar.gz | 24.9 kB | Without provenance | Details for dff_node_stats-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dff_node_stats-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for dff_node_stats-0.1.2-py3-none-any.whl |
Total release size: 57.9 kB
Release files / dff_node_stats-0.1.2.tar.gz
| Download URL | dff_node_stats-0.1.2.tar.gz |
|---|---|
| Size | 24.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea14e9f715f68e018da8ab699ee443ff28df3e0f8fb4db810b22cb58ce16593c
|
|
BLAKE2b-256 checksum How to use checksums |
5e310076110b4d39d7309db546b6bc2be983de73b2563ee5eb50575f4f48e0cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / dff_node_stats-0.1.2-py3-none-any.whl
| Download URL | dff_node_stats-0.1.2-py3-none-any.whl |
|---|---|
| Size | 33.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ef9bb213800b94a4e158244e4084f59a278276f9b5811cac2dcfed760d05008
|
|
BLAKE2b-256 checksum How to use checksums |
62b6f8ee92ceee72cd07409132e37509d3b50e1fc03e4a2dc58f47f845514acb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for dff-node-stats 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.