Skip to content

Import tableauserverclient lazily in TableauHook - #68971

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:lazy-import-tableauserverclient-in-hook
Jun 26, 2026
Merged

Import tableauserverclient lazily in TableauHook#68971
potiuk merged 1 commit into
apache:mainfrom
potiuk:lazy-import-tableauserverclient-in-hook

Conversation

@potiuk

Copy link
Copy Markdown
Member

tableauserverclient self-instruments via beartype's import hook on first import, which is slow on a cold runner (~50s observed in CI). ProvidersManager imports the tableau hook module only to discover provider metadata and never instantiates the hook, yet the module-level from tableauserverclient import ... forced that whole cost onto the provider scan — enough to hit the 60s per-test timeout on the cold-cache Pendulum2 special-test job (Tests (AMD), v3-3-test).

Import tableauserverclient lazily inside the methods that actually use it (Server in __init__, TableauAuth/JWTAuth in auth, Pager in get_all; Pager kept under TYPE_CHECKING for the annotation). Importing the hook module no longer loads tableauserverclient at all, so the provider-manager scan test drops from ~50s to ~10s. Hook-test patches are retargeted to tableauserverclient.* since the names are now imported there at call time.

Verified locally: 18/18 tableau hook tests pass; importing the hook module no longer imports tableauserverclient; the provider-manager test is ~10s; breeze run mypy + ruff clean.

Should be backported to v3-3-test (where the timeout surfaced).


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

tableauserverclient self-instruments via beartype's import hook on first import,
which is slow on a cold runner (~50s observed in CI). The ProvidersManager
imports the tableau hook module only to discover provider metadata and never
instantiates the hook, yet the module-level import forced that whole cost onto
the provider scan -- enough to hit the 60s per-test timeout on the cold-cache
Pendulum2 special-test job.
Import tableauserverclient lazily inside the methods that actually use it, so
importing the hook module no longer loads it at all. The provider-manager scan
test drops from ~50s to ~10s. Hook-test patches are retargeted to
tableauserverclient.* since the names are now imported there at call time.

@bugraoz93bugraoz93 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good import time improvement!

@potiuk
potiuk merged commit a85c7aa into apache:mainJun 26, 2026
77 checks passed
@potiuk
potiuk deleted the lazy-import-tableauserverclient-in-hook branch June 26, 2026 18:48
karenbraganz pushed a commit to karenbraganz/airflow that referenced this pull request Jun 30, 2026
tableauserverclient self-instruments via beartype's import hook on first import,
which is slow on a cold runner (~50s observed in CI). The ProvidersManager
imports the tableau hook module only to discover provider metadata and never
instantiates the hook, yet the module-level import forced that whole cost onto
the provider scan -- enough to hit the 60s per-test timeout on the cold-cache
Pendulum2 special-test job.
Import tableauserverclient lazily inside the methods that actually use it, so
importing the hook module no longer loads it at all. The provider-manager scan
test drops from ~50s to ~10s. Hook-test patches are retargeted to
tableauserverclient.* since the names are now imported there at call time.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@potiuk@bugraoz93