agentops icon indicating copy to clipboard operation
agentops copied to clipboard

[Bug]: AttributeError: module 'agentops.logging.instrument_logging' has no attribute 'print_logger'

Open HarikrishnanK9 opened this issue 5 months ago • 1 comments

Contact Details

 reply with this message

📦 Package Version

agentops==0.4.17

🎞️ Framework Version

crewai==0.130.0 crewai-tools==0.40.1

🔎 Describe the Bug

Just followed your documentation

and just added following lines

import agentops
agentops.init()

with my existing code (a working code that differs from the one on the documentation page) at the beginning. The conflict is associated with numba Attaching final part of error response

File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/agentops/instrumentation/__init__.py", line 372, in _import_monitor
    return _original_builtins_import(name, globals_dict, locals_dict, fromlist, level)
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/numba/cpython/builtins.py", line 6, in <module>
    sys.modules[__name__] = _RedirectSubpackage(locals(),
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/numba/core/utils.py", line 694, in __init__
    new_mod_obj = import_module(new_module)
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/numba/cpython/old_builtins.py", line 554, in <module>
    from numba.core.typing.builtins import IndexValue, IndexValueType
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/agentops/instrumentation/__init__.py", line 372, in _import_monitor
    return _original_builtins_import(name, globals_dict, locals_dict, fromlist, level)
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/numba/core/typing/builtins.py", line 6, in <module>
    sys.modules[__name__] = _RedirectSubpackage(
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/numba/core/utils.py", line 694, in __init__
    new_mod_obj = import_module(new_module)
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/numba/core/typing/old_builtins.py", line 21, in <module>
    @infer_global(print)
  File "/home/harikrishnan/anaconda3/envs/agent_env/lib/python3.10/site-packages/numba/core/typing/templates.py", line 1293, in register_global
    if getattr(mod, val.__name__) is not val:
AttributeError: module 'agentops.logging.instrument_logging' has no attribute 'print_logger'

🤝 Contribution

  • [x] Yes, I'd be happy to submit a pull request with these changes.
  • [x] I need some guidance on how to contribute.
  • [ ] I'd prefer the AgentOps team to handle this update.

HarikrishnanK9 avatar Jul 15 '25 06:07 HarikrishnanK9

i have editted the agentops/logging/instrument_logging.py setting print_logger = None at the beginning and

    global print_logger  #<<----------- expose print_logger for global typing
    def print_logger(*args: Any, **kwargs: Any) -> None:
        message = " ".join(str(arg) for arg in args)
        buffer_logger.info(message)
        _original_print(*args, **kwargs) 

resolved the issue for me. Expecting your response on the same.I have also made a pull request and updated the same. If it does not seems good either you can guide me to contribute with appropriate changes or you can update for the same

HarikrishnanK9 avatar Jul 15 '25 06:07 HarikrishnanK9