Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
pip install --upgrade pip
pip install -r requirements.txt -r requirements_dev.txt
- name: Test
run: python setup.py test
run: pytest tests/
- name: Lint
run: |
flake8 tests --ignore=F401,W504,E731,E123,E125,E127,E128,E501
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,5 @@ def parse_requirements(filehandle):
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
setup_requires=['pytest-runner==4.2'],
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/revdotcom/revai-python-sdk',
)
2 changes: 1 addition & 1 deletion src/rev_ai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Top-level package for rev_ai"""

__version__ = '2.21.0'
__version__ = '2.22.0'

from .models import Job, JobStatus, Account, Transcript, Monologue, Element, MediaConfig, \
CaptionType, GroupChannelsType, CustomVocabulary, TopicExtractionJob, TopicExtractionResult, \
Expand Down
8 changes: 6 additions & 2 deletions src/rev_ai/apiclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,11 @@ def _create_job_options_payload(
translation_config: TranslationOptions = None):
payload = {}
if media_url:
payload['media_url'] = media_url
if source_config:
raise ValueError(
'media_url is not compatible with source_config. '
'Use source_config for all URL-based submissions.')
payload['source_config'] = {'url': media_url}
if skip_diarization:
payload['skip_diarization'] = skip_diarization
if skip_punctuation:
Expand All @@ -842,7 +846,7 @@ def _create_job_options_payload(
payload['custom_vocabulary_id'] = custom_vocabulary_id
if transcriber:
payload['transcriber'] = transcriber
if verbatim:
if verbatim is not None:
payload['verbatim'] = verbatim
if rush:
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like we need to make this fix to all boolean options

payload['rush'] = rush
Expand Down
2 changes: 1 addition & 1 deletion tests/test_async_summarization.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_submit_source_url(self, mock_session, make_mock_response):
"POST",
JOBS_URL,
json={
'media_url': 'https://example.com/test.mp3',
'source_config': {'url': 'https://example.com/test.mp3'},
'language': 'en',
'summarization_config': {
'prompt': "Try to summarize this transcript as good as you possibly can",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_async_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_submit_source_url(self, mock_session, make_mock_response):
"POST",
JOBS_URL,
json={
'media_url': 'https://example.com/test.mp3',
'source_config': {'url': 'https://example.com/test.mp3'},
'language': 'en',
'translation_config': {
'target_languages': [
Expand Down
75 changes: 73 additions & 2 deletions tests/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def test_submit_job_url_with_success(self, mock_session, make_mock_response):
"POST",
JOBS_URL,
json={
'media_url': SOURCE_URL,
'source_config': {'url': SOURCE_URL},
'callback_url': NOTIFICATION_URL,
'metadata': METADATA,
'skip_diarization': True,
Expand Down Expand Up @@ -276,14 +276,85 @@ def test_submit_job_url_with_human_transcription_and_success(self, mock_session,
'POST',
JOBS_URL,
json={
'media_url': SOURCE_URL,
'source_config': {'url': SOURCE_URL},
'transcriber': 'human',
'verbatim': True,
'segments_to_transcribe': segments,
'speaker_names': [{'display_name': 'Kyle Bridburg'}]
},
headers=client.default_headers)

def test_submit_job_url_with_media_url_and_source_config_conflict(self, mock_session):
"""Passing both media_url and source_config should raise ValueError."""
client = RevAiAPIClient(TOKEN)

with pytest.raises(ValueError, match='media_url is not compatible with source_config'):
client.submit_job_url(
media_url=SOURCE_URL,
source_config=SOURCE_CONFIG
)

def test_submit_job_url_verbatim_false(self, mock_session, make_mock_response):
"""verbatim=False should be included in payload."""
data = {
'id': JOB_ID,
'status': 'in_progress',
'created_on': CREATED_ON,
}
response = make_mock_response(url=JOB_ID_URL, json_data=data)
mock_session.request.return_value = response
client = RevAiAPIClient(TOKEN)

client.submit_job_url(SOURCE_URL, verbatim=False)

mock_session.request.assert_called_once_with(
'POST',
JOBS_URL,
json={
'source_config': {'url': SOURCE_URL},
'verbatim': False,
},
headers=client.default_headers)

def test_submit_job_url_verbatim_true(self, mock_session, make_mock_response):
"""verbatim=True should be included in payload."""
data = {
'id': JOB_ID,
'status': 'in_progress',
'created_on': CREATED_ON,
}
response = make_mock_response(url=JOB_ID_URL, json_data=data)
mock_session.request.return_value = response
client = RevAiAPIClient(TOKEN)

client.submit_job_url(SOURCE_URL, verbatim=True)

mock_session.request.assert_called_once_with(
'POST',
JOBS_URL,
json={
'source_config': {'url': SOURCE_URL},
'verbatim': True,
},
headers=client.default_headers)

def test_submit_job_url_verbatim_none(self, mock_session, make_mock_response):
"""verbatim=None (default) should NOT be included in payload."""
data = {
'id': JOB_ID,
'status': 'in_progress',
'created_on': CREATED_ON,
}
response = make_mock_response(url=JOB_ID_URL, json_data=data)
mock_session.request.return_value = response
client = RevAiAPIClient(TOKEN)

client.submit_job_url(SOURCE_URL)

call_kwargs = mock_session.request.call_args
payload = call_kwargs[1]['json'] if 'json' in call_kwargs[1] else call_kwargs[0][2]
assert 'verbatim' not in payload

def test_submit_job_local_file_with_success(self, mocker, mock_session, make_mock_response):
created_on = '2018-05-05T23:23:22.29Z'
data = {
Expand Down
Loading