Skip to content

Commit

Permalink
Try locating the django config file relative to the script
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernard Szabo committed Jan 8, 2025
1 parent 50bb3f2 commit 9686b94
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tubular/scripts/dd_synthetic_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,28 @@ def run_synthetic_tests(enable_automated_rollbacks, slack_notification_channel):

try:
synthetic_tests_waffle_flag_name = "TUBULAR_ENABLE_SYNTHETIC_TESTS"
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tubular.envs.production')

# Get the absolute path of the current script
current_script_path = os.path.abspath(__file__)

# Get the directory of the current script
current_dir = os.path.dirname(current_script_path)

# Get the parent directory of the current script's folder
parent_dir = os.path.dirname(current_dir)

# Construct the path to the production settings module
production_settings_path = os.path.join(parent_dir, 'envs', 'production.py')

# Ensure the production settings module exists
if not os.path.exists(production_settings_path):
raise FileNotFoundError(f"Settings module not found: {production_settings_path}")

# Add the parent directory to the Python path
sys.path.insert(0, parent_dir)

# Set the default DJANGO_SETTINGS_MODULE environment variable
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'envs.production')
waffle_flag_enabled = get_setting(synthetic_tests_waffle_flag_name, False)
logging.info(f"{waffle_flag_enabled=}")

Expand Down

0 comments on commit 9686b94

Please sign in to comment.