From 20719088ffbe72bc0a63301c0c6c11f73f573a61 Mon Sep 17 00:00:00 2001 From: Shreyas-Microsoft Date: Mon, 23 Mar 2026 19:02:22 +0530 Subject: [PATCH] fix bug and Managed identity changes --- src/backend/.env.sample | 4 ++-- src/backend/common/config/config.py | 18 +++++++++------- src/backend/sql_agents/convert_script.py | 7 +++++-- src/frontend/.dockerignore | 3 +++ src/frontend/src/pages/modernizationPage.tsx | 22 +++++++------------- 5 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 src/frontend/.dockerignore diff --git a/src/backend/.env.sample b/src/backend/.env.sample index 3cced35e..2de06e7a 100644 --- a/src/backend/.env.sample +++ b/src/backend/.env.sample @@ -28,9 +28,9 @@ AZURE_AI_AGENT_MODEL_DEPLOYMENT_NAME = "" APP_ENV = "dev" # Basic application logging (default: INFO level) -AZURE_BASIC_LOGGING_LEVEL=INFO +AZURE_BASIC_LOGGING_LEVEL=DEBUG # Azure package logging (default: WARNING level to suppress INFO) -AZURE_PACKAGE_LOGGING_LEVEL=WARNING +AZURE_PACKAGE_LOGGING_LEVEL=DEBUG # Comma-separated list of specific logger names to configure (default: empty - no custom loggers) # Example: AZURE_LOGGING_PACKAGES=azure.identity.aio._internal,azure.monitor.opentelemetry.exporter.export._base AZURE_LOGGING_PACKAGES= \ No newline at end of file diff --git a/src/backend/common/config/config.py b/src/backend/common/config/config.py index faccdde1..18fcb15b 100644 --- a/src/backend/common/config/config.py +++ b/src/backend/common/config/config.py @@ -15,6 +15,8 @@ import os from azure.identity.aio import ClientSecretCredential +from azure.identity.aio import DefaultAzureCredential as AioDefaultAzureCredential +from azure.identity.aio import ManagedIdentityCredential as AioManagedIdentityCredential from helper.azure_credential_utils import get_azure_credential @@ -54,13 +56,15 @@ def __init__(self): def get_azure_credentials(self): """Retrieve Azure credentials, either from environment variables or managed identity.""" - if all([self.azure_tenant_id, self.azure_client_id, self.azure_client_secret]): - return ClientSecretCredential( - tenant_id=self.azure_tenant_id, - client_id=self.azure_client_id, - client_secret=self.azure_client_secret, - ) - return self.__azure_credentials + if os.getenv("APP_ENV", "prod").lower() == "dev": + if all([self.azure_tenant_id, self.azure_client_id, self.azure_client_secret]): + return ClientSecretCredential( + tenant_id=self.azure_tenant_id, + client_id=self.azure_client_id, + client_secret=self.azure_client_secret, + ) + return AioDefaultAzureCredential() + return AioManagedIdentityCredential(client_id=self.azure_client_id) app_config = Config() diff --git a/src/backend/sql_agents/convert_script.py b/src/backend/sql_agents/convert_script.py index eb4a2767..789bf36f 100644 --- a/src/backend/sql_agents/convert_script.py +++ b/src/backend/sql_agents/convert_script.py @@ -66,7 +66,8 @@ async def convert_script( # orchestrate the chat current_migration = "No migration" - while True: + is_complete: bool = False + while not is_complete: await comms_manager.group_chat.add_chat_message( ChatMessageContent(role=AuthorRole.USER, content=source_script) ) @@ -273,7 +274,9 @@ async def convert_script( break if comms_manager.group_chat.is_complete: - break + is_complete = True + + break migrated_query = current_migration diff --git a/src/frontend/.dockerignore b/src/frontend/.dockerignore new file mode 100644 index 00000000..a21f178d --- /dev/null +++ b/src/frontend/.dockerignore @@ -0,0 +1,3 @@ +node_modules +dist +.git diff --git a/src/frontend/src/pages/modernizationPage.tsx b/src/frontend/src/pages/modernizationPage.tsx index 53f128b5..7f232148 100644 --- a/src/frontend/src/pages/modernizationPage.tsx +++ b/src/frontend/src/pages/modernizationPage.tsx @@ -31,7 +31,7 @@ import { Light as SyntaxHighlighter } from "react-syntax-highlighter" import { vs } from "react-syntax-highlighter/dist/esm/styles/hljs" import sql from "react-syntax-highlighter/dist/cjs/languages/hljs/sql" import { useNavigate, useParams } from "react-router-dom" -import { useState, useEffect, useCallback } from "react" +import { useState, useEffect, useCallback, useRef } from "react" import { getApiUrl, headerBuilder } from '../api/config'; import BatchHistoryPanel from "../components/batchHistoryPanel" import PanelRight from "../components/Panels/PanelRight"; @@ -497,6 +497,7 @@ const ModernizationPage = () => { const [fileId, setFileId] = React.useState(""); const [expandedSections, setExpandedSections] = React.useState([]); const [allFilesCompleted, setAllFilesCompleted] = useState(false); + const [progressPercentage, setProgressPercentage] = useState(0); const [isZipButtonDisabled, setIsZipButtonDisabled] = useState(true); const [fileLoading, setFileLoading] = useState(false); const [lastActivityTime, setLastActivityTime] = useState(Date.now()); @@ -514,18 +515,9 @@ const ModernizationPage = () => { if (!selectedFile || !selectedFile.translatedCode) { setFileLoading(true); const newFileUpdate = await fetchFileFromAPI(selectedFile?.fileId || ""); - setFiles((prevFiles) => - prevFiles.map((file) => - file.fileId === selectedFile?.fileId - ? { - ...file, - code: newFileUpdate.content, - translatedCode: newFileUpdate.translated_content, - } - : file - ) - ); setFileLoading(false); + } else { + } } catch (err) { @@ -1013,16 +1005,16 @@ useEffect(() => { }; }, [handleWebSocketMessage]); - // Set a timeout for initial loading - if still loading after 30 seconds, show a warning message + // Set a timeout for initial loading - if no progress after 30 seconds, show error useEffect(() => { const loadingTimeout = setTimeout(() => { - if (showLoading) { + if (progressPercentage < 5 && showLoading) { setLoadingError('Processing is taking longer than expected. You can continue waiting or try again later.'); } }, 30000); return () => clearTimeout(loadingTimeout); - }, [showLoading]); + }, [progressPercentage, showLoading]); // Add timeout mechanism to navigate if no activity for 30 seconds useEffect(() => {