Skip to content

fix: replace wandb_gql import with execute_graphql for wandb>=0.27.1 compat#3086

Open
TM23-sanji wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
TM23-sanji:main
Open

fix: replace wandb_gql import with execute_graphql for wandb>=0.27.1 compat#3086
TM23-sanji wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
TM23-sanji:main

Conversation

@TM23-sanji

@TM23-sanji TM23-sanji commented Jul 19, 2026

Copy link
Copy Markdown

Bug: wandb_gql import fails with W&B SDK >=0.27.1

Package: prime-rl
File: prime_rl/utils/monitor/wandb.py
Commit: 256809b (latest main)

Description

prime_rl/utils/monitor/wandb.py imports from wandb_gql import gql — a private, vendored module that was bundled inside the W&B Python SDK. W&B SDK v0.27.1 removed this vendored module as part of PR #11818 (routing GraphQL through wandb-core).

This means a fresh pip install prime-rl resolves to wandb>=0.27.1 and fails at import time:

$ python3 -c "from prime_rl.utils.monitor.wandb import WandbMonitor"
Traceback (most recent call last):
  ...
  File "prime_rl/utils/monitor/wandb.py", line 18, in <module>
    from wandb_gql import gql
ModuleNotFoundError: No module named 'wandb_gql'

This also breaks the orchestrator and rl entrypoints since the monitor is imported at startup:

File "/home/ubuntu/wordle/.venv/bin/orchestrator", line 10, in <module>
    sys.exit(main())
  ...
  File "prime_rl/utils/monitor/wandb.py", line 18, in <module>
    from wandb_gql import gql
ModuleNotFoundError: No module named 'wandb_gql'

Root Cause

The file uses two private/internal APIs from the wandb SDK:

  1. from wandb_gql import gqlwandb_gql was a vendored copy of the gql GraphQL library inside wandb/vendor/gql-0.2.0/wandb_gql/. W&B SDK v0.27.1 deleted it.
  2. wandb.Api().client.execute()wandb.Api().client was the gql.Client instance. The modern replacement is wandb.Api()._service_api.execute_graphql().

Both were never public API — they were internal implementation details that happened to be importable.

Fix

Replacement API: wandb.Api()._service_api.execute_graphql() accepts a raw GraphQL query string (no gql() parsing needed) and returns a plain dict — same shape as before.

Changes (3 lines in one file)

File: prime_rl/utils/monitor/wandb.py

1. Remove the import (line 18):

-from wandb_gql import gql

2. Replace gql() parsing + client.execute() with raw string + execute_graphql():

-def list_views(entity: str, project: str) -> list[tuple[str, str]]:
-    query = gql(
-        """
+def list_views(entity: str, project: str) -> list[tuple[str, str]]:
+    query = """
         query Views($entity: String!, $project: String!) {
           project(name: $project, entityName: $entity) {
             allViews(viewType: "project-view") { edges { node { name displayName } } }
           }
         }
-        """
-    )
-    res = wandb.Api().client.execute(query, variable_values={"entity": entity, "project": project})
+    """
+    res = wandb.Api()._service_api.execute_graphql(query, {"entity": entity, "project": project})

That's it. The _service_api attribute exists in wandb SDK v0.27.0+ (earlier versions had client). Since v0.27.1 is required for the vendored wandb_gql removal to be a problem, this is always available.

Verified

  • Python 3.12, wandb 0.28.1 (latest)
  • WandbMonitor imports successfully
  • list_views imports successfully
  • Full rl @ config.toml --dry-run passes
  • No dependency pins or workarounds needed

Workaround (temporary)

Until this fix lands upstream, pin wandb<0.27.1:

uv pip install "wandb<0.27.1"

Context

This is the same issue that affected wandb-workspaces (fixed in v0.4.2) and the W&B MCP server (temporarily worked around with wandb<0.27.1 cap, then resolved by upgrading wandb-workspaces).

References


Note

Low Risk
Narrow compatibility swap in W&B overview view listing; no auth, training, or data-path changes.

Overview
Restores W&B monitor import and startup on wandb>=0.27.1, where the vendored wandb_gql module was removed.

list_views now sends a plain GraphQL string through wandb.Api()._service_api.execute_graphql() instead of gql() plus wandb.Api().client.execute(). The wandb_gql import is dropped. Behavior for listing saved project views (used by ensure_overview_view) is unchanged.

Reviewed by Cursor Bugbot for commit 3f4f653. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3f4f653. Configure here.

)
res = wandb.Api().client.execute(query, variable_values={"entity": entity, "project": project})
"""
res = wandb.Api()._service_api.execute_graphql(query, {"entity": entity, "project": project})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incompatible wandb GraphQL API call

Medium Severity

list_views now calls wandb.Api()._service_api.execute_graphql, which only exists after the wandb-core GraphQL routing change in wandb 0.27.1. The project still allows wandb>=0.26.1 and locks 0.27.0, so overview-view lookup can fail with AttributeError on supported installs. Failures are caught as warnings, so training continues but curated overview reuse/creation silently stops working.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3f4f653. Configure here.

@TM23-sanji

Copy link
Copy Markdown
Author

Closes #3087

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant