repo stringlengths 7 90 | file_url stringlengths 81 315 | file_path stringlengths 4 228 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 14:38:15 2026-01-05 02:33:18 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/diff/__init__.py | changedetectionio/diff/__init__.py | """
Diff rendering module for change detection.
This module provides functions for rendering differences between text content,
with support for various output formats and tokenization strategies.
"""
import difflib
from typing import List, Iterator, Union
from loguru import logger
import diff_match_patch as dmp_modul... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/diff/tokenizers/natural_text.py | changedetectionio/diff/tokenizers/natural_text.py | """
Simple word tokenizer using whitespace boundaries.
This is a simpler tokenizer that treats all whitespace as token boundaries
without special handling for HTML tags or other markup.
"""
from typing import List
def tokenize_words(text: str) -> List[str]:
"""
Split text into words using simple whitespace ... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/diff/tokenizers/words_and_html.py | changedetectionio/diff/tokenizers/words_and_html.py | """
Tokenizer that preserves HTML tags as atomic units while splitting on whitespace.
This tokenizer is specifically designed for HTML content where:
- HTML tags should remain intact (e.g., '<p>', '<a href="...">')
- Whitespace tokens are preserved for accurate diff reconstruction
- Words are split on whitespace bound... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/diff/tokenizers/__init__.py | changedetectionio/diff/tokenizers/__init__.py | """
Tokenizers for diff operations.
This module provides various tokenization strategies for use with the diff system.
New tokenizers can be easily added by:
1. Creating a new module in this directory
2. Importing and registering it in the TOKENIZERS dictionary below
"""
from .natural_text import tokenize_words
from ... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/Watch.py | changedetectionio/api/Watch.py | import os
from changedetectionio.validate_url import is_safe_valid_url
from . import auth
from changedetectionio import queuedWatchMetaData, strtobool
from changedetectionio import worker_handler
from flask import request, make_response, send_from_directory
from flask_expects_json import expects_json
from flask_restf... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/Notifications.py | changedetectionio/api/Notifications.py | from flask_expects_json import expects_json
from flask_restful import Resource, abort
from flask import request
from . import auth, validate_openapi_request
from . import schema_create_notification_urls, schema_delete_notification_urls
class Notifications(Resource):
def __init__(self, **kwargs):
# datastor... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/Search.py | changedetectionio/api/Search.py | from flask_restful import Resource, abort
from flask import request
from . import auth, validate_openapi_request
class Search(Resource):
def __init__(self, **kwargs):
# datastore is a black box dependency
self.datastore = kwargs['datastore']
@auth.check_token
@validate_openapi_request('sea... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/SystemInfo.py | changedetectionio/api/SystemInfo.py | from flask_restful import Resource
from . import auth, validate_openapi_request
class SystemInfo(Resource):
def __init__(self, **kwargs):
# datastore is a black box dependency
self.datastore = kwargs['datastore']
self.update_q = kwargs['update_q']
@auth.check_token
@validate_opena... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/__init__.py | changedetectionio/api/__init__.py | import copy
import functools
from flask import request, abort
from loguru import logger
from . import api_schema
from ..model import watch_base
# Build a JSON Schema atleast partially based on our Watch model
watch_base_config = watch_base()
schema = api_schema.build_watch_json_schema(watch_base_config)
schema_create... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/Tags.py | changedetectionio/api/Tags.py | from changedetectionio import queuedWatchMetaData
from changedetectionio import worker_handler
from flask_expects_json import expects_json
from flask_restful import abort, Resource
from flask import request
from . import auth
# Import schemas from __init__.py
from . import schema_tag, schema_create_tag, schema_update... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/auth.py | changedetectionio/api/auth.py | from flask import request, make_response, jsonify
from functools import wraps
# Simple API auth key comparison
# @todo - Maybe short lived token in the future?
def check_token(f):
@wraps(f)
def decorated(*args, **kwargs):
datastore = args[0].datastore
config_api_token_enabled = datastore.dat... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/Import.py | changedetectionio/api/Import.py | from changedetectionio.strtobool import strtobool
from flask_restful import abort, Resource
from flask import request
from functools import wraps
from . import auth, validate_openapi_request
from ..validate_url import is_safe_valid_url
def default_content_type(content_type='text/plain'):
"""Decorator to set a def... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/api/api_schema.py | changedetectionio/api/api_schema.py | # Responsible for building the storage dict into a set of rules ("JSON Schema") acceptable via the API
# Probably other ways to solve this when the backend switches to some ORM
from changedetectionio.notification import valid_notification_formats
def build_time_between_check_json_schema():
# Setup time between ch... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/widgets/__init__.py | changedetectionio/widgets/__init__.py | from .ternary_boolean import TernaryNoneBooleanWidget, TernaryNoneBooleanField
__all__ = ['TernaryNoneBooleanWidget', 'TernaryNoneBooleanField'] | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/widgets/test_custom_text.py | changedetectionio/widgets/test_custom_text.py | #!/usr/bin/env python3
import sys
import os
from changedetectionio.model import USE_SYSTEM_DEFAULT_NOTIFICATION_FORMAT_FOR_WATCH
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../..'))
from changedetectionio.widgets import TernaryNoneBooleanField
from wtforms import Form
class TestForm(Form):
# De... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/widgets/ternary_boolean.py | changedetectionio/widgets/ternary_boolean.py | from wtforms import Field
from wtforms import widgets
from markupsafe import Markup
class TernaryNoneBooleanWidget:
"""
A widget that renders a horizontal radio button group with either two options (Yes/No)
or three options (Yes/No/Default), depending on the field's boolean_mode setting.
"""
def __... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/realtime/socket_server.py | changedetectionio/realtime/socket_server.py | import timeago
from flask_socketio import SocketIO
from flask_babel import gettext, get_locale
import time
import os
from loguru import logger
from blinker import signal
from changedetectionio import strtobool
from changedetectionio.languages import get_timeago_locale
class SignalHandler:
"""A standalone class ... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/realtime/events.py | changedetectionio/realtime/events.py | from flask_socketio import emit
from loguru import logger
from blinker import signal
def register_watch_operation_handlers(socketio, datastore):
"""Register Socket.IO event handlers for watch operations"""
@socketio.on('watch_operation')
def handle_watch_operation(data):
"""Handle watch operation... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/realtime/__init__.py | changedetectionio/realtime/__init__.py | """
Socket.IO realtime updates module for changedetection.io
""" | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/exceptions.py | changedetectionio/processors/exceptions.py | class ProcessorException(Exception):
def __init__(self, message=None, status_code=None, url=None, screenshot=None, has_filters=False, html_content='', xpath_data=None):
self.message = message
self.status_code = status_code
self.url = url
self.screenshot = screenshot
self.has_... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/__init__.py | changedetectionio/processors/__init__.py | from functools import lru_cache
from loguru import logger
from flask_babel import gettext
import importlib
import inspect
import os
import pkgutil
def find_sub_packages(package_name):
"""
Find all sub-packages within the given package.
:param package_name: The name of the base package to scan for sub-pack... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/extract.py | changedetectionio/processors/extract.py | """
Base data extraction module for all processors.
This module handles extracting data from watch history using regex patterns
and exporting to CSV format. This is the default extractor that all processors
(text_json_diff, restock_diff, etc.) can use by default or override.
"""
import os
from flask_babel import gett... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/base.py | changedetectionio/processors/base.py | import re
import hashlib
from changedetectionio.content_fetchers.base import Fetcher
from changedetectionio.strtobool import strtobool
from copy import deepcopy
from abc import abstractmethod
import os
from loguru import logger
SCREENSHOT_FORMAT_JPEG = 'JPEG'
SCREENSHOT_FORMAT_PNG = 'PNG'
class difference_detection_p... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/magic.py | changedetectionio/processors/magic.py | """
Content Type Detection and Stream Classification
This module provides intelligent content-type detection for changedetection.io.
It addresses the common problem where HTTP Content-Type headers are missing, incorrect,
or too generic, which would otherwise cause the wrong processor to be used.
The guess_stream_type... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/util.py | changedetectionio/processors/image_ssim_diff/util.py | """
DEPRECATED: All multiprocessing functions have been removed.
The image_ssim_diff processor now uses LibVIPS via ImageDiffHandler abstraction,
which provides superior performance and memory efficiency through streaming
architecture and automatic threading.
All image operations are now handled by:
- imagehandler.py... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/processor.py | changedetectionio/processors/image_ssim_diff/processor.py | """
Core fast screenshot comparison processor.
Uses OpenCV with subprocess isolation for high-performance, low-memory
image processing. All operations run in isolated subprocesses for complete
memory cleanup and stability.
"""
import hashlib
import time
from loguru import logger
from changedetectionio.processors.exce... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/edit_hook.py | changedetectionio/processors/image_ssim_diff/edit_hook.py | """
Optional hook called when processor settings are saved in edit page.
This hook analyzes the selected region to determine if template matching
should be enabled for tracking content movement.
Template matching is controlled via ENABLE_TEMPLATE_TRACKING env var (default: False).
"""
import io
import os
from loguru... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/difference.py | changedetectionio/processors/image_ssim_diff/difference.py | """
Screenshot diff visualization for fast image comparison processor.
All image operations now use ImageDiffHandler abstraction for clean separation
of concerns and easy backend swapping (LibVIPS, OpenCV, PIL, etc.).
"""
import os
import json
import time
from flask_babel import gettext
from loguru import logger
fro... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/preview.py | changedetectionio/processors/image_ssim_diff/preview.py | """
Preview rendering for SSIM screenshot processor.
Renders images properly in the browser instead of showing raw bytes.
"""
from flask_babel import gettext
from loguru import logger
def get_asset(asset_name, watch, datastore, request):
"""
Get processor-specific binary assets for preview streaming.
T... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/__init__.py | changedetectionio/processors/image_ssim_diff/__init__.py | """
Visual/screenshot change detection using fast image comparison algorithms.
This processor compares screenshots using OpenCV (cv2.absdiff),
which is 10-100x faster than SSIM while still detecting meaningful visual changes.
"""
import os
from pathlib import Path
processor_description = "Visual/Screenshot change de... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/forms.py | changedetectionio/processors/image_ssim_diff/forms.py | """
Configuration forms for fast screenshot comparison processor.
"""
from wtforms import SelectField, StringField, validators, ValidationError, IntegerField
from flask_babel import lazy_gettext as _l
from changedetectionio.forms import processor_text_json_diff_form
import re
from changedetectionio.processors.image_s... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/image_handler/libvips_handler.py | changedetectionio/processors/image_ssim_diff/image_handler/libvips_handler.py | """
LibVIPS implementation of ImageDiffHandler.
Uses pyvips for high-performance image processing with streaming architecture
and low memory footprint. Ideal for large screenshots (8000px+).
"""
from __future__ import annotations
import os
from typing import Tuple, Any, TYPE_CHECKING
from loguru import logger
if TYP... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/image_handler/__init__.py | changedetectionio/processors/image_ssim_diff/image_handler/__init__.py | """
Abstract base class for image processing operations.
All image operations for the image_ssim_diff processor must be implemented
through this interface to allow different backends (libvips, OpenCV, PIL, etc.).
"""
from abc import ABC, abstractmethod
from typing import Tuple, Optional, Any
class ImageDiffHandler(... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/image_handler/isolated_opencv.py | changedetectionio/processors/image_ssim_diff/image_handler/isolated_opencv.py | """
OpenCV-based subprocess isolation for image comparison.
OpenCV is much more stable in multiprocessing contexts than LibVIPS.
No threading issues, no fork problems, picklable functions.
"""
import multiprocessing
import numpy as np
from .. import POLL_TIMEOUT_ABSOLUTE
# Public implementation name for logging
IMPL... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/image_ssim_diff/image_handler/isolated_libvips.py | changedetectionio/processors/image_ssim_diff/image_handler/isolated_libvips.py | """
Subprocess-isolated image operations for memory leak prevention.
LibVIPS accumulates C-level memory in long-running processes that cannot be
reclaimed by Python's GC or libvips cache management. Using subprocess isolation
ensures complete memory cleanup when the process exits.
This module wraps LibvipsImageDiffHa... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/text_json_diff/processor.py | changedetectionio/processors/text_json_diff/processor.py | # HTML to TEXT/JSON DIFFERENCE self.fetcher
import hashlib
import json
import os
import re
import urllib3
from changedetectionio.conditions import execute_ruleset_against_all_plugins
from ..base import difference_detection_processor
from changedetectionio.html_tools import PERL_STYLE_REGEX, cdata_in_document_to_text,... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/text_json_diff/difference.py | changedetectionio/processors/text_json_diff/difference.py | """
History/diff rendering for text_json_diff processor.
This module handles the visualization of text/HTML/JSON changes by rendering
a side-by-side or unified diff view with syntax highlighting and change markers.
"""
import os
import time
from loguru import logger
from changedetectionio import diff, strtobool
from... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/text_json_diff/__init__.py | changedetectionio/processors/text_json_diff/__init__.py |
from loguru import logger
def _task(watch, update_handler):
from changedetectionio.content_fetchers.exceptions import ReplyWithContentButNoText
from changedetectionio.processors.text_json_diff.processor import FilterNotFoundInResponse
text_after_filter = ''
try:
# The slow process (we run ... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/restock_diff/processor.py | changedetectionio/processors/restock_diff/processor.py | from ..base import difference_detection_processor
from ..exceptions import ProcessorException
from . import Restock
from loguru import logger
import urllib3
import time
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Translatable strings - extracted by pybabel, translated at runtime in __init__.... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/restock_diff/__init__.py | changedetectionio/processors/restock_diff/__init__.py |
from babel.numbers import parse_decimal
from changedetectionio.model.Watch import model as BaseWatch
from typing import Union
import re
class Restock(dict):
def parse_currency(self, raw_value: str) -> Union[float, None]:
# Clean and standardize the value (ie 1,400.00 should be 1400.00), even better would... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/processors/restock_diff/forms.py | changedetectionio/processors/restock_diff/forms.py | from wtforms import (
BooleanField,
validators,
FloatField
)
from wtforms.fields.choices import RadioField
from wtforms.fields.form import FormField
from wtforms.form import Form
from flask_babel import lazy_gettext as _l
from changedetectionio.forms import processor_text_json_diff_form
class RestockSett... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/jinja2_custom/safe_jinja.py | changedetectionio/jinja2_custom/safe_jinja.py | """
Safe Jinja2 render with max payload sizes
See https://jinja.palletsprojects.com/en/3.1.x/sandbox/#security-considerations
"""
import jinja2.sandbox
import typing as t
import os
from .extensions.TimeExtension import TimeExtension
from .plugins import regex_replace
JINJA2_MAX_RETURN_PAYLOAD_SIZE = 1024 * int(os.ge... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/jinja2_custom/__init__.py | changedetectionio/jinja2_custom/__init__.py | """
Jinja2 custom extensions and safe rendering utilities.
"""
from .extensions.TimeExtension import TimeExtension
from .safe_jinja import (
render,
render_fully_escaped,
create_jinja_env,
JINJA2_MAX_RETURN_PAYLOAD_SIZE,
DEFAULT_JINJA2_EXTENSIONS,
)
from .plugins.regex import regex_replace
__all__ ... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/jinja2_custom/extensions/TimeExtension.py | changedetectionio/jinja2_custom/extensions/TimeExtension.py | """
Jinja2 TimeExtension - Custom date/time handling for templates.
This extension provides the {% now %} tag for Jinja2 templates, offering timezone-aware
date/time formatting with support for time offsets.
Why This Extension Exists:
The Arrow library has a now() function (arrow.now()), but Jinja2 templates cann... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/jinja2_custom/extensions/__init__.py | changedetectionio/jinja2_custom/extensions/__init__.py | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false | |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/jinja2_custom/plugins/regex.py | changedetectionio/jinja2_custom/plugins/regex.py | """
Regex filter plugin for Jinja2 templates.
Provides regex_replace filter for pattern-based string replacements in templates.
"""
import re
import signal
from loguru import logger
def regex_replace(value: str, pattern: str, replacement: str = '', count: int = 0) -> str:
"""
Replace occurrences of a regex p... | python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
dgtlmoon/changedetection.io | https://github.com/dgtlmoon/changedetection.io/blob/0cb98229d67aa1203e745df586deb46834831859/changedetectionio/jinja2_custom/plugins/__init__.py | changedetectionio/jinja2_custom/plugins/__init__.py | """
Jinja2 custom filter plugins for changedetection.io
"""
from .regex import regex_replace
__all__ = ['regex_replace']
| python | Apache-2.0 | 0cb98229d67aa1203e745df586deb46834831859 | 2026-01-04T14:43:28.546632Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/sz.py | sz.py | #!/usr/bin/env python3
import os, sys
import token
import tokenize
import itertools
from tabulate import tabulate
from tinygrad.uop import Ops
from tinygrad.helpers import ContextVar
TOKEN_WHITELIST = [token.OP, token.NAME, token.NUMBER, token.STRING]
def is_docstring(t):
return t.type == token.STRING and t.string.... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/gradient.py | tinygrad/gradient.py | from typing import cast
import math, dataclasses
from tinygrad.uop.ops import UOp, PatternMatcher, UPat, Ops, all_metadata
from tinygrad.helpers import argsort
def reduce_gradient(ctx:UOp, ret:UOp, op:Ops):
def broadcast_to_input(x): return x.reshape(x.shape+(1,)*(len(ret.src[0].shape)-len(x.shape))).expand(ret.src[... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/dtype.py | tinygrad/dtype.py | from __future__ import annotations
from typing import Final, ClassVar, Callable, Literal
import math, struct, ctypes, functools
from dataclasses import dataclass, fields
from tinygrad.helpers import getenv, prod, round_up, next_power2
from enum import Enum, auto
class InvalidType:
_instance: ClassVar[InvalidType|Non... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/helpers.py | tinygrad/helpers.py | from __future__ import annotations
import os, functools, platform, time, re, contextlib, operator, hashlib, pickle, sqlite3, tempfile, pathlib, string, ctypes, sys, gzip, getpass, gc
import urllib.request, subprocess, shutil, math, types, copyreg, inspect, importlib, decimal, itertools, socketserver, json
from dataclas... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/__init__.py | tinygrad/__init__.py | import os
if int(os.getenv("TYPED", "0")):
from typeguard import install_import_hook
install_import_hook(__name__)
from tinygrad.tensor import Tensor # noqa: F401
from tinygrad.engine.jit import TinyJit # noqa: F401
from tinygrad.uop.ops import UOp
Va... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/tensor.py | tinygrad/tensor.py | # inspired by https://github.com/karpathy/micrograd/blob/master/micrograd/engine.py
from __future__ import annotations
import time, math, itertools, functools, struct, sys, inspect, pathlib, string, hashlib, weakref
from contextlib import ContextDecorator
from typing import Callable, ClassVar, Sequence, cast, get_args,... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | true |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/device.py | tinygrad/device.py | from __future__ import annotations
from dataclasses import dataclass, replace
from collections import defaultdict
from typing import Any, Generic, TypeVar, Iterator, Generator
import importlib, inspect, functools, pathlib, os, platform, contextlib, sys, re, atexit, pickle, decimal
from tinygrad.helpers import CI, OSX, ... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/renderer/cstyle.py | tinygrad/renderer/cstyle.py | from typing import Literal, Callable, cast
import os, math, sys
from collections import defaultdict, Counter
from tinygrad.codegen.opt import tc
from tinygrad.uop.ops import GroupOp, Ops, UOp, PatternMatcher, UPat, range_str, axis_letters
from tinygrad.helpers import strip_parens, getenv, prod, dedup, AMX, CPU_COUNT
fr... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | true |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/renderer/ptx.py | tinygrad/renderer/ptx.py | from typing import cast, Callable
import struct
from collections import defaultdict
from tinygrad.codegen.opt import tc
from tinygrad.uop.ops import Ops, UOp, PatternMatcher, UPat, GroupOp
from tinygrad.dtype import dtypes, DType, PtrDType, AddrSpace
from tinygrad.renderer import Renderer
from tinygrad.renderer.cstyle ... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/renderer/__init__.py | tinygrad/renderer/__init__.py | from __future__ import annotations
from typing import Callable, cast, TYPE_CHECKING
import functools
from dataclasses import dataclass, field
from tinygrad.helpers import to_function_name, dedup, prod, DEBUG
from tinygrad.uop.ops import Ops, UOp, sym_infer, sint, Variable, ssimplify, GroupOp, PatternMatcher, print_uops... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/renderer/nir.py | tinygrad/renderer/nir.py | from typing import Callable, cast, Any
from tinygrad.dtype import AddrSpace, DType, PtrDType, ImageDType, dtypes
from tinygrad.helpers import DEBUG, OSX, unwrap, charptr, fromimport
from tinygrad.renderer import Renderer
from tinygrad.renderer.cstyle import CUDARenderer
from tinygrad.uop.ops import GroupOp, Ops, UOp, P... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/renderer/wgsl.py | tinygrad/renderer/wgsl.py | from tinygrad.dtype import DType, PtrDType, dtypes, AddrSpace
from tinygrad.uop.ops import UOp, Ops, PatternMatcher, UPat
from tinygrad.renderer.cstyle import CStyleLanguage, base_rewrite, extra_pm
from tinygrad.helpers import strip_parens
def sign_extend(val:UOp, sext_am:int):
return (UOp.where((val >> (sext_am - 1... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/renderer/llvmir.py | tinygrad/renderer/llvmir.py | from typing import cast
import math, struct, sys
from tinygrad.codegen.opt import tc
from tinygrad.renderer import Renderer
from tinygrad.renderer.cstyle import AMDHIPRenderer, create_non_native_float_pats, pm_manual_bf16_cast
from tinygrad.uop.decompositions import xexp2, xlog2
from tinygrad.uop.ops import UOp, Patter... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/uop/divandmod.py | tinygrad/uop/divandmod.py | import functools
from tinygrad.uop.ops import PatternMatcher, UPat, Ops, UOp
from tinygrad.dtype import dtypes
from tinygrad.helpers import cdiv, cmod, CORRECT_DIVMOD_FOLDING, unwrap
# NOTE: this cache is only on index UOps and matches the cache in the old ShapeTracker in spirit
@functools.cache
def fold_divmod_genera... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/uop/spec.py | tinygrad/uop/spec.py | import math
from typing import cast, Any
from tinygrad.uop.ops import PatternMatcher, UPat, GroupOp, Ops, UOp, print_uops, AxisType, KernelInfo, pyrender, Kernel, CustomKernel
from tinygrad.dtype import DType, ImageDType, dtypes, PtrDType, AddrSpace, Invalid
from tinygrad.helpers import DEBUG, Context, prod, SPEC, Meta... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/uop/ops.py | tinygrad/uop/ops.py | from __future__ import annotations
from typing import Any, Callable, cast, TYPE_CHECKING, Type, Sequence, Iterable, Final
import sys, time, functools, itertools, math, operator, hashlib, os, types, pickle, pathlib, inspect, weakref, collections
from dataclasses import dataclass
from enum import Enum, auto
from tinygrad... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | true |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/uop/validate.py | tinygrad/uop/validate.py | from typing import Callable, cast
from tinygrad.uop.ops import PatternMatcher, UPat, GroupOp, Ops, UOp, python_alu
from tinygrad.dtype import ImageDType, dtypes, Invalid, PtrDType
from tinygrad.helpers import IGNORE_OOB, cpu_profile
try:
import z3
# older versions of z3 dont have some operators like & overloaded
... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/uop/symbolic.py | tinygrad/uop/symbolic.py | # all of symbolic lives here now
import math, operator, struct, functools
from collections import defaultdict
from tinygrad.uop.ops import Ops, PatternMatcher, UPat, UOp, GroupOp, exec_alu
from tinygrad.dtype import ConstType, dtypes, PtrDType, can_lossless_cast, Invalid
from tinygrad.helpers import partition, all_same... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/uop/decompositions.py | tinygrad/uop/decompositions.py | from typing import Callable
import math, functools
from tinygrad.dtype import dtypes, DType, promo_lattice
from tinygrad.device import is_dtype_supported
from tinygrad.helpers import polyN, DISABLE_FAST_IDIV
from tinygrad.uop.ops import UOp, UPat, Ops, PatternMatcher
TRANSCENDENTAL_DTYPES = (dtypes.float16, dtypes.flo... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/uop/__init__.py | tinygrad/uop/__init__.py | # flake8: noqa: E702
# allow semicolons to put multiple ops on one line
from enum import auto, IntEnum, Enum
# wrapper around IntEnum that preserves Enum.__str__ and makes auto() unique across all FastEnum subclasses
class FastEnum(IntEnum):
def __str__(self): return Enum.__str__(self)
def __repr__(x): return str(... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/uop/upat.py | tinygrad/uop/upat.py | from typing import Any, Callable
import itertools, inspect, functools, types
from tinygrad.helpers import partition, dedup, Context
from tinygrad.uop.ops import UPat, UOp, Ops, PatternMatcher, graph_rewrite, deconstruct_function
class UPatCompileError(Exception): pass
# **** UPat compiled ****
def _get_clause(self:U... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/apps/llm.py | tinygrad/apps/llm.py | from __future__ import annotations
import sys, argparse, typing, re, unicodedata, json, uuid, time, functools
from tinygrad import Tensor, nn, UOp, TinyJit, getenv
from tinygrad.helpers import partition, TCPServerWithReuse, HTTPRequestHandler, DEBUG, Timing, GlobalCounters, stderr_log, colored
class SimpleTokenizer:
... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/simplify.py | tinygrad/codegen/simplify.py | import itertools
from tinygrad.uop.ops import UOp, PatternMatcher, UPat, Ops, graph_rewrite, _substitute, range_start
from tinygrad.uop.symbolic import symbolic
from tinygrad.helpers import partition, dedup
from tinygrad.dtype import dtypes, ImageDType
def flatten_range(r:UOp):
off = range_start[r.op]
rngs = r.src... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/__init__.py | tinygrad/codegen/__init__.py | from typing import cast
import itertools
from tinygrad.helpers import DEVECTORIZE, TRANSCENDENTAL, SPEC, DEBUG, getenv, TracingKey
from tinygrad.uop.ops import PatternMatcher, graph_rewrite, UOp, pm_lower_index_dtype, Ops, UPat, track_rewrites, KernelInfo, pyrender
from tinygrad.uop.spec import type_verify, program_spe... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/gpudims.py | tinygrad/codegen/gpudims.py | import math, functools, operator
from tinygrad.uop.ops import UOp, Ops, sint, PatternMatcher, UPat, KernelInfo, ssimplify, AxisType, sint_to_uop
from tinygrad.helpers import all_int, dedup, get_contraction
from tinygrad.dtype import dtypes, AddrSpace, Invalid
from tinygrad.renderer import Renderer
def _group_dims(dims... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/late/linearizer.py | tinygrad/codegen/late/linearizer.py | import heapq
from typing import Any
from collections import defaultdict
from tinygrad.uop.ops import PatternMatcher, UOp, Ops, UPat, multirange_str
from tinygrad.helpers import prod, getenv, TUPLE_ORDER
def linearize(sink:UOp) -> list[UOp]:
# this is a toposort with priority
lst = list(sink.toposort())
consumers... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/late/expander.py | tinygrad/codegen/late/expander.py | # this converts a lowerer program into a vectorized program
import functools, itertools
from tinygrad.dtype import dtypes, PtrDType, AddrSpace
from tinygrad.helpers import dedup, flatten, all_same, prod, partition
from tinygrad.uop.ops import UOp, Ops, UPat, PatternMatcher, GroupOp, AxisType, range_start
from tinygrad.... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/late/devectorizer.py | tinygrad/codegen/late/devectorizer.py | from typing import Any, cast
import functools, operator, itertools
from collections import defaultdict
from dataclasses import dataclass
from tinygrad.dtype import dtypes, ImageDType, DType, AddrSpace, Invalid, PtrDType
from tinygrad.uop.ops import UOp, Ops, UPat, PatternMatcher, GroupOp, identity_element
from tinygrad... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/opt/search.py | tinygrad/codegen/opt/search.py | import functools, math, time, multiprocessing, traceback, signal, atexit
from dataclasses import replace
from tinygrad.uop.ops import sym_infer, AxisType, pyrender
from tinygrad.device import Device, Buffer, Compiler
from tinygrad.helpers import prod, flatten, DEBUG, CACHELEVEL, diskcache_get, diskcache_put, getenv, Co... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/opt/tc.py | tinygrad/codegen/opt/tc.py | import math, functools
from dataclasses import dataclass
from tinygrad.dtype import DType, dtypes
@dataclass(frozen=True)
class TensorCore: # D = A * B + C, A is (M x K), B is (K x N), C and D are (M x N)
dims: tuple[int,int,int] # N, M, K
threads: int # number of threads that construct the warp
elements_per_thr... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/opt/postrange.py | tinygrad/codegen/opt/postrange.py | import math, itertools
from collections import defaultdict
from typing import cast, Final
from tinygrad.uop.ops import PatternMatcher, UPat, Ops, UOp, KernelInfo, graph_rewrite, AxisType, ssimplify, GroupOp
from tinygrad.uop.ops import axis_letters, axis_colors, axis_to_pos
from tinygrad.device import Buffer
from tinyg... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/opt/__init__.py | tinygrad/codegen/opt/__init__.py | # opt opinionatedly transforms an ast into an optimized ast using either heuristics or beam search
from __future__ import annotations
from enum import Enum, auto
from dataclasses import dataclass
class OptOps(Enum):
TC = auto(); UPCAST = auto(); UNROLL = auto(); LOCAL = auto(); THREAD = auto() # noqa: E702
GROUP =... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/codegen/opt/heuristic.py | tinygrad/codegen/opt/heuristic.py | import itertools
from tinygrad.codegen.opt import Opt, OptOps, KernelOptError
from tinygrad.helpers import getenv, DEBUG, prod, NOLOCALS, TC_OPT, TC_SELECT, USE_TC, AMX
from tinygrad.dtype import ImageDType
from tinygrad.uop.ops import Ops, resolve, AxisType
from tinygrad.codegen.opt.postrange import Scheduler
def han... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/viz/serve.py | tinygrad/viz/serve.py | #!/usr/bin/env python3
import multiprocessing, pickle, difflib, os, threading, json, time, sys, webbrowser, socket, argparse, functools, codecs, io, struct
import ctypes, pathlib, traceback, itertools
from contextlib import redirect_stdout, redirect_stderr, contextmanager
from decimal import Decimal
from urllib.parse i... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_cl.py | tinygrad/runtime/ops_cl.py | from __future__ import annotations
from typing import cast
import ctypes, functools, hashlib
from tinygrad.runtime.autogen import opencl as cl
from tinygrad.helpers import init_c_var, to_char_p_p, from_mv, OSX, DEBUG, mv_address, suppress_finalizing
from tinygrad.renderer.cstyle import OpenCLRenderer, IntelRenderer
fro... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_cuda.py | tinygrad/runtime/ops_cuda.py | from __future__ import annotations
import ctypes, functools
from tinygrad.helpers import DEBUG, getenv, mv_address, init_c_var, init_c_struct_t, suppress_finalizing, CUDA_CC, CUDA_PTX
from tinygrad.device import Compiled, BufferSpec, LRUAllocator, CompilerPair, CompilerSet
from tinygrad.renderer.cstyle import CUDARende... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_tinyfs.py | tinygrad/runtime/ops_tinyfs.py | import socket, json, asyncio, threading, math
from contextlib import asynccontextmanager
from tinygrad.device import Compiled, Allocator
from tinygrad.helpers import DEBUG, getenv
from tinygrad import Tensor
TINYFS_ENDPOINT = getenv("TINYFS_ENDPOINT", "localhost:6767")
TINYFS_TIMEOUT = getenv("TINYFS_TIMEOUT", 60)
cl... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_dsp.py | tinygrad/runtime/ops_dsp.py | from __future__ import annotations
import ctypes, os, mmap, tempfile, pathlib, array, functools, threading, contextlib, sys, subprocess, struct
assert sys.platform != 'win32'
from tinygrad.device import BufferSpec, Compiled, Allocator, Compiler, CompilerSet, CompilerPair
from tinygrad.runtime.ops_cpu import CPUAllocato... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_webgpu.py | tinygrad/runtime/ops_webgpu.py | import functools, struct
from tinygrad.device import Compiled, Allocator, Compiler, BufferSpec, CompilerSet, CompilerPair
from tinygrad.renderer.wgsl import WGSLRenderer
from tinygrad.helpers import round_up, suppress_finalizing
from tinygrad.runtime.autogen import webgpu
from typing import List, Any, TypeAlias
import... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_qcom.py | tinygrad/runtime/ops_qcom.py | from __future__ import annotations
import os, ctypes, functools, mmap, struct, array, math, sys, weakref, contextlib
assert sys.platform != 'win32'
from typing import Any, cast
from tinygrad.device import BufferSpec, CompilerSet, CompilerPair
from tinygrad.runtime.support.hcq import HCQBuffer, HWQueue, HCQProgram, HCQC... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_metal.py | tinygrad/runtime/ops_metal.py | import subprocess, pathlib, struct, ctypes, tempfile, functools, contextlib, decimal, platform, sys
from tinygrad.helpers import prod, to_mv, getenv, round_up, cache_dir, PROFILE, ProfileRangeEvent, cpu_profile, unwrap
import tinygrad.runtime.support.objc as objc
from tinygrad.device import Compiled, Compiler, CompileE... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_npy.py | tinygrad/runtime/ops_npy.py | import numpy as np
from tinygrad.helpers import flat_mv
from tinygrad.device import Compiled, Allocator
class NpyAllocator(Allocator['NpyDevice']):
def _alloc(self, size:int, options=None) -> np.ndarray: return np.empty(size, dtype=np.uint8)
def _as_buffer(self, src:np.ndarray) -> memoryview: return flat_mv(np.req... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_disk.py | tinygrad/runtime/ops_disk.py | import os, sys, mmap, io, ctypes, contextlib, pathlib
from typing import Generator, Callable
from tinygrad.helpers import OSX, round_up
from tinygrad.device import Compiled, Allocator
with contextlib.suppress(ImportError):
import _posixshmem
from tinygrad.runtime.autogen import io_uring, libc
class DiskDevice(Comp... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_nv.py | tinygrad/runtime/ops_nv.py | from __future__ import annotations
import os, ctypes, contextlib, re, functools, mmap, struct, array, sys, weakref
assert sys.platform != 'win32'
from typing import cast, ClassVar
from dataclasses import dataclass
from tinygrad.runtime.support.hcq import HCQCompiled, HCQAllocator, HCQBuffer, HWQueue, CLikeArgsState, HC... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | true |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_cpu.py | tinygrad/runtime/ops_cpu.py | from __future__ import annotations
import platform, sys, ctypes, functools, time, mmap, threading, queue
from tinygrad.helpers import from_mv, to_mv, OSX, WIN, mv_address, wait_cond, cpu_profile, suppress_finalizing, unwrap, data64_le
from tinygrad.helpers import CPU_CC, CPU_LVP, CPU_LLVM
from tinygrad.device import Bu... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_null.py | tinygrad/runtime/ops_null.py | import functools
from tinygrad.device import Compiled, Compiler, Allocator, CompilerSet, CompilerPair
from tinygrad.engine.jit import MultiGraphRunner
from tinygrad.renderer.cstyle import Renderer, CStyleLanguage
from tinygrad.renderer.llvmir import AMDLLVMRenderer
from tinygrad.uop.ops import Ops
from tinygrad.helpers... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_hip.py | tinygrad/runtime/ops_hip.py | import ctypes, functools
from tinygrad.helpers import init_c_var, mv_address, init_c_struct_t, getenv
from tinygrad.device import Compiled, LRUAllocator, BufferSpec, CompilerSet, CompilerPair
from tinygrad.runtime.autogen import hip
from tinygrad.renderer.cstyle import HIPRenderer
if getenv("IOCTL"): import extra.hip_g... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_python.py | tinygrad/runtime/ops_python.py | # pylint: disable=cell-var-from-loop
# a python uops emulator
# works to test the tensor cores, and all the uops in general
# this is the (living) definition of uops
from typing import Any, TYPE_CHECKING, cast
import pickle, base64, itertools, time, struct, sys, functools
from tinygrad.dtype import DType, dtypes, Image... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/__init__.py | tinygrad/runtime/__init__.py | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false | |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/ops_amd.py | tinygrad/runtime/ops_amd.py | from __future__ import annotations
from typing import cast, ClassVar
import os, ctypes, struct, hashlib, functools, importlib, mmap, errno, array, contextlib, sys, weakref, itertools, collections, atexit
assert sys.platform != 'win32'
from dataclasses import dataclass
from tinygrad.runtime.support.hcq import HCQCompile... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | true |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/compiler_mesa.py | tinygrad/runtime/support/compiler_mesa.py | import base64, ctypes, pathlib, tempfile, hashlib, sys
from tinygrad.device import Compiler
from tinygrad.helpers import cpu_objdump, system, data64
from tinygrad.runtime.autogen import mesa, llvm
from tinygrad.runtime.support.compiler_cpu import CPULLVMCompiler, expect, cerr
# NB: compilers assume mesa's glsl type ca... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/objc.py | tinygrad/runtime/support/objc.py | import ctypes, ctypes.util, functools, sys
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING: id_ = ctypes.c_void_p
else:
class id_(ctypes.c_void_p):
_is_finalizing = sys.is_finalizing # FIXME: why is this needed
retain: bool = False
# This prevents ctypes from converting response to plain int, and... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
tinygrad/tinygrad | https://github.com/tinygrad/tinygrad/blob/bf356ae99621f42ad218b902ae7afdcb1f4a2f03/tinygrad/runtime/support/memory.py | tinygrad/runtime/support/memory.py | import collections, functools, dataclasses, enum
from typing import Any, ClassVar
from tinygrad.helpers import round_up, getenv
class BumpAllocator:
def __init__(self, size:int, base:int=0, wrap:bool=True): self.size, self.ptr, self.base, self.wrap = size, 0, base, wrap
def alloc(self, size:int, alignment:int=1) -... | python | MIT | bf356ae99621f42ad218b902ae7afdcb1f4a2f03 | 2026-01-04T14:43:17.197982Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.