Attempting to create a BarGauge panel with orientation="auto" raises an exception #634
Open
Description
What you expected to happen?
I can generate JSON for a dashboard with a BarGauge
panel with orientation set to auto.
What happened?
Attempting to create a BarGauge
panel with orientation="auto"
raises an exception when running the dashboard code through generate-dashboard
Traceback (most recent call last):
File "/Users/jwalgran/.pyenv/versions/3.8.10/bin/generate-dashboard", line 8, in <module>
sys.exit(generate_dashboard_script())
File "/Users/jwalgran/.pyenv/versions/3.8.10/lib/python3.8/site-packages/grafanalib/_gen.py", line 242, in generate_dashboard_script
run_script(generate_dashboard)
File "/Users/jwalgran/.pyenv/versions/3.8.10/lib/python3.8/site-packages/grafanalib/_gen.py", line 80, in run_script
sys.exit(f(sys.argv[1:]))
File "/Users/jwalgran/.pyenv/versions/3.8.10/lib/python3.8/site-packages/grafanalib/_gen.py", line 223, in generate_dashboard
dashboard = loader(opts.dashboard)
File "/Users/jwalgran/.pyenv/versions/3.8.10/lib/python3.8/site-packages/grafanalib/_gen.py", line 60, in loader
spec.loader.exec_module(module)
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/jwalgran/Downloads/bargauge_auto_example.dashboard.py", line 6, in <module>
BarGauge(orientation="auto"),
File "<attrs generated init grafanalib.core.BarGauge>", line 76, in __init__
File "/Users/jwalgran/.pyenv/versions/3.8.10/lib/python3.8/site-packages/attr/validators.py", line 307, in __call__
raise ValueError(
ValueError: ("'orientation' must be in ['horizontal', 'vertical'] (got 'auto')", Attribute(name='orientation', default='horizontal', validator=<in_ validator with options ['horizontal', 'vertical']>, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None, alias='orientation'), ['horizontal', 'vertical'], 'auto')
How to reproduce it?
Create bargauge_auto_example.dashboard.py
from grafanalib.core import *
dashboard = Dashboard(
panels=[
BarGauge(orientation="auto"),
],
title="Operations Dashboard",
).auto_panel_ids()
Attempt to generate JSON
generate-dashboard bargauge_auto_example.dashboard.py > bargauge_auto_example.dashboard.json
Additional context
Definition of the BarGauge.orientation
attribute is here
Lines 3372 to 3375 in c82a679
The documentation for BarGauge
list auto
as a valid option
https://grafana.com/docs/grafana/latest/panels-visualizations/visualizations/bar-gauge/#orientation
Metadata
Assignees
Labels
No labels