From 5eedd0ed9d44e9bc8de61714e312531c2997f6a1 Mon Sep 17 00:00:00 2001 From: AMATH <116212274+amathxbt@users.noreply.github.com> Date: Fri, 3 Apr 2026 22:43:03 +0100 Subject: [PATCH] fix: replace print() with logger.warning() in new_workflow() and _register_with_scheduler() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/opengradient/client/alpha.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/opengradient/client/alpha.py b/src/opengradient/client/alpha.py index d2957c2..25ef089 100644 --- a/src/opengradient/client/alpha.py +++ b/src/opengradient/client/alpha.py @@ -6,6 +6,7 @@ """ import base64 +import logging import json import urllib.parse from typing import Dict, List, Optional, Union @@ -21,6 +22,8 @@ from ._conversions import convert_array_to_model_output, convert_to_model_input, convert_to_model_output # type: ignore[attr-defined] from ._utils import get_abi, get_bin, run_with_retry +logger = logging.getLogger(__name__) + DEFAULT_RPC_URL = "https://ogevmdevnet.opengradient.ai" DEFAULT_API_URL = "https://sdk-devnet.opengradient.ai" DEFAULT_INFERENCE_CONTRACT_ADDRESS = "0x8383C9bD7462F12Eb996DD02F78234C0421A6FaE" @@ -299,9 +302,8 @@ def deploy_transaction(): estimated_gas = contract.constructor(*constructor_args).estimate_gas({"from": self._wallet_account.address}) gas_limit = int(estimated_gas * 1.2) except Exception as e: - print(f"Gas estimation failed: {str(e)}") + logger.warning("Gas estimation failed: %s. Using conservative fallback gas limit of 5,000,000.", e) gas_limit = 5000000 # Conservative fallback - print(f"Using fallback gas limit: {gas_limit}") transaction = contract.constructor(*constructor_args).build_transaction( { @@ -369,8 +371,12 @@ def _register_with_scheduler(self, contract_address: str, scheduler_params: Sche scheduler_tx_hash = self._blockchain.eth.send_raw_transaction(signed_scheduler_tx.raw_transaction) self._blockchain.eth.wait_for_transaction_receipt(scheduler_tx_hash, timeout=REGULAR_TX_TIMEOUT) 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.") + logger.warning( + "Failed to register workflow contract %s with scheduler: %s. " + "The contract is still deployed and can be executed manually.", + contract_address, + e, + ) def read_workflow_result(self, contract_address: str) -> ModelOutput: """