https://kedro.org/ logo
Title
i

Isaac89

02/18/2022, 2:13 PM
Hi! is there a way to show the list of all the versions of a dataset in the catalog?
a

antony.milne

02/18/2022, 2:26 PM
It's a bit hacky but something like this should work:
pattern = str(dataset._get_versioned_path("*"))
        version_paths = sorted(dataset._glob_function(pattern))
(assuming you're trying to do this through Python... otherwise just
ls
the directory or something like that)
i

Isaac89

02/18/2022, 2:28 PM
Thanks !
I will give it a try right now
the _get_versioned_path is what I was looking for 🙂
It's working fine! thanks! I wrapped it in a function in case one needs it :
import pathlib
def get_all_versions_of_a_dataset(dataset_name):
    dataset = catalog._get_dataset(dataset_name)
    pattern = dataset._get_versioned_path("*")
    paths = dataset._glob_function(pattern)
    return [pathlib.Path(i).parent.name for i in paths]
get_all_versions_of_a_dataset("dataset_name")