Skip to content

Commit

Permalink
Merge pull request #8749 from OpenMined/endpoint_markdown_descriptions
Browse files Browse the repository at this point in the history
Endpoint markdown descriptions
  • Loading branch information
IonesioJunior committed Apr 29, 2024
2 parents 821d97e + a8d2654 commit 156635f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
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

0 comments on commit 156635f

Please sign in to comment.