sinarezaei/pinform

Dynamic measurement name creation

mazamsezer opened this issue · 0 comments

Hi,

Thank you for this nice helper package.

My problem is about dynamic measurement name creation. No matter what I do, I can not make MeasurementNameComponent work. I even wrote the very same lines below, but could not make it run:

from pinform import Measurement, MeasurementNameComponent
from pinform.fields import FloatField
from pinform.tags import Tag

class OHLC(Measurement):
class Meta:
measurement_name = 'ohlc_(symbol)'

symbol = MeasurementNameComponent(name='symbol')
open = FloatField(null=False)
high = FloatField(null=False)
low = FloatField(null=False)
close = FloatField(null=False)

today_ohlc = OHLC(time_point=datetime.datetime.now(), symbol='AAPL', open=80.2, high=86.0, low=78.9, close=81.25)

Python keeps saying I provided a value for symbol, but did not inform if it is a tag or field. But I want to use it as the dynamic measurement name variable. This way I will be able to use one class for all of my readings. How can I achieve this?

Also rather than sending the field as string, integer or float I only want to send it with something like value = Field(null=True). Is this possible? If yes, how can I do it? And why did you make a differentiation on fields with different data types? If the measurement's name is different, then why didn't you use one field with "value" as tag?

Thank you,