Hi, for prefect 2.0b4, how can I add a json file a...
# best-practices
s
Hi, for prefect 2.0b4, how can I add a json file as parameter in a deployment?
a
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:
Copy code
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:
Copy code
DeploymentSpec(
    flow=parametrized_flow_with_path,
    name="staging",
    schedule=IntervalSchedule(interval=timedelta(days=1)),
    parameters={"path": "/your/path"},
    tags=["local"],
)
s
Ik cool. Looks like I was on the right path:)
👍 1
a
on the right "path" indeed 😄
🤣 1
s
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
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
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
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
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
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
In an earlier version I saw flow and deployments and flowruns and tasks on the landing page.
Self hosted
a
UI should show up as soon as you start Orion:
Copy code
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
Send you a DM with some screenshots
👍 1
a
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
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
how is that different?
s
It seems the landing page doesn't show any data.
It's just empty
a
what do you mean by data in this context?
s
Data on the flows registered at the server (meaning there is a definition and id for the flow in the database)
a
what data would you expect there?
s
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
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
Yep I know:) thanks. Trying to figure out how best to communicate this:)
👍 1
Without wasting your time with ambiguous/unclear comments.
a
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
I may need to create some simple example that's easy to replicate.
💯 1
a
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
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
Great idea! Feel free to document how you do it and add it to your GitHub issue with your UI feedback
👍 1
s
Tried to replicate this at home but messed up my network in the process:)
a
haha no rush, take your time
s
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