Skip to content
Snippets Groups Projects

Add slim_output argument when creating sub element

Merged Yoann Schneider requested to merge create-sub-element-returns-whole-payload into master
All threads resolved!
2 files
+ 31
15
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -60,6 +60,7 @@ class ElementMixin(object):
name: str,
polygon: List[List[Union[int, float]]],
confidence: Optional[float] = None,
slim_output: bool = True,
) -> str:
"""
Create a child element on the given element through the API.
@@ -95,6 +96,7 @@ class ElementMixin(object):
assert confidence is None or (
isinstance(confidence, float) and 0 <= confidence <= 1
), "confidence should be None or a float in [0..1] range"
assert isinstance(slim_output, bool), "slim_output should be of type bool"
if self.is_read_only:
logger.warning("Cannot create element as this worker is in read-only mode")
@@ -102,6 +104,7 @@ class ElementMixin(object):
sub_element = self.request(
"CreateElement",
slim_output=slim_output,
body={
"type": type,
"name": name,
@@ -111,4+114,4 @@
"parent": element.id,
"worker_version": self.worker_version_id,
"confidence": confidence,
},
)
self.report.add_element(element.id, type)
return sub_element["id"]
return sub_element["id"] if slim_output else sub_element
def create_elements(
self,
Loading