Michael Kennely
10/22/2020, 9:07 PM.py
file locally to test that it works as intended before pushing to GH without changing any code? From my understanding you shouldn’t have flow.run()
in your file when using Prefect cloud, but that’s how I started off running things locally
Simple hello world script for reference
import prefect
from prefect import task, Flow
from prefect.environments.storage import GitHub
@task
def hello_task():
logger = prefect.context.get("logger")
<http://logger.info|logger.info>("Hello world!")
hello_flow = Flow("gh_storage_flow", tasks=[hello_task])
hello_flow.storage = GitHub(
repo="{redacted}",
path="{redacted}",
secrets=["{redacted}"]
)
# Basically, I want the functionality of the below line so I can run this locally via Pycharm and then push to GH, merge to main branch, register, etc, and schedule via the UI to execute in our dedicated execution environment, but when you aren't running this as a script my understanding is that you need to remove the following line
hello_flow.run()
Chris White
10/22/2020, 9:08 PM.run
block within the following check:
if __name__ == "__main__":
hello_flow.run()
this way, the run command will only run when you call python my_file.py
but will not run when the file is loaded for use with CloudMichael Kennely
10/22/2020, 9:10 PMChris White
10/22/2020, 9:10 PM