gufolabs / gufo_snmp

Gufo SNMP is the accelerated Python SNMP library
Other
8 stars 0 forks source link

ENH: <sync version support> #5

Closed wangxin688 closed 4 months ago

wangxin688 commented 5 months ago

Proposed new feature or change:

appreciate hardworking on this project. Is there any possible to support sync version rather that async only?

dvolodin7 commented 5 months ago

Rust part does not use async indeed. But timeout handling in syncronous code may be rather tricky

wangxin688 commented 5 months ago

Rust part does not use async indeed. But timeout handling in syncronous code may be rather tricky I totally agree with you. Asyncio is better to handle io bound task. It's just a good option to use sync integrate with threading(sure i can run asyncio code in a separate thread). Cause a lot of history project was written with sync way. Currently there is no good option for snmplibs to choose. pysnmp is good but with poor performance and API sucks. easysnmp is fast for synchronize But pure C code is not maintainced anymore and lack of upgrading. As well as aiosnmp. I saw you guys has developed noc system more than 7 years in netdevops field. some things similar like netmiko nornir in this field is sync way.

wangxin688 commented 5 months ago

If that's is acceptable. Maybe I can make some contributions on that

dvolodin7 commented 5 months ago

Sure, you are welcome.

To be correct, we're developing NOC for over than 16 years.

dvolodin7 commented 5 months ago

Timeout handling may be implemented either by:

wangxin688 commented 5 months ago

Sure, you are welcome.

To be correct, we're developing NOC for over than 16 years.

amazing! I’m the new birds on netdevops ,although I have worked as network engineer more than 7 years. Your noc system is absolutely fantastic

dvolodin7 commented 5 months ago

I've successfully implemented synchronous GET operations with minimal adjustments to the Rust core. However, we're currently facing challenges with getnext/getbulk, and I'm actively investigating and addressing these issues.

wangxin688 commented 5 months ago

I've successfully implemented synchronous GET operations with minimal adjustments to the Rust core. However, we're currently facing challenges with getnext/getbulk, and I'm actively investigating and addressing these issues.

omg, you guys are absolutely amazing. I was just trying to start with source code, I see the docs has been updated, thanks

wangxin688 commented 5 months ago

seems it's broken when install package on macOS. ubuntu 20.4 works fine. I have tested on MACOS 14.2.1(Intel chip). I remember a few days ago. I installed the package on my M1 and M3 laptop, it's worked. I could do some test later. here's the message on Inter chip: python version: 3.11.6 pip: 23.3.2

(.venv) ➜  netsight git:(main) ✗ rye sync                     
Reusing already existing virtualenv
Generating production lockfile: /Users/jeffry/Documents/netsight/requirements.lock
Generating dev lockfile: /Users/jeffry/Documents/netsight/requirements-dev.lock
Installing dependencies
Looking in indexes: https://pypi.org/simple/
Obtaining file:///. (from -r /var/folders/hp/4_09kt050ygf18xnhj6nd1mw0000gn/T/tmptbkftrax (line 1))
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Collecting gufo-snmp==0.3.0 (from -r /var/folders/hp/4_09kt050ygf18xnhj6nd1mw0000gn/T/tmptbkftrax (line 2))
  Using cached gufo_snmp-0.3.0.tar.gz (21 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: gufo-snmp, netsight
  Building wheel for gufo-snmp (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for gufo-snmp (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [42 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.9-x86_64-cpython-311
      creating build/lib.macosx-10.9-x86_64-cpython-311/gufo
      creating build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/version.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/util.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/protocol.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/client.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/getnext.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/__init__.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/policer.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/snmpd.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/typing.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/getbulk.py -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      running egg_info
      writing src/gufo_snmp.egg-info/PKG-INFO
      writing dependency_links to src/gufo_snmp.egg-info/dependency_links.txt
      writing top-level names to src/gufo_snmp.egg-info/top_level.txt
      reading manifest file 'src/gufo_snmp.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      no previously-included directories found matching '__pycache__'
      warning: no previously-included files matching '*.py[cod]' found anywhere in distribution
      adding license file 'LICENSE.md'
      writing manifest file 'src/gufo_snmp.egg-info/SOURCES.txt'
      copying src/gufo/snmp/_fast.pyi -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      copying src/gufo/snmp/py.typed -> build/lib.macosx-10.9-x86_64-cpython-311/gufo/snmp
      running build_ext
      running build_rust
      error: can't find Rust compiler

      If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need for a Rust compiler.

      To update pip, run:

          pip install --upgrade pip

      and then retry package installation.

      If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (available at https://rustup.rs) is the recommended way to download and update the Rust compiler toolchain.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for gufo-snmp
  Building editable for netsight (pyproject.toml) ... done
  Created wheel for netsight: filename=netsight-0.1.0-py3-none-any.whl size=3958 sha256=4b770a979cc8f36b25d334cc3f5d12ec718d90cbc3007e781dcbe4facae08bbd
  Stored in directory: /private/var/folders/hp/4_09kt050ygf18xnhj6nd1mw0000gn/T/pip-ephem-wheel-cache-stg4tzvx/wheels/97/54/f5/d849319cdfa096e074df352654ee2e7c919da8951f090690c6
Successfully built netsight
Failed to build gufo-snmp
ERROR: Could not build wheels for gufo-snmp, which is required to install pyproject.toml-based projects
Traceback (most recent call last):
  File "/Users/jeffry/.rye/pip-tools/cpython@3.11/bin/pip-sync", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/jeffry/.rye/pip-tools/cpython@3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffry/.rye/pip-tools/cpython@3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/jeffry/.rye/pip-tools/cpython@3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffry/.rye/pip-tools/cpython@3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jeffry/.rye/pip-tools/cpython@3.11/lib/python3.11/site-packages/piptools/scripts/sync.py", line 174, in cli
    sync.sync(
  File "/Users/jeffry/.rye/pip-tools/cpython@3.11/lib/python3.11/site-packages/piptools/sync.py", line 244, in sync
    run(  # nosec
  File "/Users/jeffry/.rye/py/cpython@3.11.6/install/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/Users/jeffry/Documents/netsight/.venv/bin/python', '-m', 'pip', 'install', '-r', '/var/folders/hp/4_09kt050ygf18xnhj6nd1mw0000gn/T/tmptbkftrax', '--index-url', 'https://pypi.org/simple/', '--python=/Users/jeffry/Documents/netsight/.venv/bin/python', '--no-deps']' returned non-zero exit status 1.
error: Installation of dependencies failed
dvolodin7 commented 4 months ago

Building of binary wheels for MacOS and for MUSL is disabled for now. You may try to install rust toolchain using tools/build/setup-rust.sh script.