Skip to content

Instantly share code, notes, and snippets.

View dan-osull's full-sized avatar

Dan O'Sullivan dan-osull

View GitHub Profile
from dataclasses import dataclass
from typing import Self
class Example:
field1: str
field2: str
def from_input_data(cls, data) -> Self:
dan-osull /
Created October 28, 2022 19:04
Async PostgreSQL with FastAPI dependency injection & SQLAlchemy
import os
from abc import ABC, abstractmethod
from typing import AsyncIterator, Optional
import uvicorn
from dotenv import load_dotenv
from fastapi import Depends, FastAPI
from fastapi.responses import JSONResponse
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
import asyncio
from functools import wraps
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
def cache_response(func):
$InformationPreference = "Continue"
$ErrorActionPreference = "Stop"
try {
$vmPartitionAdapter = Get-VMGpuPartitionAdapter -VMName $vmName
if ($vmPartitionAdapter) {
Write-Information "Removing Partition Adapter. Checkpoints work."