Skip to content

fix(git-auto-export): Start export only if GIT_URL exists in the course settings #495

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

marslanabdulrauf
Copy link
Contributor

@marslanabdulrauf marslanabdulrauf commented May 7, 2025

What are the relevant tickets?

https://github.com/mitodl/hq/issues/6803

Description (What does it do?)

This PR:

  1. Start course export on publish only when giturl exists

How can this be tested?

  1. Checkout to this branch
  2. Create installable package by following the instructions in Readme file
  3. Install the package in edX.
  4. Create a course in studio and make sure giturl value is set to empty or null in course advance settings
  5. Publish the course
  6. Keep an eye on logs -- you should see Course {course_key} does not have a giturl, skipping export. instead of error saying 'NoneType' object has no attribute 'endswith'

@marslanabdulrauf marslanabdulrauf changed the title fix: only start export if giturl exists Only start export if giturl exists May 7, 2025
@arslanashraf7 arslanashraf7 self-assigned this May 8, 2025
Copy link
Contributor

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

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

I left some inline comment.

Along with these inline comments I have some other thoughts too which I came across setting this plugin up after a long time.

  1. The default path for GIT_REPO_EXPORT_DIR is set to /edx/var/edxapp/export_course_repos, which does not work by default with Tutor and this was the first step installation failed for me. A more suitable path with tutor will be openedx/course_repos because it works with Tutor. I tried and it works because openedx is mounted into the container.
  2. While working on point/1 I would recommend checking the settings set for GIT_REPO_EXPORT_DIR in https://github.com/mitodl/ol-infrastructure because if that is using a default path anywhere then this change will break a few things because we are not using Tutor for our deployments yet. It would be ideal if the infrastructure uses a custom path for GIT_REPO_EXPORT_DIR.
  3. Additionally, With this new check in place, the task will still start and stop right away if there is no Git URL. An optimization could be to place this check in signals.py because why start a celery task when we already know that it will stop right away.
  4. You will also need to bump the version in BUILD file.

Additionally, based on @pdpinch 's comment https://github.com/mitodl/hq/issues/6803#issuecomment-2741336346 where he wanted to create the repo automatically and have the Github URL set (Not in the advanced setting but our own mapping table). But, We are probably not going towards that approach at the moment we are not going towards that approach in favor of #492

@@ -15,6 +15,13 @@ def async_export_to_git(course_key_string, user=None):
course_key = CourseKey.from_string(course_key_string)
course_module = modulestore().get_course(course_key)

if course_module.giturl is None:
LOGGER.debug(
"Course %s does not have a giturl, skipping export.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Course %s does not have a giturl, skipping export.",
"Course %s does not have a GIT URL set in course advanced settings, skipping auto export.",

@@ -15,6 +15,13 @@ def async_export_to_git(course_key_string, user=None):
course_key = CourseKey.from_string(course_key_string)
course_module = modulestore().get_course(course_key)

if course_module.giturl is None:
LOGGER.debug(
Copy link
Contributor

Choose a reason for hiding this comment

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

We should log this as info and not debug. These logs from the tasks do not show on the terminal when debug is used. Also, Debug will be false in live deployments. I do not know how you were able to see and verify these logs as you mentioned in the PR description.

fix: default git export directory path updated
@marslanabdulrauf
Copy link
Contributor Author

I did a basic search in ol-infrastructur and they are using /openedx/data/export_course_repos which is safe.

@marslanabdulrauf marslanabdulrauf changed the title Only start export if giturl exists Only start export if giturl exists -- ol_openedx_git_auto_export May 13, 2025
@arslanashraf7 arslanashraf7 changed the title Only start export if giturl exists -- ol_openedx_git_auto_export chore(git-auto-export): Start export only if GIT_URL exists in the course settings May 15, 2025
@arslanashraf7 arslanashraf7 changed the title chore(git-auto-export): Start export only if GIT_URL exists in the course settings fix(git-auto-export): Start export only if GIT_URL exists in the course settings May 15, 2025
Copy link
Contributor

@arslanashraf7 arslanashraf7 left a comment

Choose a reason for hiding this comment

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

👍

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

Successfully merging this pull request may close these issues.

2 participants