Skip to content

[cards] debugging statements.#3273

Open
valayDave wants to merge 1 commit into
Netflix:masterfrom
valayDave:valay/card-debugging
Open

[cards] debugging statements.#3273
valayDave wants to merge 1 commit into
Netflix:masterfrom
valayDave:valay/card-debugging

Conversation

@valayDave

Copy link
Copy Markdown
Collaborator

PR Type

  • Debugging
  • Bug fix
  • New feature
  • Core Runtime change (higher bar -- see CONTRIBUTING.md)
  • Docs / tooling
  • Refactoring

Summary

Have a env var that allow debugging cards through metaflow's debug module.

@valayDave
valayDave requested review from npow, saikonen and talsperre and removed request for saikonen June 15, 2026 11:05
@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a "card" debug option to Metaflow's debug module, enabling card-subsystem tracing via METAFLOW_DEBUG_CARD=1. Debug log calls are added at key lifecycle points in card creation and decoration.

  • metaflow_config.py: registers \"card\" in DEBUG_OPTIONS, auto-generating debug.card_exec and the debug.card boolean flag.
  • card_creator.py: adds logging around card creation, async process management, and subprocess error output; two minor issues in the exception handlers (dead-code conditional and unguarded UTF-8 decode).
  • card_decorator.py: adds logging in task_pre_step and task_finished; changes are clean and well-placed.

Confidence Score: 4/5

Safe to merge; changes are limited to debug logging paths that only activate when METAFLOW_DEBUG_CARD is set.

All changes are confined to debug logging paths that only activate when METAFLOW_DEBUG_CARD is set, so normal card execution is unaffected. The dead-code ternary and unguarded UTF-8 decode in the exception handlers are worth cleaning up but cannot impact production runs.

metaflow/plugins/cards/card_creator.py — the exception handler debug blocks have a dead-code conditional and an unguarded UTF-8 decode worth cleaning up.

Important Files Changed

Filename Overview
metaflow/metaflow_config.py Adds "card" to DEBUG_OPTIONS, which causes the debug module to auto-generate debug.card_exec and debug.card attributes; straightforward and consistent with existing entries.
metaflow/plugins/cards/card_creator.py Adds card-debug logging at key points in card creation; the exception handlers contain a dead-code ternary and a potential UnicodeDecodeError from bare rep.decode("utf-8"); the first debug statement also misses the early-return silent-ignore path.
metaflow/plugins/cards/card_decorator.py Adds two debug log calls in task_pre_step and task_finished; clean and correctly placed after the relevant state is set.

Reviews (1): Last reviewed commit: "[cards] debugging statements." | Re-trigger Greptile

Comment on lines 225 to +248
except subprocess.CalledProcessError as e:
rep = e.output
fail = True
if debug.card and rep is not None:
debug.card_exec(
"render subprocess for %s %s output:\n%s"
% (
card_uuid,
"FAILED" if fail else "succeeded",
rep.decode("utf-8"),
)
)
except subprocess.TimeoutExpired as e:
rep = e.output
fail = True
if debug.card and rep is not None:
debug.card_exec(
"render subprocess for %s %s output:\n%s"
% (
card_uuid,
"FAILED" if fail else "succeeded",
rep.decode("utf-8"),
)
)

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.

P2 The "FAILED" if fail else "succeeded" conditional is dead code in both exception handlers — fail is set to True on the line immediately above, so the else branch can never execute. The suggestion also adds errors="replace" to rep.decode("utf-8") to avoid a UnicodeDecodeError if subprocess output contains non-UTF-8 bytes.

Suggested change
except subprocess.CalledProcessError as e:
rep = e.output
fail = True
if debug.card and rep is not None:
debug.card_exec(
"render subprocess for %s %s output:\n%s"
% (
card_uuid,
"FAILED" if fail else "succeeded",
rep.decode("utf-8"),
)
)
except subprocess.TimeoutExpired as e:
rep = e.output
fail = True
if debug.card and rep is not None:
debug.card_exec(
"render subprocess for %s %s output:\n%s"
% (
card_uuid,
"FAILED" if fail else "succeeded",
rep.decode("utf-8"),
)
)
except subprocess.CalledProcessError as e:
rep = e.output
fail = True
if debug.card and rep is not None:
debug.card_exec(
"render subprocess for %s FAILED output:\n%s"
% (
card_uuid,
rep.decode("utf-8", errors="replace"),
)
)
except subprocess.TimeoutExpired as e:
rep = e.output
fail = True
if debug.card and rep is not None:
debug.card_exec(
"render subprocess for %s TIMED OUT output:\n%s"
% (
card_uuid,
rep.decode("utf-8", errors="replace"),
)
)

Comment on lines +91 to +94
debug.card_exec(
"create card_uuid=%s mode=%s final=%s sync=%s runtime_card=%s save_metadata=%s"
% (card_uuid, mode, final, sync, runtime_card, save_metadata)
)

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.

P2 Silent-ignore case not captured by debug log

When mode != "render" and not runtime_card the method returns early (line 82) before reaching this debug.card_exec call, so calls that are silently dropped are invisible even with debug enabled. Moving the debug statement before the if/elif/else block (or adding a separate log in the early-return branch) would make this case observable.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 9 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@38797e3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
metaflow/plugins/cards/card_creator.py 22.22% 7 Missing ⚠️
metaflow/plugins/cards/card_decorator.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3273   +/-   ##
=========================================
  Coverage          ?   28.94%           
=========================================
  Files             ?      381           
  Lines             ?    52525           
  Branches          ?     9268           
=========================================
  Hits              ?    15202           
  Misses            ?    36287           
  Partials          ?     1036           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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