Skip to content

gpsaggese/helpers / .claude/skills/notebook.fix_logging

notebook.fix_logging

Verified

Use idiom for controlling logging in Jupyter notebooks

Goal

  • Implement the instructions in .claude/skills/notebook.rules.md under ## Use Standard Template Structure

  • Use the structure from .claude/templates/notebook.template.py for notebook initialization

  • Use display

  • The local utility *_utils.py should have a function like

    import helpers.hnotebook as hnotebo
    
    def init_loggers(notebook_log: logging.Logger) -> None:
        """
        Wire the notebook logger into the utils logger.
    
        :param notebook_log: logger owned by the notebook
        """
        hnotebo.init_loggers(notebook_log, utils_log=_LOG)
    
    • hnotebo.init_loggers() already calls config_notebook(), initializes hdbg at INFO level, and redirects the notebook and utils loggers to print
    • For a third-party logger (e.g., causalml), redirect it inside init_loggers() with hnotebo.set_logger_to_print():
      hnotebo.set_logger_to_print(logging.getLogger("causalml"))
      
  • The last setup cell in the notebook calls utils.init_loggers(_LOG), not logging.basicConfig() or hdbg.init_logger()

Workflow

Sync Notebook

  • At the end, sync the paired .py file with Jupytext following the conventions in # Code Architecture and Responsibility -> ## Utilities vs. Notebook Responsibilities in .claude/skills/notebook.rules.md

Conventions

  • Always follow the conventions and guidelines in .claude/skills/notebook.rules.md

Verification

  • Confirm the notebook init cell matches .claude/templates/notebook.template.py
  • Confirm utils.init_loggers() is called and log messages print in the notebook
  • Confirm the .ipynb and paired .py file are in sync via Jupytext
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 117kUpdated Claude CodeCodexVerifiedInstall
Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 117kUpdated Claude CodeCodexVerifiedInstall