Skip to content

Commit

Permalink
Enhance dependency management: add 'github' to critical dependencies …
Browse files Browse the repository at this point in the history
…in app.py and lambda_setup.py, ensuring proper installation and verification during Lambda setup
  • Loading branch information
Your Name committed May 12, 2025
1 parent 02fa8ce commit ba558d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
sys.path.insert(0, path)

# Fallback check for critical dependencies
for module in ['pydantic', 'jinja2']:
for module in ['pydantic', 'jinja2', 'github']:
try:
importlib.import_module(module)
except ImportError:
Expand Down
13 changes: 9 additions & 4 deletions scripts/lambda_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ def install_dependencies():

# Explicitly install critical dependencies
print("=== Explicitly installing critical dependencies ===")
run_command(f"pip3 install --no-cache-dir pydantic jinja2 -t {LAMBDA_TASK_ROOT}")
run_command(f"pip3 install --no-cache-dir pydantic jinja2 PyGithub -t {LAMBDA_TASK_ROOT}")

# Create a .pth file to ensure the Lambda runtime can find the packages
with open(f"{LAMBDA_TASK_ROOT}/lambda_path.pth", "w") as f:
f.write(f"{LAMBDA_TASK_ROOT}\n")

print("=== Installing package in development mode ===")
run_command(f"pip3 install --no-cache-dir -e {TMP_DIR} -t {LAMBDA_TASK_ROOT}")
run_command(f"pip3 install --no-cache-dir -e {TMP_DIR} -t {LAMBDA_TASK_ROOT} -v")

def verify_dependencies():
"""Verify that key dependencies are installed correctly"""
Expand All @@ -63,7 +63,7 @@ def verify_dependencies():
run_command("python3 -c 'import sys; print(sys.path)'")

# Check key dependencies
dependencies = ['pydantic', 'jinja2'] # Add critical dependencies here
dependencies = ['pydantic', 'jinja2', 'github'] # Add critical dependencies here
with open(f"{TMP_DIR}/requirements.txt") as f:
for line in f:
line = line.strip()
Expand Down Expand Up @@ -113,7 +113,7 @@ def setup_lambda_environment():
run_command(f"ls -la {LAMBDA_TASK_ROOT}")
run_command(f"ls -la {LAMBDA_TASK_ROOT}/template_automation")

# Final check - try to import jinja2 and pydantic from the Lambda environment
# Final check - try to import critical modules from the Lambda environment
print("=== Testing key imports from Lambda environment ===")
test_import = """
import sys
Expand All @@ -128,6 +128,11 @@ def setup_lambda_environment():
print("jinja2 successfully imported:", jinja2.__file__)
except ImportError as e:
print("Error importing jinja2:", str(e))
try:
import github
print("github successfully imported:", github.__file__)
except ImportError as e:
print("Error importing github:", str(e))
"""
with open(f"{LAMBDA_TASK_ROOT}/test_imports.py", "w") as f:
f.write(test_import)
Expand Down

0 comments on commit ba558d8

Please sign in to comment.