This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typing | |
from dataclasses import dataclass | |
@dataclass | |
class BodyBase: | |
content_type: str | |
@dataclass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from dataclasses import dataclass as dataclass | |
from dataclasses import field | |
from typing import Any, Dict, List, Literal, Mapping, Optional, Union | |
ParameterLocations = Literal["header", "path", "query", "cookie"] | |
PathParamStyles = Literal["simple", "label", "matrix"] | |
QueryParamStyles = Literal["form", "spaceDelimited", "pipeDelimited", "deepObject"] | |
HeaderParamStyles = Literal["simple"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Awaitable, Callable | |
from fastapi import FastAPI, Request, Response | |
from fastapi.exceptions import HTTPException | |
from opentelemetry import trace | |
from opentelemetry.sdk.trace import TracerProvider | |
from opentelemetry.propagate import inject | |
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor | |
trace.set_tracer_provider(TracerProvider()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from dataclasses import dataclass, field | |
from logging import Filter, Formatter, Handler, Logger, LogRecord | |
from logging import config as logging_config_mod | |
from logging import getLogger | |
from typing import Generator, List, Optional, Sequence, Union | |
@dataclass(frozen=True) | |
class CapturedRecord: | |
records: List[LogRecord] = field(default_factory=list) | |
output: List[str] = field(default_factory=list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextvars import Context, ContextVar, copy_context | |
from typing import Any | |
def _set_cvar(cvar: ContextVar, val: Any): | |
cvar.set(val) | |
class CaptureContext: | |
"""Capture changes to the Context within the block. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from contextlib import asynccontextmanager | |
import contextvars | |
ctxvar = contextvars.ContextVar("ctx") | |
@asynccontextmanager | |
async def lifespan(): | |
ctxvar.set("spam") | |
yield |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import contextvars | |
ctxvar = contextvars.ContextVar("ctx") | |
async def lifespan(): | |
ctxvar.set("spam") | |
return contextvars.copy_context() | |
async def endpoint(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tempfile | |
from timeit import default_timer, timeit | |
from typing import List, Tuple | |
from matplotlib import pyplot as plt | |
import numpy as np | |
from tensorflow import keras | |
from tensorflow.keras.models import load_model | |
from scikeras._saving_utils import pack_keras_model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exclude: ['_config.yml', '*.py'] | |
include: ['_*', 'versions.json'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This script is run from docs_deploy.yml | |
It writes JSON like this: | |
{"latest": "refs/heads/main"} | |
To a file called versions.json at the root | |
of the docs branch. | |
It will also update index.html to point to the |