Running a validator consists of setting weights on miners. Once every tempo, rewards are distributed based on the score of modules. You can use the vote method to set weights. Please note that every subnet has its own min_allowed_weights and max_allowed_weights and you should respect those parameters when casting votes
The general idea is to query the addresses of every module on the subnet, call their respective endpoints, run a scoring function, in accord to your subnet validation mechanism, against their answers and set weights.
For a more concrete example, you can take a look at this sketch of a validator