Skip to content

Commit

Permalink
Merge branch 'main' into florence-2-fts-in-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
probicheaux committed Nov 13, 2024
2 parents 93c8c21 + f202755 commit f58f51c
Show file tree
Hide file tree
Showing 177 changed files with 7,543 additions and 1,873 deletions.
1 change: 1 addition & 0 deletions docs/workflows/blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ hide:
<p class="card block-card" data-url="vl_mas_classifier" data-name="VLM as Classifier" data-desc="Parses raw string into classification prediction." data-labels="FORMATTER, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="vl_mas_detector" data-name="VLM as Detector" data-desc="Parses raw string into object-detection prediction." data-labels="FORMATTER, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="yolo_world_model" data-name="YOLO-World Model" data-desc="Run a zero-shot object detection model." data-labels="MODEL, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="keypoint_visualization" data-name="Keypoint Visualization" data-desc="Draws keypoints on detected objects in an image." data-labels="VISUALIZATION, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="data_aggregator" data-name="Data Aggregator" data-desc="Aggregates workflow data to produce time-based statistics" data-labels="ANALYTICS, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="csv_formatter" data-name="CSV Formatter" data-desc="Creates CSV files with specified columns." data-labels="FORMATTER, APACHE-2.0" data-author="dummy"></p>
<p class="card block-card" data-url="email_notification" data-name="Email Notification" data-desc="Send notification via E-Mail" data-labels="SINK, APACHE-2.0" data-author="dummy"></p>
Expand Down
59 changes: 59 additions & 0 deletions docs/workflows/blocks_bundling.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,65 @@ REGISTERED_INITIALIZERS = {
}
```

## Serializers and deserializers for *Kinds*

Support for custom serializers and deserializers was introduced in Execution Engine `v1.3.0`.
From that version onward it is possible to point custom functions that
Execution Engine should use to serialize and deserialize any *[kind](/workflows/kinds/)*.

Deserializers will determine how to decode inputs send through the wire
into internal data representation used by blocks. Serializers, on the other hand,
are useful when Workflow results are to be send through the wire.

Below you may find example on how to add serializer and deserializer
for arbitrary kind. The code should be placed in main `__init__.py` of
your plugin:

```python
from typing import Any

def serialize_kind(value: Any) -> Any:
# place here the code that will be used to
# transform internal Workflows data representation into
# the external one (that can be sent through the wire in JSON, using
# default JSON encoder for Python).
pass


def deserialize_kind(parameter_name: str, value: Any) -> Any:
# place here the code that will be used to decode
# data sent through the wire into the Execution Engine
# and transform it into proper internal Workflows data representation
# which is understood by the blocks.
pass


KINDS_SERIALIZERS = {
"name_of_the_kind": serialize_kind,
}
KINDS_DESERIALIZERS = {
"name_of_the_kind": deserialize_kind,
}
```

### Tips And Tricks

* Each serializer must be a function taking the value to serialize
and returning serialized value (accepted by default Python JSON encoder)

* Each deserializer must be a function accepting two parameters - name of
Workflow input to be deserialized and the value to be deserialized - the goal
of the function is to align input data with expected internal representation

* *Kinds* from `roboflow_core` plugin already have reasonable serializers and
deserializers

* If you do not like the way how data is serialized in `roboflow_core` plugin,
feel free to alter the serialization methods for *kinds*, simply registering
the function in your plugin and loading it to the Execution Engine - the
serializer/deserializer defined as the last one will be in use.


## Enabling plugin in your Workflows ecosystem

To load a plugin you must:
Expand Down
Loading

0 comments on commit f58f51c

Please sign in to comment.