Hello, we always use checkpoints and want to enabl...
# ask-community
a
Hello, we always use checkpoints and want to enable checkpointing in Python by default to avoid potentially error-prone extra steps for correct environment setup. It seems that the following approaches do not work (before creating a flow):
Copy code
prefect.config.flows.checkpointing = True
or
Copy code
os.environ["PREFECT__FLOWS__CHECKPOINTING"] = "True"
Instead, we need to ensure that no
prefect
import statement (direct or indirect) occurs before setting this environment variable. It seems impractical that prefect reads such configuration in top-level code (executed on import) and not in functions. Are there any better solutions?
k
Not 100% sure, but you may be able to put some kind of setting into your
~/.prefect/config.toml
file. Something like:
Copy code
[flows]
checkpointing = true
Should be on whatever host/container the flows run in I think?
👍 1
k
Hey @Andreas Eisenbarth, the config is indeed instantiated when you import Prefect and it is only instantiated once. There is some info here that explains that even if we had a
refresh
method, certain changes would not take affect like logging. At the same time, we need that configuration instantiated to run Prefect. The
toml
is the only other option like Kyle is suggesting.
on.environ
at the top of the script as you mentioned would work.
a
Thanks! So far our application could be run without
.prefect/config.toml
, but there will probably come more things for which we need that.