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
Maybe we should list_datasets(status='active') and if a dataset_id from the iterable of dataset_ids that we want to check is in the results, we can mark it as True, otherwise False.
The distinction here is that you no longer check whether the dataset id exists at all. I.e. a dataset which is inactive and one that does not exist altogether would be be returned as False. Unless I misunderstand your meaning.
@PGijsbers you understood the idea right and the point you are making is valid.
Then, I would propose to further improve my initial idea and only list_datasets(data_id=[dataset_ids]) for the dataset_ids that we have. This is supported on the live server now ( we should also update the documentation and function of list_datasets, because data_id is not shown as a valid filter).
In the end we can just compare len(results) == len(dataset_ids) in case we want to know if there was a dataset_id that does not exist. (If we also want the specific dataset_id, we can check the keys)
I definitely think we should raise an error if the passed dataset id does not exist, consider the following use case of the function:
dids= [ ... someids ... ]
dids_active=check_datasets_active(dids)
ifall(dids_active.values()):
# All datasets are active, do something
...
If there is a more efficient way to retrieve active status for the datasets from the server, I am all for it.
Even if that means afterwards specifically checking if there is a dataset missing.
Having the mentioned clause
if len(results) != len(dataset_ids):
<find out missing datasets>
<raise error about missing datasets> `
is absolutely fine as in good-weather scenarios the simple length comparison should be negligible in terms of performance. Adding a parameter raise_error_if_not_exist to only optionally raise errors is also acceptable fine, but it should (in my opinion) default to True.
Activity
PGijsbers commentedon Apr 10, 2019
The distinction here is that you no longer check whether the dataset id exists at all. I.e. a dataset which is inactive and one that does not exist altogether would be be returned as
False. Unless I misunderstand your meaning.ArlindKadra commentedon Apr 10, 2019
@PGijsbers you understood the idea right and the point you are making is valid.
Then, I would propose to further improve my initial idea and only
list_datasets(data_id=[dataset_ids])for thedataset_idsthat we have. This is supported on the live server now ( we should also update the documentation and function oflist_datasets, becausedata_idis not shown as a valid filter).In the end we can just compare
len(results) == len(dataset_ids)in case we want to know if there was adataset_idthat does not exist. (If we also want the specificdataset_id, we can check the keys)PGijsbers commentedon Apr 10, 2019
I definitely think we should raise an error if the passed dataset id does not exist, consider the following use case of the function:
If there is a more efficient way to retrieve active status for the datasets from the server, I am all for it.
Even if that means afterwards specifically checking if there is a dataset missing.
Having the mentioned clause
is absolutely fine as in good-weather scenarios the simple length comparison should be negligible in terms of performance. Adding a parameter
raise_error_if_not_existto only optionally raise errors is also acceptable fine, but it should (in my opinion) default toTrue.