Hello! I’m excited at getting my feet wet with Pre...
# ask-community
d
Hello! I’m excited at getting my feet wet with Prefect, just installed it locally on macOS, ran
prefect backend server
and
prefect server start
, got the web UI up and wonder how I can make the standard hello world example below appear in that UI? Do I need a “project”? If so how do I wire that up with the example code running?
Copy code
from prefect import task, Flow, Parameter

@task(log_stdout=True)
def say_hello(name):
    print("Hello, {}!".format(name))

with Flow("My First Flow") as flow:
    name = Parameter('name')
    say_hello(name)

flow.run(name='world') # "Hello, world!" 
flow.run(name='Marvin') # "Hello, Marvin!"
j
Hey @Dinu Gherman welcome! Yes you will need to create a project for your flow to live and then you will
register
it to that project. I recommend walking through this deployment tutorial which will outline some of these features 🙂 https://docs.prefect.io/orchestration/tutorial/first.html
d
Thanks a lot!!
Ok, if I append
flow.register(project_name="Project1")
to some sample code, I get this error below.
Copy code
ClientError: Malformed response received from Cloud - please ensure that you have an API token properly configured.
But I don’t see a way to create an API token for the local server.
j
Can you confirm that you ran
prefect backend server
on that same machine? That is an error when attempting to talk to Cloud
Try running
prefect diagnostics
and see the backend set
d
Definitely, yes.
j
Can you post the output of the diagnostics command?
d
Copy code
$ prefect diagnostics
{
  "config_overrides": {},
  "env_vars": [],
  "system_information": {
    "platform": "Darwin-18.7.0-x86_64-i386-64bit",
    "prefect_backend": "server",
    "prefect_version": "0.13.6",
    "python_version": "3.7.6"
  }
}
j
Interesting 🤔 and this is in the same terminal session that you are running the script that has the register call?
d
Nope, I’m running the code in a Jupyer notebook running in the same conda environment.
Started in a different terminal.
j
In the notebook can you try this:
Copy code
from prefect import config
print(config.backend)
d
Says “cloud”.
j
Yeah so wherever that notebook is running it is not respecting the
prefect backend server
If the notebook has a terminal or something you could call it there
d
Hmm, have set it in a terminal inside Jupyter as well as in a cell. No change. Let me restart Jupyter…
Still no luck from Jupyter, but I could run it from a terminal IPython session! After running
flow.run_agent()
I still had to run the flow in the UI manually, which came up with unenxpected strings like “nickel-roadrunner” 😉 I guess there is some way to start the entire flow from code, too…