Hello, I am trying to run this integration with <S...
# ask-community
c
Hello, I am trying to run this integration with Soda and Prefect but getting an error from the example in the docs:
Copy code
NameError: name 'get_run_context' is not defined
Here is my slightly modified code (modified to find the
yaml
files):
Copy code
from prefect import flow
from prefect_soda_core.soda_configuration import SodaConfiguration
from prefect_soda_core.sodacl_check import SodaCLCheck
from prefect_soda_core.tasks import soda_scan_execute

@flow
def run_soda_scan():
    soda_configuration_block = SodaConfiguration(
        configuration_yaml_path="./soda/configuration.yaml"
    )
    soda_check_block = SodaCLCheck(
        sodacl_yaml_path="./soda/checks.yaml"
    )

    # Using the flow_run_name as the name of the file to store the scan results
    flow_run_name = get_run_context().flow_run.name
    scan_results_file_path = f"{flow_run_name}.json"

    return soda_scan_execute(
        data_source_name="my_datasource",
        configuration=soda_configuration_block,
        checks=soda_check_block,
        variables={"var": "value"},
        scan_results_file=scan_results_file_path,
        verbose=True,
        return_scan_result_file_content=False,
    )

run_soda_scan()
1
n
hi @Christian Sanchez, i think the example is just missing the import
Copy code
from prefect.context import get_run_context
c
@Nate - thank you. I opened an issue on this integration’s github because there was a missing comma in the return value as well.
🙌 1
Maybe I can fix it and open a pull request
smart
c
damn, did you beat me to it? lol
I was literally in the middle of creating the pull request lmao
n
haha sorry, i have a habit of just trying to do things that would take <5 mins right away - makes for context switchy days tho 🤪
💯 1
c
Thanks for the quick response.
n
no prob!