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

Endpoint markdown descriptions #8749

Merged
merged 6 commits into from
Apr 29, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/syft/src/syft/client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def _repr_markdown_(self, wrap_as_python: bool = False, indent: int = 0) -> str:
str_repr = "## API: " + custom_path + "\n"
str_repr += (
"### Description: "
+ f'<span style="font-weight: lighter;">{endpoint.description}</span><br>'
+ f'<span style="font-weight: lighter;">{endpoint.description.text}</span><br>'
+ "\n"
)
str_repr += "#### Private Code:\n"
Expand Down
21 changes: 15 additions & 6 deletions packages/syft/src/syft/service/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from ...types.transforms import transform
from ...types.uid import UID
from ..context import AuthedServiceContext
from ..dataset.dataset import MarkdownDescription
from ..response import SyftError
from ..user.user import UserView

Expand Down Expand Up @@ -84,7 +85,7 @@ class TwinAPIEndpointView(SyftObject):
access: str = "Public"
mock_function: str | None = None
private_function: str | None = None
description: str | None = None
description: MarkdownDescription | None = None
mock_helper_functions: list[str] | None = None
private_helper_functions: list[str] | None = None
worker_pool: str | None = None
Expand Down Expand Up @@ -328,7 +329,7 @@ class UpdateTwinAPIEndpoint(PartialSyftObject, BaseTwinAPIEndpoint):
path: str
private_function: PrivateAPIEndpoint | None = None
mock_function: PublicAPIEndpoint
description: str | None = None
description: MarkdownDescription | None = None
endpoint_timeout: int = 60


Expand All @@ -342,10 +343,18 @@ class CreateTwinAPIEndpoint(BaseTwinAPIEndpoint):
private_function: PrivateAPIEndpoint | None = None
mock_function: PublicAPIEndpoint
signature: Signature
description: str | None = None
description: MarkdownDescription | None = None
worker_pool: str | None = None
endpoint_timeout: int = 60

def __init__(
self, description: str | MarkdownDescription | None = "", **kwargs: Any
) -> None:
if isinstance(description, str):
description = MarkdownDescription(text=description)

super().__init__(**kwargs, description=description)


@serializable()
class TwinAPIEndpoint(SyncableSyftObject):
Expand All @@ -360,7 +369,7 @@ def __init__(self, **kwargs: Any) -> None:
private_function: PrivateAPIEndpoint | None = None
mock_function: PublicAPIEndpoint
signature: Signature
description: str | None = None
description: MarkdownDescription | None = None
action_object_id: UID
worker_pool: str | None = None
endpoint_timeout: int = 60
Expand Down Expand Up @@ -626,7 +635,7 @@ def api_endpoint(
path: str,
settings: dict[str, str] | None = None,
helper_functions: list[Callable] | None = None,
description: str | None = None,
description: MarkdownDescription | None = None,
worker_pool: str | None = None,
endpoint_timeout: int = 60,
) -> Callable[..., TwinAPIEndpoint | SyftError]:
Expand Down Expand Up @@ -687,7 +696,7 @@ def create_new_api_endpoint(
path: str,
mock_function: Endpoint,
private_function: Endpoint | None = None,
description: str | None = None,
description: MarkdownDescription | None = None,
worker_pool: str | None = None,
endpoint_timeout: int = 60,
) -> CreateTwinAPIEndpoint | SyftError:
Expand Down