Permalink
Browse files

Remove some unused code.

Celery and transcription is not currently used, so remove it from the
repository. Can always bring back if we want to use it again.
  • Loading branch information...
1 parent 5d675ef commit 66919aaf2d655ab690f49136a1f09795864395d3 @dracos dracos committed Feb 4, 2014
View
@@ -28,21 +28,6 @@ BASE_PORT: 8000
# be used in the templates.
GOOGLE_ANALYTICS_ACCOUNT: ''
-# AT&T api details
-ATT_OAUTH_URL: ''
-ATT_CLIENT_ID: ''
-ATT_SECRET: ''
-ATT_API_URL: ''
-ATT_TIMEOUT: ''
-
-# Celery
-# 'django://' is the default, using Django's ORM, but is probably not suitable
-# for production, see: http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html#choosing-a-broker
-# for more info
-CELERY_BROKER_URL: 'django://'
-
# Content formatting
# How many characters of speech text to show
SPEECH_SUMMARY_LENGTH: 30
-# Default auto-transcription text
-DEFAULT_TRANSCRIPTION: "This speech could not be transcribed automatically"
@@ -1,257 +0,0 @@
-#!/bin/sh -e
-# ============================================
-# celeryd - Starts the Celery worker daemon.
-# ============================================
-#
-# :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status}
-# :Configuration file: /etc/default/celeryd
-#
-# See http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts
-
-### BEGIN INIT INFO
-# Provides: !!(*= $daemon_name *)!!
-# Required-Start: $network $local_fs $remote_fs
-# Required-Stop: $network $local_fs $remote_fs
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: celery task worker daemon
-### END INIT INFO
-
-#set -e
-
-DEFAULT_PID_FILE="/var/run/celery/%N.pid"
-DEFAULT_LOG_FILE="/var/log/celery/%N.log"
-DEFAULT_LOG_LEVEL="INFO"
-DEFAULT_NODES="celery"
-DEFAULT_CELERYD="-m celery worker --detach"
-
-# /etc/init.d/celeryd: start and stop the celery task worker daemon.
-
-# Don't load celery defaults from /etc/default/celeryd, put them right here
-
-# CELERY_DEFAULTS=${CELERY_DEFAULTS:-"/etc/default/celeryd"}
-
-# test -f "$CELERY_DEFAULTS" && . "$CELERY_DEFAULTS"
-# if [ -f "/etc/default/celeryd" ]; then
-# . /etc/default/celeryd
-# fi
-
-# Daemon name
-NAME=!!(*= $daemon_name *)!!
-
-# Name of nodes to start, here we have a single node
-CELERYD_NODES="w1"
-# or we could have three nodes:
-#CELERYD_NODES="w1 w2 w3"
-
-# Where to chdir at start.
-CELERYD_CHDIR=/data/vhost/!!(*= $vhost *)!!
-
-# Python interpreter from environment.
-ENV_PYTHON="$CELERYD_CHDIR/virtualenv-sayit/bin/python"
-
-# How to call "manage.py celeryd_multi"
-CELERYD_MULTI="$ENV_PYTHON $CELERYD_CHDIR/sayit/manage.py celeryd_multi"
-
-# How to call "manage.py celeryctl"
-CELERYCTL="$ENV_PYTHON $CELERYD_CHDIR/sayit/manage.py celeryctl"
-
-# Extra arguments to celeryd
-CELERYD_OPTS="--time-limit=300 --concurrency=8"
-
-# Name of the celery config module.
-CELERY_CONFIG_MODULE="celeryconfig"
-
-# %n will be replaced with the nodename.
-CELERYD_LOG_FILE="$CELERYD_CHDIR/celery-%n.log"
-CELERYD_PID_FILE="$CELERYD_CHDIR/celery-%n.pid"
-
-# Workers should run as an unprivileged user.
-CELERYD_USER=!!(*= $user *)!!
-
-# We can't get a group explicitly, so just run as the default for the user
-#CELERYD_GROUP="celery"
-
-# Name of the projects settings module.
-export DJANGO_SETTINGS_MODULE="spoke.settings"
-
-# Sets --app argument for CELERY_BIN
-CELERY_APP_ARG=""
-if [ ! -z "$CELERY_APP"]; then
- CELERY_APP_ARG="--app=$CELERY_APP"
-fi
-
-
-# Set CELERY_CREATE_DIRS to always create log/pid dirs.
-CELERY_CREATE_DIRS=${CELERY_CREATE_DIRS:-0}
-CELERY_CREATE_RUNDIR=$CELERY_CREATE_DIRS
-CELERY_CREATE_LOGDIR=$CELERY_CREATE_DIRS
-if [ -z "$CELERYD_PID_FILE" ]; then
- CELERYD_PID_FILE="$DEFAULT_PID_FILE"
- CELERY_CREATE_RUNDIR=1
-fi
-if [ -z "$CELERYD_LOG_FILE" ]; then
- CELERYD_LOG_FILE="$DEFAULT_LOG_FILE"
- CELERY_CREATE_LOGDIR=1
-fi
-
-CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL:-${CELERYD_LOGLEVEL:-$DEFAULT_LOG_LEVEL}}
-CELERY_BIN=${CELERY_BIN:-"celery"}
-CELERYD_MULTI=${CELERYD_MULTI:-"$CELERY_BIN multi"}
-CELERYD=${CELERYD:-$DEFAULT_CELERYD}
-CELERYCTL=${CELERYCTL:=$CELERY_BIN}
-CELERYD_NODES=${CELERYD_NODES:-$DEFAULT_NODES}
-
-export CELERY_LOADER
-
-if [ -n "$2" ]; then
- CELERYD_OPTS="$CELERYD_OPTS $2"
-fi
-
-CELERYD_LOG_DIR=`dirname $CELERYD_LOG_FILE`
-CELERYD_PID_DIR=`dirname $CELERYD_PID_FILE`
-
-# Extra start-stop-daemon options, like user/group.
-if [ -n "$CELERYD_USER" ]; then
- DAEMON_OPTS="$DAEMON_OPTS --uid=$CELERYD_USER"
-fi
-if [ -n "$CELERYD_GROUP" ]; then
- DAEMON_OPTS="$DAEMON_OPTS --gid=$CELERYD_GROUP"
-fi
-
-if [ -n "$CELERYD_CHDIR" ]; then
- DAEMON_OPTS="$DAEMON_OPTS --workdir=\"$CELERYD_CHDIR\""
-fi
-
-
-check_dev_null() {
- if [ ! -c /dev/null ]; then
- echo "/dev/null is not a character device!"
- exit 75 # EX_TEMPFAIL
- fi
-}
-
-
-maybe_die() {
- if [ $? -ne 0 ]; then
- echo "Exiting: $* (errno $?)"
- exit 77 # EX_NOPERM
- fi
-}
-
-create_default_dir() {
- if [ ! -d "$1" ]; then
- echo "- Creating default directory: '$1'"
- mkdir -p "$1"
- maybe_die "Couldn't create directory $1"
- echo "- Changing permissions of '$1' to 02755"
- chmod 02755 "$1"
- maybe_die "Couldn't change permissions for $1"
- if [ -n "$CELERYD_USER" ]; then
- echo "- Changing owner of '$1' to '$CELERYD_USER'"
- chown "$CELERYD_USER" "$1"
- maybe_die "Couldn't change owner of $1"
- fi
- if [ -n "$CELERYD_GROUP" ]; then
- echo "- Changing group of '$1' to '$CELERYD_GROUP'"
- chgrp "$CELERYD_GROUP" "$1"
- maybe_die "Couldn't change group of $1"
- fi
- fi
-}
-
-
-check_paths() {
- if [ $CELERY_CREATE_LOGDIR -eq 1 ]; then
- create_default_dir "$CELERYD_LOG_DIR"
- fi
- if [ $CELERY_CREATE_RUNDIR -eq 1 ]; then
- create_default_dir "$CELERYD_PID_DIR"
- fi
-}
-
-create_paths() {
- create_default_dir "$CELERYD_LOG_DIR"
- create_default_dir "$CELERYD_PID_DIR"
-}
-
-export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
-
-
-stop_workers () {
- $CELERYD_MULTI stopwait $CELERYD_NODES --pidfile="$CELERYD_PID_FILE"
-}
-
-
-start_workers () {
- $CELERYD_MULTI start $CELERYD_NODES $DAEMON_OPTS \
- --pidfile="$CELERYD_PID_FILE" \
- --logfile="$CELERYD_LOG_FILE" \
- --loglevel="$CELERYD_LOG_LEVEL" \
- --cmd="$CELERYD" \
- $CELERY_APP_ARG \
- $CELERYD_OPTS
-}
-
-
-restart_workers () {
- $CELERYD_MULTI restart $CELERYD_NODES $DAEMON_OPTS \
- --pidfile="$CELERYD_PID_FILE" \
- --logfile="$CELERYD_LOG_FILE" \
- --loglevel="$CELERYD_LOG_LEVEL" \
- --cmd="$CELERYD" \
- $CELERY_APP_ARG \
- $CELERYD_OPTS
-}
-
-
-
-case "$1" in
- start)
- check_dev_null
- check_paths
- start_workers
- ;;
-
- stop)
- check_dev_null
- check_paths
- stop_workers
- ;;
-
- reload|force-reload)
- echo "Use restart"
- ;;
-
- status)
- (
- chdir "$CELERYD_CHDIR"
- $CELERYCTL $CELERY_APP_ARG status $CELERYCTL_OPTS
- )
- ;;
-
- restart)
- check_dev_null
- check_paths
- restart_workers
- ;;
- try-restart)
- check_dev_null
- check_paths
- restart_workers
- ;;
- create-paths)
- check_dev_null
- create_paths
- ;;
- check-paths)
- check_dev_null
- check_paths
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME {start|stop|restart|kill|create_paths}"
- exit 64 # EX_USAGE
- ;;
-esac
-
-exit 0
View
@@ -7,6 +7,7 @@ PyYAML
psycopg2
python-memcached
python-dateutil<2
+pytz
### Django related
Django>=1.4.2
@@ -21,10 +22,6 @@ django-pipeline-compass-rubygem
# Only for debugging, but very useful and easiest to just have it here
django-debug-toolbar
-# Celery
-celery
-django-celery
-
# Testing
selenium
mock
View
@@ -483,8 +483,7 @@ def is_public(self):
@property
def summary(self):
summary_length = settings.SPEECH_SUMMARY_LENGTH
- default_transcription = settings.DEFAULT_TRANSCRIPTION
- if self.audio and (not self.text or self.text == default_transcription):
+ if self.audio and not self.text:
return "[ recorded audio ]"
else:
text = strip_tags(self.text)
@@ -567,18 +566,8 @@ def get_previous_speech(self):
return s and s[0] or None
def start_transcribing(self):
- """Kick off a celery task to transcribe this speech"""
- # We only do anything if there's no text already
- if not self.text:
- # If someone is adding a new audio file and there's already a task
- # We need to clear it
- if self.celery_task_id:
- celery.task.control.revoke(self.celery_task_id)
- # Now we can start a new one
- result = speeches.tasks.transcribe_speech.delay(self.id)
- # Finally, we can remember the new task in the model
- self.celery_task_id = result.task_id
- self.save()
+ """In the past, kicked off a celery task to transcribe this speech"""
+ return
# A timestamp of a particular speaker at a particular time.
# Used to record events like "This speaker started speaking at 00:33"
View
@@ -1,55 +0,0 @@
-import tempfile
-import os
-
-from celery import task
-from celery.utils.log import get_task_logger
-
-from django.conf import settings
-
-from speeches.models import Speech
-from speeches.utils import TranscribeHelper, TranscribeException, AudioHelper, AudioException
-
-logger = get_task_logger(__name__)
-
-@task()
-def transcribe_speech(speech_id):
- """Celery task to transcribe the audio for the given speech"""
-
- # Note, we have to catch exceptions to be able to retry them if we want
- # to, at the moment we just give up
- speech = Speech.objects.get(id=speech_id)
- default_transcription = settings.DEFAULT_TRANSCRIPTION
- try:
- # Check speech is ok to be transcribed
- transcribe_helper = TranscribeHelper();
- transcribe_helper.check_speech(speech)
-
- # Convert to wav
- audio_helper = AudioHelper();
- # Make an 8khz version of the audio using ffmpeg
- tmp_filename = None
- try:
- tmp_filename = audio_helper.make_wav(speech.audio.path)
- transcription = transcribe_helper.get_transcription(tmp_filename)
- # Save the result into the DB
- speech.text = transcription
- finally:
- if tmp_filename is not None:
- os.remove(tmp_filename)
-
- return transcription
-
- except (AudioException, TranscribeException, OSError) as e:
- # We could retry here with something like:
-
- # backoff = 2 ** transcribe_speech.request.retries
- # transcribe_speech.retry(exc=e, countdown=backoff)
-
- # But for now we just give up
- if not speech.text:
- speech.text = default_transcription
- finally:
- # Wipe the celery task id and save the speech no matter what happens
- # TODO - would this work in the case of a retry?
- speech.celery_task_id = None
- speech.save()
@@ -145,7 +145,6 @@ def test_add_recording_with_multiple_timestamps(self, filename='lamb.mp3'):
else:
self.assertEquals(speech.end_date, expected_timestamps[i+1].date())
self.assertEquals(speech.end_time, expected_timestamps[i+1].time())
- self.assertIsNotNone(speech.celery_task_id)
self.assertIsNotNone(speech.audio.path)
self.assertRegexpMatches(speech.audio.path, r'\.mp3$')
self.assertEquals(speech, ordered_timestamps[i].speech)
Oops, something went wrong.

0 comments on commit 66919aa

Please sign in to comment.