Skip to content

Commit 6cfa119

Browse files
Comment out backup, format, clean-up
1 parent 74b0f84 commit 6cfa119

File tree

3 files changed

+85
-51
lines changed

3 files changed

+85
-51
lines changed

.devcontainer/configure-azure-mount.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ def get_user_choice() -> str:
7373
# Check if we're in a non-interactive environment (like GitHub Codespaces automation)
7474
if not sys.stdin.isatty() or os.environ.get('CODESPACES') == 'true':
7575
print("\nNon-interactive environment detected (GitHub Codespaces).")
76-
print("Automatically selecting option 2 (manual login) as the most reliable choice.")
77-
print("You can reconfigure later by running this script manually.")
76+
print("Automatically selecting option 2 (manual login) as the most reliable choice. You can reconfigure later by running this script manually.\n")
7877
return "2"
7978

8079
print("\nWaiting for your input...")
@@ -97,27 +96,27 @@ def get_user_choice() -> str:
9796
return "2"
9897

9998

100-
def backup_devcontainer_json() -> bool:
101-
"""Create a backup of the current devcontainer.json file."""
102-
try:
103-
backup_path = DEVCONTAINER_JSON_PATH.with_suffix(DEVCONTAINER_JSON_PATH.suffix + BACKUP_SUFFIX)
99+
# def backup_devcontainer_json() -> bool:
100+
# """Create a backup of the current devcontainer.json file."""
101+
# try:
102+
# backup_path = DEVCONTAINER_JSON_PATH.with_suffix(DEVCONTAINER_JSON_PATH.suffix + BACKUP_SUFFIX)
104103

105-
if DEVCONTAINER_JSON_PATH.exists():
106-
with open(DEVCONTAINER_JSON_PATH, 'r', encoding='utf-8') as src:
107-
content = src.read()
104+
# if DEVCONTAINER_JSON_PATH.exists():
105+
# with open(DEVCONTAINER_JSON_PATH, 'r', encoding='utf-8') as src:
106+
# content = src.read()
108107

109-
with open(backup_path, 'w', encoding='utf-8') as dst:
110-
dst.write(content)
108+
# with open(backup_path, 'w', encoding='utf-8') as dst:
109+
# dst.write(content)
111110

112-
print(f"✅ Backup created: {backup_path}")
113-
return True
114-
else:
115-
print("❌ devcontainer.json not found")
116-
return False
111+
# print(f"✅ Backup created: {backup_path}")
112+
# return True
113+
# else:
114+
# print("❌ devcontainer.json not found")
115+
# return False
117116

118-
except Exception as e:
119-
print(f"❌ Failed to create backup: {e}")
120-
return False
117+
# except Exception as e:
118+
# print(f"❌ Failed to create backup: {e}")
119+
# return False
121120

122121

123122
def load_devcontainer_json() -> dict:
@@ -162,8 +161,8 @@ def save_devcontainer_json(config: dict) -> bool:
162161

163162
def configure_azure_mount(choice: str) -> bool:
164163
"""Configure Azure CLI mounting based on user choice."""
165-
if not backup_devcontainer_json():
166-
return False
164+
# if not backup_devcontainer_json():
165+
# return False
167166

168167
config = load_devcontainer_json()
169168
if not config:

.devcontainer/post-start.sh

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,14 @@
44
# POST-START VERIFICATION
55
# ------------------------------
66

7-
echo ""
87
echo ""
98
echo ""
109
echo "🚀 APIM Samples environment starting..."
10+
echo ""
1111

12-
# Check if this is a prebuild-created environment
12+
# Check if this is a prebuild-created environment based on the marker set at the end of setup-prebuild.sh.
1313
if [ -f ".devcontainer/.prebuild-complete" ]; then
1414
echo "✅ Detected prebuild environment - skipping heavy setup"
15-
PREBUILD_ENV=true
16-
else
17-
echo "⚠️ No prebuild detected - running full setup"
18-
PREBUILD_ENV=false
19-
fi
20-
21-
# ------------------------------
22-
# INTERACTIVE AZURE SETUP
23-
# ------------------------------
24-
25-
if [ "$PREBUILD_ENV" = "false" ]; then
26-
echo "🔧 Running full setup (no prebuild detected)..."
27-
bash .devcontainer/setup.sh
28-
else
2915
echo "🔧 Running Azure CLI interactive configuration..."
3016

3117
# Only run the interactive Azure configuration part
@@ -46,25 +32,36 @@ else
4632
echo " python3 .devcontainer/configure-azure-mount.py"
4733
echo ""
4834
fi
35+
else
36+
echo "⚠️ No prebuild detected - running full setup..."
37+
bash .devcontainer/setup.sh
4938
fi
5039

5140
# ------------------------------
5241
# QUICK VERIFICATION
5342
# ------------------------------
5443

55-
echo " ✅ Verifying Python environment..."
44+
echo "✅ Verifying Python environment..."
5645
python --version
5746

5847
echo ""
59-
echo " ✅ Verifying Azure CLI..."
48+
echo "✅ Verifying Azure CLI..."
6049
az --version | head -1
6150

6251
echo ""
63-
echo " ✅ Verifying Python packages..."
52+
echo "✅ Verifying Python packages..."
6453
python -c "import requests, jwt; print('✅ Core packages available')" || echo "⚠️ Some packages may need reinstalling"
6554

6655
echo ""
67-
echo " ✅ Running environment verification..."
56+
echo "✅ Ensuring Jupyter is accessible..."
57+
# Add user local bin to PATH if it exists and jupyter is installed there
58+
if [ -d "$HOME/.local/bin" ] && [ -f "$HOME/.local/bin/jupyter" ]; then
59+
export PATH="$HOME/.local/bin:$PATH"
60+
echo "Added $HOME/.local/bin to PATH for Jupyter access"
61+
fi
62+
63+
echo ""
64+
echo "✅ Running environment verification..."
6865
python .devcontainer/verify-setup.py
6966

7067
echo ""
@@ -98,4 +95,5 @@ echo "💡 Tip: The Python path has been configured to include shared/python mod
9895
echo "🔧 To reconfigure Azure CLI authentication, run: python3 .devcontainer/configure-azure-mount.py"
9996
echo ""
10097
echo " 🎉 ALL DONE!"
98+
echo ""
10199
echo ""

.devcontainer/verify-setup.py

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,34 @@ def check_commands():
8282

8383
for command in REQUIRED_COMMANDS:
8484
try:
85-
subprocess.run([command, '--version'],
86-
capture_output=True,
87-
check=True,
88-
timeout=10)
85+
if command == 'jupyter':
86+
# Jupyter uses different command syntax
87+
subprocess.run([command, '--version'],
88+
capture_output=True,
89+
check=True,
90+
timeout=10)
91+
else:
92+
subprocess.run([command, '--version'],
93+
capture_output=True,
94+
check=True,
95+
timeout=10)
8996
print(f" ✅ {command}")
9097
except (subprocess.CalledProcessError, FileNotFoundError, subprocess.TimeoutExpired):
91-
missing_commands.append(command)
92-
print(f" ❌ {command}")
98+
# For Jupyter, try alternative methods
99+
if command == 'jupyter':
100+
try:
101+
# Try using python -m jupyter
102+
subprocess.run(['python', '-m', 'jupyter', '--version'],
103+
capture_output=True,
104+
check=True,
105+
timeout=10)
106+
print(f" ✅ {command} (via python -m)")
107+
except (subprocess.CalledProcessError, FileNotFoundError, subprocess.TimeoutExpired):
108+
missing_commands.append(command)
109+
print(f" ❌ {command}")
110+
else:
111+
missing_commands.append(command)
112+
print(f" ❌ {command}")
93113

94114
if missing_commands:
95115
print(f" ❌ Missing commands: {', '.join(missing_commands)}")
@@ -102,6 +122,7 @@ def check_jupyter_kernel():
102122
"""Check if the custom Jupyter kernel is installed."""
103123
print("\n📓 Checking Jupyter kernel...")
104124
try:
125+
# Try direct jupyter command first
105126
result = subprocess.run(['jupyter', 'kernelspec', 'list'],
106127
capture_output=True,
107128
text=True,
@@ -115,9 +136,25 @@ def check_jupyter_kernel():
115136
print(" ❌ APIM Samples kernel not found")
116137
return False
117138

118-
except (subprocess.CalledProcessError, subprocess.TimeoutExpired):
119-
print(" ❌ Failed to check Jupyter kernels")
120-
return False
139+
except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError):
140+
# Try using python -m jupyter if direct command fails
141+
try:
142+
result = subprocess.run(['python', '-m', 'jupyter', 'kernelspec', 'list'],
143+
capture_output=True,
144+
text=True,
145+
check=True,
146+
timeout=10)
147+
148+
if 'apim-samples' in result.stdout:
149+
print(" ✅ APIM Samples kernel found")
150+
return True
151+
else:
152+
print(" ❌ APIM Samples kernel not found")
153+
return False
154+
155+
except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError):
156+
print(" ❌ Failed to check Jupyter kernels")
157+
return False
121158

122159

123160
def check_azure_cli():
@@ -153,7 +190,7 @@ def check_azure_cli():
153190

154191
def main():
155192
"""Main verification function."""
156-
print("🔍 Verifying APIM Samples dev container setup...\n")
193+
print("\n🔍 Verifying APIM Samples dev container setup...\n")
157194

158195
checks = [
159196
check_python_packages(),

0 commit comments

Comments
 (0)