Hi! Any advice in running debug / troubleshooting ...
# ask-community
j
Hi! Any advice in running debug / troubleshooting runs of a flow locally without it being registered on Prefect Cloud? Flow is being run like so
Copy code
python flows/flow.py
and parameters are filled in via
Copy code
if __name__ == "__main__":
    my_flow(
        parameter_1=value_1,
        parameter_2=value_2,
        parameter_3=value_3,
    )
I do not want
my_flow
run to be registered on prefect cloud due to many different reasons 😞 How can I achieve this?
d
You can always spin a local server with
prefect server start
r
You could use a separate profile, i.e.
prefect profile create local
and then
prefect profile use local
. Or, something like this should work as well:
Copy code
# your code here 

if __name__ == "__main__":
    from prefect.settings import temporary_settings, PREFECT_API_URL

    with temporary_settings(restore_defaults={PREFECT_API_URL}):
        my_flow(
            parameter_1=value_1,
            parameter_2=value_2,
            parameter_3=value_3,
        )
j
Thank you for suggestions, but this will not work because the same flow run I do not want to be registered on the server, fetches a few secret blocks from it. The way I see it, is to 1. Spin up my local prefect server for development 2. Sync all required secret blocks and other to it 3. Do my tests 4. Nuke the dev server --- Repeat for every dev session.. facepalm
Perhaps this is a worthwhile feature request 🤷
r
I have one other idea that might work; I'm just going to give it a quick test
d
@jpuris I personally do not use any prefect blocks. Any block you need can be setup using the python prefect client in memory without having to store it in the server.
j
It is the secrets we use across many different flows, hence it is out of convenience and to avoid stray .env files
d
Yeah in that case. I just put all the secrets into a cloud key vault.
j
Indeed. We sort of are leaning towards doing something similar, but no plans currently 👍
d
Just a question, are the flows in multiple repo?
j
Flows are currently on local fs the prefect agent is running on
If you mean version control, then no, they can be across multiple repositories, tho not sure this would be relevant to the thread 🤷
🙌 1
a
you can use the prefect test harness to easily use a local temporary server rather than the prefect cloud:
Copy code
from prefect.testing.utilities import prefect_test_harness

with prefect_test_harness():
    my_flow()
🙌 3
j
I've never heard of this one! Thank you @Austin Weisgrau!