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

feat: csv loader updates for multi course runs of External LOBs #4177

Merged
merged 1 commit into from
Nov 27, 2023

Conversation

AfaqShuaib09
Copy link
Contributor

@AfaqShuaib09 AfaqShuaib09 commented Nov 10, 2023

PROD-3741

This PR adds CSV Loader updates to support multi course runs in case of external LOBs.

Details:

A New Course Run will be created if none of the existing active run have same start & end date or same variantId coming from the CSV. Otherwise it will pick the existing run and update course run in it. To enable editing of variant_id, we need to enable waffle switch from django admin is_course_run_variant_id_editiable

Testing Instruction:

Run ingest_getsmarter_data on local by setting GET_SMARTER_CREDENTIALS in private.py.

  1. Go to django admin and create waffle switch course_metadata.is_course_run_variant_id_editable with active value.
  2. Setup following credentials dict in private.py for ingest_getsmarter_data cmd.
GETSMARTER_CLIENT_CREDENTIALS = {
    'CLIENT_ID' : '{id}',
    'CLIENT_SECRET' : '{secret_key}',
    'API_URL' : 'https://test-enterprise.getsmarter.test.com/api/v1',
    'PROVIDER_URL' : 'https://auth-test-enterprise.getsmarter.test.com',
    'PRODUCTS_DETAILS_URL' : 'https://test-enterprise.getsmarter.com/api/v1/products',
}
  1. Run ingest_getsmarter_data mgmt cmd
./manage.py ingest_getsmarter_data --product_source=2u

@AfaqShuaib09 AfaqShuaib09 marked this pull request as draft November 10, 2023 09:27
@AfaqShuaib09 AfaqShuaib09 marked this pull request as ready for review November 15, 2023 20:36
Copy link
Contributor

@DawoudSheraz DawoudSheraz left a comment

Choose a reason for hiding this comment

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

Tested locally on small set of CSV, looks good.

  • Ingested CSV, first row was going to create variant and it did.
  • Re-run csv, no new variants
  • Changed first row to create new variant (variant id change + start/end date change).
  • Loader run created variant

Copy link
Contributor

@Ali-D-Akbar Ali-D-Akbar left a comment

Choose a reason for hiding this comment

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

A bunch of comments to address. Looks good to me otherwise.

Comment on lines +327 to +332
if not course_run and is_course_run_created:
course_run = CourseRun.objects.filter_drafts(course=course).order_by('created').last()
return course_run, is_course_run_created
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just move this inside the try block? Seems redundant to add a separate check later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup we can move it to try block, but it will become unrelated there because it can't raise an exception

Comment on lines +318 to +322
if hasattr(exc, 'response'):
exception_message = exc.response.content.decode('utf-8')
Copy link
Contributor

Choose a reason for hiding this comment

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

Do this instead:
exception_message = getattr(exc, 'response', str(exc).encode('utf-8'))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AfaqShuaib09 AfaqShuaib09 merged commit e2c8b3e into master Nov 27, 2023
13 checks passed
@AfaqShuaib09 AfaqShuaib09 deleted the afaq/prod_3741 branch November 27, 2023 12:31
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.

4 participants