Skip to content

Commit 699b4c8

Browse files
Fix module imports
1 parent 6929dc6 commit 699b4c8

File tree

12 files changed

+162
-19
lines changed

12 files changed

+162
-19
lines changed

.devcontainer/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,30 @@ az account show
8686
### Continue with Development
8787
After setup is complete:
8888
1. **Verify your Azure setup**: Execute `shared/jupyter/verify-az-account.ipynb`
89-
2. **Start exploring**:
89+
2. **Test your environment**: Run `python .devcontainer/verify-setup.py`
90+
3. **Start exploring**:
9091
- Navigate to any infrastructure folder (`infrastructure/`)
9192
- Run the `create.ipynb` notebook to set up infrastructure
9293
- Explore samples in the `samples/` directory
9394

95+
## 🔧 Troubleshooting
96+
97+
If you encounter import errors or module resolution issues, see:
98+
- [Import Troubleshooting Guide](.devcontainer/IMPORT-TROUBLESHOOTING.md)
99+
- [Setup Notes](.devcontainer/SETUP-NOTES.md)
100+
101+
Common quick fixes:
102+
```bash
103+
# Fix Python path for local development
104+
python setup/setup_python_path.py --generate-env
105+
106+
# Verify setup
107+
python .devcontainer/verify-setup.py
108+
109+
# Rebuild dev container if needed
110+
Dev Containers: Rebuild Container
111+
```
112+
94113
## 🏗️ Architecture
95114

96115
The dev container is built on:

.devcontainer/configure-azure-mount.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def get_user_choice() -> str:
6060
print("\nHow would you like to handle Azure CLI authentication?")
6161
print("\n 1. Mount local Azure CLI config")
6262
print(" - Preserves login between container rebuilds")
63-
print(" - Uses your existing tenant-specific 'az login' from host machine")
63+
print(" - Uses your existing 'az login' from host machine")
6464
print(" - Best for: Personal development with stable logins")
6565
print("\n 2. Use manual login inside container [RECOMMENDED]")
66-
print(" - Run tenant-specific 'az login' each time container starts")
66+
print(" - Run 'az login' each time container starts")
6767
print(" - More secure, fresh authentication each session")
6868
print(" - Best for: Shared environments, GitHub Codespaces")
6969
print("\n 3. Let me configure this manually later")
@@ -215,11 +215,8 @@ def configure_azure_mount(choice: str) -> bool:
215215
print("✅ Configured Azure CLI mounting for {platform_name}")
216216

217217
elif choice == "2": # Manual login
218-
print("✅ Configured for manual Azure CLI login with tenant/subscription specification")
219-
print(" You'll need to run tenant-specific login after container startup:")
220-
print(" az login --tenant <your-tenant-id-or-domain>")
221-
print(" az account set --subscription <your-subscription-id-or-name>")
222-
print(" az account show # Verify your context")
218+
print("✅ Configured for manual Azure CLI login (az login)")
219+
print(" You'll need to run 'az login' after container startup")
223220
print(" (Removed any existing Azure CLI mounts)")
224221

225222
elif choice == "3": # Manual configuration
@@ -272,16 +269,10 @@ def main() -> int:
272269
print("\nNext steps:")
273270
if is_initial_setup:
274271
print("1. The setup script will complete automatically")
275-
print("2. Sign in with tenant-specific authentication when setup finishes:")
276-
print(" az login --tenant <your-tenant-id-or-domain>")
277-
print(" az account set --subscription <your-subscription-id-or-name>")
278-
print(" az account show # Verify your context")
272+
print("2. Run 'az login' inside the container when setup finishes")
279273
else:
280274
print("1. Start/rebuild your dev container")
281-
print("2. Sign in with tenant-specific authentication inside the container:")
282-
print(" az login --tenant <your-tenant-id-or-domain>")
283-
print(" az account set --subscription <your-subscription-id-or-name>")
284-
print(" az account show # Verify your context")
275+
print("2. Run 'az login' inside the container")
285276
else:
286277
print("\nNext steps:")
287278
print("1. Edit .devcontainer/devcontainer.json manually if needed")

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
}
6161
},
6262
"containerEnv": {
63-
"PYTHONPATH": "/workspaces/Apim-Samples/shared/python"
63+
"PYTHONPATH": "/workspaces/Apim-Samples/shared/python:/workspaces/Apim-Samples"
6464
},
6565
"postCreateCommand": "bash .devcontainer/setup.sh",
6666
"forwardPorts": [

.devcontainer/setup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ cat > .vscode/settings.json << 'EOF'
9595
{
9696
"python.terminal.activateEnvironment": true,
9797
"python.defaultInterpreterPath": "/usr/local/bin/python",
98+
"python.analysis.extraPaths": [
99+
"/workspaces/Apim-Samples/shared/python"
100+
],
98101
"jupyter.kernels.filter": [
99102
{
100103
"path": "/usr/local/bin/python",

.devcontainer/test_config.py

Whitespace-only changes.

.devcontainer/test_mount.py

Whitespace-only changes.

.devcontainer/test_mount_logic.py

Whitespace-only changes.

.devcontainer/verify-setup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ def check_python_packages():
5353
return True
5454

5555

56+
def check_shared_python_modules():
57+
"""Check if shared Python modules can be imported."""
58+
print("📦 Checking shared Python modules...")
59+
shared_modules = ['utils', 'apimrequests', 'apimtypes', 'authfactory', 'users']
60+
missing_modules = []
61+
62+
for module in shared_modules:
63+
try:
64+
importlib.import_module(module)
65+
print(f" ✅ {module}")
66+
except ImportError as e:
67+
missing_modules.append(module)
68+
print(f" ❌ {module} - {e}")
69+
70+
if missing_modules:
71+
print(f" ⚠️ Missing shared modules: {', '.join(missing_modules)}")
72+
print(" 💡 Tip: Run 'python setup/setup_python_path.py --generate-env' to fix the Python path")
73+
return False
74+
75+
return True
76+
77+
5678
def check_commands():
5779
"""Check if required command-line tools are available."""
5880
print("\n🔧 Checking command-line tools...")
@@ -135,6 +157,7 @@ def main():
135157

136158
checks = [
137159
check_python_packages(),
160+
check_shared_python_modules(),
138161
check_commands(),
139162
check_jupyter_kernel(),
140163
check_azure_cli()

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"python.analysis.extraPaths": [
1515
"${workspaceFolder}/shared/python"
1616
],
17-
"python.defaultInterpreterPath": "./venv/bin/python",
17+
"python.defaultInterpreterPath": "./.venv/Scripts/python.exe",
1818
"python.envFile": "${workspaceFolder}/.env",
1919
"python.terminal.activateEnvironment": true,
2020
"terminal.integrated.env.windows": {

.vscode/tasks.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,25 @@
5656
},
5757
"problemMatcher": [],
5858
"detail": "Manually run the dev container setup script"
59+
},
60+
{
61+
"label": "Verify Setup",
62+
"type": "shell",
63+
"command": "${config:python.pythonPath}",
64+
"args": [
65+
".devcontainer/verify-setup.py"
66+
],
67+
"group": "test",
68+
"presentation": {
69+
"echo": true,
70+
"reveal": "always",
71+
"focus": false,
72+
"panel": "shared",
73+
"showReuseMessage": true,
74+
"clear": false
75+
},
76+
"problemMatcher": [],
77+
"detail": "Verify that the development environment is set up correctly"
5978
}
6079
],
6180
"inputs": [

0 commit comments

Comments
 (0)