Accessing parameters.yaml and CLI parameters before Kedro session is launched?

I am trying to figure out how to modify our based on parameters, similar to how it’s possible to modify catalog.yaml using parameters.

The problem is that we have a circular dependency: calls on the with KedroSession.create(...) as session: line, but requires an initalized KedroSession to read parameters & modify dataset paths/parameters.

I tried to break this circular dependency by directly reading the config yamls, but then if I override variables from the CLI (e.g. --params "env:prod") the catalog will only ever read the default env: dev setting from the yaml.

As a terrible hack, I store some variables in my OS environement variables inside, but this is ugly and only supports saving strings. Is there a better way?

# inside run()

    # TODO: make atexit register to clean these env vars up after finished running
    global_params = ["zoom", "env", "export"]
    for param in global_params:
        if param in params:
            param_val = params[param]
            param_val = get_kedro_param(param)  # manually creates ConfigLoader(conf_paths) and fetches param

        os.environ[param] = param_val