Open sajith opened 1 year ago
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'
This will work:
fablib.list_sites(
filter_function=lambda s: s["nic_connectx_5_available"] > 1,
fields=["name", "nic_connectx_5_available", "nvme_available"],
)
However:
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.