Hello. I tried to deploy this locally but get an e...
# ask-community
w
Hello. I tried to deploy this locally but get an exception.
- name_input: field required
I see that in the do not edit below line part of the deployment.yaml it has name_input set to required.
Copy code
from prefect import flow, task
from prefect.tasks import task_input_hash
from datetime import timedelta

@task(cache_key_fn=task_input_hash, cache_expiration=timedelta(minutes=1))
def hello_task(name_input):
    # Doing some work
    print(f"Saying hello {name_input}")
    return "hello " + name_input

@flow
def hello_flow(name_input):
    hello_task(name_input)

if __name__ == "__main__":
    hello_flow("Marvin")
1
j
What was your
deployment build
command?
w
prefect deployment build tutorial8.py:hello_flow --name dev --tag dev
Copy code
###
### A complete description of a Prefect Deployment for flow 'hello-flow'
###
name: dev
description: null
version: 6141de3121e99956798d30ea890e6c44
# The work queue that will handle this deployment's runs
work_queue_name: dev
tags:
- dev
parameters: {}
schedule: null
infra_overrides: {}

###
### DO NOT EDIT BELOW THIS LINE
###
flow_name: hello-flow
manifest_path: null
infrastructure:
  type: process
  env: {}
  labels: {}
  name: null
  command:
  - python
  - -m
  - prefect.engine
  stream_output: true
  _block_document_id: 2ddaa9ca-0e26-4079-8ad0-3d4825178bb5
  _block_document_name: anonymous-17a3bf0b-9c45-4c4e-be6f-f11d246964a8
  _is_anonymous: true
storage: null
path: /Users/wei/Projects/prefect-extract-2
entrypoint: tutorial8.py:hello_flow
parameter_openapi_schema:
  title: Parameters
  type: object
  properties:
    name_input:
      title: name_input
  required:
  - name_input
  definitions: null
j
And you get the error when you try to run it, I presume. The name=main block isn’t executed, so you can get the
name_input
argument into your flow several ways. Under
parameters
in your deployment YAML manifest you can add a
name_input: marvin
Or you can add the parameter from the GUI.
w
aha, added in via the gui and it worked!
🙌 1
j
Or you could make a default argument in this line:
def hello_flow(name_input):
1
w
Thanks Jeff, I am in the process of playing with 2.0 as all my flows are 1.0
I use Parameters extensively in 1.0 and am a bit confused as to how this changes in 2.0
j
Cool. As you can see, there are a number of ways to set params in Prefect 2, so let us know if there is a feature missing. Have fun exploring!
gratitude thank you 1