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

Revert "Add application and tools enumeration functions." #251

Merged
merged 1 commit into from
Jun 19, 2024
Merged
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
44 changes: 0 additions & 44 deletions ayon_server/settings/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,47 +99,3 @@ async def _get_app_host_names():
async def addon_all_app_host_names_enum():
result = await _get_app_host_names()
return [{"label": host_name, "value": host_name} for host_name in result]


async def application_enum(apps: list[str] | None = None) -> list[dict[str, str]]:
"""Return a list of all applications.

If app is provided, return only applications that start with app.

Example:
nuke_variant: str = SettingsField(
default="",
title="Nuke variant",
description="Nuke variant to be used for transcoding.",
enum_resolver=functools.partial(application_enum, "nuke"),
)

Args:
app Optional[list[str]]: Application names to filter. Defaults to None.

Returns:
list[dict]: List of applications.
"""
res = await Postgres.fetch(
"SELECT data FROM attributes WHERE name = 'applications'"
)
if not res:
return []
all_apps = res[0]["data"].get("enum", [])

if apps:
return_apps = []
for app in apps:
return_apps += [
a for a in all_apps if a["value"].split("/")[0] == app.lower()
]
return return_apps

return all_apps


async def tools_enum() -> list[dict[str, str]]:
"""Return a list of all tools."""
res = await Postgres.fetch("SELECT data FROM attributes WHERE name = 'tools'")

return res[0]["data"].get("enum", []) if res else []