-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbackpopulate_oll_files.py
47 lines (40 loc) · 1.58 KB
/
backpopulate_oll_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""Management command for populating OLL course run file data"""
from django.core.management import BaseCommand
from learning_resources.tasks import import_all_oll_files
from main import settings
from main.utils import now_in_utc
class Command(BaseCommand):
"""Populate OLL course run files"""
help = "Populate OLL course run files"
def add_arguments(self, parser):
parser.add_argument(
"-c",
"--chunk-size",
dest="chunk_size",
default=settings.LEARNING_COURSE_ITERATOR_CHUNK_SIZE,
type=int,
help="Chunk size for batch import task",
)
parser.add_argument(
"--overwrite",
dest="force_overwrite",
action="store_true",
help="Overwrite any existing records",
)
def handle(self, *args, **options): # noqa: ARG002
"""Run Populate OLL course run files"""
if not settings.OLL_LEARNING_COURSE_BUCKET_NAME:
self.stderr.write("OLL contentfile settings not configured, skipping")
return
chunk_size = options["chunk_size"]
task = import_all_oll_files.delay(
chunk_size=chunk_size, overwrite=options["force_overwrite"]
)
self.stdout.write(f"Started task {task} to get OLL course run file data")
self.stdout.write("Waiting on task...")
start = now_in_utc()
task.get()
total_seconds = (now_in_utc() - start).total_seconds()
self.stdout.write(
f"Population of OLL file data finished, took {total_seconds} seconds"
)