Skip to content

fix: resolve configured priors for plain function models #1702

Closed

Description

@Jammy2211

Overview

fix: resolve configured priors for plain function models

Plan

Inspect Model.make_prior and Prior.for_class_and_attribute_name. Preserve class/method lookup and resolve a plain function using its own identity, or provide an actionable configuration error if unsupported. Add tests for configured defaults, explicit priors, and missing config; run mapper tests and the full suite.

Tier: glance — merge mode: human /prm.

Detailed implementation plan

Primary repository: PyAutoFit. Current branch: main, clean; no existing open PR or active Mind claim at selection. Suggested branch: feature/function-config-priors. Each task uses an isolated branch and is handled sequentially within the four-task request. Tests must pass before shipping; report blockers honestly. User authorized implementation of four linked dashboard tasks; no merge or release authorization. Heart: STALE locally, published feed unreachable.

Original Prompt

Starting prompt

af.Model(function) cannot resolve config priors

Type: bug
Target: PyAutoFit
Repos:

  • PyAutoFit
    Difficulty: small
    Autonomy: safe
    Priority: normal
    Status: formalised
    Consequence: glance
    Witness: af.Model(some_function) with no explicit priors builds a model instead of raising AttributeError: 'NoneType' object has no attribute 'module'.
    Review-minutes: 3
    Unattended: ready
    Filed: 2026-09-10

af.Model accepts a plain function — prior_model.py:137 explicitly tests
inspect.isfunction — but the model then crashes unless every prior is
supplied explicitly.

make_prior passes cls=None into path_for_class, which immediately does
cls.__module__ and raises AttributeError: 'NoneType' object has no attribute '__module__'. So the config lookup that would supply a default prior for a
function argument can never run, and the function case only ever arrives with
explicit priors.

Either derive a usable config path for a function (module + qualified name, the
same shape a class gets) so config defaults work, or — if config priors are
genuinely not intended to be supported for functions — fail early with a clear
message at af.Model(function) construction time instead of an AttributeError
from deep inside path_for_class. A silent trap that only fires on the
no-explicit-priors path is the worst of the three options.

Add a test for whichever behaviour is chosen: config priors resolved, or a
clear, immediate error.

Found on 2026-09-10 by execution while auditing the PyAutoFit model API for the
model-figures design (research leg B, construct 13 and "What is missing from the
PyAutoFit model API", item 8).

Activity

  1. Jammy2211 commented on Oct 17, 2026

    @Jammy2211
    CollaboratorAuthor

    Shipped

    Merged #1705 at debd95d on 2026-10-17, following the user's /prm authorization. fix: resolve configured priors for plain function models

    All exact-head GitHub test legs passed (Python 3.12, 3.13, no-JAX); applicable docs checks passed. Model/search unique identifiers and exact output-folder paths were checked against unmodified main and remain unchanged. Pending release; merging does not publish a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions