Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): fix incorrect I2I OpenAPI gateway spec #105

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions runner/app/routes/image_to_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def image_to_video(
motion_bucket_id=motion_bucket_id,
noise_aug_strength=noise_aug_strength,
safety_check=safety_check,
seed=seed
seed=seed,
)
except Exception as e:
logger.error(f"ImageToVideoPipeline error: {e}")
Expand All @@ -95,7 +95,11 @@ async def image_to_video(
for frames in batch_frames:
output_frames.append(
[
{"url": image_to_data_url(frame), "seed": seed, "nsfw": has_nsfw_concept[0]}
{
"url": image_to_data_url(frame),
"seed": seed,
"nsfw": has_nsfw_concept[0],
}
for frame in frames
]
)
Expand Down
17 changes: 14 additions & 3 deletions runner/gen_openapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import argparse
import json
import os
import copy

import yaml
from app.main import app, use_route_names_as_operation_ids
Expand All @@ -21,9 +22,11 @@ def translate_to_gateway(openapi):
entrypoint created by the https://github.com/livepeer/go-livepeer package.

.. note::
Differences between 'runner' and 'gateway' entrypoints:
- 'health' endpoint is removed.
- 'model_id' is enforced in all endpoints.
Differences between 'runner' and 'gateway' entrypoints:
- 'health' endpoint is removed.
- 'model_id' is enforced in all endpoints.
- 'VideoResponse' schema is updated to match the Gateway's transcoded mp4
response.

Args:
openapi (dict): The OpenAPI schema to be translated.
Expand All @@ -49,6 +52,14 @@ def translate_to_gateway(openapi):
if "model_id" in schema["properties"]:
schema["required"].append("model_id")

# Update the 'VideoResponse' schema to match the Gateway's response.
# NOTE: This is necessary because the Gateway transcodes the runner's response and
# returns an mp4 file.
openapi["components"]["schemas"]["VideoResponse"] = copy.deepcopy(
openapi["components"]["schemas"]["ImageResponse"]
)
openapi["components"]["schemas"]["VideoResponse"]["title"] = "VideoResponse"

return openapi


Expand Down
Loading