Hello, I am starting using prefect, I am a luigi u...
# ask-community
r
Hello, I am starting using prefect, I am a luigi user so I am testing the “Result/Checkpoint/target” feature in prefect.. I tried the simple ex.
Copy code
import prefect
from prefect import task, Flow, Parameter
from prefect.engine.results import LocalResult

result = LocalResult(dir="./prefect-results", )

@task
def hello_task(named_params):
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>(named_params)
    return 'asd'

with Flow("hello-flow", result=result) as flow:
    named_params = Parameter("named_params",)
    hello_task(named_params)

flow.run(named_params='param')
I was expecting to find a file in the the
./prefect-results
folder.. the folder is there but it is empty.. I also tried
Copy code
import prefect
from prefect import task, Flow, Parameter
from prefect.engine.results import LocalResult

@task(checkpoint=True, result=LocalResult(dir="./prefect-results"))
def hello_task(named_params):
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>(named_params)
    return 'asd'

with Flow("hello-flow", ) as flow:
    named_params = Parameter("named_params",)
    hello_task(named_params)

flow.run(named_params='param')
also empty.. Am I doing something wrong, or I misunderstood how this feature work?
a
Did you also set checkpoint globally
export PREFECT__FLOWS__CHECKPOINTING=true
? as mentioned here: https://docs.prefect.io/core/advanced_tutorials/using-results.html#setting-up-to-handle-results
r
with the env variable it worked.. but even passing the
checkpoint=True,
parameter I need to have this?
👍 1
m
Hello Rafael! You can see in the doc, which Abhishek pointed to 🙏, that:
Copy code
For Core-only users, you must:

Opt-in to checkpointing globally by setting the prefect.config.flows.checkpointing to "True"
which is equivalent to
export PREFECT__FLOWS__CHECKPOINTING=true
, but if you run your flow with backend (Prefect Server or Prefect Cloud, and you use
flow.register
instead of
flow.run
Copy code
Checkpointing will automatically be turned on
upvote 1
r
i got it.. thx a lot