sami
07/29/2024, 7:43 PMMarvin
07/29/2024, 7:43 PMprefect cloud login -k '<my-api-key>'
.
2. Write a Flow:
- Example of creating a simple flow:
from prefect import flow
@flow(log_prints=True) # Send `print` statements as INFO logs
def my_workflow():
print("I can call any python code here, including prefect tasks or flows")
if __name__ == "__main__":
my_workflow() # Call it like a normal Python function
3. Set Up the Flow:
- Create a directory and a file for your flow.
- Example of a flow with an API call:
import httpx
from prefect import flow, task
@task
def fetch_data():
response = httpx.get("<https://example.com/api/data>")
return response.json()
@flow
def my_flow():
data = fetch_data()
print(data)
4. Deploy the Flow:
- Deploy the flow using: my_flow.deploy("my-deployment-name")
.
References:
- Manage Prefect Cloud API Keys
- Basic Flow Example
Feel free to ask if you need more specific information or further assistance!sami
07/29/2024, 7:44 PMsami
07/29/2024, 7:45 PMMarvin
07/29/2024, 7:45 PMfrom prefect.client import get_client
async def get_deployment_url(deployment_name):
async with get_client() as client:
deployment = await client.read_deployment_by_name(deployment_name)
return deployment["url"]
deployment_url = await get_deployment_url("my-deployment-name")
print(deployment_url)
3. Prefect CLI:
- Use the Prefect CLI to get deployment information:
prefect deployment describe my-deployment-name
- This should display details, including the endpoint URL.
If you have followed these steps and still can't locate the URL, please provide additional details about your setup, and I can assist further.