-
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
This comment was marked as outdated.
This comment was marked as outdated.
@@ -75,8 +75,29 @@ nav: | |||
- Core: reference/core.md | |||
- REST Apis: reference/rest_apis.md | |||
- Experimental: | |||
- Object-Orientated Models: reference/oop/models.md | |||
- Async Object-Orientated Models: reference/oop/models_async.md | |||
- Mixins: |
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 is really nice - thanks for this on the fly refactor
"""Send the job to the Asynchronous Job service and wait for it to complete. | ||
Arguments: | ||
post_exchange_args: Additional arguments to pass to the request. |
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.
Could you update what I wrote here to be a little more verbose on how this is intended to be used? Maybe an example too?
Could you also update the language for the synapse_client
docstring to match the other areas of the code?
f"Timeout waiting for query results: {time.time() - start_time} seconds" | ||
) | ||
|
||
return result |
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.
Should we update this to return back the AsynchronousJobStatus
instance instead of the raw result from the API call?
Returns: | ||
A AsynchronousJobStatus object. | ||
""" | ||
self.state = async_job_status.get("jobState", None) |
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.
We'll need to instantiate a AsynchronousJobState object here
- register | ||
- get | ||
- start_session | ||
- get_session | ||
- prompt |
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.
These functions are not showing on the doc site:
https://synapsepythonclient--1152.org.readthedocs.build/en/1152/reference/experimental/sync/agent/#synapseclient.models.Agent-functions
I think because it's missing inherited_members: true
AGENT_AWS_ID = "QOTV3KQM1X" | ||
AGENT_REGISTRATION_ID = "29" |
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.
Add a comment what these map to
await agent_session.update_async(synapse_client=self.syn) | ||
# THEN I expect the access level to be updated | ||
assert ( | ||
agent_session.access_level == AgentSessionAccessLevel.READ_YOUR_PRIVATE_DATA | ||
) |
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.
A better verification of this is to make sure that the data was stored in Synapse. Consider if this silently failed and did not persist the data to Synapse. Your instance would have the updated attribute value, but the next time the session is retrieved it could be using the previous access level.
Perform a new read with a new instance after calling update_async
and verify on that newly read instance that it contains the right access_level
|
||
def get_test_agent(self) -> Agent: | ||
return Agent( | ||
cloud_agent_id="QOTV3KQM1X", |
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.
You have the AGENT_AWS_ID
constant available
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.
Great work! See my comments and re-request a review when you're ready
Description:
This PR is the implementation of an OOP model for interacting with the new Synapse Agent API endpoints. The design for the model implementation can be found in Confluence.
The core implementation includes (from "bottom to top"):
synapseclient.api.agent_services
:synapseclient.models.AgentPrompt
:AgentSession
class and is not intended to be used directly.AsynchronousCommunicator
Mixin which includes reusable logic for starting an async job, waiting for it to complete, and returning the response.synapseclient.models.AgentSession
:AgentSession
logic is used in theAgent
class, and we will generally recommend that users utilize theAgent
class as the primary interface.synapseclient.models.Agent
:prompt
) becomes the default for prompting, but examples for conducting more than one session at a time can be found in the POC script and class docstring.Notes:
Experimental
section of the documentation, breaking up each model into it's own markdown script which makes maintaining the docs for OOP models a little easier.