client_python icon indicating copy to clipboard operation
client_python copied to clipboard

Publically expose immutable attributes on MetricWrapperBase

Open nmichlo opened this issue 3 years ago • 3 comments

things like MetricWrapperBase._labelnames are immutable, but are passed in as parameters when instantiating MetricWrapperBase objects. These would be useful if they were exposed?

@property
def labelnames(self) -> Tuple[str, ...]:
    return self._labelnames

nmichlo avatar Oct 03 '22 12:10 nmichlo

Hello, do you have a concrete use case where you would like to use the the labelnames specified on a metric? If it is helpful I can see exposing it, but I don't know of a required use case today.

csmarchbanks avatar Oct 03 '22 18:10 csmarchbanks

(Admittedly this is from legacy code that I have not written myself, so I am not entirely sure about the original intention) But what I can see is that we current have to keep track of these label names externally and compare them against inputs accepted by a function just to make sure that what the metric is going to receive is correct. Its just not very clean this way if we don't access the property. I know we can access the private variable as a workaround, but that isn't ideal.

nmichlo avatar Oct 03 '22 22:10 nmichlo

Hmm, for that use case could you use the kwargs that can be passed to .labels() to ensure safety?

csmarchbanks avatar Oct 05 '22 15:10 csmarchbanks