netenglabs / suzieq

Using network observability to operate and design healthier networks
https://www.stardustsystems.net/
Apache License 2.0
775 stars 105 forks source link

[Bug]: Python API with namespace parameter #925

Closed vsurresh closed 3 months ago

vsurresh commented 4 months ago

Suzieq version

0.22.0

Install Type

hand deployed python

Python version

3.9

Impacted component

other

Steps to Reproduce

If you use the python API to get path information using this code, for example, it gives an error.


path_tbl = get_sqobject('path')
path_df = path_tbl().get(src='1.1.1.1', dest='6.6.6.6', namespace='my_ns')

print(path_df)

The code expects the namespace argument as a list instead of a string. It would be good to get an error message that indicates this behaviour. This is the error we get at the moment.

  File "/Users/sureshv/Documents/python/suzieq_project/venv/lib/python3.9/site-packages/suzieq/engines/pandas/path.py", line 54, in _init_dfs
    raise EmptyDataframeError
suzieq.shared.exceptions.EmptyDataframeError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sureshv/Documents/python/suzieq_project/path_example.py", line 4, in <module>
    path_df = path_tbl().get(src='1.1.1.1', dest='6.6.6.6', namespace='my_ns')
  File "/Users/sureshv/Documents/python/suzieq_project/venv/lib/python3.9/site-packages/suzieq/sqobjects/path.py", line 19, in get
    return super().get(**kwargs)
  File "/Users/sureshv/Documents/python/suzieq_project/venv/lib/python3.9/site-packages/suzieq/sqobjects/basicobj.py", line 226, in get
    result = self.engine.get(**kwargs, columns=columns)
  File "/Users/sureshv/Documents/python/suzieq_project/venv/lib/python3.9/site-packages/suzieq/engines/pandas/path.py", line 800, in get
    self._init_dfs(self.namespace, src, dest)
  File "/Users/sureshv/Documents/python/suzieq_project/venv/lib/python3.9/site-packages/suzieq/engines/pandas/path.py", line 56, in _init_dfs
    raise EmptyDataframeError(
suzieq.shared.exceptions.EmptyDataframeError: No interface information found for ['m']

Expected Behavior

The script should work even if we pass it as a string or an error message that indicates this problem.

Observed Behavior

we need to pass the namespace as a list

Screenshots

Additional Context