Skip to content

Commit 67fe5f8

Browse files
authored
Merge pull request #755 from NVIDIA/am/bokeh-ver
Fix bokeh charts generation
2 parents e7a2ab8 + daf6be3 commit 67fe5f8

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

src/cloudai/report_generator/comparison_report.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,14 @@ def create_chart(
179179
hover = lazy.bokeh_models.HoverTool(tooltips=[("X", "@x"), ("Y", "@y"), ("Segment Type", "@segment_type")])
180180
p.add_tools(hover)
181181

182+
if all(df.empty for df in dfs):
183+
logging.debug(f"No data available to create chart for group {group.name}, skipping.")
184+
return p
185+
182186
for df, name in zip(dfs, [item.name for item in group.items], strict=True):
187+
if df.empty:
188+
continue
189+
183190
for col in data_columns:
184191
source = lazy.bokeh_models.ColumnDataSource(
185192
data={
@@ -196,12 +203,13 @@ def create_chart(
196203
p.legend.location = "top_left"
197204
p.legend.click_policy = "hide"
198205

199-
y_max = max(df[col].max() for df in dfs for col in data_columns)
200-
y_min = min(df[col].min() for df in dfs for col in data_columns)
206+
y_max = max(df[col].max() for df in dfs for col in data_columns if not df.empty)
207+
y_min = min(df[col].min() for df in dfs for col in data_columns if not df.empty)
201208
p.y_range = lazy.bokeh_models.Range1d(start=y_min * -1 * y_max * 0.01, end=y_max * 1.1)
202209

203-
x_min = dfs[0][info_columns[0]].min()
204-
x_max = dfs[0][info_columns[0]].max()
210+
df_with_max_rows = max(dfs, key=len)
211+
x_min = df_with_max_rows[info_columns[0]].min()
212+
x_max = df_with_max_rows[info_columns[0]].max()
205213
p.xaxis.ticker = calculate_power_of_two_ticks(x_min, x_max)
206214
p.xaxis.formatter = lazy.bokeh_models.CustomJSTickFormatter(code=bokeh_size_unit_js_tick_formatter)
207215
p.xaxis.major_label_orientation = lazy.np.pi / 4

src/cloudai/util/nixl_report_template.jinja2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<head>
55
<title>{{ title }}</title>
66
<meta charset="UTF-8">
7-
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-3.4.0.min.js"></script>
8-
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.4.0.min.js"></script>
9-
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.4.0.min.js"></script>
7+
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-3.8.0.min.js"></script>
8+
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.8.0.min.js"></script>
9+
<script src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.8.0.min.js"></script>
1010
<style>
1111
body {
1212
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

tests/report_generation_strategy/test_comparison_report.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
from pathlib import Path
18+
1719
import bokeh.plotting as bk
1820
import pandas as pd
1921
import pytest
22+
import toml
23+
from packaging.requirements import Requirement
24+
from packaging.version import Version
2025
from rich.table import Table
2126

2227
from cloudai.core import TestRun, TestScenario
@@ -135,3 +140,30 @@ def test_create_charts(cmp_report: MyComparisonReport, nccl_tr: TestRun) -> None
135140
["value"],
136141
"y_axis_label",
137142
)
143+
144+
145+
def test_bokeh_cdn_version_matches_pyproject():
146+
bokeh_dep = None
147+
for dep in toml.load(Path("pyproject.toml"))["project"]["dependencies"]:
148+
if dep.startswith("bokeh"):
149+
bokeh_dep = dep
150+
break
151+
152+
assert bokeh_dep is not None, "bokeh dependency not found in pyproject.toml"
153+
154+
req = Requirement(bokeh_dep)
155+
assert req.specifier, f"No version specifier found in: {bokeh_dep}"
156+
157+
template_path = Path("src/cloudai/util/nixl_report_template.jinja2")
158+
template_content = template_path.read_text()
159+
160+
pyproject_version = Version(f"{req.specifier}".lstrip("~=<>!"))
161+
ver_str = f"-{pyproject_version.major}.{pyproject_version.minor}.0"
162+
163+
for line in template_content.splitlines():
164+
if "cdn.bokeh.org/bokeh/release" not in line:
165+
continue
166+
167+
assert ver_str in line, (
168+
f"Bokeh CDN version ({line}) in template does not match pyproject.toml version ({pyproject_version})."
169+
)

0 commit comments

Comments
 (0)