Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions apipod/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ def input_yes_no(question: str, default: bool = True) -> bool:
def select_base_image(manager: DeploymentManager, config_data: dict) -> str:
"""Interactive base image selection process."""
recommended_image = manager.recommend_image(config_data)
print(f"Detected configuration: Python {config_data.get('python_version')}, "
f"PyTorch: {config_data.get('pytorch')}, TensorFlow: {config_data.get('tensorflow')}, "
f"ONNX: {config_data.get('onnx')}")
print(
f"Detected configuration: profile={config_data.get('profile')}, "
f"Python {config_data.get('python_version')}, "
f"PyTorch: {config_data.get('pytorch')}, TensorFlow: {config_data.get('tensorflow')}, "
f"ONNX: {config_data.get('onnx')}"
)
print(f"Recommended Base Image: {recommended_image}")

if input_yes_no("Is this correct?"):
Expand Down
3 changes: 2 additions & 1 deletion apipod/deploy/detectors/IDetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def should_ignore(self, path: str) -> bool:
'__pycache__', '.git', '.svn', '.hg', '.DS_Store',
'node_modules', 'venv', 'env', '.env', '.venv',
'build', 'dist', '.pytest_cache', '.mypy_cache',
'.tox', '.coverage', 'htmlcov', '.eggs', '*.egg-info'
'.tox', '.coverage', 'htmlcov', '.eggs', '*.egg-info',
'apipod-deploy',
}

# Check if any part of the path matches ignore patterns
Expand Down
32 changes: 24 additions & 8 deletions apipod/deploy/detectors/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ def detect(self, target_file: Optional[str] | None = None) -> Dict[str, Any]:

result = {
"file": None,
"title": "apipod-service", # Default
"found_config": False
"title": "apipod-service",
"found_config": False,
"orchestrator": "local",
"compute": "dedicated",
"provider": "localhost",
}

# 1. Prioritize user-provided target file
Expand Down Expand Up @@ -85,17 +88,30 @@ def _scan_file_for_title(self, file_path: str, result: Dict[str, Any]):
for node in ast.walk(tree):
if isinstance(node, ast.Call):
if isinstance(node.func, ast.Name) and node.func.id == "APIPod":
result["found_config"] = True
for keyword in node.keywords:
value = self._ast_constant(keyword.value)
if value is None:
continue
if keyword.arg == "title":
if isinstance(keyword.value, ast.Constant): # Python 3.8+
result["title"] = keyword.value.value
result["found_config"] = True
elif isinstance(keyword.value, ast.Str): # Python < 3.8
result["title"] = keyword.value.s
result["found_config"] = True
result["title"] = value
elif keyword.arg == "orchestrator":
result["orchestrator"] = value
elif keyword.arg == "compute":
result["compute"] = value
elif keyword.arg == "provider":
result["provider"] = value
except Exception:
pass

@staticmethod
def _ast_constant(node) -> Optional[str]:
if isinstance(node, ast.Constant) and isinstance(node.value, str):
return node.value
if isinstance(node, ast.Str):
return node.s
return None

def _scan_file_for_indicators(self, file_path: str, result: Dict[str, Any]) -> bool:
try:
with open(file_path, "r", encoding="utf-8") as f:
Expand Down
Loading