Hi all. Can anyone advise on the best way to resol...
# questions
p
Hi all. Can anyone advise on the best way to resolve a relative path to absolute? I want to specify relative paths in parameters, such as 'data/01_raw/myfile', but have a particular tool that requires passing it an absolute path. Does Kedro have a method to resolve or how to get the absolute project path perhaps?
a
Hey Paul, you might define a custom resolver to do this. Hereโ€™s the docs link: https://docs.kedro.org/en/1.0.0/configure/advanced_configuration/#how-to-use-resolvers-in-the-omegaconfigloader
p
Thanks Ankita, that sounds like a good way to implement. But I'm still wondering how to actually resolve a relative path to an absolute path. Once I figure that out, using a custom resolver to actually perform the resolution and make it available via a parameter sounds like a great idea.
d
Not sure where exactly you're looking to use it, but there is a built-in method: https://docs.python.org/3/library/pathlib.html#pathlib.Path.resolve Or do you need something Kedro-related, like getting the project root dir? Im which case you may check
find_kedro_project()
p
Kedro related. Kedro itself will resolve parameter relative paths such as 'data/01_raw...." when working with the DataCatalog, but I need to resolve that path, relative to the kedro project (which might be moved around different machines and locations) to pass to an external tool. The find_kedro_project() might be what I'm after? Do you know where the documentation and examples for using can be found? As another example, this doc page: https://docs.kedro.org/en/1.0.0/configure/parameters/#how-to-load-parameters-in-code shows an example of getting the conf path - the example starts with a project_path variable but doesn't show how to obtain that project_path in the first place. conf_path = str(project_path / settings.CONF_SOURCE)
d
p
Hi Deepyaman, that's great, the find_kedro_project method does what I need. Thanks for the reply!
๐Ÿ‘ 1
๐Ÿ™Œ 1