You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Passing that example fields does not work when output argument of list_sites() is set to text or pandas:
$ pythonPython 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from fabrictestbed_extensions.fablib.fablib import FablibManager>>> fablib = FablibManager()>>> fablib.list_sites(fields=['Name','ConnectX-5 Available', 'NVMe Total'])Traceback (most recent call last): File "<stdin>", line 1, in <module> File "fabrictestbed-extensions/fabrictestbed_extensions/fablib/fablib.py", line 1074, in list_sites ).list_sites( ^^^^^^^^^^^ File "fabrictestbed-extensions/fabrictestbed_extensions/fablib/resources.py", line 961, in list_sites return self.get_fablib_manager().list_table( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "fabrictestbed-extensions/fabrictestbed_extensions/fablib/fablib.py", line 2341, in list_table table = self.create_list_table(data, fields=fields) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "fabrictestbed-extensions/fabrictestbed_extensions/fablib/fablib.py", line 2366, in create_list_table row.append(entry[field]) ~~~~~^^^^^^^KeyError: 'Name'
This is from a quick test in a Python REPL and a Jupyter notebook.
Further, when output is set to json, the returned JSON has all the fields, not just the fields that are asked for. That may be intentional, but it still is surprising behavior.
The text was updated successfully, but these errors were encountered:
Turned out that filter_function also does not work as documented:
>>> fablib.list_sites(filter_function=lambda s: s['ConnectX-5 Available'] > 3 and s['NVMe Available'] <= 10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fabrictestbed_extensions/fablib/fablib.py", line 1074, in list_sites
).list_sites(
^^^^^^^^^^^
File "fabrictestbed_extensions/fablib/resources.py", line 961, in list_sites
return self.get_fablib_manager().list_table(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "fabrictestbed_extensions/fablib/fablib.py", line 2319, in list_table
data = list(filter(filter_function, data))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<stdin>", line 1, in <lambda>
KeyError: 'ConnectX-5 Available'
We have an example
fields=['Name','ConnectX-5 Available', 'NVMe Total'])
in the API docs ofFablibManager.list_sites()
.https://fabric-fablib.readthedocs.io/en/latest/fablib.html#fabrictestbed_extensions.fablib.fablib.FablibManager.list_sites
Passing that example
fields
does not work whenoutput
argument oflist_sites()
is set totext
orpandas
:This is from a quick test in a Python REPL and a Jupyter notebook.
Further, when
output
is set tojson
, the returned JSON has all the fields, not just the fields that are asked for. That may be intentional, but it still is surprising behavior.The text was updated successfully, but these errors were encountered: