Skip to content

docs: add missing examples for commitment-related methods#3255

Open
thecaptain789 wants to merge 1 commit intoopentensor:masterfrom
thecaptain789:docs/add-missing-examples
Open

docs: add missing examples for commitment-related methods#3255
thecaptain789 wants to merge 1 commit intoopentensor:masterfrom
thecaptain789:docs/add-missing-examples

Conversation

@thecaptain789
Copy link

Summary

This PR adds practical code examples for commitment-related methods in both subtensor.py and async_subtensor.py, addressing existing TODO comments in the codebase.

Changes

Added examples for the following methods:

get_all_commitments()

  • Shows how to retrieve and process commitment data for all neurons in a subnet
  • Demonstrates iterating through results and filtering active commitments

get_commitment()

  • Demonstrates how to retrieve commitment data for a specific neuron by UID
  • Shows proper handling of empty/missing commitment cases

get_commitment_metadata()

  • Illustrates how to fetch and handle raw commitment metadata from the blockchain
  • Shows type checking for the Union return type (dict | str)

Motivation

These methods had TODO comments requesting realistic examples:

  • TODO add example of how to handle realistic commitment data
  • TODO: add a real example of how to handle realistic commitment data, or chop example
  • TODO: how to handle return data? need good example @roman

The examples follow the existing documentation style and provide practical guidance for developers using the commit-reveal mechanism.

Testing

Documentation-only change. Examples use standard SDK patterns and have been verified for correctness against the method signatures.

Added practical code examples for the following methods in both
subtensor.py and async_subtensor.py:

- get_all_commitments(): Example showing how to retrieve and process
  commitment data for all neurons in a subnet
- get_commitment(): Example demonstrating how to retrieve commitment
  data for a specific neuron by UID
- get_commitment_metadata(): Example illustrating how to fetch and
  handle raw commitment metadata from the blockchain

These examples address the existing TODO comments requesting realistic
examples for handling commitment data in the commit-reveal mechanism.

Resolves documentation TODOs for commitment-related methods.
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.

1 participant