repo_full_name stringlengths 6 93 | repo_url stringlengths 25 112 | repo_api_url stringclasses 28
values | owner stringclasses 28
values | repo_name stringclasses 28
values | description stringclasses 28
values | stars int64 617 98.8k | forks int64 31 355 ⌀ | watchers int64 990 999 ⌀ | license stringclasses 2
values | default_branch stringclasses 2
values | repo_created_at timestamp[s]date 2012-07-24 23:12:50 2025-06-16 08:07:28 ⌀ | repo_updated_at timestamp[s]date 2026-02-23 15:23:15 2026-05-03 18:52:12 ⌀ | repo_topics listlengths 0 13 ⌀ | repo_languages unknown | is_fork bool 1
class | open_issues int64 3 104 ⌀ | file_path stringlengths 3 208 | file_name stringclasses 509
values | file_extension stringclasses 1
value | file_size_bytes int64 101 84k ⌀ | file_url stringclasses 627
values | file_raw_url stringclasses 627
values | file_sha stringclasses 624
values | language stringclasses 8
values | parsed_at stringdate 2026-05-04 01:12:36 2026-05-04 19:41:55 | text stringlengths 100 102k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bit_attention.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.725251 | from typing import Optional, Tuple
import torch
import torch.nn.functional as F
from einops import einsum, rearrange
from torch import Tensor, nn
from bitnet.bitlinear import BitLinear
def scaled_dot_product_gqa(
query: Tensor,
key: Tensor,
value: Tensor,
dropout: float = 0.0,
scale: Optional[flo... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/at.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.726748 | import torch
import torch.nn.functional as F
from einops import rearrange
from torch import nn
# helper function
def exists(val):
return val is not None
def eval_decorator(fn):
def inner(model, *args, **kwargs):
was_training = model.training
model.eval()
out = fn(model, *args, **kwa... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bit_moe.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.728187 | import torch
from torch import nn
from bitnet.bitlinear import BitLinear
import torch.nn.functional as F
# Feedforward = mlp = expert
# = Linear projection + non linear activation functions like [RELU, GELU, etc] + Dropout[optional] + Normalization[optional, LayerNorm]
# Expert module
class Expert(nn.Module):
""... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bit_mamba.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.754054 | import math
from dataclasses import dataclass
from typing import Union
import torch
from torch import nn
import torch.nn.functional as F
from bitnet.bitlinear import BitLinear
from zeta.nn import OutputHead
# taken straight from https://github.com/johnma2006/mamba-minimal/blob/master/model.py
class RMSNorm(nn.Module... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.755633 | from bitnet.bit_attention import BitMGQA
from bitnet.bit_ffn import BitFeedForward
from bitnet.bit_linear_new import BitLinearNew
from bitnet.bit_transformer import BitNetTransformer
from bitnet.bitlinear import BitLinear
from bitnet.inference import BitNetInference
from bitnet.replace_hf import replace_linears_in_hf, ... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bit_llama.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:00.756796 | # Copyright (c) Meta Platforms, Inc. and affiliates.
# This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
import math
from dataclasses import dataclass
from typing import Optional, Tuple
import fairscale.nn.model_parallel.initialize as fs_init
import torch
impo... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/replace_hf.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:01.610546 | from torch import nn
from bitnet.bitlinear import BitLinear
def replace_linears_in_hf(
model,
):
"""
Replaces all instances of nn.Linear in the given model with BitLinear15b.
Args:
model (nn.Module): The model to modify.
Returns:
None
"""
for name, module in model.named_... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/bitlinear.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:01.611865 | from torch import nn, Tensor
from zeta.nn.modules.simple_rmsnorm import SimpleRMSNorm
import torch.nn.functional as F
def activation_quant(x: Tensor):
"""Per token quantization to 8bits. No grouping is needed for quantization
Args:
x (Tensor): _description_
Returns:
_type_: _description_... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/inference.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:01.612999 | import numpy as np
import torch
from bitnet.at import AutoregressiveWrapper
from bitnet.bit_transformer import BitNetTransformer
class BitNetInference:
"""
A class used to perform inference with the BitNetTransformer model.
...
Attributes
----------
model : torch.nn.Module
an instan... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | examples/bit_attention.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:01.726274 | import torch
from bitnet import BitMGQA
# Create a random tensor of shape (1, 10, 512)
x = torch.randn(1, 10, 512)
# Create an instance of the BitMGQA model with input size 512, 8 attention heads, and 4 layers
gqa = BitMGQA(512, 8, 4)
# Pass the input tensor through the BitMGQA model and get the output and attention... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | examples/bit_linear_new.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:02.445388 | import torch
from bitnet import BitLinearNew
# Create a random tensor of shape (16, 10)
x = torch.randn(16, 1000, 512)
# Create an instance of the BitLinearNew class with input size 10, output size 20, and 2 groups
layer = BitLinearNew(
512,
20,
)
# Perform a forward pass through the BitLinearNew layer with ... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | example.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:02.446003 | import torch
from bitnet import BitLinear
# Input
x = torch.randn(10, 10000, 512)
# BitLinear layer
layer = BitLinear(512, 400)
# Output
y = layer(x)
print(y)
print(y.shape)
|
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | examples/bit_mamba.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:02.650583 | import torch
from bitnet import BitMamba
# Create a tensor of size (2, 10) with random values between 0 and 100
x = torch.randint(0, 100, (2, 10))
# Create an instance of the BitMamba model with input size 512, hidden size 100, output size 10, and depth size 6
model = BitMamba(512, 100, 10, 6, return_tokens=True)
# ... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | bitnet/one_bit_vision_transformers.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:02.764618 | import torch
from torch import nn
import torch.nn.functional as F
from einops.layers.torch import Rearrange
from bitnet.bitlinear import BitLinear
from zeta import MultiQueryAttention
# helpers
def pair(t):
return t if isinstance(t, tuple) else (t, t)
def posemb_sincos_2d(h, w, dim, temperature: int = 10000, ... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | examples/bit_ffn.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:02.878220 | import torch
from bitnet import BitFeedForward
# Create a random input tensor of shape (10, 512)
x = torch.randn(10, 512)
# Create an instance of the BitFeedForward class with the following parameters:
# - input_dim: 512
# - hidden_dim: 512
# - num_layers: 4
# - swish: True (use Swish activation function)
# - post_ac... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | examples/bit_moe_example.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:02.879604 | import torch
from bitnet.bit_moe import BitMoE
# Create input tensor
x = torch.randn(2, 4, 8)
# Create BitMoE model with specified input and output dimensions
model = BitMoE(8, 4, 2)
# Forward pass through the model
output = model(x)
# Print the output
print(output)
|
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | setup.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:02.991894 | import ast
import os
import platform
import re
import shutil
import subprocess
import sys
import urllib.error
import urllib.request
import warnings
from pathlib import Path
import torch
from packaging.version import Version, parse
from setuptools import find_packages, setup
from torch.utils.cpp_extension import (
... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | examples/one_bit_vit.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:03.085760 | import torch
from bitnet import OneBitViT
# Create an instance of the OneBitViT model
v = OneBitViT(
image_size=256,
patch_size=32,
num_classes=1000,
dim=1024,
depth=6,
heads=16,
mlp_dim=2048,
)
# Generate a random image tensor
img = torch.randn(1, 3, 256, 256)
# Pass the image through th... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | tests/test_bitffn.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:03.123509 | import torch
from torch import nn
from bitnet.bit_ffn import BitFeedForward
from bitnet.bitlinear import BitLinear
def test_bitfeedforward_initialization():
bitffn = BitFeedForward(dim=512, ff_mult=4)
assert isinstance(bitffn.layer, nn.Sequential)
assert len(bitffn.layer) == 3
assert isinstance(bitff... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | tests/test_bitlinear.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:03.174230 | import torch
from bitnet.bitlinear import BitLinear
def test_bitlinear_initialization():
bitlinear = BitLinear(in_features=512, out_features=256, bias=True)
assert bitlinear.in_features == 512
assert bitlinear.out_features == 256
assert bitlinear.weight.shape == (256, 512)
assert bitlinear.bias.s... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | tests/test_transformer.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:03.557795 | import torch
from bitnet.bit_transformer import BitFeedForward, BitNetTransformer, MultiheadAttention
def test_bitnet_transformer_initialization():
bitnet = BitNetTransformer(num_tokens=20000, dim=512, heads=8, depth=6, ff_mult=4)
assert len(bitnet.layers) == 6
assert len(bitnet.ffn_layers) == 6
asse... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | train.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:04.186626 | import gzip
import random
import numpy as np
import torch
import tqdm
from torch.utils.data import DataLoader, Dataset
from zeta.optim import StableAdamWUnfused
from bitnet.at import AutoregressiveWrapper
from bitnet import BitNetTransformer
# constants
NUM_BATCHES = int(1e5)
BATCH_SIZE = 4
GRADIENT_ACCUMULATE_EVERY ... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | transformer_example.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:04.187366 | # Import the necessary libraries
import torch
from bitnet import BitNetTransformer
# Create a random tensor of integers
x = torch.randint(0, 20000, (1, 1024))
# Initialize the BitNetTransformer model
bitnet = BitNetTransformer(
num_tokens=20000, # Number of unique tokens in the input
dim=1024, # Dimension o... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | tests/tests.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:04.390807 | import pytest
import torch
from torch.nn import functional as F
from bitnet.bitlinear import BitLinear, absmax_quantize
from bitnet.bit_transformer import (
BitNetTransformer,
ParallelTransformerBlock,
Transformer,
)
# Basic Tests:
def test_absmax_quantize():
tensor = torch.tensor([1.5, -2.0, 3.0, -... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | examples/huggingface_example.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:08.795833 | import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from bitnet import replace_linears_in_hf
# Load a model from Hugging Face's Transformers
model_name = "bert-base-uncased"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretra... |
kyegomez/BitNet | https://github.com/kyegomez/BitNet | null | null | null | null | 1,924 | null | null | mit | null | null | null | null | null | null | null | examples/kernel_test.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:09.612838 | import torch
from gemm_lowbit_ext import gemm_lowbit
# Example usage
a = torch.randn(10, 20, dtype=torch.half, device="cuda") # Example tensor
b = torch.randn(20, 30, dtype=torch.half, device="cuda") # Example tensor
c = torch.empty(10, 30, dtype=torch.half, device="cuda") # Output tensor
w_scale = 1.0 # Example ... |
deepseek-ai/DeepSeek-MoE | https://github.com/deepseek-ai/DeepSeek-MoE | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | finetune/finetune.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:13.411298 | import copy
import random
from dataclasses import dataclass, field
from typing import Optional, Dict, Sequence
import logging
import os
import torch
import torch.distributed
import transformers
from transformers import Trainer, BitsAndBytesConfig
from datasets import load_dataset
import datasets
import numpy as np
fro... |
Puyodead1/udemy-downloader | https://github.com/Puyodead1/udemy-downloader | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:15.556778 | import base64
import codecs
import os
import mp4parse
import widevine_pssh_data_pb2
def extract_kid(mp4_file):
"""
Parameters
----------
mp4_file : str
MP4 file with a PSSH header
Returns
-------
String
"""
boxes = mp4parse.F4VParser.parse(filename=mp4_file)
if not... |
Puyodead1/udemy-downloader | https://github.com/Puyodead1/udemy-downloader | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | tls.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:15.557283 | import ssl
from typing import Optional
from requests.adapters import HTTPAdapter
class SSLCiphers(HTTPAdapter):
"""
Custom HTTP Adapter to change the TLS Cipher set, and therefore it's fingerprint.
"""
def __init__(self, cipher_list: Optional[str] = None, *args, **kwargs):
ctx = ssl.create_d... |
Puyodead1/udemy-downloader | https://github.com/Puyodead1/udemy-downloader | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | constants.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:15.557731 | import base64
import logging
import os
import time
CLIENT_SECRET = "f2lgDUDxjFiOlVHUpwQNFUfCQPyMO0tJQMaud53PF01UKueW8enYjeEYoyVeP0bb2XVEDkJ5GLJaVTfM5QgMVz6yyXyydZdA5QhzgvG9UmCPUYaCrIVf7VpmiilfbLJc"
CLIENT_ID = "TH96Ov3Ebo3OtgoSH5mOYzYolcowM3ycedWQDDce"
BASIC_AUTH = base64.b64encode(f"{CLIENT_ID}:{CLIENT_SECRET}".encod... |
Puyodead1/udemy-downloader | https://github.com/Puyodead1/udemy-downloader | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | vtt_to_srt.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:15.558399 | from webvtt import WebVTT
import html
import os
from pysrt.srtitem import SubRipItem
from pysrt.srttime import SubRipTime
def convert(directory, filename):
index = 0
vtt_filepath = os.path.join(directory, filename + ".vtt")
srt_filepath = os.path.join(directory, filename + ".srt")
srt = open(srt_filep... |
Puyodead1/udemy-downloader | https://github.com/Puyodead1/udemy-downloader | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | mp4parse.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:15.559286 | """ MP4 Parser based on:
http://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf
@author: Alastair McCormack
@license: MIT License
"""
import bitstring
from datetime import datetime
from collections import namedtuple
import logging
import six
log = logging.getLogger(__name__)
#log.addHandler(logging.Nu... |
Puyodead1/udemy-downloader | https://github.com/Puyodead1/udemy-downloader | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | main.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:15.575088 | # -*- coding: utf-8 -*-
import argparse
import json
import logging
import math
import os
import re
import subprocess
import sys
import time
from http.cookiejar import MozillaCookieJar
from pathlib import Path
from typing import IO, Union
import browser_cookie3
import demoji
import m3u8
import requests
from curl_cffi i... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | backend/auth/auth_utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:18.845558 | def get_authenticated_user_details(request_headers):
user_object = {}
## check the headers for the Principal-Id (the guid of the signed in user)
if "X-Ms-Client-Principal-Id" not in request_headers.keys():
## if it's not, assume we're in development mode and return a default user
from . imp... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | backend/settings.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:18.846825 | import os
import json
import logging
from abc import ABC, abstractmethod
from pydantic import (
BaseModel,
confloat,
conint,
conlist,
Field,
field_validator,
model_validator,
PrivateAttr,
ValidationError,
ValidationInfo
)
from pydantic.alias_generators import to_snake
from pydant... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | gunicorn.conf.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:18.852255 | import multiprocessing
max_requests = 1000
max_requests_jitter = 50
log_file = "-"
bind = "0.0.0.0"
timeout = 230
# https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/web-apps-performance-faqs#why-does-my-request-time-out-after-230-seconds
num_cpus = multiprocessing.cpu_count()
workers = (num_cpus * 2)... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | backend/auth/sample_user.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:18.973113 | sample_user = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en",
"Client-Ip": "22.222.222.2222:64379",
"Content-Length": "192",
"Content-Type": "application/json",
"Cookie": "AppServiceAuthSession=/AuR5ENU+pmpoN3jnymP8fzpmVBgphx9uPQrYLEWGcxjIITIeh8NZW7r3ePkG8yBcMaItlh1pX4n... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | backend/security/ms_defender_utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:18.977223 | from typing import Dict, Any
from dataclasses import dataclass, asdict, field
import os
@dataclass
class UserSecurityContext:
application_name: str = field(default=None)
end_user_id: str = field(default=None)
end_user_tenant_id: str = field(default=None)
source_ip: str = field(default=None)
de... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | backend/history/cosmosdbservice.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:18.981274 | import uuid
from datetime import datetime
from azure.cosmos.aio import CosmosClient
from azure.cosmos import exceptions
class CosmosConversationClient():
def __init__(self, cosmosdb_endpoint: str, credential: any, database_name: str, container_name: str, enable_message_feedback: bool = False):
self.... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | backend/utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:18.987280 | import os
import json
import logging
import requests
import dataclasses
from typing import List
DEBUG = os.environ.get("DEBUG", "false")
if DEBUG.lower() == "true":
logging.basicConfig(level=logging.DEBUG)
AZURE_SEARCH_PERMITTED_GROUPS_COLUMN = os.environ.get(
"AZURE_SEARCH_PERMITTED_GROUPS_COLUMN"
)
class... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | app.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.060692 | import copy
import json
import os
import logging
import uuid
import httpx
import asyncio
from quart import (
Blueprint,
Quart,
jsonify,
make_response,
request,
send_from_directory,
render_template,
current_app,
)
from openai import AsyncAzureOpenAI
from azure.identity.aio import (
D... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/auth_init.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.399281 | import argparse
import subprocess
from azure.identity import AzureDeveloperCliCredential
import urllib3
def get_auth_headers(credential):
return {
"Authorization": "Bearer "
+ credential.get_token("https://graph.microsoft.com/.default").token
}
def check_for_application(credential, app_id):... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/auth_update.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.417755 | import argparse
from azure.identity import AzureDeveloperCliCredential
import urllib3
def update_redirect_uris(credential, app_id, uri):
urllib3.request(
"PATCH",
f"https://graph.microsoft.com/v1.0/applications/{app_id}",
headers={
"Authorization": "Bearer "
+ cred... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/chunk_documents.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.419337 | import argparse
import dataclasses
import json
import os
from azure.identity import DefaultAzureCredential
from azure.core.credentials import AzureKeyCredential
from azure.keyvault.secrets import SecretClient
from azure.ai.formrecognizer import DocumentAnalysisClient
from data_utils import chunk_directory
def get_do... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/prepdocs.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.603447 | import argparse
import dataclasses
import time
from tqdm import tqdm
from azure.identity import AzureDeveloperCliCredential
from azure.core.credentials import AzureKeyCredential
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
SearchableField,
Sea... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/embed_documents.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.603959 | import argparse
from asyncio import sleep
import json
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from data_utils import get_embedding
RETRY_COUNT = 5
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--input_data_path", ... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/push_to_acs.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.643793 | import argparse
from asyncio import sleep
import dataclasses
import json
import os
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from data_preparation import create_or_update_search_index, upload_documents_to_index
RETRY_COUNT = 5
if __name__ == "__main__":
pa... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/data_utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.645192 | """Data utilities for index preparation."""
import ast
import html
import json
import os
import re
import ssl
import subprocess
import tempfile
import time
import urllib.request
from abc import ABC, abstractmethod
from concurrent.futures import ProcessPoolExecutor
from dataclasses import dataclass
from fu... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/pinecone_data_preparation.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.677546 | """Data Preparation Script for an Azure Cognitive Search Index."""
import argparse
import json
import os
import time
import uuid
import pinecone
import requests
from data_utils import Document
from azure.ai.formrecognizer import DocumentAnalysisClient
from azure.core.credentials import AzureKeyCredential
from azure.id... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/data_preparation.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.692481 | """Data Preparation Script for an Azure Cognitive Search Index."""
import argparse
import dataclasses
import json
import os
import subprocess
import time
import requests
from azure.ai.documentintelligence import DocumentIntelligenceClient
from azure.core.credentials import AzureKeyCredential
from azure.iden... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/cosmos_mongo_vcore_data_preparation.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.693207 | """Data Preparation Script for an Azure Cognitive Search Index."""
import argparse
import json
import os
import uuid
import requests
from data_utils import Document
from azure.ai.formrecognizer import DocumentAnalysisClient
from azure.core.credentials import AzureKeyCredential
from azure.identity import AzureCliCreden... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | scripts/run_batch_create_index.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:19.989830 | import copy
import json
import os
from pathlib import Path
import subprocess
import tqdm
from openai import AzureOpenAI
from dotenv import load_dotenv
load_dotenv()
FORM_RECOGNIZER_KEY = os.getenv("FORM_RECOGNIZER_KEY")
with open("./config.json", "r") as f:
config = json.loads(f.read())
# this is an example, ... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | tests/conftest.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:20.055190 | import pytest
def pytest_addoption(parser):
parser.addoption(
"--use-keyvault-secrets",
help='Get secrets from a keyvault instead of the environment.',
action='store_true', default=False
)
@pytest.fixture(scope="session")
def use_keyvault_secrets(request) -> str:
return request.confi... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | tests/integration_tests/conftest.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:20.059192 | import json
import os
import pytest
from azure.identity import AzureCliCredential
from azure.keyvault.secrets import SecretClient
from pydantic.alias_generators import to_snake
VAULT_NAME = os.environ.get("VAULT_NAME")
@pytest.fixture(scope="module")
def secret_client() -> SecretClient:
kv_uri = f"https://{VAU... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | tools/data_collection.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:20.273060 | import os
import sys
import asyncio
import json
from dotenv import load_dotenv
#import the app.py module to gain access to the methods to construct payloads and
#call the API through the sdk
# Add parent directory to sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
import app... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | tests/integration_tests/test_datasources.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:20.273509 | import os
import pytest
from tempfile import NamedTemporaryFile
from importlib import import_module, reload
from jinja2 import FileSystemLoader
from jinja2 import Environment
from quart import Quart
datasources = [
"AzureCognitiveSearch",
"Elasticsearch",
"none" # TODO: add tests for additional data sour... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | tests/unit_tests/test_settings.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:20.343070 | import os
import pytest
from importlib import import_module, reload
@pytest.fixture(scope="function")
def dotenv_path(request):
test_case_name = request.node.originalname.partition("test_")[2]
return os.path.join(
os.path.dirname(__file__),
"dotenv_data",
test_case_name
)
@pytest... |
microsoft/sample-app-aoai-chatGPT | https://github.com/microsoft/sample-app-aoai-chatGPT | null | null | null | null | 1,921 | null | null | mit | null | null | null | null | null | null | null | tests/unit_tests/test_utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:20.343512 | import pytest
from backend.utils import format_as_ndjson, parse_multi_columns
@pytest.mark.asyncio
async def test_format_as_ndjson():
async def dummy_generator():
yield {"message": "test message\n"}
async for event in format_as_ndjson(dummy_generator()):
assert event == '{"message": "test mes... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | cereal/messaging/tests/test_messaging.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:22.832761 | import os
import capnp
import multiprocessing
import numbers
import random
import threading
import time
from openpilot.common.parameterized import parameterized
import pytest
from cereal import log, car
import cereal.messaging as messaging
from cereal.services import SERVICE_LIST
events = [evt for evt in log.Event.sc... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | cereal/services.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:22.833737 | #!/usr/bin/env python3
from enum import IntEnum
from typing import Optional
# TODO: this should be automatically determined using the capnp schema
class QueueSize(IntEnum):
BIG = 10 * 1024 * 1024 # 10MB - video frames, large AI outputs
MEDIUM = 2 * 1024 * 1024 # 2MB - high freq (CAN), livestream
SMALL =... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/api/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:22.838357 | from openpilot.common.api.comma_connect import CommaConnectApi
class Api:
def __init__(self, dongle_id):
self.service = CommaConnectApi(dongle_id)
def request(self, method, endpoint, **params):
return self.service.request(method, endpoint, **params)
def get(self, *args, **kwargs):
return self.serv... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | cereal/messaging/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:22.839538 | # must be built with scons
from msgq import fake_event_handle, drain_sock_raw, MultiplePublishersError, IpcError, \
Context, Poller, SubSocket, PubSocket, SocketEventHandle, toggle_fake_events, \
set_fake_prefix, get_fake_prefix, delete_fake_prefix, wait_for_one_event
import msgq
impor... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | cereal/messaging/tests/validate_sp_cereal_upstream.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:22.851376 | #!/usr/bin/env python3
"""Schema-level cereal compat check between sunnypilot and upstream openpilot.
Rules (per struct matched across sides by typeId):
R1 shared ordinal must reference the same type.
R2 sunnypilot-only ordinal in a union -> FAIL (unknown discriminant upstream).
R3 sunnypilot-only ordinal on ... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | cereal/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:22.852015 | import os
import capnp
from importlib.resources import as_file, files
capnp.remove_import_hook()
with as_file(files("cereal")) as fspath:
CEREAL_PATH = fspath.as_posix()
log = capnp.load(os.path.join(CEREAL_PATH, "log.capnp"))
car = capnp.load(os.path.join(CEREAL_PATH, "car.capnp"))
custom = capnp.load(os.pat... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | cereal/messaging/tests/test_services.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:22.884379 | import os
import tempfile
from typing import Dict
from openpilot.common.parameterized import parameterized
import cereal.services as services
from cereal.services import SERVICE_LIST
class TestServices:
@parameterized.expand(SERVICE_LIST.keys())
def test_services(self, s):
service = SERVICE_LIST[s]
asse... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | cereal/messaging/tests/test_pub_sub_master.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:22.894231 | import random
import time
from typing import Sized, cast
import cereal.messaging as messaging
from cereal.messaging.tests.test_messaging import events, random_sock, random_socks, \
random_bytes, random_carstate, assert_carstate, \
... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/api/comma_connect.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:23.714554 | import os
from openpilot.common.api.base import BaseApi
API_HOST = os.getenv('API_HOST', 'https://api.commadotai.com')
class CommaConnectApi(BaseApi):
def __init__(self, dongle_id):
super().__init__(dongle_id, API_HOST)
self.user_agent = "openpilot-"
|
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/api/base.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:23.716032 | import jwt
import os
import requests
import unicodedata
from datetime import datetime, timedelta, UTC
from openpilot.system.hardware.hw import Paths
from openpilot.system.version import get_version
# name: jwt signature algorithm
KEYS = {"id_rsa": "RS256",
"id_ecdsa": "ES256"}
class BaseApi:
def __init__(s... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/constants.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:23.717717 | import numpy as np
# conversions
class CV:
# Speed
MPH_TO_KPH = 1.609344
KPH_TO_MPH = 1. / MPH_TO_KPH
MS_TO_KPH = 3.6
KPH_TO_MS = 1. / MS_TO_KPH
MS_TO_MPH = MS_TO_KPH * KPH_TO_MPH
MPH_TO_MS = MPH_TO_KPH * KPH_TO_MS
MS_TO_KNOTS = 1.9438
KNOTS_TO_MS = 1. / MS_TO_KNOTS
# Angle
DEG_TO_RAD = np.pi / ... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/basedir.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:23.890281 | import os
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../"))
|
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/git.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:23.891541 | from functools import cache
import subprocess
from openpilot.common.utils import run_cmd, run_cmd_default
@cache
def get_commit(cwd: str | None = None, branch: str = "HEAD") -> str:
return run_cmd_default(["git", "rev-parse", branch], cwd=cwd)
@cache
def get_commit_date(cwd: str | None = None, commit: str = "HEAD... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/i2c.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:23.908313 | import os
import fcntl
import ctypes
# I2C constants from /usr/include/linux/i2c-dev.h
I2C_SLAVE = 0x0703
I2C_SLAVE_FORCE = 0x0706
I2C_SMBUS = 0x0720
# SMBus transfer types
I2C_SMBUS_READ = 1
I2C_SMBUS_WRITE = 0
I2C_SMBUS_BYTE_DATA = 2
I2C_SMBUS_I2C_BLOCK_DATA = 8
I2C_SMBUS_BLOCK_MAX = 32
class _I2cSmbusData(ctype... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/gps.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:23.909349 | from openpilot.common.params import Params
def get_gps_location_service(params: Params) -> str:
if params.get_bool("UbloxAvailable"):
return "gpsLocationExternal"
else:
return "gpsLocation"
|
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/gpio.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.002994 | import os
import fcntl
import ctypes
from functools import cache
def gpio_init(pin: int, output: bool) -> None:
try:
with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f:
f.write(b"out" if output else b"in")
except Exception as e:
print(f"Failed to set gpio {pin} direction: {e}")
def gpio_se... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/file_chunker.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.071773 | import math
import os
from pathlib import Path
CHUNK_SIZE = 45 * 1024 * 1024 # 45MB, under GitHub's 50MB limit
def get_chunk_name(name, idx, num_chunks):
return f"{name}.chunk{idx+1:02d}of{num_chunks:02d}"
def get_manifest_path(name):
return f"{name}.chunkmanifest"
def get_chunk_paths(path, file_size):
num_c... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/logging_extra.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.333065 | import io
import os
import sys
import copy
import json
import time
import uuid
import socket
import logging
import traceback
import numpy as np
from threading import local
from collections import OrderedDict
from contextlib import contextmanager
LOG_TIMESTAMPS = "LOG_TIMESTAMPS" in os.environ
def json_handler(obj):
... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/mock/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.334038 | """
Utilities for generating mock messages for testing.
example in common/tests/test_mock.py
"""
import functools
import threading
from cereal.messaging import PubMaster
from cereal.services import SERVICE_LIST
from openpilot.common.mock.generators import generate_livePose
from openpilot.common.realtime import Rateke... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/markdown.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.339033 | HTML_REPLACEMENTS = [
(r'&', r'&'),
(r'"', r'"'),
]
def parse_markdown(text: str, tab_length: int = 2) -> str:
lines = text.split("\n")
output: list[str] = []
list_level = 0
def end_outstanding_lists(level: int, end_level: int) -> int:
while level > end_level:
level -= 1
output.ap... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/parameterized.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.473850 | import sys
import pytest
import inspect
class parameterized:
@staticmethod
def expand(cases):
cases = list(cases)
if not cases:
return lambda func: pytest.mark.skip("no parameterized cases")(func)
def decorator(func):
params = [p for p in inspect.signature(func).parameters if p != 'self'... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/pid.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.513264 | import numpy as np
from numbers import Number
class PIDController:
def __init__(self, k_p, k_i, k_d=0., pos_limit=1e308, neg_limit=-1e308, rate=100):
self._k_p: list[list[float]] = [[0], [k_p]] if isinstance(k_p, Number) else k_p
self._k_i: list[list[float]] = [[0], [k_i]] if isinstance(k_i, Number) else k_i... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/mock/generators.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.514053 | from cereal import messaging
def generate_livePose():
msg = messaging.new_message('livePose')
meas = {'x': 0.0, 'y': 0.0, 'z': 0.0, 'xStd': 0.0, 'yStd': 0.0, 'zStd': 0.0, 'valid': True}
msg.livePose.orientationNED = meas
msg.livePose.velocityDevice = meas
msg.livePose.angularVelocityDevice = meas
msg.live... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/params.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.515183 | from openpilot.common.params_pyx import Params, ParamKeyFlag, ParamKeyType, UnknownKeyName
assert Params
assert ParamKeyFlag
assert ParamKeyType
assert UnknownKeyName
if __name__ == "__main__":
import sys
params = Params()
key = sys.argv[1]
assert params.check_key(key), f"unknown param: {key}"
if len(sys.a... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/prefix.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.605998 | import os
import platform
import shutil
import uuid
from openpilot.common.params import Params
from openpilot.system.hardware import PC
from openpilot.system.hardware.hw import Paths
from openpilot.system.hardware.hw import DEFAULT_DOWNLOAD_CACHE_ROOT
class OpenpilotPrefix:
def __init__(self, prefix: str | None = ... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/realtime.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:24.721370 | """Utilities for reading real time clocks and keeping soft real time constraints."""
import gc
import os
import sys
import time
from setproctitle import getproctitle
from openpilot.common.utils import MovingAverage
from openpilot.system.hardware import PC
# time step for each process
DT_CTRL = 0.01 # controlsd
DT_... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/simple_kalman.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.202830 | import numpy as np
def get_kalman_gain(dt, A, C, Q, R, iterations=100):
P = np.zeros_like(Q)
for _ in range(iterations):
P = A.dot(P).dot(A.T) + dt * Q
S = C.dot(P).dot(C.T) + R
K = P.dot(C.T).dot(np.linalg.inv(S))
P = (np.eye(len(P)) - K.dot(C)).dot(P)
return K
class KF1D:
# this EKF assume... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/stat_live.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.203917 | import numpy as np
class RunningStat:
# tracks realtime mean and standard deviation without storing any data
def __init__(self, priors=None, max_trackable=-1):
self.max_trackable = max_trackable
if priors is not None:
# initialize from history
self.M = priors[0]
self.S = priors[1]
s... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/filter_simple.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.316287 | class FirstOrderFilter:
def __init__(self, x0, rc, dt, initialized=True):
self.x = x0
self.dt = dt
self.update_alpha(rc)
self.initialized = initialized
def update_alpha(self, rc):
self.alpha = self.dt / (rc + self.dt)
def update(self, x):
if self.initialized:
self.x = (1. - self.al... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/swaglog.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.397393 | import logging
import os
import time
import warnings
from pathlib import Path
from logging.handlers import BaseRotatingHandler
import zmq
from openpilot.common.logging_extra import SwagLogger, SwagFormatter, SwagLogFileFormatter
from openpilot.system.hardware.hw import Paths
def get_file_handler():
Path(Paths.swa... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/spinner.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.510371 | import os
import subprocess
from openpilot.common.basedir import BASEDIR
class Spinner:
def __init__(self):
try:
self.spinner_proc = subprocess.Popen(["./spinner.py"],
stdin=subprocess.PIPE,
cwd=os.path.join(BASEDIR, "sy... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/tests/test_params.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.558853 | import pytest
import datetime
import os
import threading
import time
import uuid
from openpilot.common.params import Params, ParamKeyFlag, UnknownKeyName
class TestParams:
def setup_method(self):
self.params = Params()
def test_params_put_and_get(self):
self.params.put("DongleId", "cb38263377b873ee")
... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/text_window.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.779840 | #!/usr/bin/env python3
import os
import time
import subprocess
from openpilot.common.basedir import BASEDIR
class TextWindow:
def __init__(self, text):
try:
self.text_proc = subprocess.Popen(["./text.py", text],
stdin=subprocess.PIPE,
... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/time_helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.805676 | import datetime
from pathlib import Path
MIN_DATE = datetime.datetime(year=2025, month=2, day=21)
MAX_DATE = datetime.datetime(year=2035, month=1, day=1)
def min_date():
# on systemd systems, the default time is the systemd build time
systemd_path = Path("/lib/systemd/systemd")
if systemd_path.exists():
d =... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/timeout.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:25.915385 | import signal
class TimeoutException(Exception):
pass
class Timeout:
"""
Timeout context manager.
For example this code will raise a TimeoutException:
with Timeout(seconds=5, error_msg="Sleep was too long"):
time.sleep(10)
"""
def __init__(self, seconds, error_msg=None):
if error_msg is None:
... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/tests/test_file_helpers.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:26.457649 | import os
from uuid import uuid4
from openpilot.common.utils import atomic_write
class TestFileHelpers:
def run_atomic_write_func(self, atomic_write_func):
path = f"/tmp/tmp{uuid4()}"
with atomic_write_func(path) as f:
f.write("test")
assert not os.path.exists(path)
with open(path) as f:
... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/transformations/camera.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:26.459087 | import itertools
import numpy as np
from dataclasses import dataclass
import openpilot.common.transformations.orientation as orient
## -- hardcoded hardware params --
@dataclass(frozen=True)
class CameraConfig:
width: int
height: int
focal_length: float
@property
def size(self):
return (self.width, sel... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/tests/test_markdown.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:26.460143 | import os
from openpilot.common.basedir import BASEDIR
from openpilot.common.markdown import parse_markdown
class TestMarkdown:
def test_all_release_notes(self):
with open(os.path.join(BASEDIR, "CHANGELOG.md")) as f:
release_notes = f.read().split("\n\n")
assert len(release_notes) > 10
for r... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/transformations/coordinates.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:26.460754 | from openpilot.common.transformations.orientation import numpy_wrap
from openpilot.common.transformations.transformations import (ecef2geodetic_single,
geodetic2ecef_single)
from openpilot.common.transformations.transformations import LocalCoord as LocalCoord_single
... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/transformations/tests/test_coordinates.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:27.009402 | import numpy as np
import openpilot.common.transformations.coordinates as coord
geodetic_positions = np.array([[37.7610403, -122.4778699, 115],
[27.4840915, -68.5867592, 2380],
[32.4916858, -113.652821, -6],
[15.1392514... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/transformations/tests/test_orientation.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:27.156888 | import numpy as np
import pytest
from openpilot.common.transformations.orientation import euler2quat, quat2euler, euler2rot, rot2euler, \
rot2quat, quat2rot, \
ned_euler_from_ecef
eulers = np.array([[ 1.46520501, 2.78688383... |
sunnypilot/sunnypilot | https://github.com/sunnypilot/sunnypilot | null | null | null | null | 1,922 | null | null | mit | null | null | null | null | null | null | null | common/transformations/transformations.py | null | null | null | null | null | null | Python | 2026-05-04T01:49:27.167268 | import numpy as np
# Constants
a = 6378137.0
b = 6356752.3142
esq = 6.69437999014e-3
e1sq = 6.73949674228e-3
def geodetic2ecef_single(g):
"""
Convert geodetic coordinates (latitude, longitude, altitude) to ECEF.
"""
try:
if len(g) != 3:
raise ValueError("Geodetic must be size 3")
except TypeErro... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.