Alex Litvinov
10/23/2023, 6:41 PMNate
10/23/2023, 7:08 PMAlex Litvinov
10/23/2023, 7:33 PMa sqlite/postgres instance locallyit's a vectorDB (milvus in this case) but yea, I don't think it actually matters
or you want to spin up a worker / flow run (e.g. client) in a container?a flow run
there's no automatic solution for porting block instance between workspaces, but one could script that rather quickly if thats what you're interested inthe prefect workspace is the same ie my prefect cloud account
sorry if im not getting at the point, if im not, could you be more specific about what you want best practices for / what you're interested in doing?no worries, I think it's me not being extremely clear I'll try to rephrase my question with examples tomorrow Thanks @Nate!
Nate
10/23/2023, 7:34 PMAlex Litvinov
10/25/2023, 5:28 PMdef connect_to_db(environment: str):
db_uri = Secret.load(f'db-cloud-uri-{environment}').get()
//connect to DB
is this a way people do it?Alex Litvinov
10/25/2023, 5:30 PMNate
10/25/2023, 5:37 PMENV_VAR
that I would set with a unique value in each environment, but yeah having some consistent naming scheme for blocks would certainly not be a bad idea to make this easier - i have seen people do similar things
I'd be happy to help with specific questions you have here, don't have time at the moment to go deep into your use case. i would just say that ideally if i have a dockerized version of something like this, i would want it to work for whatever prefect server instance I'm pointing at, i.e. i can just inject PREFECT_API_URL
at docker run
time and it should just workAlex Litvinov
10/25/2023, 6:15 PMdef connect_to_db():
env = os.getenv('ENV_VAR', 'local')
db_uri = Secret.load(f'db-cloud-uri-{env}').get()
//connect to DB
to have the flow discover what it needs from a singlethen in code it'd be something like this?ENV_VAR
Nate
10/25/2023, 6:20 PMENV_VAR
as a placeholder name, but structurally thats exactly what i was thinkingNate
10/25/2023, 6:21 PMAlex Litvinov
10/25/2023, 6:22 PMi just saidyes-yes, I got itas a placeholder nameENV_VAR
Nate
10/25/2023, 6:23 PMyes-yes, I got ithaha yeah i figured, i tend to try and be overly verbose in text-only mediums to avoid ambiguity 🙂
Alex Litvinov
10/25/2023, 6:48 PMi can just injectyea, this does indeed work perfectly but that's not exactly what I want to achieve. My intention is to have a worker of docker type running somewhere Create a scheduled deployment (I mean all the point of creating a deployment here is to have it scheduled not to have to run it manually) that pulls my code, builds my image and runs it (on that docker worker) and also be able to parametrize it Here's where I'm kinda getting lost. I think I'm missing some fundamental link. This is my prefect.yaml Problem 1. Losing a parameter along the way Note: I was having this before I commited the code to git, when it was only in local Steps: 1. with the said prefect.yaml doat docker run time and it should just workPREFECT_API_URL
prefect deploy --all
2. then using said prefect.yaml do prefect deployment run 'Flow name/deployment-name' -p parameter=value
Then what I see is 2 flow runs. The first one is Worker 'DockerWorker bla-bla' submitting flow run 'blu-blu'
that has my parameter=value
And the second one (the submitted blu-blu
) that has no clue about the parameter I set.
So, the question is (I guess) how do I pass this parameter to that flow that my deployment submits?Alex Litvinov
10/25/2023, 6:50 PMAlex Litvinov
10/25/2023, 6:50 PMAlex Litvinov
10/25/2023, 7:22 PMFlow could not be retrieved from deployment.
caused by Failed to clone repository
and I guess it's failing because it's trying to clone the repo from within the container but I'm not even worried about this error cause that's not what I want it to do anyways.
So here I have 2 questions:
1. (curiosity) any idea why wasn't I seeing this error when my code was local?
2. how do I fix it? I imagine that I'm just misusing prefect.yaml sections but I'm struggling to figure out "what's happening where". like when I do prefect deploy --all
it's also building an image. I was following this guide but it's not giving me answers.
I'll continue experimenting and reading the docs ofc, let's see if I can figure it out.Alex Litvinov
10/25/2023, 8:01 PMNate
10/25/2023, 8:44 PMAlex Litvinov
10/26/2023, 1:35 PM