what's the best way of having a variable that cont...
# questions
j
what's the best way of having a variable that contains the absolute path of the project root? something like
Copy code
dataset:
  filepath: ${custom_kedro_resolver_magic:project_root}/data/01_raw/iris.csv
? has anybody come up with a custom resolver that can do this dynamically, rather than having to, say, hardcode it in
globals.yml
?
that's a promising idea, how would you include it in a custom resolver then @Takieddine Kadiri?
t
We can register a custom resolver that dynamiclly resolve
package_path
settings.py
Copy code
from kedro.config import OmegaConfigLoader

CONFIG_LOADER_CLASS = OmegaConfigLoader

CONFIG_LOADER_ARGS = {
    "custom_resolvers": {
        "package_path": lambda: os.path.basename(__file__),
    }
}
catalog.yml
Copy code
dataset:
  filepath: ${package_path:}
We used to resolve
package_path
inside a CustomConfigLoader (before custom resolver was a thing) this let us have a sort of application conf, where we bundle some artifact alongside the src code (stopwords, referentials, …) and having them versioned and released with the python package. A dataset would point to them relative to
package_path
. Maybe this is outside of the scope of the question, since it’s about projet_root. I don’t know how to do that for project root
j
oh that's where I got stuck too. the
settings.py
, the place where this resolver would go, doesn't have enough info to know where
project_root
is. one could hack something around but it would be brittle I guess.