-
Notifications
You must be signed in to change notification settings - Fork 68
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
[SYNPY-1544] Synapse Agent OOP Model #1152
base: develop
Are you sure you want to change the base?
Conversation
Hello @BWMac! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2025-01-16 14:57:29 UTC |
synapseclient/api/agent_services.py
Outdated
start_time = asyncio.get_event_loop().time() | ||
TIMEOUT = 60 | ||
|
||
while True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
synapsePythonClient/synapseclient/client.py
Line 5029 in 8bd5e19
def _waitForAsync(self, uri, request, endpoint=None): |
This function exists on the client, but it not built with asyncio in mind. There is some additional error handling it does for the failed state. I could see an asyncio compliant version being written and used here.
Maybe it could go in this file? https://github.com/Sage-Bionetworks/synapsePythonClient/blob/8bd5e195c389e3a83bd1308be3c6a42f25d87b8f/synapseclient/core/async_utils.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_waitForAync
does both the POST call (starting the job) and the GET call (retrieving the result). Should the functionality I have written here work that way too? I was viewing it as 1 function per API endpoint in agent_services originally.
I can still write a reusable async function for getting the response and handling incomplete and failed jobs, but just wondering what you think about division of responsibility there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They can be 2 separate functions that handle each part. In the Agent script you'll chain them together
synapseclient/models/agent.py
Outdated
""" | ||
Enum representing the type of agent as defined in | ||
<https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/AgentType.html> | ||
'BASELINE' is a default agent provided by Synapse. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit. Can be a list. Syntax is a empty newline before and each entry starts with -
.
Might need to make sure it renders properly on my docs.
Related to ^
These will be "Less" experimental APIs, so we can add a new non-experimental section to
synapsePythonClient/mkdocs.yml
Line 55 in 8bd5e19
- API Reference: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this should not be considered experimental? The API endpoints are brand new and could potentially change/be added to which may lead to updates in the OOP interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Throw it under there as a new section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be its own section, or just fall under this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a new entry under - Experimental:
for this
agent_registration_id: The registration ID of the agent that will be used for this session. | ||
etag: The etag of the agent session. | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out the tables refactor PR for examples of the syntax for an Examples section. I'd like for the docstring to have scripts (Copy/pastable) that folks could run and get started.
* Changes for async mixin * Remove arg * bug fix * generalizes send_job_and_wait_async * removes typing.Self --------- Co-authored-by: bwmac <[email protected]>
return self._return_rest_body(response) | ||
except Exception: | ||
self.logger.exception("Error in rest_get_async") | ||
response = await self._rest_call_async( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error handling was preventing Synapse API errors from being surfaced to client users. All tests passed after making this change.
@@ -4,10 +4,9 @@ | |||
|
|||
from synapseclient import Synapse | |||
from synapseclient.core.exceptions import SynapseError | |||
from synapseclient.models import Annotations | |||
|
|||
if TYPE_CHECKING: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was causing a circular import error
WIP
Implementation of design doc: https://sagebionetworks.jira.com/wiki/spaces/DPE/pages/3833954306/SYNPY-1544+Synapse+Agent+OOP+Model+Mini-Design