bossenti commented on code in PR #1286:
URL: https://github.com/apache/streampipes/pull/1286#discussion_r1106369806


##########
streampipes-client-python/streampipes/model/common.py:
##########
@@ -73,17 +87,19 @@ class EventProperty(BasicModel):
     Data model of an `EventProperty` in compliance to the StreamPipes Backend.
     """
 
-    class_name: Optional[StrictStr] = Field(alias="@class")
-    element_id: Optional[StrictStr]
+    class_name: StrictStr = Field(
+        alias="@class", default_factory=lambda: 
"org.apache.streampipes.model.schema.EventPropertyPrimitive"
+    )
+    element_id: StrictStr = Field(default_factory=lambda: 
f"sp:eventproperty:{random_letters(6)}")
     label: Optional[StrictStr]
     description: Optional[StrictStr]
     runtime_name: StrictStr
-    required: StrictBool
-    domain_properties: List[StrictStr]
-    property_scope: Optional[StrictStr]
-    index: StrictInt
+    required: StrictBool = False

Review Comment:
   it would be beneficial to use the pydantic functionality here, so in this 
case `Field(default=False)`
   Some applies for the upcoming rows, for an empty array you can use the 
`default_factory`



##########
streampipes-client-python/streampipes/model/resource/data_stream.py:
##########
@@ -72,26 +73,31 @@ def convert_to_pandas_representation(self):
             "num_included_locales": len(self.included_locales) if 
self.included_locales is not None else 0,
         }
 
-    class_name: Optional[StrictStr] = Field(alias="@class")
-    element_id: StrictStr
-    name: Optional[StrictStr]
+    def __init__(self, **kwargs):
+        super().__init__(**kwargs)
+        if not self.uri:
+            self.uri = self.element_id
+
+    class_name: StrictStr = Field(alias="@class", default_factory=lambda: 
"org.apache.streampipes.model.SpDataStream")
+    element_id: StrictStr = Field(default_factory=lambda: 
f"sp:spdatastream:{random_letters(6)}")
+    name: StrictStr = "Unnamed"
     description: Optional[StrictStr]
     icon_url: Optional[StrictStr]
     app_id: Optional[StrictStr]
-    includes_assets: Optional[StrictBool]
-    includes_locales: Optional[StrictBool]
-    included_assets: Optional[List[Optional[StrictStr]]]
-    included_locales: Optional[List[Optional[StrictStr]]]
-    application_links: Optional[List[Optional[ApplicationLink]]]
-    internally_managed: Optional[StrictBool]
-    connected_to: Optional[List[Optional[StrictStr]]]
-    event_grounding: EventGrounding
+    includes_assets: StrictBool = False
+    includes_locales: StrictBool = False
+    included_assets: List[StrictStr] = []
+    included_locales: List[StrictStr] = []
+    application_links: List[ApplicationLink] = []
+    internally_managed: StrictBool = False
+    connected_to: Optional[List[StrictStr]]
+    event_grounding: EventGrounding = Field(default_factory=EventGrounding)
     event_schema: Optional[EventSchema]
-    measurement_capability: Optional[List[Optional[MeasurementCapability]]]
-    measurement_object: Optional[List[Optional[MeasurementObject]]]
-    index: Optional[StrictInt]
+    measurement_capability: Optional[List[MeasurementCapability]]
+    measurement_object: Optional[List[MeasurementObject]]
+    index: StrictInt = 0

Review Comment:
   same as above



##########
streampipes-client-python/streampipes/model/common.py:
##########
@@ -73,17 +87,19 @@ class EventProperty(BasicModel):
     Data model of an `EventProperty` in compliance to the StreamPipes Backend.
     """
 
-    class_name: Optional[StrictStr] = Field(alias="@class")
-    element_id: Optional[StrictStr]
+    class_name: StrictStr = Field(
+        alias="@class", default_factory=lambda: 
"org.apache.streampipes.model.schema.EventPropertyPrimitive"

Review Comment:
   In this case you could simply use `default` and provide the string value



##########
streampipes-client-python/streampipes/model/common.py:
##########
@@ -30,6 +33,17 @@
 ]
 
 
+def random_letters(n: int):

Review Comment:
   I'm not really happy with this function, but don't really have a better idea 
🤔 
   I'll try to come with one



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to