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_endpoints() view for DS #8757

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Changes from 2 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
14 changes: 8 additions & 6 deletions packages/syft/src/syft/service/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ class TwinAPIEndpointView(SyftObject):
]

def _coll_repr_(self) -> dict[str, Any]:
mock_parsed_code = ast.parse(self.mock_function)
mock_function_name = [
node.name
for node in ast.walk(mock_parsed_code)
if isinstance(node, ast.FunctionDef)
][0]
mock_function_name = NOT_ACCESSIBLE_STRING
if self.mock_function != NOT_ACCESSIBLE_STRING:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer to keep the NOT_ACCESSIBLE_STRING only to the repr methods, and have self.mock_function be None if it is not defined:

if self.mock_function is None:
    mock_function_name = NOT_ACCESSIBLE_STRING
else:
    # parse function name

Same in api.py:562

That would clear the logic here up a lot I think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved by: b56b3e1

mock_parsed_code = ast.parse(self.mock_function)
mock_function_name = [
node.name
for node in ast.walk(mock_parsed_code)
if isinstance(node, ast.FunctionDef)
][0]
private_function_name = NOT_ACCESSIBLE_STRING
if self.private_function != NOT_ACCESSIBLE_STRING:
private_parsed_code = ast.parse(self.private_function)
Expand Down