Scheduling issue... Running basic task `hello_wor...
# ask-community
y
Scheduling issue... Running basic task
hello_world.py
the Prefect.io server runs on a VM on AWS, with python 3.6 with latest prefect python package agent is running: agent LocalAgent LAST QUERY 11:19am | 1 seconds ago CORE VERSION 0.15.3 when running
hello_world.py
using python3.6, the schedule does not work when running using python3.8, the schedule works, but I get errors Why does the schedule does not work with the python3.6 ? (It used to work.. not sure what changed) I tried pip install prefect --upgrade (both on laptop and VM) killed the old agent (on lap top) prefect backend server (on laptop) prefect agent local start --label "<label>" (on laptop) this did not help
k
Hey @YD, I’ll type up an explanation, but if you could move the code snippet to the thread, that would help so it doesn’t crowd the main channel.👍
So about this, the issue is really a mismatch of Python versions (and Prefect) between flow registration and flow execution. At the very least, you run into serialization errors between Python versions. Something serialized in Python 3.8 will have problems being deserialized in Python 3.6. I don’t think this is related to the schedule. So the best practice is same Prefect version and Python version for Flow registration and the agent. They either both need to be on 3.6 or 3.8
Thanks for moving it!
y
I tried to have both 3.6 but then the schedule dose not appear to be working
k
When you say it doesn’t work, do you mean it does not show up in the UI? Or do you get an error message?
y
there are no upcoming runs
k
Did you try turning the schedule off then on again? What do you see when you go to the Schedules page attached to the FLow?
y
I can run by clicking [quick run]
turning schedule off and on did not help
k
Can you click on the Flow, then Settings on the top right, then schedules, and see if there is a schedule there?
y
k
Can I see your Flow again? Just add it here in the thread?
y
Copy code
from prefect import task, Flow
from prefect.schedules import IntervalSchedule
from datetime import timedelta, datetime


@task(log_stdout=True)
def say_hello():
    print("Hello world!")


def main():
    schedule = IntervalSchedule(
        start_date=datetime.utcnow() + timedelta(seconds=1),
        interval=timedelta(minutes=1),
    )

    with Flow("hello_world", schedule=schedule) as flow:
        say_hello()
   
    flow.register(project_name="test")
    print('done')


if __name__ == "__main__":
    main()
k
This looks good, and it does seem attached. Does that flow have parameters attached? I assume no cuz there’s none in the Flow code?
y
what params I need to attach ?
why the quick-run works ?
k
You don’t need to attach any Parameter specifically, was just checking if you had because there is an issue that schedules can’t be set if you don’t supply required parameters to a flow. I don’t know yet why the Quick Run works and the Schedule doesn’t. This seems like it should be working with just a toggle. What version is your Server on?
y
how to I check the server version ?
k
Try this query:
Copy code
query Api {
  api {
    backend
    mode
    version
    core_version
    release_timestamp
  }
}
y
where to run this ?
k
In the Interactive API tab in the UI
y
I tried to do prefect server stop prefect server start and it looks like all the agents and flows are gone. is this an expected behavior ? how do I set the server so that all the flows survives a restart ?
k
You need to do this to persist data across restarts.
y
so I need to install a postgres DB ? there is one running in the docker
k
There is one. You just need to supply
--use-volume
to persist the data.
y
after restarting the VM server it looks like the issue with the schedule went away trying to to use --use-volume
yes.. this worked thanks
One follow up question... why in the main "flows" dashboard I do not see anything in run history, while I do see it if I click on the flow ?
k
Is it different flow versions you’re looking at?
y
suppose to be the same flow how can I tell ?
k
The dashboard will show the latest version. If you click the flow, you should see the version you are looking at. Is it the latest version?
y
yes, it is the same version
k
That is the only thing we can think of. Does it persist with a refresh?
y
it is ok now...
k
Oh ok I guess maybe the browser was just stale there for a bit