<@ULVA73B9P> How to use Prefect Core’s local serve...
# ask-marvin
a
@Marvin How to use Prefect Core’s local server mode, which allows for local execution and tracking of flow runs without connecting to Prefect Cloud. Give specific instructions on configuring Prefect Core to run flows without Prefect Cloud
m
To configure Prefect Core for local execution and tracking of flow runs without connecting to Prefect Cloud, you need to use Prefect's local server mode. Since the documentation search did not return relevant results, I will provide general instructions based on my understanding: 1. Install Prefect Core: If you haven't already, install Prefect Core via pip with the following command:
Copy code
pip install prefect
2. Start the Local Server: Use
prefect orion start
command to start the Prefect Orion local development server. 3. Set Local API URL: Configure Prefect to use the local API server by setting the
PREFECT_API_URL
environment variable to the local server's URL. The default is usually
<http://localhost:4200/api>
.
Copy code
bash
   export PREFECT_API_URL="<http://localhost:4200/api>"
Or you can set the
PREFECT_API_URL
configuration in the Prefect user configuration file (~/.prefect/config.toml). 4. Create a Local Work Queue: Create a work queue for your local server that your flows will be submitted to:
Copy code
bash
   prefect work-queue create local-queue
5. Run Worker: Start a Prefect worker that pulls from the local work queue. Make sure the API URL points to your local server:
Copy code
bash
   prefect worker start -q local-queue
6. Register and Run Flows: When defining your flows, make sure to specify
local-runner
as your flow runner. Then you can register your flow with the local server and run it using the Prefect CLI. The documentation pages returned in the search were not specific to Prefect Core's local server mode. For more detailed instructions, you should consult the Prefect Core documentation on local execution and the tutorial on flow orchestration with Prefect, which will have the most up-to-date and relevant information: - Prefect Docs - FAQ - Prefect Docs - Cloud Connecting Please note that, at the time of writing, the Prefect Orion local development server (part of Prefect 2.0+) would be the actual server to start. If you're using Prefect Core 1.0, the instructions might differ slightly. You should consult the Prefect documentation for the version you're using for exact details.
a
@Marvin when I run
Copy code
prefect orion start
I get
Copy code
Usage: prefect [OPTIONS] COMMAND [ARGS]...
Try 'prefect --help' for help.
╭─ Error ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ No such command 'orion'.                                                                                                        │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
(venv) avl@avl-mac isolated-short % prefect --help
m
It appears that there is some confusion around starting Prefect Orion. The correct command should not be
prefect orion start
but rather just
prefect server start
for starting a local server instance with Prefect Core 1.0. This command will spin up a local Prefect server UI that you can access by default at
<http://127.0.0.1:4200>
. Based on the error message you've received and the accompanying help output, it's possible that you might be using an older version of Prefect Core that pre-dates Orion features or Prefect 2.0 commands. Make sure you have the latest version of Prefect installed, which you can check by running:
Copy code
bash
prefect version
If you indeed want to use Prefect 2.0 features (Orion), you may need to install or update to the latest version. You can do this with the following pip command:
Copy code
bash
pip install -U "prefect>=2.0"
After updating to Prefect 2.0, the Orion server can be started with:
Copy code
bash
prefect orion start
Please note that as Prefect 2.0 was approaching a stable release in early 2022, if you are looking to use the very latest features, the commands might differ. Always refer to the Prefect documentation for the most current and version-specific information.