Commit 8211311b by Gregory Martin Committed by GitHub

Merge pull request #23 from edx/yro/refactor_newrelic

Eliminate NR decorators
parents 82cf064f 9efbc408
...@@ -25,7 +25,6 @@ class DeliverCli: ...@@ -25,7 +25,6 @@ class DeliverCli:
os.path.abspath(__file__) os.path.abspath(__file__)
)) ))
self.auth_yaml = os.path.join(self.ROOT_DIR, 'instance_config.yaml') self.auth_yaml = os.path.join(self.ROOT_DIR, 'instance_config.yaml')
self.new_relic_config = os.path.join(self.ROOT_DIR, 'veda_newrelic.ini')
self.celery_daemon = os.path.join(self.ROOT_DIR, 'control', 'celeryapp.py') self.celery_daemon = os.path.join(self.ROOT_DIR, 'control', 'celeryapp.py')
def get_args(self): def get_args(self):
...@@ -62,8 +61,7 @@ class DeliverCli: ...@@ -62,8 +61,7 @@ class DeliverCli:
if auth_dict is not None: if auth_dict is not None:
os.system( os.system(
' '.join(( ' '.join((
'NEW_RELIC_CONFIG_FILE=' + self.new_relic_config, 'python',
'newrelic-admin run-program python',
self.celery_daemon, self.celery_daemon,
'worker', 'worker',
'--loglevel=info', '--loglevel=info',
......
...@@ -10,15 +10,8 @@ from os.path import expanduser ...@@ -10,15 +10,8 @@ from os.path import expanduser
import requests import requests
import datetime import datetime
import ftplib import ftplib
import newrelic.agent
import shutil import shutil
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
try: try:
boto.config.add_section('Boto') boto.config.add_section('Boto')
...@@ -84,7 +77,6 @@ class VedaDelivery: ...@@ -84,7 +77,6 @@ class VedaDelivery:
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
return None return None
@newrelic.agent.background_task()
def run(self): def run(self):
""" """
Check the destination, route via available methods, Check the destination, route via available methods,
......
...@@ -4,7 +4,6 @@ import sys ...@@ -4,7 +4,6 @@ import sys
import django import django
import yaml import yaml
import uuid import uuid
import newrelic.agent
""" """
...@@ -16,13 +15,6 @@ Get a list of needed encodes from VEDA ...@@ -16,13 +15,6 @@ Get a list of needed encodes from VEDA
from control_env import * from control_env import *
from dependencies.shotgun_api3 import Shotgun from dependencies.shotgun_api3 import Shotgun
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
class VedaEncode(): class VedaEncode():
...@@ -62,7 +54,6 @@ class VedaEncode(): ...@@ -62,7 +54,6 @@ class VedaEncode():
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
return None return None
@newrelic.agent.background_task()
def determine_encodes(self): def determine_encodes(self):
self.match_profiles() self.match_profiles()
......
...@@ -3,7 +3,6 @@ import os.path ...@@ -3,7 +3,6 @@ import os.path
import boto import boto
import boto.s3 import boto.s3
from boto.exception import S3ResponseError, S3DataError from boto.exception import S3ResponseError, S3DataError
import newrelic.agent
import yaml import yaml
try: try:
...@@ -12,12 +11,6 @@ except: ...@@ -12,12 +11,6 @@ except:
pass pass
boto.config.set('Boto', 'http_socket_timeout', '100') boto.config.set('Boto', 'http_socket_timeout', '100')
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
""" """
multi-point videofile discovery multi-point videofile discovery
Currently: Currently:
...@@ -61,7 +54,6 @@ class FileDiscovery(object): ...@@ -61,7 +54,6 @@ class FileDiscovery(object):
self.ftp_faillog = "/Users/Shared/edX1/LG/FailedTransfers.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)
@newrelic.agent.background_task()
def about_video_ingest(self): def about_video_ingest(self):
""" """
Crawl VEDA Upload bucket Crawl VEDA Upload bucket
...@@ -136,7 +128,6 @@ class FileDiscovery(object): ...@@ -136,7 +128,6 @@ class FileDiscovery(object):
reset_queries() reset_queries()
@newrelic.agent.background_task()
def studio_s3_ingest(self): def studio_s3_ingest(self):
""" """
Ingest files from studio upload endpoint Ingest files from studio upload endpoint
......
...@@ -12,14 +12,7 @@ from django.db import reset_queries ...@@ -12,14 +12,7 @@ from django.db import reset_queries
import uuid import uuid
import yaml import yaml
import hashlib import hashlib
import newrelic.agent
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
""" """
Discovered file ingest/insert/job triggering Discovered file ingest/insert/job triggering
...@@ -111,7 +104,6 @@ class VedaIngest: ...@@ -111,7 +104,6 @@ class VedaIngest:
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
return None return None
@newrelic.agent.background_task()
def insert(self): def insert(self):
""" """
NOTE: NOTE:
...@@ -245,7 +237,6 @@ class VedaIngest: ...@@ -245,7 +237,6 @@ class VedaIngest:
else: else:
self.video_proto.resolution = '1920x1080' self.video_proto.resolution = '1920x1080'
@newrelic.agent.background_task()
def database_record(self): def database_record(self):
""" """
Start DB Inserts, Get Information Start DB Inserts, Get Information
...@@ -393,7 +384,6 @@ class VedaIngest: ...@@ -393,7 +384,6 @@ class VedaIngest:
) )
VAC.call() VAC.call()
@newrelic.agent.background_task()
def abvid_report(self): def abvid_report(self):
if self.video_proto.abvid_serial is None: if self.video_proto.abvid_serial is None:
return None return None
...@@ -406,7 +396,6 @@ class VedaIngest: ...@@ -406,7 +396,6 @@ class VedaIngest:
R.upload_status() R.upload_status()
self.complete = True self.complete = True
@newrelic.agent.background_task()
def rename(self): def rename(self):
""" """
Rename to VEDA ID, Rename to VEDA ID,
......
...@@ -6,14 +6,6 @@ from datetime import timedelta ...@@ -6,14 +6,6 @@ from datetime import timedelta
import yaml import yaml
import uuid import uuid
import newrelic.agent
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
""" """
Heal Process Heal Process
...@@ -76,7 +68,6 @@ class VedaHeal(): ...@@ -76,7 +68,6 @@ class VedaHeal():
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
return None return None
@newrelic.agent.background_task()
def discovery(self): def discovery(self):
self.video_query = Video.objects.filter( self.video_query = Video.objects.filter(
video_trans_start__lt=self.current_time - timedelta( video_trans_start__lt=self.current_time - timedelta(
...@@ -122,7 +113,6 @@ class VedaHeal(): ...@@ -122,7 +113,6 @@ class VedaHeal():
queue=cel_queue queue=cel_queue
) )
@newrelic.agent.background_task()
def determine_fault(self, video_object): def determine_fault(self, video_object):
""" """
Is there anything to do with this? Is there anything to do with this?
...@@ -222,7 +212,6 @@ class VedaHeal(): ...@@ -222,7 +212,6 @@ class VedaHeal():
self.val_status = 'transcode_queue' self.val_status = 'transcode_queue'
return encode_list return encode_list
@newrelic.agent.background_task()
def purge(self): def purge(self):
""" """
Purge Work Directory Purge Work Directory
......
...@@ -8,7 +8,6 @@ import yaml ...@@ -8,7 +8,6 @@ import yaml
import boto.s3 import boto.s3
from boto.s3.key import Key from boto.s3.key import Key
from boto.exception import S3ResponseError from boto.exception import S3ResponseError
import newrelic.agent
from os.path import expanduser from os.path import expanduser
from veda_utils import ErrorObject from veda_utils import ErrorObject
...@@ -19,12 +18,6 @@ except: ...@@ -19,12 +18,6 @@ except:
pass pass
boto.config.set('Boto', 'http_socket_timeout', '100') boto.config.set('Boto', 'http_socket_timeout', '100')
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
homedir = expanduser("~") homedir = expanduser("~")
...@@ -62,7 +55,6 @@ class Hotstore(object): ...@@ -62,7 +55,6 @@ class Hotstore(object):
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
return None return None
@newrelic.agent.background_task()
def upload(self): def upload(self):
if self.auth_dict is None: if self.auth_dict is None:
return False return False
......
...@@ -6,14 +6,7 @@ import datetime ...@@ -6,14 +6,7 @@ import datetime
import boto.ses import boto.ses
import hashlib import hashlib
import subprocess import subprocess
import newrelic.agent
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
""" """
Let's do some quick and dirty error handling & logging Let's do some quick and dirty error handling & logging
...@@ -50,7 +43,6 @@ class EmailAlert(): ...@@ -50,7 +43,6 @@ class EmailAlert():
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
return None return None
@newrelic.agent.background_task()
def email(self): def email(self):
email_subject = '[ VEDA ALERTING ]' email_subject = '[ VEDA ALERTING ]'
email_subject += ' : ' + self.subject email_subject += ' : ' + self.subject
...@@ -165,7 +157,6 @@ class Report(): ...@@ -165,7 +157,6 @@ class Report():
except yaml.YAMLError as exc: except yaml.YAMLError as exc:
return None return None
@newrelic.agent.background_task()
def upload_status(self): def upload_status(self):
if self.upload_serial is None: if self.upload_serial is None:
return None return None
...@@ -286,7 +277,6 @@ class Metadata(): ...@@ -286,7 +277,6 @@ class Metadata():
self.freezing_bug = False self.freezing_bug = False
self.val_status = None self.val_status = None
@newrelic.agent.background_task()
def _METADATA(self): def _METADATA(self):
""" """
use st filesize for filesize use st filesize for filesize
...@@ -324,7 +314,6 @@ class Metadata(): ...@@ -324,7 +314,6 @@ class Metadata():
if self.video_proto.resolution is None: if self.video_proto.resolution is None:
self.video_proto.resolution = vid_breakout[3].strip() self.video_proto.resolution = vid_breakout[3].strip()
@newrelic.agent.background_task()
def _FAULT(self, video_object): def _FAULT(self, video_object):
if self.video_object is None: if self.video_object is None:
return [] return []
......
...@@ -6,16 +6,9 @@ import ast ...@@ -6,16 +6,9 @@ import ast
import json import json
import datetime import datetime
import yaml import yaml
import newrelic.agent
requests.packages.urllib3.disable_warnings() requests.packages.urllib3.disable_warnings()
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
""" """
Send data to VAL, either Video ID data or endpoint URLs Send data to VAL, either Video ID data or endpoint URLs
...@@ -69,7 +62,6 @@ class VALAPICall(): ...@@ -69,7 +62,6 @@ class VALAPICall():
) )
self.auth_dict = self._AUTH() self.auth_dict = self._AUTH()
@newrelic.agent.background_task()
def call(self): def call(self):
if self.auth_dict is None: if self.auth_dict is None:
print 'No AUTH' print 'No AUTH'
...@@ -102,7 +94,6 @@ class VALAPICall(): ...@@ -102,7 +94,6 @@ class VALAPICall():
) )
return None return None
@newrelic.agent.background_task()
def val_tokengen(self): def val_tokengen(self):
""" """
Generate a API token for VAL Generate a API token for VAL
......
...@@ -4,14 +4,6 @@ import sys ...@@ -4,14 +4,6 @@ import sys
import subprocess import subprocess
import fnmatch import fnmatch
import django import django
import newrelic.agent
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
""" """
VEDA Intake/Product Final Testing Suite VEDA Intake/Product Final Testing Suite
...@@ -43,7 +35,6 @@ class Validation(): ...@@ -43,7 +35,6 @@ class Validation():
seconds_duration = (((hours * 60) + minutes) * 60) + seconds seconds_duration = (((hours * 60) + minutes) * 60) + seconds
return seconds_duration return seconds_duration
@newrelic.agent.background_task()
def validate(self): def validate(self):
""" """
Test #1 - assumes file is in 'work' directory of node Test #1 - assumes file is in 'work' directory of node
......
...@@ -7,7 +7,6 @@ import sys ...@@ -7,7 +7,6 @@ import sys
import datetime import datetime
from datetime import timedelta from datetime import timedelta
import django import django
import newrelic.agent
from django.utils.timezone import utc from django.utils.timezone import utc
...@@ -24,13 +23,6 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'VEDA.settings' ...@@ -24,13 +23,6 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'VEDA.settings'
django.setup() django.setup()
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
""" """
Defaults Defaults
""" """
...@@ -46,7 +38,6 @@ def get_course(course_id): ...@@ -46,7 +38,6 @@ def get_course(course_id):
return course return course
@newrelic.agent.background_task()
def generate_course_list(): def generate_course_list():
course_list = [] course_list = []
...@@ -79,7 +70,6 @@ def generate_course_list(): ...@@ -79,7 +70,6 @@ def generate_course_list():
return course_list return course_list
@newrelic.agent.background_task()
def weed_dupes(course_list, course): def weed_dupes(course_list, course):
for c in course_list: for c in course_list:
if c.yt_logon == course.yt_logon: if c.yt_logon == course.yt_logon:
...@@ -87,7 +77,6 @@ def weed_dupes(course_list, course): ...@@ -87,7 +77,6 @@ def weed_dupes(course_list, course):
return True return True
@newrelic.agent.background_task()
def determine_missing_url(course_object): def determine_missing_url(course_object):
video_query = Video.objects.filter( video_query = Video.objects.filter(
......
...@@ -7,7 +7,6 @@ from datetime import timedelta ...@@ -7,7 +7,6 @@ from datetime import timedelta
import django import django
from django.utils.timezone import utc from django.utils.timezone import utc
import fnmatch import fnmatch
import newrelic.agent
import os import os
from os.path import expanduser from os.path import expanduser
import pysftp import pysftp
...@@ -27,13 +26,6 @@ from control.veda_val import VALAPICall ...@@ -27,13 +26,6 @@ from control.veda_val import VALAPICall
from control.veda_utils import ErrorObject, Metadata, VideoProto from control.veda_utils import ErrorObject, Metadata, VideoProto
from youtube_callback.daemon import get_course from youtube_callback.daemon import get_course
newrelic.agent.initialize(
os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'veda_newrelic.ini'
)
)
""" """
Defaults: Defaults:
""" """
...@@ -42,7 +34,6 @@ workdir = os.path.join(homedir, 'download_data_holding') ...@@ -42,7 +34,6 @@ workdir = os.path.join(homedir, 'download_data_holding')
YOUTUBE_LOOKBACK_DAYS = 15 YOUTUBE_LOOKBACK_DAYS = 15
@newrelic.agent.background_task()
def callfunction(course): def callfunction(course):
""" """
...@@ -64,7 +55,6 @@ def callfunction(course): ...@@ -64,7 +55,6 @@ def callfunction(course):
urlpatch(upload_data) urlpatch(upload_data)
@newrelic.agent.background_task()
def xml_downloader(course): def xml_downloader(course):
""" """
...@@ -96,7 +86,6 @@ def xml_downloader(course): ...@@ -96,7 +86,6 @@ def xml_downloader(course):
return None return None
@newrelic.agent.background_task()
def crawl_sftp(d, s1): def crawl_sftp(d, s1):
""" """
crawl the sftp dir and dl the XML files for parsing crawl the sftp dir and dl the XML files for parsing
...@@ -147,7 +136,6 @@ def crawl_sftp(d, s1): ...@@ -147,7 +136,6 @@ def crawl_sftp(d, s1):
s1.cwd('..') s1.cwd('..')
@newrelic.agent.background_task()
def domxml_parser(file): def domxml_parser(file):
""" """
...@@ -209,7 +197,6 @@ def domxml_parser(file): ...@@ -209,7 +197,6 @@ def domxml_parser(file):
return upload_data return upload_data
@newrelic.agent.background_task()
def urlpatch(upload_data): def urlpatch(upload_data):
""" """
......
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