Skip to content

fix: replace print() with logger.warning() in new_workflow() and _register_with_scheduler()#235

Open
amathxbt wants to merge 1 commit intoOpenGradient:mainfrom
amathxbt:fix/alpha-replace-print-with-logger
Open

fix: replace print() with logger.warning() in new_workflow() and _register_with_scheduler()#235
amathxbt wants to merge 1 commit intoOpenGradient:mainfrom
amathxbt:fix/alpha-replace-print-with-logger

Conversation

@amathxbt
Copy link
Copy Markdown
Contributor

@amathxbt amathxbt commented Apr 3, 2026

Bug Fix: Replace print() with logger.warning() in alpha.py — diagnostic messages bypass logging configuration

Summary

Two places in alpha.py use print() for diagnostic output instead of the logger used everywhere else in the SDK. This means these messages bypass any log handler the user has configured and are completely invisible in non-interactive environments.


Bug 1 — new_workflow() gas estimation fallback

# BEFORE — prints to stdout, bypasses logging
except Exception as e:
    print(f"Gas estimation failed: {str(e)}")
    gas_limit = 5000000  # Conservative fallback
    print(f"Using fallback gas limit: {gas_limit}")
# AFTER — uses logger, visible in log files and monitoring
except Exception as e:
    logger.warning("Gas estimation failed: %s. Using conservative fallback gas limit of 5,000,000.", e)
    gas_limit = 5000000  # Conservative fallback

Bug 2 — _register_with_scheduler() failure

# BEFORE — prints to stdout, no contract address context
except Exception as e:
    print(f"Error registering contract with scheduler: {str(e)}")
    print("  The workflow contract is still deployed and can be executed manually.")
# AFTER — uses logger, includes contract_address for traceability
except Exception as e:
    logger.warning(
        "Failed to register workflow contract %s with scheduler: %s. "
        "The contract is still deployed and can be executed manually.",
        contract_address,
        e,
    )

Why This Matters

print() logger.warning()
Visible in log files
Works in daemon/container environments
Suppressible via log level
Visible in monitoring/alerting systems
Consistent with rest of SDK

Any user running the SDK as a service (Docker container, background process, anything with redirected stdout) would silently lose these warnings — including the critical gas estimation fallback message that tells them their transaction is using a 5M gas conservative limit instead of the estimated amount.


Affected Methods

  • Alpha.new_workflow() — gas estimation failure path
  • Alpha._register_with_scheduler() — scheduler registration failure path

@adambalogh @kylexqian — two print() calls that should be logger.warning(). Also added contract_address to the scheduler error message for better traceability. 🙏

…ister_with_scheduler()

Two diagnostic messages in alpha.py used print() instead of the logger
that the rest of the SDK uses universally:

1. new_workflow() gas estimation fallback — printed to stdout, invisible
   to any logging handler the caller has configured.
2. _register_with_scheduler() failure — same issue; also loses the
   contract_address context that is now included in the log message.

Replacing with logger.warning() makes these messages:
- Suppressible via standard log-level configuration
- Visible in log files, monitoring systems, and structured loggers
- Consistent with every other diagnostic in the SDK
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.

2 participants