Skip to content

Commit c35d612

Browse files
Merge pull request #854 from roboflow/fix/rendering_docs_for_external_workflows_integrations
Fix problem with docs rendering
2 parents 90508fe + 1f36fc7 commit c35d612

File tree

6 files changed

+57
-34
lines changed

6 files changed

+57
-34
lines changed

development/docs/build_block_docs.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@
133133
{details}
134134
"""
135135

136+
INLINE_UQL_PARAMETER_PATTERN = re.compile(r"({{\s*\$parameters\.(\w+)\s*}})")
137+
138+
136139

137140
def main() -> None:
138141
os.makedirs(BLOCK_DOCUMENTATION_DIRECTORY, exist_ok=True)
@@ -251,7 +254,7 @@ def main() -> None:
251254
],
252255
block_type2manifest_type_identifier=block_type2manifest_type_identifier,
253256
),
254-
example="\n\t".join(json.dumps(example_definition, indent=4).split("\n")),
257+
example=_dump_step_example_definition(example_definition=example_definition),
255258
)
256259
versions_content.append(version_content)
257260
all_versions_compact = "\n\n".join(versions_content)
@@ -279,6 +282,16 @@ def main() -> None:
279282
)
280283

281284

285+
def _dump_step_example_definition(example_definition: dict) -> str:
286+
definition_stringified = "\n\t".join(json.dumps(example_definition, indent=4).split("\n"))
287+
return INLINE_UQL_PARAMETER_PATTERN.sub(_escape_uql_brackets, definition_stringified)
288+
289+
290+
def _escape_uql_brackets(match: re.Match) -> str:
291+
content = match.group(0)
292+
return "{{ '{{' }}" + content[2:-2] + "{{ '}}' }}"
293+
294+
282295
def get_auto_generation_markers(
283296
documentation_lines: List[str],
284297
token: str,

development/docs/workflows_gallery_builder.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
API_KEY_PATTERN = re.compile(r"api_key=(.[^&]*)")
1717
KEY_VALUE_GROUP = 1
1818
MIN_KEY_LENGTH_TO_REVEAL_PREFIX = 8
19-
20-
19+
INLINE_UQL_PARAMETER_PATTERN = re.compile(r"({{\s*\$parameters\.(\w+)\s*}})")
2120
INTEGRATION_TESTS_DIRECTORY = os.path.abspath(os.path.join(
2221
os.path.dirname(__file__),
2322
"..",
@@ -120,14 +119,25 @@ def generate_gallery_entry_docs(entry: WorkflowGalleryEntry) -> str:
120119
workflow_name_in_app=entry.workflow_name_in_app,
121120
workflow_definition=entry.workflow_definition,
122121
)
122+
workflow_definition = _dump_workflow_definition(workflow_definition=entry.workflow_definition)
123123
return GALLERY_ENTRY_TEMPLATE.format(
124124
title=entry.use_case_title,
125125
description=entry.use_case_description,
126126
preview_iframe=preview_iframe,
127-
workflow_definition="\n\t".join(json.dumps(entry.workflow_definition, indent=4).split("\n")),
127+
workflow_definition=workflow_definition,
128128
)
129129

130130

131+
def _dump_workflow_definition(workflow_definition: dict) -> str:
132+
definition_stringified = "\n\t".join(json.dumps(workflow_definition, indent=4).split("\n"))
133+
return INLINE_UQL_PARAMETER_PATTERN.sub(_escape_uql_brackets, definition_stringified)
134+
135+
136+
def _escape_uql_brackets(match: re.Match) -> str:
137+
content = match.group(0)
138+
return "{{ '{{' }}" + content[2:-2] + "{{ '}}' }}"
139+
140+
131141
def generate_preview_iframe(workflow_name_in_app: str, workflow_definition: dict) -> str:
132142
api_key = os.environ["WORKFLOWS_GALLERY_API_KEY"]
133143
workspace_name = retrieve_workspace_name_from_api(api_key=api_key)

docs/workflows/kinds.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -68,39 +68,39 @@ providing compile-time verification of Workflows definitions.
6868

6969
## Kinds declared in Roboflow plugins
7070
<!--- AUTOGENERATED_KINDS_LIST -->
71-
* [`float_zero_to_one`](/workflows/kinds/float_zero_to_one): `float` value in range `[0.0, 1.0]`
72-
* [`image_keypoints`](/workflows/kinds/image_keypoints): Image keypoints detected by classical Computer Vision method
7371
* [`float`](/workflows/kinds/float): Float value
74-
* [`image_metadata`](/workflows/kinds/image_metadata): Dictionary with image metadata required by supervision
75-
* [`object_detection_prediction`](/workflows/kinds/object_detection_prediction): Prediction with detected bounding boxes in form of sv.Detections(...) object
76-
* [`integer`](/workflows/kinds/integer): Integer value
77-
* [`bytes`](/workflows/kinds/bytes): This kind represent bytes
78-
* [`roboflow_model_id`](/workflows/kinds/roboflow_model_id): Roboflow model id
79-
* [`boolean`](/workflows/kinds/boolean): Boolean flag
80-
* [`list_of_values`](/workflows/kinds/list_of_values): List of values of any type
81-
* [`instance_segmentation_prediction`](/workflows/kinds/instance_segmentation_prediction): Prediction with detected bounding boxes and segmentation masks in form of sv.Detections(...) object
82-
* [`video_metadata`](/workflows/kinds/video_metadata): Video image metadata
83-
* [`secret`](/workflows/kinds/secret): Secret value
84-
* [`classification_prediction`](/workflows/kinds/classification_prediction): Predictions from classifier
85-
* [`string`](/workflows/kinds/string): String value
8672
* [`bar_code_detection`](/workflows/kinds/bar_code_detection): Prediction with barcode detection
87-
* [`point`](/workflows/kinds/point): Single point in 2D
88-
* [`parent_id`](/workflows/kinds/parent_id): Identifier of parent for step output
89-
* [`zone`](/workflows/kinds/zone): Definition of polygon zone
73+
* [`secret`](/workflows/kinds/secret): Secret value
9074
* [`keypoint_detection_prediction`](/workflows/kinds/keypoint_detection_prediction): Prediction with detected bounding boxes and detected keypoints in form of sv.Detections(...) object
91-
* [`serialised_payloads`](/workflows/kinds/serialised_payloads): Serialised element that is usually accepted by sink
92-
* [`roboflow_api_key`](/workflows/kinds/roboflow_api_key): Roboflow API key
75+
* [`list_of_values`](/workflows/kinds/list_of_values): List of values of any type
76+
* [`roboflow_model_id`](/workflows/kinds/roboflow_model_id): Roboflow model id
77+
* [`prediction_type`](/workflows/kinds/prediction_type): String value with type of prediction
9378
* [`rgb_color`](/workflows/kinds/rgb_color): RGB color
94-
* [`image`](/workflows/kinds/image): Image in workflows
95-
* [`contours`](/workflows/kinds/contours): List of numpy arrays where each array represents contour points
79+
* [`roboflow_api_key`](/workflows/kinds/roboflow_api_key): Roboflow API key
80+
* [`instance_segmentation_prediction`](/workflows/kinds/instance_segmentation_prediction): Prediction with detected bounding boxes and segmentation masks in form of sv.Detections(...) object
9681
* [`roboflow_project`](/workflows/kinds/roboflow_project): Roboflow project name
82+
* [`contours`](/workflows/kinds/contours): List of numpy arrays where each array represents contour points
83+
* [`serialised_payloads`](/workflows/kinds/serialised_payloads): Serialised element that is usually accepted by sink
9784
* [`language_model_output`](/workflows/kinds/language_model_output): LLM / VLM output
98-
* [`numpy_array`](/workflows/kinds/numpy_array): Numpy array
99-
* [`inference_id`](/workflows/kinds/inference_id): Inference identifier
100-
* [`dictionary`](/workflows/kinds/dictionary): Dictionary
85+
* [`string`](/workflows/kinds/string): String value
86+
* [`zone`](/workflows/kinds/zone): Definition of polygon zone
87+
* [`top_class`](/workflows/kinds/top_class): String value representing top class predicted by classification model
88+
* [`image_metadata`](/workflows/kinds/image_metadata): Dictionary with image metadata required by supervision
89+
* [`video_metadata`](/workflows/kinds/video_metadata): Video image metadata
90+
* [`object_detection_prediction`](/workflows/kinds/object_detection_prediction): Prediction with detected bounding boxes in form of sv.Detections(...) object
91+
* [`integer`](/workflows/kinds/integer): Integer value
92+
* [`classification_prediction`](/workflows/kinds/classification_prediction): Predictions from classifier
93+
* [`image`](/workflows/kinds/image): Image in workflows
94+
* [`point`](/workflows/kinds/point): Single point in 2D
10195
* [`detection`](/workflows/kinds/detection): Single element of detections-based prediction (like `object_detection_prediction`)
96+
* [`bytes`](/workflows/kinds/bytes): This kind represent bytes
97+
* [`boolean`](/workflows/kinds/boolean): Boolean flag
10298
* [`*`](/workflows/kinds/*): Equivalent of any element
103-
* [`top_class`](/workflows/kinds/top_class): String value representing top class predicted by classification model
99+
* [`float_zero_to_one`](/workflows/kinds/float_zero_to_one): `float` value in range `[0.0, 1.0]`
100+
* [`inference_id`](/workflows/kinds/inference_id): Inference identifier
101+
* [`dictionary`](/workflows/kinds/dictionary): Dictionary
102+
* [`numpy_array`](/workflows/kinds/numpy_array): Numpy array
104103
* [`qr_code_detection`](/workflows/kinds/qr_code_detection): Prediction with QR code detection
105-
* [`prediction_type`](/workflows/kinds/prediction_type): String value with type of prediction
104+
* [`parent_id`](/workflows/kinds/parent_id): Identifier of parent for step output
105+
* [`image_keypoints`](/workflows/kinds/image_keypoints): Image keypoints detected by classical Computer Vision method
106106
<!--- AUTOGENERATED_KINDS_LIST -->

inference/core/workflows/core_steps/sinks/email_notification/v1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
message using dynamic parameters:
6161
6262
```
63-
message = "This is example notification. Predicted classes: \{\{ $parameters.predicted_classes \}\}"
63+
message = "This is example notification. Predicted classes: {{ '{{' }} $parameters.predicted_classes {{ '}}' }}"
6464
```
6565
6666
Message parameters are delivered by Workflows Execution Engine by setting proper data selectors in
@@ -181,7 +181,7 @@ class BlockManifest(WorkflowBlockManifest):
181181
message: str = Field(
182182
description="Content of the message to be send",
183183
examples=[
184-
"During last 5 minutes detected \{\{ $parameters.num_instances \}\} instances"
184+
"During last 5 minutes detected {{ $parameters.num_instances }} instances"
185185
],
186186
)
187187
sender_email: Union[str, Selector(kind=[STRING_KIND])] = Field(

inference/core/workflows/core_steps/sinks/slack/notification/v1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class BlockManifest(WorkflowBlockManifest):
8787
message: str = Field(
8888
description="Content of the message to be send",
8989
examples=[
90-
"During last 5 minutes detected \{\{ $parameters.num_instances \}\} instances"
90+
"During last 5 minutes detected {{ $parameters.num_instances }} instances"
9191
],
9292
)
9393
channel: Union[str, Selector(kind=[STRING_KIND])] = Field(

inference/core/workflows/core_steps/sinks/twilio/sms/v1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class BlockManifest(WorkflowBlockManifest):
9494
message: str = Field(
9595
description="Content of the message to be send",
9696
examples=[
97-
"During last 5 minutes detected \{\{ $parameters.num_instances \}\} instances"
97+
"During last 5 minutes detected {{ $parameters.num_instances }} instances"
9898
],
9999
)
100100
sender_number: Union[str, Selector(kind=[STRING_KIND])] = Field(

0 commit comments

Comments
 (0)