Skip to content

feat: worker abstractions; fix: various improvements and bug fixes#328

Merged
tazlin merged 131 commits intomainfrom
even-better-tests-rebase
Mar 22, 2026
Merged

feat: worker abstractions; fix: various improvements and bug fixes#328
tazlin merged 131 commits intomainfrom
even-better-tests-rebase

Conversation

@tazlin
Copy link
Copy Markdown
Member

@tazlin tazlin commented Jan 26, 2025

This PR introduces new features (mostly around generation/worker abstractions), refactors core SDK structures, expands endpoint support, improves testing and documentation, and fixes a range of issues across API models, naming, logging, and compatibility.

Features

  • Add support for remaining endpoints
    • Add shared key support
      • Introduce shared key models and API mappings
      • Add MessageSpecifiesSharedKeyMixin
      • Warn on empty shared keys
    • Add support for user deletion endpoint
  • Add time_constructed property to HordeResponse
  • Introduce generation_parameters namespace for backend-agnostic parameter models
    • Add initial HordeSingleGeneration support
    • Add generation, dispatch handling, and related infrastructure
  • Add backend parsing modules and example worker generation scripts
  • Add opt-in telemetry
  • Add _async_client_exceptions standardization in SDK namespace
  • Add image utilities:
    • first_pass_resolution
    • calc_upscale_sampler_steps
    • base64_str_to_pil_image
  • Add bridge agent string helper with default usage
  • Add safety-related classes and feature flags
  • Add support for load_large_models argument in model_meta (for worker model choices)

Refactoring

  • Rename JobIDGenerationID and related variables (job_idgen_id)
  • Rename generation_idsresult_ids
  • Refactor states, result types, and thread safety
  • Refactor image-specific constants naming
  • Move constants into more appropriate namespaces
  • Move generation constants into gen._params/*/consts.py
  • Refactor namespace ai_horde_workerworker
  • Refactor bridge data and dispatch source constants
  • Refactor dynamic request handling using requests.request(...)
  • Introduce dynamic parameters via additional_params
  • Remove cyclic dependencies between namespaces
  • Remove unused and superseded code
  • Remove pydantic pin

Fixes

  • UUID handling:
    • Warn on incompatible UUID comparisons
    • Handle additional comparison cases
  • Naming and consistency:
    • Improve naming for user ID mixin and known type aliases
    • Fix inconsistent naming for job pop types
  • API/model correctness:
    • Fix API model name mismatches
    • Fix malformed models and missing fields/imports
    • Fix request/response model mappings
    • Fix python→API field rewriting on submit
    • Fix protected namespace usage (model_)
    • Fix incorrect API methods (e.g., PUT vs POST)
  • Logging:
    • Align logging with other projects
    • Ensure safe dump on timeout
    • Fix logger handler behavior
  • Async/client:
    • Fix ssl_context not passed in async client
    • Expose NoValidRequestFound
  • Job/generation behavior:
    • Fix sorting behavior for IDs and uploads in responses
    • Fix hashing behavior for job pop responses
    • Fix default factories (e.g., skipped, _time_constructed)
  • Image and processing:
    • Fix concurrent download of source images
  • Compatibility:
    • Fix Python <3.12 and <3.13 issues
    • Use typing_extensions where required
  • Misc:
    • Fix recursive submodule checkout
    • Fix missing __init__.py files
    • Fix enum and type handling
    • Fix message namespace issues

Tests

  • Expand and refactor pytest fixtures:
    • Add reusable fixtures (id_factory, image fixtures, job fixtures)
    • Add request and response validation in dynamic_json_load
  • Add tests for:
    • Stats and model state handling
    • Shared keys
    • Job and generation flows
    • HTTP verb coverage
    • API surface validation
  • Improve test reliability:
    • Use fixed UUIDs
    • Add compatibility handling for Python versions
  • Refactor test structure:
    • Move shared fixtures to conftest
    • Rename namespaces to match refactors
  • Improve debugging:
    • Add detailed output on validation failures
  • Ignore certain API models intentionally in tests

Documentation

  • Update terminology (JobIDGenerationID)
  • Add and update shared key documentation
  • Add SDK model map entries
  • Standardize docstrings for requests, responses, and API models
  • Fix dangling docstring references
  • Rebuild mkdocs and autogenerated docs
  • Improve MkDocs configuration:
    • Layout adjustments
    • Mermaid support
    • Asset integration
  • Add and restructure documentation:
    • Move AI Horde–specific docs to subdirectory
    • Add onboarding, contribution guide, and style guide
    • Add naming conventions and metadata clarifications
  • Fix markdown linting and formatting issues
  • Add docstring coverage in tests

CI / Build / Tooling

  • Add CI enforcement for inter-package dependencies (tach)
  • Update and apply pre-commit fixes
  • Update submodules and include assets in docs builds
  • Add temporary requirements file prior to tooling transition
  • Ignore additional virtual environment directories and config files

Chores / Style

  • Apply lint and formatting fixes across codebase
  • Remove unused imports and references
  • Add additional trace logging for UUID handling
  • Clean up documentation and formatting
  • Remove outdated references (e.g., date black config)

Notes

  • Includes large-scale refactors to job/generation systems, API mappings, and package structure
  • Expands SDK coverage of API endpoints and behaviors
  • Aligns naming, typing, and logging conventions across the codebase

@tazlin tazlin changed the title Even better tests rebase feat: worker abstractions; fix: various improvements and bug fixes Jan 26, 2025
@tazlin

This comment was marked as outdated.

@tazlin

This comment was marked as outdated.

@QodoAI-Agent

This comment was marked as outdated.

@QodoAI-Agent

This comment was marked as outdated.

@tazlin tazlin force-pushed the even-better-tests-rebase branch 4 times, most recently from a2a6db0 to 27e6932 Compare March 1, 2025 17:03
@tazlin

This comment was marked as outdated.

@QodoAI-Agent

This comment was marked as outdated.

@tazlin tazlin force-pushed the even-better-tests-rebase branch from 055117e to 60350da Compare March 1, 2025 19:45
@tazlin tazlin force-pushed the even-better-tests-rebase branch from d12fced to 6d44d18 Compare May 4, 2025 13:17
This includes scenarios where, for example, JobIDs and WorkerIDs.
This more accurately reflects the usage of this field type

fix: rename `job_id` vars to `gen_id`
`object` and `any` have distinct meanings. particularly, I do in fact mean "any" here rather than expecting an object compatible with `object`
`id_factory`, `default_testing_image_bytes`, `default_testing_image_PIL`
- Fixes the `SharedKeyCreateRequest` class to use the `PUT` method instead of `POST`.
- A new mixin class, `MessageSpecifiesSharedKeyMixin`
- Accordingly updates the api <-> sdk map json
- Adds a warning when shared keys are empty (probably unintended but still useful for testing)

docs: add missing shared keys mkdocs stub
The `time_constructed` property is the time at which the model is constructed and will be used to infer pop times if not otherwise specified for jobs. It may also serve some purpose with testing and/or debugging.
Unordered indents were locally configured to lint as 2-space, which mkdocs does not support.
This more accurately reflects that they are simply the well defined and known to the SDK types. "Any" implies a generic (child class) relationship which these type aliases do not actually encapsulate.
Due to the evolution of the design of the sdk, most of the usages of the `generation_id`(s) variables were confusingly named. In the current iteration, `generations` are instances of inference (or generating) , where `results` are the actual outputs from those. There can be 1...N results, but generations are always a single, discrete, entity from the perspective of the SDK.
This closes a gap in testing where if an endpoint was supported in the SDK by any verb, but not all verbs, testing would still pass. This was specifically in response that a newly added DELETE verb to a previously existing endpoint (`/users/`) did not cause the testing to fail.
…pdates

- A substantial rework of the job/generation systems, their semantic meanings, and improved their separation of responsibilities
- Introduces backend_parsing modules and example worker generation scripts.
- Updates API payload/response maps and field descriptions for user endpoints, including support for user deletion and undeletion.
- Enhances documentation with backend values mapper and client design guides,
- Reworks package structure
- Improves many test methodologies, and adds tests for new/changed modules/classes
- Uses python 3.12+ typing features to better define the relationships for generations and jobs, especially when generics/generic parameters.
- Adjust the logging system for logfire
- Also includes a number of ruff lint fixes
- Fixes docstring test to properly identify and correct docstrings for API models
- Fixes missing docstrings in API models
@tazlin tazlin force-pushed the even-better-tests-rebase branch from 8e377ed to 517a6e8 Compare December 24, 2025 15:29
@tazlin tazlin force-pushed the even-better-tests-rebase branch from d92eeaa to 2d88b17 Compare December 24, 2025 15:44
@tazlin tazlin marked this pull request as ready for review March 22, 2026 02:36
@tazlin tazlin merged commit e788809 into main Mar 22, 2026
3 of 9 checks passed
@tazlin tazlin mentioned this pull request Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants