Commit 1b69155e by muzaffaryousaf

Fixing few bugs that were found during sandbox testing.

parent 255fd487
...@@ -117,7 +117,7 @@ class Cielo24TranscriptTests(APITestCase): ...@@ -117,7 +117,7 @@ class Cielo24TranscriptTests(APITestCase):
'file_format': transcripts.TRANSCRIPT_SJSON, 'file_format': transcripts.TRANSCRIPT_SJSON,
'video_id': self.video.studio_id, 'video_id': self.video.studio_id,
'name': '{directory}{uuid}.sjson'.format( 'name': '{directory}{uuid}.sjson'.format(
directory=CONFIG_DATA['transcript_bucket_directory'], uuid=self.uuid_hex directory=CONFIG_DATA['aws_video_transcripts_prefix'], uuid=self.uuid_hex
), ),
'language_code': 'en', 'language_code': 'en',
'provider': TranscriptProvider.CIELO24 'provider': TranscriptProvider.CIELO24
...@@ -204,7 +204,7 @@ class Cielo24TranscriptTests(APITestCase): ...@@ -204,7 +204,7 @@ class Cielo24TranscriptTests(APITestCase):
# create s3 bucket -- all this is happening in moto's virtual environment # create s3 bucket -- all this is happening in moto's virtual environment
conn = S3Connection() conn = S3Connection()
conn.create_bucket(CONFIG_DATA['transcript_bucket_name']) conn.create_bucket(CONFIG_DATA['aws_video_transcripts_bucket'])
transcripts.cielo24_transcript_callback(None, **REQUEST_PARAMS) transcripts.cielo24_transcript_callback(None, **REQUEST_PARAMS)
...@@ -225,7 +225,7 @@ class Cielo24TranscriptTests(APITestCase): ...@@ -225,7 +225,7 @@ class Cielo24TranscriptTests(APITestCase):
self.assertEqual(json.loads(responses.calls[3].request.body), self.video_transcript_ready_status_data) self.assertEqual(json.loads(responses.calls[3].request.body), self.video_transcript_ready_status_data)
# verify sjson data uploaded to s3 # verify sjson data uploaded to s3
bucket = conn.get_bucket(CONFIG_DATA['transcript_bucket_name']) bucket = conn.get_bucket(CONFIG_DATA['aws_video_transcripts_bucket'])
key = Key(bucket) key = Key(bucket)
key.key = transcript_create_request_data['name'] key.key = transcript_create_request_data['name']
sjson = json.loads(key.get_contents_as_string()) sjson = json.loads(key.get_contents_as_string())
......
...@@ -24,6 +24,7 @@ from VEDA_OS01.models import (TranscriptPreferences, TranscriptProcessMetadata, ...@@ -24,6 +24,7 @@ from VEDA_OS01.models import (TranscriptPreferences, TranscriptProcessMetadata,
requests.packages.urllib3.disable_warnings(InsecurePlatformWarning) requests.packages.urllib3.disable_warnings(InsecurePlatformWarning)
logging.basicConfig()
LOGGER = logging.getLogger(__name__) LOGGER = logging.getLogger(__name__)
TRANSCRIPT_SJSON = 'sjson' TRANSCRIPT_SJSON = 'sjson'
CIELO24_TRANSCRIPT_COMPLETED = django.dispatch.Signal(providing_args=['job_id', 'lang_code', 'org', 'video_id']) CIELO24_TRANSCRIPT_COMPLETED = django.dispatch.Signal(providing_args=['job_id', 'lang_code', 'org', 'video_id'])
...@@ -178,7 +179,7 @@ def cielo24_transcript_callback(sender, **kwargs): ...@@ -178,7 +179,7 @@ def cielo24_transcript_callback(sender, **kwargs):
sjson_file_name = upload_sjson_to_s3(CONFIG, sjson) sjson_file_name = upload_sjson_to_s3(CONFIG, sjson)
except Exception: except Exception:
LOGGER.exception( LOGGER.exception(
'[CIELO24 TRANSCRIPTS] Request failed for video=%s -- lang=%s -- job_id=%s -- message=%s', '[CIELO24 TRANSCRIPTS] Request failed for video=%s -- lang=%s -- job_id=%s',
video_id, video_id,
lang_code, lang_code,
job_id job_id
...@@ -256,11 +257,11 @@ def upload_sjson_to_s3(config, sjson_data): ...@@ -256,11 +257,11 @@ def upload_sjson_to_s3(config, sjson_data):
Upload sjson data to s3. Upload sjson data to s3.
""" """
s3_conn = boto.connect_s3() s3_conn = boto.connect_s3()
bucket = s3_conn.get_bucket(config['transcript_bucket_name']) bucket = s3_conn.get_bucket(config['aws_video_transcripts_bucket'])
k = Key(bucket) k = Key(bucket)
k.content_type = 'application/json' k.content_type = 'application/json'
k.key = '{directory}{uuid}.sjson'.format( k.key = '{directory}{uuid}.sjson'.format(
directory=config['transcript_bucket_directory'], directory=config['aws_video_transcripts_prefix'],
uuid=uuid.uuid4().hex uuid=uuid.uuid4().hex
) )
k.set_contents_from_string(json.dumps(sjson_data)) k.set_contents_from_string(json.dumps(sjson_data))
......
...@@ -15,6 +15,10 @@ if project_path not in sys.path: ...@@ -15,6 +15,10 @@ if project_path not in sys.path:
This is a cheapo way to get a pager (using SES) This is a cheapo way to get a pager (using SES)
""" """
import django
django.setup()
from control.veda_file_discovery import FileDiscovery from control.veda_file_discovery import FileDiscovery
from youtube_callback.daemon import generate_course_list from youtube_callback.daemon import generate_course_list
from youtube_callback.sftp_id_retrieve import callfunction from youtube_callback.sftp_id_retrieve import callfunction
......
...@@ -105,165 +105,163 @@ class HealTests(TestCase): ...@@ -105,165 +105,163 @@ class HealTests(TestCase):
heal = VedaHeal() heal = VedaHeal()
heal.discovery() heal.discovery()
@data(
@data( {
{
'edx_id': '1',
'video_trans_status': 'Corrupt File',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
},
{
'edx_id': '1',
'video_trans_status': 'Review Reject',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
},
{
'edx_id': '1',
'video_trans_status': 'Review Hold',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
},
{
'edx_id': '1',
'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': False,
},
{
'edx_id': '2',
'video_trans_status': 'Ingest',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
},
{
'edx_id': '1',
'video_trans_status': 'Corrupt File',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
},
)
@unpack
def test_determine_fault(self, edx_id, video_trans_status, video_trans_start, video_active):
"""
Tests that determine_fault works in various video states.
"""
video_instance = Video(
edx_id=edx_id,
video_trans_status=video_trans_status,
video_trans_start=video_trans_start,
video_active=video_active,
inst_class=Course()
)
encode_list = self.heal_instance.determine_fault(video_instance)
if video_instance.edx_id == '1':
self.assertEqual(encode_list, [])
elif video_instance.edx_id == '2':
for e in encode_list:
self.assertTrue(e in self.encode_list)
@data(
{
'uncompleted_encodes': [],
'expected_encodes': ['test_obj'],
'video_object': {
'edx_id': '1', 'edx_id': '1',
'video_trans_status': 'Complete', 'video_trans_status': 'Corrupt File',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc), 'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True, 'video_active': True,
} },
}, {
{ 'edx_id': '1',
'uncompleted_encodes': ['test_obj'], 'video_trans_status': 'Review Reject',
'expected_encodes': ['test_obj'],
'video_object': {
'edx_id': '2',
'video_trans_status': 'Ingest',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc), 'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True, 'video_active': True,
} },
} {
)
@unpack
def test_differentiate_encodes(self, uncompleted_encodes, expected_encodes, video_object):
"""
Tests that differentiate_encodes list comparison works as expected. This doesn't test video states,
just the list comparison function.
"""
video_instance = Video(
edx_id=video_object['edx_id'],
video_trans_status=video_object['video_trans_status'],
video_trans_start=video_object['video_trans_start'],
video_active=video_object['video_active'],
inst_class=Course()
)
encode_list = self.heal_instance.differentiate_encodes(
uncompleted_encodes,
expected_encodes,
video_instance
)
if video_instance.edx_id == '1':
self.assertEqual(encode_list, [])
elif video_instance.edx_id == '2':
self.assertEqual(encode_list, ['test_obj'])
@data(
{
'uncompleted_encodes': ['test_encode', 'test_encode'],
'expected_encodes': ['test_encode', 'test_encode'],
'video_object': {
'edx_id': '1', 'edx_id': '1',
'video_trans_status': 'Complete', 'video_trans_status': 'Review Hold',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc), 'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True, 'video_active': True,
} },
}, {
{ 'edx_id': '1',
'uncompleted_encodes': ['test_encode', 'test_encode', 'hls'],
'expected_encodes': ['test_encode', 'test_encode', 'hls'],
'video_object': {
'edx_id': '2',
'video_trans_status': 'Complete', 'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc), 'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True, 'video_active': False,
} },
}, {
{ 'edx_id': '2',
'uncompleted_encodes': ['test_encode', 'test_encode', 'hls'],
'expected_encodes': ['test_encode', 'test_encode', 'hls'],
'video_object': {
'edx_id': '3',
'video_trans_status': 'Ingest', 'video_trans_status': 'Ingest',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc) - timedelta(days=10), 'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True, 'video_active': True,
},
{
'edx_id': '1',
'video_trans_status': 'Corrupt File',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
},
)
@unpack
def test_determine_fault(self, edx_id, video_trans_status, video_trans_start, video_active):
"""
Tests that determine_fault works in various video states.
"""
video_instance = Video(
edx_id=edx_id,
video_trans_status=video_trans_status,
video_trans_start=video_trans_start,
video_active=video_active,
inst_class=Course()
)
encode_list = self.heal_instance.determine_fault(video_instance)
if video_instance.edx_id == '1':
self.assertEqual(encode_list, [])
elif video_instance.edx_id == '2':
for e in encode_list:
self.assertTrue(e in self.encode_list)
@data(
{
'uncompleted_encodes': [],
'expected_encodes': ['test_obj'],
'video_object': {
'edx_id': '1',
'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
}
},
{
'uncompleted_encodes': ['test_obj'],
'expected_encodes': ['test_obj'],
'video_object': {
'edx_id': '2',
'video_trans_status': 'Ingest',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
}
} }
}
)
@unpack
def test_determine_longterm_corrupt(self, uncompleted_encodes, expected_encodes, video_object):
video_instance = Video(
edx_id=video_object['edx_id'],
video_trans_status=video_object['video_trans_status'],
video_trans_start=video_object['video_trans_start'],
video_active=video_object['video_active'],
inst_class=Course()
) )
@unpack
def test_differentiate_encodes(self, uncompleted_encodes, expected_encodes, video_object):
"""
Tests that differentiate_encodes list comparison works as expected. This doesn't test video states,
just the list comparison function.
"""
video_instance = Video(
edx_id=video_object['edx_id'],
video_trans_status=video_object['video_trans_status'],
video_trans_start=video_object['video_trans_start'],
video_active=video_object['video_active'],
inst_class=Course()
)
encode_list = self.heal_instance.differentiate_encodes(
uncompleted_encodes,
expected_encodes,
video_instance
)
if video_instance.edx_id == '1':
self.assertEqual(encode_list, [])
elif video_instance.edx_id == '2':
self.assertEqual(encode_list, ['test_obj'])
longterm_corrupt = self.heal_instance.determine_longterm_corrupt(
uncompleted_encodes, @data(
expected_encodes, {
video_instance 'uncompleted_encodes': ['test_encode', 'test_encode'],
'expected_encodes': ['test_encode', 'test_encode'],
'video_object': {
'edx_id': '1',
'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
}
},
{
'uncompleted_encodes': ['test_encode', 'test_encode', 'hls'],
'expected_encodes': ['test_encode', 'test_encode', 'hls'],
'video_object': {
'edx_id': '2',
'video_trans_status': 'Complete',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc),
'video_active': True,
}
},
{
'uncompleted_encodes': ['test_encode', 'test_encode', 'hls'],
'expected_encodes': ['test_encode', 'test_encode', 'hls'],
'video_object': {
'edx_id': '3',
'video_trans_status': 'Ingest',
'video_trans_start': datetime.datetime.utcnow().replace(tzinfo=utc) - timedelta(days=10),
'video_active': True,
}
}
) )
@unpack
def test_determine_longterm_corrupt(self, uncompleted_encodes, expected_encodes, video_object):
video_instance = Video(
edx_id=video_object['edx_id'],
video_trans_status=video_object['video_trans_status'],
video_trans_start=video_object['video_trans_start'],
video_active=video_object['video_active'],
inst_class=Course()
)
longterm_corrupt = self.heal_instance.determine_longterm_corrupt(
uncompleted_encodes,
expected_encodes,
video_instance
)
if video_instance.edx_id == '1': if video_instance.edx_id == '1':
self.assertEqual(longterm_corrupt, False) self.assertEqual(longterm_corrupt, False)
elif video_instance.edx_id == '2': elif video_instance.edx_id == '2':
self.assertEqual(longterm_corrupt, False) self.assertEqual(longterm_corrupt, False)
elif video_instance.edx_id == '3': elif video_instance.edx_id == '3':
self.assertEqual(longterm_corrupt, True) self.assertEqual(longterm_corrupt, True)
...@@ -181,6 +181,15 @@ class VedaDelivery: ...@@ -181,6 +181,15 @@ class VedaDelivery:
""" """
Transcript, Xuetang Transcript, Xuetang
""" """
self._XUETANG_ROUTE()
self.status = self._DETERMINE_STATUS()
self._UPDATE_DATA()
self._CLEANUP()
self._THREEPLAY_UPLOAD() self._THREEPLAY_UPLOAD()
# Transcription Process # Transcription Process
# We only want to generate transcripts for `desktop_mp4` profile. # We only want to generate transcripts for `desktop_mp4` profile.
...@@ -194,13 +203,6 @@ class VedaDelivery: ...@@ -194,13 +203,6 @@ class VedaDelivery:
if self.video_query.provider == TranscriptProvider.CIELO24: if self.video_query.provider == TranscriptProvider.CIELO24:
self.cielo24_transcription_flow() self.cielo24_transcription_flow()
self._XUETANG_ROUTE()
self.status = self._DETERMINE_STATUS()
self._UPDATE_DATA()
self._CLEANUP()
def _INFORM_INTAKE(self): def _INFORM_INTAKE(self):
""" """
......
...@@ -8,6 +8,7 @@ from boto.exception import S3ResponseError, S3DataError ...@@ -8,6 +8,7 @@ from boto.exception import S3ResponseError, S3DataError
import yaml import yaml
from VEDA_OS01.models import TranscriptPreferences from VEDA_OS01.models import TranscriptPreferences
from VEDA_OS01.utils import extract_course_org
try: try:
boto.config.add_section('Boto') boto.config.add_section('Boto')
...@@ -237,9 +238,7 @@ class FileDiscovery(object): ...@@ -237,9 +238,7 @@ class FileDiscovery(object):
try: try:
transcript_preferences = json.loads(transcript_preferences) transcript_preferences = json.loads(transcript_preferences)
TranscriptPreferences.objects.get( TranscriptPreferences.objects.get(
# TODO: Once ammar is done with cielo24. org=extract_course_org(course_url),
# org=extract_course_org(course_url),
org=transcript_preferences.get('org'),
provider=transcript_preferences.get('provider') provider=transcript_preferences.get('provider')
) )
process_transcription = True process_transcription = True
......
...@@ -32,11 +32,15 @@ debug: false ...@@ -32,11 +32,15 @@ debug: false
edx_s3_ingest_prefix: edx_s3_ingest_prefix:
edx_s3_ingest_bucket: edx_s3_ingest_bucket:
edx_s3_endpoint_bucket: edx_s3_endpoint_bucket:
# CF # CF
edx_cloudfront_prefix: edx_cloudfront_prefix:
# Images # Images
aws_video_images_bucket: aws_video_images_bucket:
aws_video_images_prefix: "video-images/" aws_video_images_prefix: "video-images/"
# VEDA Internal # VEDA Internal
veda_s3_upload_bucket: veda_s3_upload_bucket:
veda_s3_hotstore_bucket: veda_s3_hotstore_bucket:
...@@ -47,13 +51,12 @@ veda_base_url: ...@@ -47,13 +51,12 @@ veda_base_url:
s3_base_url: https://s3.amazonaws.com s3_base_url: https://s3.amazonaws.com
# transcript bucket config # Transcripts
transcript_bucket_name: aws_video_transcripts_bucket:
transcript_bucket_directory: video-transcripts/ aws_video_transcripts_prefix: video-transcripts/
# a token identifying a valid request from transcript provider # a token identifying a valid request from transcript provider
transcript_provider_request_token: transcript_provider_request_token: test-token
# Ingest Secret # Ingest Secret
# TODO: Elminate access key after AWS Support ticket 08/20/17 regarding cross-account IAM role access. # TODO: Elminate access key after AWS Support ticket 08/20/17 regarding cross-account IAM role access.
......
...@@ -6,8 +6,8 @@ s3_base_url: https://s3.amazonaws.com ...@@ -6,8 +6,8 @@ s3_base_url: https://s3.amazonaws.com
# transcript bucket config # transcript bucket config
transcript_bucket_name: bucket_name aws_video_transcripts_bucket: bucket_name
transcript_bucket_directory: video-transcripts/ aws_video_transcripts_prefix: video-transcripts/
# a token identifying a valid request from transcript provider # a token identifying a valid request from transcript provider
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment