Skip to content

Instantly share code, notes, and snippets.

View discdiver's full-sized avatar

Jeff Hale discdiver

View GitHub Profile
@discdiver
discdiver / .zpreztorc
Created January 30, 2024 20:11
Prezto zsh configuration file 2024-01-30
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
@discdiver
discdiver / get_weather.py
Created September 20, 2023 15:28
Prefect serve method code from demo video
import requests
from prefect import flow
@flow(log_prints=True)
def fetch_weather(lat: float = 38.9, lon: float = -77.0):
weather = requests.get(
"https://api.open-meteo.com/v1/forecast/",
params=dict(latitude=lat, longitude=lon, hourly="temperature_2m"),
)
from demo import pipeline2
from prefect.deployments import Deployment
from prefect.filesystems import S3
from prefect.orion.schemas.schedules import IntervalSchedule
deployment2 = Deployment.build_from_flow(
flow=pipeline2,
name="Second Python Deployment Example",
schedule=(IntervalSchedule(interval=60)),
tags=["extract"],

Starting agent with ephemeral API...

  ___ ___ ___ ___ ___ ___ _____     _   ___ ___ _  _ _____
 | _ \ _ \ __| __| __/ __|_   _|   /_\ / __| __| \| |_   _|
 |  _/   / _|| _|| _| (__  | |    / _ \ (_ | _|| .` | | |
 |_| |_|_\___|_| |___\___| |_|   /_/ \_\___|___|_|\_| |_|

Usage: prefect deployment build [OPTIONS] PATH                                             
                                                                                           
Generate a deployment YAML from /path/to/file.py:flow_function                             
                                                                                           
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────╮
│ *    path      TEXT  The path to a flow entrypoint, in the form of                       │
│                      `./path/to/file.py:flow_func_name`                                  │
│                      [default: None]                                                     │
│                      [required]                                                          │
(base) jeffhale prefect/demo [main] $ prefect --help
                                                                                            
 Usage: prefect [OPTIONS] COMMAND [ARGS]...                                                 
                                                                                            
╭─ Options ────────────────────────────────────────────────────────────────────────────────╮
│ --version  -v            Display the current version.                                    │
│ --profile  -p      TEXT  Select a profile for this this CLI run. [default: None]         │
│ --help                   Show this message and exit.                                     │
╰──────────────────────────────────────────────────────────────────────────────────────────╯
from demo import pipeline
from prefect.deployments import Deployment
deployment = Deployment.build_from_flow(
flow=pipeline,
name="Python Deployment Example",
)
if __name__ == "__main__":
deployment.apply()
@discdiver
discdiver / prefect2-deploy-and-apply.md
Last active August 27, 2022 13:50
build and apply in one step
prefect deployment build demo.py:pipeline -n cool-deployment --apply
prefect deployment build demo.py:pipeline -n cool-deployment
prefect deployment apply pipeline-deployment.yaml
import pandas
import yfinance as yf
from datetime import timedelta
from prefect import flow, task
@task(retries=3, cache_expiration=timedelta(30))
def fetch_data(ticker):
return yf.download(ticker)
@task