Skip to content

Reports API v2 accepts operators that don't work in the UI #71

@al-stev

Description

@al-stev

Reports API v2 accepts operators that don't work in the UI

Problem

The Reports API v2 parser in wandb_workspaces/reports/v2/expr_parsing.py accepts the operators < (less than) and > (greater than), but these operators are not supported in the W&B UI.

The UI only supports these operators:

  • = (equals)
  • != (not equals)
  • <= (less than or equal to)
  • >= (greater than or equal to)

When users create filters with < or > operators programmatically, the filter appears in the UI but the operator dropdown is blank/unset, making the filter non-functional.

Example

import wandb_workspaces.reports.v2 as wr

# This creates a filter that won't work properly in the UI
report = wr.Report(
    entity="my-entity",
    project="my-project",
    blocks=[
        wr.PanelGrid(
            runsets=[
                wr.Runset(
                    filters='SummaryMetric("loss") < 0.5'  # < operator not supported in UI
                )
            ],
            panels=[wr.LinePlot(y=["loss"])]
        )
    ]
)

Current Code

In wandb_workspaces/reports/v2/expr_parsing.py:

def _map_op(op_node) -> str:
    op_map = {
        ast.Gt: ">",      # Not supported in UI
        ast.Lt: "<",      # Not supported in UI
        ast.Eq: "=",      
        ast.NotEq: "!=",
        ast.GtE: ">=",
        ast.LtE: "<=",
        ast.In: "IN",
        ast.NotIn: "NIN",
    }
    return op_map[type(op_node)]

Proposed Solutions

Option 1: Remove unsupported operators (Breaking Change)

Remove < and > from the parser and raise an error when users try to use them. This would be a breaking change but would prevent confusion.

Option 2: Auto-convert to supported operators

Automatically convert unsupported operators to their supported equivalents:

  • <<=
  • >>=

This maintains backward compatibility but might give slightly different results than users expect.

Option 3: Add support in the UI

Add < and > operators to the UI dropdown. This would be the ideal solution but requires frontend changes.

Workaround

For now, users should use <= and >= instead of < and >:

# Instead of: 
filters='SummaryMetric("loss") < 0.5'

# Use:
filters='SummaryMetric("loss") <= 0.5'

Related PR

This issue was discovered while working on PR #70, which added documentation about this limitation as a comment in the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions