Skip to content

Standardize predict() method signatures across Score implementations #77

@endymion

Description

@endymion

Problem

During validation system implementation, I discovered inconsistent predict() method signatures across different Score implementations:

Current Signatures Found:

  1. Standard signature (intended): predict(self, context, model_input: Score.Input)
  2. Legacy signature: predict(self, model_input: Score.Input)
  3. Keyword-only signature: predict(self, *, context, model_input: Score.Input)

Examples in Codebase:

Legacy signature examples:

  • plexus/processors/RelevantWindowsTranscriptFilter_test.py:19
  • Various test mock implementations

Standard signature examples:

  • Abstract method definition in Score.py:576
  • Most production Score implementations

Keyword-only signature examples:

  • Some test implementations

Impact

  • Inconsistent API: Different calling conventions confuse developers
  • Maintenance burden: Need to support multiple signatures
  • Error-prone: Easy to call methods incorrectly
  • Documentation clarity: Unclear which signature is "correct"

Proposed Solution

  1. Standardize on: predict(self, context, model_input: Score.Input) -> Union[Score.Result, List[Score.Result]]

    • This matches the abstract method definition
    • Provides context for future extensibility
    • Most implementations already use this
  2. Migration plan:

    • Update legacy implementations to standard signature
    • Add deprecation warnings for old signatures (optional)
    • Update tests and documentation
    • Consider adding linting rules to prevent regression
  3. Files to update:

    • Test mock classes in plexus/processors/RelevantWindowsTranscriptFilter_test.py
    • Any other legacy implementations found via codebase search

Current Workaround

The validation system now includes compatibility handling for all three signatures using signature inspection and argument adaptation. While this works, it adds complexity and should be temporary.

Next Steps

  1. Search codebase for all predict() method implementations
  2. Identify which ones need updating
  3. Create migration plan with backward compatibility considerations
  4. Update implementations systematically
  5. Remove compatibility code once migration is complete

This standardization will improve code consistency, reduce maintenance burden, and make the API clearer for developers.

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