Does anyone have any links to docs/code for settin...
# prefect-community
j
Does anyone have any links to docs/code for setting up a Prefect Orion webserver for testing client interractions specifically?
r
Are their specific things you want to test? And are you looking to just do private/internal testing? If so, I've got a Docker Compose config + instructions that might be useful: https://github.com/rpeden/prefect-docker-compose You can pick and choose which parts you need; you could run just Orion + a database, or you could also run a CLI container and run your client interaction tests in it. And if that doesn't sound like it will meet your needs, I or others here can likely help you find other code or docs that will help. 🙂
gratitude thank you 1
j
Hey Ryan thanks for the help - just looking to do some lightweight internal testing that confirms we are interacting with the
OrionClient
correctly. I'd prefer to keep the setup as minimal as possible given that I don't need full end-to-end testing here.
r
Makes sense! If you already have Docker installed, it's an easy way to do it since you wouldn't need to install anything else. If not, though, all you really need is Python. If you run
pip install prefect
and then when it finishes, run
prefect orion start
, you'll have an Orion server running on port 4200. If you want to be able to access Orion from machines other than the one it is running on, you'll probably need to run
prefect orion start --host 0.0.0.0
Then, to ensure the client connects to the Orion server, you can run
prefect config set PREFECT_API_URL=<http://localhost:4200/api>
if running the client on the same machine, or
prefect config set PREFECT_API_URL=<http://your-orion-server-ip:4200/api>
if running elsewhere. I think that's the absolute minimal setup; if there's more you need beyond that, I'll do my best to point you in the right direction!
gratitude thank you 1
j
I see in
prefect.testing.fixtures
there's a
hosted_orion_api
pytest fixture - will this work out of the box in pytest or is there additional configuration required (e.g. environment variables/prefect context, etc)? https://github.com/PrefectHQ/prefect/blob/main/src/prefect/testing/fixtures.py#L36
Ideally I'd like to just run this as a background task in the same thread (not create a separate process)
r
Ahh - understood! I think that will work. I'll try to find you some examples.