Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added logs while importing course #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

muhammadadeeltajamul
Copy link
Owner

Added logs near course validation in course import.

@@ -526,9 +526,11 @@ def get_dir_for_filename(directory, filename):
return

if not user_has_access(user):
logging.info(f'Course import {course_key_string}: User is not allowed to import')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is required.

return

if not file_is_supported():
logging.info(f'Course import {course_key_string}: File not supported')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is required.

@@ -737,14 +739,18 @@ def validate_course_olx(courselike_key, course_dir, status):
if not course_import_olx_validation_is_enabled():
return olx_is_valid
try:
if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3":
logging.info(log_prefix + "Validating. Calling olxcleaner.validate")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is log_prefix here?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default prefix they are using in every log of this function. This string is equal to f"Course import {courselike_key}"

if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3":
logging.info(log_prefix + "Course validated. No errors")
except Exception as e: # pylint: disable=broad-except
LOGGER.exception(f'{log_prefix}: CourseOlx could not be validated' + str(e))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOGGER.exception automatically prints the stack trace so I don't think `str(e) is needed here.

@@ -13,9 +13,11 @@ def monitor_import_failure(course_key, import_step, message=None, exception=None
"""
set_custom_attribute('course_import_failure', import_step)
set_custom_attributes_for_course_key(course_key)
logging.info(f"Course import failed at step {import_step} for course with key {course_key}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't these also be behind the course key condition?

Copy link

@saadyousafarbi saadyousafarbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a prefix of Investigation Log: to all the conditional logs we are adding, so other developers have an idea of why these logs have been added!

@@ -743,7 +743,7 @@ def validate_course_olx(courselike_key, course_dir, status):
ignore=settings.COURSE_OLX_VALIDATION_IGNORE_LIST,
allowed_xblocks=ALL_ALLOWED_XBLOCKS
)
except Exception: # pylint: disable=broad-except
except Exception as e: # pylint: disable=broad-except

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this changed?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added "as e" after Exception to print it. Awais bhai told me LOGGER.Exception prints exception. Restored old code.

Comment on lines 384 to 385
if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3":
logging.info(f"Investigation Log: {target_course_id} : Course Descriptor is None")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be part of the if course_descriptor is None: block. the logs should be immediately after the finally: block.

logging.info(f"Investigation Log: {target_course_id} : {course_descriptor} ") something like this.

@@ -522,6 +525,8 @@ def get_policy(usage_id):
course_descriptor = system.process_xml(etree.tostring(course_data, encoding='unicode'))
# If we fail to load the course, then skip the rest of the loading steps
if isinstance(course_descriptor, ErrorBlock):
if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3":
logging.info(f"Investigation Log: {target_course_id} : Course Descriptor is instance of ErrorBlock")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see single quotes here in this file, please use single quotes here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants