import dbt for ref and source commands

The problem I’m having

Trying to call the dbt.ref and dbt.source commands in a regular python script; not a model.

The context of why I’m trying to do this

Using a python script to analyze sample data from a snowflake table and produce output that will be saved as a model. Would rather call the sql model by the dbt commands than open the sources.yml file and parse it the hard way.

What I’ve already tried

import dbt
from dbt.include.global_project.macros.python_model import ref

but cannot find the sub-module where the ref and source commands are.
I searched for def ref( in all of the files of the dbt site-packages folder and found 2 functions, but neither one of them returns the ref or source as expected.

Some example code or error messages

dbt.include.global_project.macros.python_model has a definition for “ref”, but it’s not available.

ImportError: cannot import name 'ref' from 'dbt.include.global_project.macros.python_model'

Is there a more comprehensive way to search for functions in a module with many sub-modules besides using the inspect module? Or does anyone just know where the ref() and source() functions are?

Many thanks,