openedx.core.djangoapps.content.course_overviews.management.commands package#

Submodules#

openedx.core.djangoapps.content.course_overviews.management.commands.backfill_history module#

Management command to backfill history.

class openedx.core.djangoapps.content.course_overviews.management.commands.backfill_history.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Backfill history for models using django-simple-history. Example usage: $ ./manage.py lms backfill_history –batch_size 1000 –sleep_between 1 –input_root /tmp/data/ –settings=devstack

DATE = '2019-06-29'#
DEFAULT_SIZE = 1000#
DEFAULT_SLEEP_BETWEEN_INSERTS = 1#
HISTORY_CHANGE_REASON = 'initial history population'#
HISTORY_USER_ID = None#
TABLES = [{'exclude_column': None, 'input_filename': 'course_modes_coursemode_2019-06-29', 'name': 'course_modes_coursemode'}]#
add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

chunks(ids, chunk_size)#
handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

help = 'Populates the historical records with snapshot data.'#
replace_values(values, original, replacement)#

openedx.core.djangoapps.content.course_overviews.management.commands.generate_course_overview module#

Command to load course overviews.

class openedx.core.djangoapps.content.course_overviews.management.commands.generate_course_overview.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Example usage:

$ ./manage.py lms generate_course_overview –all-courses –settings=devstack –chunk-size=100 $ ./manage.py lms generate_course_overview ‘edX/DemoX/Demo_Course’ –settings=devstack

add_arguments(parser)#

Add arguments to the command parser.

args = '<course_id course_id ...>'#
handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

help = 'Generates and stores course overview for one or more courses.'#

openedx.core.djangoapps.content.course_overviews.management.commands.simulate_publish module#

Many apps in the LMS maintain their own optimized data structures that they update whenever a course publish is detected. To do this, they listen for the SignalHandler.course_published signal. Sometimes we want to rebuild the data on these apps regardless of an actual change in course content, either to recover from a bug or to bootstrap a new app we’re rolling out for the first time. To date, each app has implemented its own management command for this kind of bootstrapping work (e.g. generate_course_overviews, generate_course_blocks).

This management command will emit the SignalHandler.course_published signal for some subset of courses and signal listeners, and then rely on existing listener behavior to trigger the necessary data updates.

class openedx.core.djangoapps.content.course_overviews.management.commands.simulate_publish.Command(stdout=None, stderr=None, no_color=False, force_color=False)#

Bases: BaseCommand

Example usage:

# Send the course_published signal to all listeners and courses with 10 # seconds between courses. We might use a delay like this to make sure we # don’t flood the queue and unnecessarily delay normal publishing via # Studio. $ ./manage.py lms –settings=devstack_docker simulate_publish –delay 10

# Find all available listeners $ ./manage.py lms –settings=devstack_docker simulate_publish –show_receivers

# Send the publish signal to two courses and two listeners $ ./manage.py lms –settings=devstack_docker simulate_publish –receivers openedx.core.djangoapps.content.course_overviews.signals._listen_for_course_publish openedx.core.djangoapps.bookmarks.signals.trigger_update_xblocks_cache_task –courses course-v1:edX+DemoX+Demo_Course edX/MODULESTORE_100/2018

A Dry Run will produce output that looks like:

DRY-RUN: This command would have sent course_published to… 1 Receivers:

openedx.core.djangoapps.content.course_overviews.signals._listen_for_course_publish

27 Courses:

course-v1:DEV_153+A2E_CHINESE+JAN2018 course-v1:edX+100+MITPhysics course-v1:edX+DemoX+Demo_Course course-v1:edX+E2E-101+course course-v1:edX+MEMORY+2018 course-v1:edX+MK101+2018 edX/MODULESTORE_100/2018_1 edX/MODULESTORE_100/2018_2 edX/MODULESTORE_100/2018_3 edX/MODULESTORE_100/2018_4 (+ 17 more)

add_arguments(parser)#

Entry point for subclassed commands to add custom arguments.

course_published_signal = SwitchedSignal('course_published')#
get_args_from_database()#

Returns an options dictionary from the current SimulateCoursePublishConfig model.

get_course_keys(courses)#

Return a list of CourseKeys that we will emit signals to.

courses is an optional list of strings that can be parsed into CourseKeys. If courses is empty or None, we will default to returning all courses in the modulestore (which can be very expensive). If one of the strings passed in the list for courses does not parse correctly, it is a fatal error and will cause us to exit the entire process.

handle(*args, **options)#

The actual logic of the command. Subclasses must implement this method.

help = 'Simulate course publish signals without actually modifying course content. This command is useful for triggering various async tasks that listen for course_published signals.'#
modify_receivers(receiver_names, skip_ccx)#

Modify our signal to only have the user-specified receivers.

This method modifies the process global SignalHandler.course_published to disconnect any receivers that were not in the receiver_names list. If any of the receiver_names is not found (i.e. is not in the list of receivers printed in self.print_show_receivers), it is a fatal error and we will exit the process.

print_dry_run(course_keys)#

Give a preview of what courses and signals we will emit to.

print_show_receivers()#

Print receivers with accompanying docstrings for context.

openedx.core.djangoapps.content.course_overviews.management.commands.simulate_publish.get_receiver_fns()#

Return the list of active receiver functions.

openedx.core.djangoapps.content.course_overviews.management.commands.simulate_publish.get_receiver_names()#

Return an unordered set of receiver names (full.module.path.function)

openedx.core.djangoapps.content.course_overviews.management.commands.simulate_publish.name_from_fn(fn)#

Human readable module.function name.

Module contents#