https://prefect.io logo
Title
l

Luca Schneider

10/10/2022, 8:16 PM
Hi all, I’m trying to add headers (basic auth) to the http request to the orion client. I have a python script to deploy flows and blocks. How am I supposed to update the client with httpx settings in my script ? thanks
k

Kalise Richmond

10/10/2022, 8:36 PM
Hi Luca, here's an example of adding the headers to a request.
l

Luca Schneider

10/10/2022, 8:49 PM
Is there a way to pass headers to the actual OrionClient with httpx_settings? https://docs.prefect.io/api-ref/prefect/client/. I was hoping to do something like that:
with … as client:
deployment.apply()
k

Kalise Richmond

10/10/2022, 8:55 PM
yes, you can pass api, api_key, api_version, and httpx_settings to the OrionClient. https://docs.prefect.io/api-ref/prefect/client/#prefect.client.orion.OrionClient The api_key will add the authentication to the headers.
l

Luca Schneider

10/10/2022, 8:59 PM
it seems that inject_client() could be what i’m looking for https://docs.prefect.io/api-ref/prefect/client/#prefect.client.orion.inject_client. I could inject the new client into my actual deployment script
k

Kalise Richmond

10/10/2022, 9:10 PM
are you using the create_deployment() call from the orion client?
l

Luca Schneider

10/10/2022, 10:02 PM
No, at the moment my script looks like something like that:
minio_block = RemoteFileSystem(...)
minio_block.save("minio")

k8s_job = KubernetesJob(...)
k8s_job.save('k8sdev')

deployment = Deployment.build_from_flow(
    flow=pipeline,
    storage=minio_block,
    infrastructure=k8s_job,
)

if __name__ == '__main__':
    deployment.apply()
What would be your suggestion to easily pass header to the client with such script ?
k

Kalise Richmond

10/11/2022, 2:58 PM
Hi Luca, I'm not entirely sure what you are trying to accomplish here? Can you provide more details about what you are trying to do with the Client or the deployment class?
l

Luca Schneider

10/25/2022, 8:44 AM
Hi @Kalise Richmond, my prefect orion server sits behind a reverse proxy with basic authentification. I’m trying to transform the previous script to be compatible with such set up. I need to be able to pass the required settings to the underlying prefect client being called, while create deployment, infra, storage,…
thanks for your help