https://prefect.io logo
Title
s

Sander

05/16/2022, 9:24 AM
Hi, for prefect 2.0b4, how can I add a json file as parameter in a deployment?
a

Anna Geller

05/16/2022, 10:28 AM
If you mean a file name of a JSON file, then you could configure it as a string - parameters are validated with pydantic and must be JSON serializable - example:
from prefect import flow, task


@task
def do_something_with_path(path: str):
    filename = f"{path}/some_data.txt"
    data = "Hello world from Prefect 2.0!"
    with open(filename, "w") as file:
        file.write(data)
    return filename


@flow
def parametrized_flow_with_path(path: str):
    do_something_with_path(path)


if __name__ == "__main__":
    parametrized_flow_with_path(path_val)
then DeploymentSpec:
DeploymentSpec(
    flow=parametrized_flow_with_path,
    name="staging",
    schedule=IntervalSchedule(interval=timedelta(days=1)),
    parameters={"path": "/your/path"},
    tags=["local"],
)
s

Sander

05/16/2022, 10:29 AM
Ik cool. Looks like I was on the right path:)
👍 1
a

Anna Geller

05/16/2022, 10:32 AM
on the right "path" indeed 😄
🤣 1
s

Sander

05/16/2022, 10:33 AM
This path is an absolute path based on the storage?
I guess prefect isn't that smart that it includes the json at create time of the deployment?
a

Anna Geller

05/16/2022, 10:35 AM
Based on the execution layer specified on the flow runner, e.g. if you started an agent and used SubprocessFlowRunner, then the flow run will be deployed as a subprocess on that agent and it would be best if this path is absolute to avoid any weird issues
s

Sander

05/16/2022, 10:36 AM
In that sense it sounds like the smartest would be to parse the json within the deployment spec (but that's not possible in my case 🙁)?
a

Anna Geller

05/16/2022, 10:36 AM
as the Zen of Python says: explicit is better than implicit, and an absolute path will likely save you trouble down the road
it depends on your use case - perhaps your parameter can just point at something and you can then determine the path in your flow code? don't forget in 2.0 you can run arbitrary Python code in your flow
s

Sander

05/16/2022, 10:49 AM
That's what I do now indeed.
Maybe on a separate note. The GUI sees my deployments (with separate parameters) but not my flow?
Does that make sense?
Actually. Seems that the main landing page isn't showing anything.
Backend database looks fine
Where should I mention this?
a

Anna Geller

05/16/2022, 10:53 AM
yes it does, you're right that there's no flow page, only a deployment page in 2.0 since the flow is supposed to be a dynamic concept and deployment spec is more a static concept defining static deployment-specific metadata that can be optionally overridden from the UI (on the roadmap)
are you on self-hosted Orion or on Cloud 2.0?
s

Sander

05/16/2022, 10:54 AM
In an earlier version I saw flow and deployments and flowruns and tasks on the landing page.
Self hosted
a

Anna Geller

05/16/2022, 10:55 AM
UI should show up as soon as you start Orion:
prefect orion start
there is no flow page in 2.0
there is only this bar on the right when you click on a flow
s

Sander

05/16/2022, 11:12 AM
Send you a DM with some screenshots
👍 1
a

Anna Geller

05/16/2022, 11:45 AM
Your screenshots look fine, no issue there, that's the current state of the UI. Feel free to leave feedback if you want, I can forward that to the UI team
s

Sander

05/16/2022, 11:48 AM
What I would expect in this case is to see one flow on the landing page with 13 deployments and only scheduled flow runs.
👍 1
However I only see the flow and 13 deployments on the flow page.
a

Anna Geller

05/16/2022, 11:49 AM
how is that different?
s

Sander

05/16/2022, 11:50 AM
It seems the landing page doesn't show any data.
It's just empty
a

Anna Geller

05/16/2022, 11:50 AM
what do you mean by data in this context?
s

Sander

05/16/2022, 11:51 AM
Data on the flows registered at the server (meaning there is a definition and id for the flow in the database)
a

Anna Geller

05/16/2022, 11:54 AM
what data would you expect there?
s

Sander

05/16/2022, 11:54 AM
Could be related to my definitions. Let me investigate a bit
👍 1
What I see is one bar at the run time window and in the lateness window. But that's it. The filters show my flow and state=running.
With the runtime visible I'd expect 1 flow run.
a

Anna Geller

05/16/2022, 12:00 PM
can you send a screenshot showing the AS-IS state and the TO-BE state in your view? hard to say what's exactly missing based on the description, maybe you can take a screenshot and draw over it what you mean?
I'm only asking about it because you seem to be concerned about it and I want to forward your concern to the UI team
s

Sander

05/16/2022, 12:02 PM
Yep I know:) thanks. Trying to figure out how best to communicate this:)
👍 1
Without wasting your time with ambiguous/unclear comments.
a

Anna Geller

05/16/2022, 12:02 PM
you may also open a GitHub issue here with label v2 and UI - this would actually help a lot since it's easier to share feedback this way
s

Sander

05/16/2022, 12:03 PM
I may need to create some simple example that's easy to replicate.
💯 1
a

Anna Geller

05/16/2022, 12:03 PM
it's not about wasting time but more about shared understanding 🙂
👍 1
and in general, we welcome and appreciate feedback about 2.0, especially when it comes to the UI as we are currently working very actively on improving the UX there
s

Sander

05/16/2022, 12:07 PM
I ran the UI at home on my Mac and all looked fine. Then trying out on a separate server at work this didn't work at all in b3. Now with b4 this is definitely better. Hence I need to make sure all is ok on my side:)
👍 1
I think I'll first try to replicate this in a separate setup.
a

Anna Geller

05/16/2022, 12:43 PM
Great idea! Feel free to document how you do it and add it to your GitHub issue with your UI feedback
👍 1
s

Sander

05/17/2022, 8:25 AM
Tried to replicate this at home but messed up my network in the process:)
a

Anna Geller

05/17/2022, 11:26 AM
haha no rush, take your time
s

Sander

05/17/2022, 11:38 AM
Actually, when you run the gui you can see in chrome dev tab still calls to 127.0.0.1. (Forgot to check that one) so no need to replicate elsewhere.
👍 1