Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-video-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-video-pipeline
Commits
f579279e
Unverified
Commit
f579279e
authored
Dec 06, 2017
by
Gregory Martin
Committed by
GitHub
Dec 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70 from edx/yro/release_bugfix
1.2.0 Release Debug
parents
e0e2d4c9
56b28ce3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
88 deletions
+71
-88
bin/heal
+10
-6
control/tests/test_heal.py
+1
-1
control/veda_file_discovery.py
+24
-33
control/veda_file_ingest.py
+1
-1
control/veda_heal.py
+6
-6
youtube_callback/sftp_id_retrieve.py
+29
-41
No files found.
bin/heal
View file @
f579279e
#!/usr/bin/env python
#!/usr/bin/env python
"""
Deliver
Command Line Interface
"""
import
os
import
os
import
sys
import
sys
import
argparse
import
argparse
...
@@ -14,12 +19,7 @@ from control.celeryapp import maintainer_healer
...
@@ -14,12 +19,7 @@ from control.celeryapp import maintainer_healer
from
control.veda_heal
import
VedaHeal
from
control.veda_heal
import
VedaHeal
from
VEDA_OS01.models
import
Course
,
Video
from
VEDA_OS01.models
import
Course
,
Video
from
VEDA_OS01.transcripts
import
retrieve_three_play_translations
from
VEDA_OS01.transcripts
import
retrieve_three_play_translations
from
VEDA.utils
import
get_config
"""
Deliver
Command Line Interface
"""
class
HealCli
:
class
HealCli
:
...
@@ -30,6 +30,10 @@ class HealCli:
...
@@ -30,6 +30,10 @@ class HealCli:
self
.
binscript
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'heal'
)
self
.
binscript
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'heal'
)
def
schedule
(
self
):
def
schedule
(
self
):
"""
Reschedule Heal process via Celery ETA
"""
auth_dict
=
get_config
()
go_time
=
datetime
.
datetime
.
now
(
pytz
.
timezone
(
"America/New_York"
))
\
go_time
=
datetime
.
datetime
.
now
(
pytz
.
timezone
(
"America/New_York"
))
\
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
)
\
.
replace
(
hour
=
0
,
minute
=
0
,
second
=
0
,
microsecond
=
0
)
\
.
astimezone
(
pytz
.
utc
)
+
timedelta
(
days
=
1
)
.
astimezone
(
pytz
.
utc
)
+
timedelta
(
days
=
1
)
...
...
control/tests/test_heal.py
View file @
f579279e
...
@@ -125,7 +125,7 @@ class HealTests(TestCase):
...
@@ -125,7 +125,7 @@ class HealTests(TestCase):
'video_active'
:
True
,
'video_active'
:
True
,
},
},
{
{
'edx_id'
:
'
1
'
,
'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'
:
False
,
'video_active'
:
False
,
...
...
control/veda_file_discovery.py
View file @
f579279e
"""
multi-point videofile discovery
Currently:
Amazon S3 (studio-ingest as well as about/marketing
video ingest
)
Local (watchfolder w/o edit priv.)
"""
import
json
import
json
import
logging
import
logging
import
os.path
import
boto
import
boto
import
boto.s3
import
boto.s3
from
boto.exception
import
S3ResponseError
,
S3DataError
from
boto.exception
import
NoAuthHandlerFound
,
S3DataError
,
S3ResponseError
from
opaque_keys
import
InvalidKeyError
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
CourseKey
from
opaque_keys.edx.keys
import
CourseKey
from
control_env
import
*
from
VEDA.utils
import
extract_course_org
,
get_config
from
VEDA.utils
import
extract_course_org
,
get_config
from
veda_file_ingest
import
VedaIngest
,
VideoProto
from
VEDA_OS01.models
import
TranscriptCredentials
from
VEDA_OS01.models
import
TranscriptCredentials
from
veda_utils
import
ErrorObject
from
veda_val
import
VALAPICall
try
:
try
:
boto
.
config
.
add_section
(
'Boto'
)
boto
.
config
.
add_section
(
'Boto'
)
...
@@ -17,21 +31,6 @@ except:
...
@@ -17,21 +31,6 @@ except:
pass
pass
boto
.
config
.
set
(
'Boto'
,
'http_socket_timeout'
,
'100'
)
boto
.
config
.
set
(
'Boto'
,
'http_socket_timeout'
,
'100'
)
"""
multi-point videofile discovery
Currently:
FTP
Amazon S3 (studio-ingest as well as about/marketing
video ingest
)
Local (watchfolder w/o edit priv.)
"""
from
control_env
import
*
from
veda_utils
import
ErrorObject
from
veda_file_ingest
import
VideoProto
,
VedaIngest
from
veda_val
import
VALAPICall
LOGGER
=
logging
.
getLogger
(
__name__
)
LOGGER
=
logging
.
getLogger
(
__name__
)
...
@@ -39,18 +38,8 @@ class FileDiscovery(object):
...
@@ -39,18 +38,8 @@ class FileDiscovery(object):
def
__init__
(
self
,
**
kwargs
):
def
__init__
(
self
,
**
kwargs
):
self
.
video_info
=
{}
self
.
video_info
=
{}
self
.
auth_dict
=
get_config
()
self
.
auth_dict
=
get_config
()
self
.
bucket
=
None
self
.
bucket
=
None
"""
FTP Server Vars
"""
self
.
ftp_key
=
None
self
.
ftp_follow_delay
=
str
(
5000
)
self
.
ftp_log
=
"/Users/Shared/edX1/LG/Transfers.log"
self
.
wfm_log
=
"/Users/Shared/edX1/LG/WFM.log"
self
.
ftp_faillog
=
"/Users/Shared/edX1/LG/FailedTransfers.log"
self
.
node_work_directory
=
kwargs
.
get
(
'node_work_directory'
,
WORK_DIRECTORY
)
self
.
node_work_directory
=
kwargs
.
get
(
'node_work_directory'
,
WORK_DIRECTORY
)
def
about_video_ingest
(
self
):
def
about_video_ingest
(
self
):
...
@@ -58,12 +47,13 @@ class FileDiscovery(object):
...
@@ -58,12 +47,13 @@ class FileDiscovery(object):
Crawl VEDA Upload bucket
Crawl VEDA Upload bucket
"""
"""
if
self
.
node_work_directory
is
None
:
if
self
.
node_work_directory
is
None
:
ErrorObject
()
.
print_error
(
print
'[Discovery Error] No Workdir'
message
=
'No Workdir'
return
)
try
:
conn
=
boto
.
connect_s3
()
except
NoAuthHandlerFound
:
print
'[Discovery Error] BOTO Auth Handler'
return
return
conn
=
boto
.
connect_s3
()
try
:
try
:
self
.
bucket
=
conn
.
get_bucket
(
self
.
auth_dict
[
'veda_s3_upload_bucket'
])
self
.
bucket
=
conn
.
get_bucket
(
self
.
auth_dict
[
'veda_s3_upload_bucket'
])
except
S3ResponseError
:
except
S3ResponseError
:
...
@@ -217,7 +207,6 @@ class FileDiscovery(object):
...
@@ -217,7 +207,6 @@ class FileDiscovery(object):
"""
"""
if
len
(
file_extension
)
==
3
:
if
len
(
file_extension
)
==
3
:
file_name
=
u'{file_name}.{ext}'
.
format
(
file_name
=
file_name
,
ext
=
file_extension
)
file_name
=
u'{file_name}.{ext}'
.
format
(
file_name
=
file_name
,
ext
=
file_extension
)
try
:
try
:
key
.
get_contents_to_filename
(
os
.
path
.
join
(
self
.
node_work_directory
,
file_name
))
key
.
get_contents_to_filename
(
os
.
path
.
join
(
self
.
node_work_directory
,
file_name
))
file_ingested
=
True
file_ingested
=
True
...
@@ -263,6 +252,8 @@ class FileDiscovery(object):
...
@@ -263,6 +252,8 @@ class FileDiscovery(object):
self
.
validate_metadata_and_feed_to_ingest
(
video_s3_key
=
self
.
bucket
.
get_key
(
video_s3_key
.
name
))
self
.
validate_metadata_and_feed_to_ingest
(
video_s3_key
=
self
.
bucket
.
get_key
(
video_s3_key
.
name
))
except
S3ResponseError
:
except
S3ResponseError
:
ErrorObject
.
print_error
(
message
=
'[File Ingest] S3 Ingest Connection Failure'
)
ErrorObject
.
print_error
(
message
=
'[File Ingest] S3 Ingest Connection Failure'
)
except
NoAuthHandlerFound
:
ErrorObject
.
print_error
(
message
=
'[Discovery Error] BOTO Auth Handler'
)
else
:
else
:
ErrorObject
.
print_error
(
message
=
'[File Ingest] No Working Node directory'
)
ErrorObject
.
print_error
(
message
=
'[File Ingest] No Working Node directory'
)
...
...
control/veda_file_ingest.py
View file @
f579279e
...
@@ -162,7 +162,7 @@ class VedaIngest:
...
@@ -162,7 +162,7 @@ class VedaIngest:
jobid
=
uuid
.
uuid1
()
.
hex
[
0
:
10
]
jobid
=
uuid
.
uuid1
()
.
hex
[
0
:
10
]
celeryapp
.
worker_task_fire
.
apply_async
(
celeryapp
.
worker_task_fire
.
apply_async
(
(
veda_id
,
encode_profile
,
jobid
),
(
veda_id
,
encode_profile
,
jobid
),
queue
=
self
.
auth_dict
[
'celery_worker_queue'
]
queue
=
self
.
auth_dict
[
'celery_worker_queue'
]
.
split
(
','
)[
0
]
)
)
"""
"""
...
...
control/veda_heal.py
View file @
f579279e
...
@@ -85,7 +85,7 @@ class VedaHeal(object):
...
@@ -85,7 +85,7 @@ class VedaHeal(object):
jobid
=
uuid
.
uuid1
()
.
hex
[
0
:
10
]
jobid
=
uuid
.
uuid1
()
.
hex
[
0
:
10
]
celeryapp
.
worker_task_fire
.
apply_async
(
celeryapp
.
worker_task_fire
.
apply_async
(
(
veda_id
,
encode_profile
,
jobid
),
(
veda_id
,
encode_profile
,
jobid
),
queue
=
self
.
auth_dict
[
'celery_worker_queue'
]
queue
=
self
.
auth_dict
[
'celery_worker_queue'
]
.
split
(
','
)[
0
]
)
)
def
determine_fault
(
self
,
video_object
):
def
determine_fault
(
self
,
video_object
):
...
@@ -95,15 +95,15 @@ class VedaHeal(object):
...
@@ -95,15 +95,15 @@ class VedaHeal(object):
LOGGER
.
info
(
'[HEAL] : {id}'
.
format
(
id
=
video_object
.
edx_id
))
LOGGER
.
info
(
'[HEAL] : {id}'
.
format
(
id
=
video_object
.
edx_id
))
if
self
.
freezing_bug
is
True
:
if
self
.
freezing_bug
is
True
:
if
video_object
.
video_trans_status
==
'Corrupt File'
:
if
video_object
.
video_trans_status
==
'Corrupt File'
:
self
.
val_status
=
'file_corrupt'
return
[]
return
[]
if
video_object
.
video_trans_status
==
'Review Reject'
:
if
video_object
.
video_trans_status
==
'Review Reject'
or
video_object
.
video_trans_status
==
'Review Hold'
or
\
video_object
.
video_trans_status
==
'Review Hold'
:
return
[]
return
[]
if
video_object
.
video_trans_status
==
'Review Hold'
:
if
video_object
.
video_trans_status
==
'Youtube Duplicate'
:
return
[]
self
.
val_status
=
'duplicate'
if
video_object
.
video_active
is
False
:
return
[]
return
[]
"""
"""
...
...
youtube_callback/sftp_id_retrieve.py
View file @
f579279e
...
@@ -3,16 +3,23 @@ Check SFTP dropboxes for YT Video ID XML information
...
@@ -3,16 +3,23 @@ Check SFTP dropboxes for YT Video ID XML information
"""
"""
import
datetime
import
datetime
from
datetime
import
timedelta
import
django
from
django.utils.timezone
import
utc
import
fnmatch
import
fnmatch
import
os
import
os
from
os.path
import
expanduser
import
pysftp
import
shutil
import
shutil
import
sys
import
sys
import
xml.etree.ElementTree
as
ET
import
xml.etree.ElementTree
as
ET
from
datetime
import
timedelta
from
os.path
import
expanduser
import
django
import
pysftp
from
django.utils.timezone
import
utc
from
control.veda_utils
import
ErrorObject
,
Metadata
,
VideoProto
from
control.veda_val
import
VALAPICall
from
frontend.abvid_reporting
import
report_status
from
VEDA_OS01.models
import
URL
,
Encode
,
Video
from
youtube_callback.daemon
import
get_course
project_path
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
project_path
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
if
project_path
not
in
sys
.
path
:
if
project_path
not
in
sys
.
path
:
...
@@ -21,11 +28,6 @@ if project_path not in sys.path:
...
@@ -21,11 +28,6 @@ if project_path not in sys.path:
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'VEDA.settings.local'
)
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'VEDA.settings.local'
)
django
.
setup
()
django
.
setup
()
from
VEDA_OS01.models
import
Video
,
Encode
,
URL
from
frontend.abvid_reporting
import
report_status
from
control.veda_val
import
VALAPICall
from
control.veda_utils
import
ErrorObject
,
Metadata
,
VideoProto
from
youtube_callback.daemon
import
get_course
"""
"""
Defaults:
Defaults:
...
@@ -72,19 +74,16 @@ def xml_downloader(course):
...
@@ -72,19 +74,16 @@ def xml_downloader(course):
cnopts
=
pysftp
.
CnOpts
()
cnopts
=
pysftp
.
CnOpts
()
cnopts
.
hostkeys
=
None
cnopts
.
hostkeys
=
None
try
:
with
pysftp
.
Connection
(
with
pysftp
.
Connection
(
'partnerupload.google.com'
,
'partnerupload.google.com'
,
username
=
course
.
yt_logon
,
username
=
course
.
yt_logon
,
private_key
=
private_key
,
private_key
=
private_key
,
port
=
19321
,
port
=
19321
,
cnopts
=
cnopts
cnopts
=
cnopts
)
as
s1
:
)
as
s1
:
s1
.
timeout
=
60.0
for
d
in
s1
.
listdir_attr
():
for
d
in
s1
.
listdir_attr
():
crawl_sftp
(
d
=
d
,
s1
=
s1
)
crawl_sftp
(
d
=
d
,
s1
=
s1
)
except
:
ErrorObject
.
print_error
(
"Failed Auth: Youtube SFTP"
)
return
None
def
crawl_sftp
(
d
,
s1
):
def
crawl_sftp
(
d
,
s1
):
...
@@ -284,30 +283,25 @@ def urlpatch(upload_data):
...
@@ -284,30 +283,25 @@ def urlpatch(upload_data):
return
None
return
None
if
len
(
encode_list
)
==
0
:
if
len
(
encode_list
)
==
0
:
Video
.
objects
.
filter
(
Video
.
objects
.
filter
(
edx_id
=
upload_data
[
'edx_id'
])
.
update
(
video_trans_status
=
'Complete'
)
edx_id
=
upload_data
[
'edx_id'
]
)
.
update
(
video_trans_status
=
'Complete'
)
val_status
=
'file_complete'
val_status
=
'file_complete'
else
:
else
:
val_status
=
'transcode_active'
val_status
=
'transcode_active'
VAC
=
VALAPICall
(
ApiConn
=
VALAPICall
(
video_proto
=
video_proto
,
video_proto
=
video_proto
,
val_status
=
val_status
,
val_status
=
val_status
,
endpoint_url
=
upload_data
[
'youtube_id'
],
endpoint_url
=
upload_data
[
'youtube_id'
],
encode_profile
=
'youtube'
encode_profile
=
'youtube'
)
)
VAC
.
call
()
ApiConn
.
call
()
elif
upload_data
[
'status'
]
==
'Duplicate'
and
\
elif
upload_data
[
'status'
]
==
'Duplicate'
and
\
upload_data
[
'file_suffix'
]
==
'100'
:
upload_data
[
'file_suffix'
]
==
'100'
:
url_query
=
URL
.
objects
.
filter
(
url_query
=
URL
.
objects
.
filter
(
videoID
=
Video
.
objects
.
filter
(
videoID
=
Video
.
objects
.
filter
(
edx_id
=
test_id
.
edx_id
edx_id
=
upload_data
[
'edx_id'
]
)
.
latest
(),
)
.
latest
(),
encode_profile
=
Encode
.
objects
.
get
(
encode_profile
=
Encode
.
objects
.
get
(
encode_suffix
=
upload_data
[
'file_suffix'
]
encode_suffix
=
upload_data
[
'file_suffix'
]
...
@@ -322,12 +316,7 @@ def urlpatch(upload_data):
...
@@ -322,12 +316,7 @@ def urlpatch(upload_data):
youtube_id
=
''
youtube_id
=
''
)
)
Video
.
objects
.
filter
(
Video
.
objects
.
filter
(
edx_id
=
upload_data
[
'edx_id'
])
.
update
(
video_trans_status
=
'Youtube Duplicate'
)
edx_id
=
upload_data
[
'edx_id'
]
)
.
update
(
video_trans_status
=
'Youtube Duplicate'
)
video_proto
=
VideoProto
(
video_proto
=
VideoProto
(
veda_id
=
test_id
.
edx_id
,
veda_id
=
test_id
.
edx_id
,
val_id
=
test_id
.
studio_id
,
val_id
=
test_id
.
studio_id
,
...
@@ -336,11 +325,10 @@ def urlpatch(upload_data):
...
@@ -336,11 +325,10 @@ def urlpatch(upload_data):
bitrate
=
'0'
,
bitrate
=
'0'
,
s3_filename
=
test_id
.
studio_id
s3_filename
=
test_id
.
studio_id
)
)
ApiConn
=
VALAPICall
(
VAC
=
VALAPICall
(
video_proto
=
video_proto
,
video_proto
=
video_proto
,
val_status
=
"duplicate"
,
val_status
=
"duplicate"
,
endpoint_url
=
"DUPLICATE"
,
endpoint_url
=
"DUPLICATE"
,
encode_profile
=
'youtube'
encode_profile
=
'youtube'
)
)
VAC
.
call
()
ApiConn
.
call
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment