Skip to content

Instantly share code, notes, and snippets.

View discdiver's full-sized avatar

Jeff Hale discdiver

View GitHub Profile
@discdiver
discdiver / python-virtual-environment-with-venv.md
Created October 18, 2024 19:58
Create a Python virtual environment with venv

Instructions for creating and activating a virtual environment with venv

If you are comfortable with conda, uv, pipenv or another virtual environment tool, feel free to use one of those tools to create a virtual environment instead.

Ensure you are not in a virtual environment already. Generally, you will know you are in a virtual environment because your command line prompt will include the virtual environment name in parentheses.

Venv comes installed with Python. If you need to install Python 3.12, download it from python.org.

@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