Skip to content

Commit

Permalink
Merge pull request #677 from roboflow/nick/docs/schema-api-and-notebo…
Browse files Browse the repository at this point in the history
…ok-fix

Add workflow schema api docs
  • Loading branch information
PawelPeczek-Roboflow authored Sep 25, 2024
2 parents e1f1c0c + 337b032 commit 8aa4c51
Show file tree
Hide file tree
Showing 5 changed files with 428 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/notebooks/inference_pipeline_rtsp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"# InferencePipeline on RTSP Stream\n",
"\n",
"---\n",
"[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/roboflow/notebooks/blob/main/notebooks/inferencePipeline.ipynb)\n",
"[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/roboflow/inference/blob/main/docs/notebooks/inference_pipeline_rtsp.ipynb)\n",
"\n",
"The Roboflow Inference Pipeline is a drop-in replacement for the Hosted Inference API that can be deployed on your own hardware. The Inference Pipeline interface is made for streaming and is likely the best route to go for real time use cases. It is an asynchronous interface that can consume many different video sources including local devices (like webcams), RTSP video streams, video files, etc. With this interface, you define the source of a video stream and sinks.\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/rgb_anomaly_detection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"# RGB Anomaly Detection\n",
"\n",
"---\n",
"[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://github.com/roboflow/notebooks/blob/main/notebooks/rgb_anomalyDetection.ipynb)\n",
"[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/roboflow/inference/blob/main/docs/notebooks/rgb_anomaly_detection.ipynb)\n",
"\n",
"In this cookbook, we identify color / RGB anomalies for segmented items. Capture a base image to extract your ground truth RGB with Roboflow and compare to neew data collected. In this scenario, we are assessing variations in logo color.\n",
"\n",
Expand Down
361 changes: 361 additions & 0 deletions docs/notebooks/workflow_schema_api.ipynb

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions docs/workflows/schema_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Workflows Schema API

The Workflows Schema API provides developers with a clear, programmatic understanding of a workflow's structure, inputs, and outputs. It addresses the challenge of programmatically determining a workflow's input requirements and output types.

## Purpose and Benefits

The API offers structured access to:

1. **Input Parameters**: Required workflow inputs.
2. **Output Structure**: Details of the returned data.
3. **Type Hints**: Expected data types for inputs and outputs.
4. **Schemas of Kinds**: Detailed schemas for complex data types.

This enables developers to:

- Validate inputs programmatically
- Understand output data structures
- Integrate workflows into larger systems
- Generate documentation or UIs based on workflow requirements

## Using the API
[![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/roboflow/inference/blob/main/docs/notebooks/workflow_schema_api.ipynb)

```python
import requests

WORKSPACE_NAME = "workspace-name"
WORKFLOW_ID = "workflow-id"
INFERENCE_SERVER_URL = "https://detect.roboflow.com"

WORKFLOW_SCHEMA_ENDPOINT = f"{INFERENCE_SERVER_URL}/{WORKSPACE_NAME}/workflows/{WORKFLOW_ID}/describe_interface"
ROBOFLOW_API_KEY = "Your Roboflow API Key"

headers = {
"Content-Type": "application/json",
}

data = {
"api_key": ROBOFLOW_API_KEY,
}

res = requests.post(WORKFLOW_SCHEMA_ENDPOINT, headers=headers, json=data)

schema = res.json()

inputs = schema["inputs"]
outputs = schema["outputs"]
kinds_schemas = schema["kinds_schemas"]
typing_hints = schema["typing_hints"]
```

## Inputs and Outputs

The `inputs` and `outputs` keys show all of the inputs and outputs the workflow expects to run and return.

## Typing Hints

The `typing_hints` key shows the data types of the inputs and outputs.

## Kinds Schemas

The `kinds_schemas` key returns an OpenAPI specification with more detailed information about the data
types being returned and how to parse them. For example, the `object_detection_prediction` contains
information about the nested data that will be present.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ nav:
- Dynamic Python Blocks: workflows/custom_python_code_blocks.md
- Versioning: workflows/versioning.md
- Testing: workflows/testing.md
- Schema API: workflows/schema_api.md
- Reference:
- Inference Pipeline: using_inference/inference_pipeline.md
- Active Learning:
Expand Down

0 comments on commit 8aa4c51

Please sign in to comment.