Skip to content

Add describe_method() for parameter-level API introspection#1267

Open
anushkaxg wants to merge 1 commit intomalariagen:masterfrom
anushkaxg:feat/describe-method-1262
Open

Add describe_method() for parameter-level API introspection#1267
anushkaxg wants to merge 1 commit intomalariagen:masterfrom
anushkaxg:feat/describe-method-1262

Conversation

@anushkaxg
Copy link
Copy Markdown

Summary

Closes #1262

This PR adds a new describe_method() API on AnophelesDescribe to improve method discoverability for users and agents.

describe_method(method: str) returns a pandas.DataFrame with one row per parameter and the following columns:

  • parameter
  • type
  • default
  • description

This complements describe_api(), which lists methods at a high level.

What changed

Implementation

  • Added describe_method() to malariagen_data/anoph/describe.py.
  • Added internal parameter-doc parsing helper to extract NumPy-style parameter metadata from method docstrings.
  • Validation added for:
    • unknown method names (ValueError)
    • private method names (ValueError)
    • non-callable attributes (ValueError)

Tests

Updated tests/anoph/test_describe.py with coverage for:

  • expected output schema of describe_method()
  • exclusion of self from output
  • presence of known parameter for a known method (describe_api -> category)
  • unknown method error handling
  • private method error handling

Notes

  • Output preserves method signature order.
  • Type is sourced from function annotations when present, otherwise falls back to docstring parameter type.
  • Default is None when no default is defined.

Example usage

import malariagen_data

ag3 = malariagen_data.Ag3()
df = ag3.describe_method("aa_allele_frequencies")
print(df.head())

@caiocrocha
Copy link
Copy Markdown

Hi @anushkaxg , I noticed that you’ve linked this PR to issue #1262 , which I originally opened. I created PR #1263 as a starting point to improve discoverability for AI agents and implemented a describe_method that is very similar to your changes.

It would have been useful to mention my PR in yours, since it already addresses the same issue. Could you clarify how this PR improves upon mine and why it closes the issue? I’d like to avoid duplicating effort and make sure we’re both aligning with the maintainers’ expectations.

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.

Improve API and methods discoverability for agents and natural‑language interfaces

2 participants