1. I removed the default values for my entrypoint ...
# pacc-may-31-2023
k
1. I removed the default values for my entrypoint function:
Copy code
@flow
def get_weather_data(lat, lon):
    weather_data = fetch_weather(lat, lon)
    soil_data = fetch_soil_data(lat, lon)
    to_write = transform_weather_data(weather_data, soil_data)
    save_weather(to_write)


if __name__ == '__main__':
    get_weather_data()
2. I created a deployment and left
parameters
as an empty dict:
Copy code
deployments:
  - name: My weather deployment
    version: 0.1
    tags: [ ]
    description: null
    schedule: { }
    flow_name: null
    entrypoint: "weather.py:get_weather_data"
    parameters: {}
    work_pool:
      name: null
      work_queue_name: null
      job_variables: { }
3. I deployed it:
prefect deploy "./weather.py:get_weather_data" -p my_pool
4. Now if I open the deployment in the UI and choose "Quick Run", I am shown a form with
lat
and
lon
fields, which are empty, but they're also marked as (Optional) when they clearly aren't. The Run button is also enabled, it allows me to click it even if I leave the form fields empty, and if I do that, the flow fails. Did I do something wrong?
e
Hmm, I see your point. We’ll talk to the team after the course and see if we could differentiate the default behavior between required args and optional kwargs. In practice most users add type hints and defaults, but this could definitely be clearer.
k
sure, not really a big deal, I was just wondering if maybe I messed up. Type-hinting the params did change the HTML field type (it's now a number input), but they're still considered optional
Copy code
@flow
def get_weather_data(lat: float, lon: float):
    weather_data = fetch_weather(lat, lon)
    soil_data = fetch_soil_data(lat, lon)
    to_write = transform_weather_data(weather_data, soil_data)
    save_weather(to_write)
👀 1
e
No, that’s good feedback. Makes sense that
args
should be required, though perhaps there are technical reasons preventing it. We have to do a non-trivial amount of translation from Pydantic -> openAPI schema -> UI components
(and back again)