-
Notifications
You must be signed in to change notification settings - Fork 12
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
REVAI-3855: Update python sdk to support Super API #105
Conversation
Tests are coming shortly |
|
||
response = self._make_http_request( | ||
"GET", | ||
urljoin(self.base_url, 'jobs/{}/transcript/summary'.format(id_)), |
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.
Any way to extract 'jobs/{}/transcript/summary'
to be reusable?
speakers_count=None, | ||
summarization: Summarization = None, | ||
translation: Translation = 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.
speakers_count=None, | |
summarization: Summarization = None, | |
translation: Translation = None): | |
speakers_count=None, | |
summarization: Summarization=None, | |
translation: Translation=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.
Same as bellow:
I follow PEP8, which is commonly accepted standard for python formatting, PyCharm supports PEP 8 and suggests this formatting here. I Used autoformat everywhere where reasonable.
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.
I think it is less matter what is the autoformatting when all the remaining code will be formatted differently.
at the same time, as per PEP8
Don’t use spaces around the = sign when used to indicate a keyword argument, or when used to indicate a default value for an unannotated function parameter:
# Correct:
def complex(real, imag=0.0):
return magic(r=real, i=imag)
# Wrong:
def complex(real, imag = 0.0):
return magic(r = real, i = imag)
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.
Discussed on Zoom. Agreed that formatting of arguments with type annotation is different according to the standard.
def __init__( | ||
self, | ||
prompt: str = None, | ||
model: NlpModel = None, | ||
formattingType: SummarizationFormattingOptions = 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.
Is this formatting correct?
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.
I used auto formatter as suggested with linter, no complaints.
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.
I follow PEP8, which is commonly accepted standard for python formatting, PyCharm supports PEP 8 and suggests this formatting here. I Used autoformat everywhere where reasonable.
tests/test_superapi.py
Outdated
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.
I would split the unit tests up into simpler test cases. They are pretty hefty, each testing three or four response methods along with the request method. I would maybe split each test case into
- request_local_file - assert request with proper params
- request_source_url - assert request with proper params
- get_transcript_summary_text
- get_transcript_summary_json
- get_transcript_summary_streamed_json
- get_translation...
...
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 used to be a real integration test before, but as of now I agree that it makes more sense to split those tests. Thanks!
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.
Looking good so far - had some comments regarding simplifying the unit tests and the need for the audio files and transcript file since they can just be mocked in code.
In addition, it would nice to add an example to https://github.com/revdotcom/revai-python-sdk/tree/develop/examples and document some usage in the README - like we have for Human Transcription - https://github.com/revdotcom/revai-python-sdk?tab=readme-ov-file#human-transcription
Can you also bump version to |
@@ -66,7 +70,9 @@ def submit_job_url( | |||
notification_config=None, | |||
skip_postprocessing=False, | |||
remove_atmospherics=False, | |||
speakers_count=None): | |||
speakers_count=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.
it looks like we are missing to pass these parameters to _create_job_options_payload
remove_atmospherics=False,
speakers_count=None,
@amikofalvy do you know whether it is intentional?
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.
src/rev_ai/apiclient.py
Outdated
|
||
response = self._make_http_request( | ||
"GET", | ||
urljoin(self.base_url, 'jobs/{0}/captions/translation/{2}{1}'.format(id_, query, language)), |
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.
why don't you pass params as format(id_, language, query)
?
it is a bit difficult to read the code with the unnecessary {2}{1}
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.
The idea was to avoid adding changes to format arguments order, but at this point it is better to change it, Thanks!
speakers_count=None, | ||
summarization: Summarization = None, | ||
translation: Translation = 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.
I think it is less matter what is the autoformatting when all the remaining code will be formatted differently.
at the same time, as per PEP8
Don’t use spaces around the = sign when used to indicate a keyword argument, or when used to indicate a default value for an unannotated function parameter:
# Correct:
def complex(real, imag=0.0):
return magic(r=real, i=imag)
# Wrong:
def complex(real, imag = 0.0):
return magic(r = real, i = imag)
from .summarization_job_status import SummarizationJobStatus | ||
from ..nlp_model import NlpModel | ||
|
||
"""Summarization request options.""" |
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.
I think this should be inside the class
|
||
|
||
class SummarizationOptions: | ||
def __init__( |
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.
based on other files, it looks like the trailing ):
should be on the same line with the last argument.
nit, but this is a public code. also, there should be a comment
return dict_result | ||
|
||
|
||
"""Summarization options.""" |
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.
not sure what kind of syntax is this. I believe this should be inside the class
@@ -0,0 +1,20 @@ | |||
from typing import List, Dict | |||
|
|||
"""Transcript summary model.""" |
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 should be either before imports, or inside the class
Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants.
so the file might look like this:
"""Module description here"""
import xyz
class MyClass:
"""This is my class"""
pass
class MyClass2:
"""This is my class 2"""
pass
model: NlpModel = None, | ||
status: SummarizationJobStatus = None, | ||
failure: str = 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.
remove line
def __init__( | ||
self, | ||
language: str = None, | ||
model: NlpModel = 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.
not sure whether you discussed it already., I see that some code is written in py2.x style without the type annotations, other - with..
while strict typing is good, wondering how can we be more consistent in the publicly available code
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.
Agreed to encourage incremental improvements going forward.
tests/test_async_summarization.py
Outdated
"POST", | ||
JOBS_URL, | ||
json={ | ||
'metadata': "python sdk SuperApi test", |
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.
not sure SuperApi
should be here
Examples to follow in another PR once this update is published |
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.
LGTM - I'll let @dmtrrk provide the final approval
REVAI-3855: Update python sdk to support Super API
https://revinc.atlassian.net/browse/REVAI-3855