Skip to content

Fixes logging when passing multiple objects#2477

Merged
ibraheem-abe merged 1 commit intostagingfrom
fix/logging/concat-msgs
Nov 26, 2024
Merged

Fixes logging when passing multiple objects#2477
ibraheem-abe merged 1 commit intostagingfrom
fix/logging/concat-msgs

Conversation

@ibraheem-abe
Copy link
Contributor

When passing multiple objects, the logger breaks in the current implementation due to the check in the current _concat_message.

Traceback (most recent call last):
  File "/Users/ibraheem/Desktop/bittensor sdk/bittensor/bittensor/core/test.py", line 23, in <module>
    logging.debug("Raw weights", raw_weights)
  File "/Users/ibraheem/Desktop/bittensor sdk/bittensor/bittensor/utils/btlogging/loggingmachine.py", line 454, in debug
    msg = _concat_message(msg, prefix, suffix)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ibraheem/Desktop/bittensor sdk/bittensor/bittensor/utils/btlogging/loggingmachine.py", line 54, in _concat_message
    msg = f"{f'{prefix} - ' if prefix not in empty_pref_suf else ''}{msg}{f' - {suffix}' if suffix not in empty_pref_suf else ''}"
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

This PR fixes that that and achieves the same outcome

To reproduce the issue:

import numpy as np
from bittensor.utils.btlogging import logging

raw_weights = np.array([0, 0, 0, 0])

logging.warning("Raw weights", raw_weights)

@ibraheem-abe ibraheem-abe added the bug Something isn't working label Nov 26, 2024
@ibraheem-abe ibraheem-abe merged commit e50b749 into staging Nov 26, 2024
@ibraheem-abe ibraheem-abe deleted the fix/logging/concat-msgs branch November 26, 2024 01:36
@ibraheem-abe ibraheem-abe mentioned this pull request Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants