Skip to content

Commit 31fd2e8

Browse files
Merge pull request #304 from microsoft/psl-codequality2
fix: Reverting my changes from dev
2 parents 62b08d3 + 6434419 commit 31fd2e8

23 files changed

Lines changed: 165 additions & 40 deletions

File tree

docs/DeploymentGuide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ If you're not using one of the above options for opening the project, then you'l
124124
2. Download the project code:
125125

126126
```shell
127-
azd init -t microsoft/Modernize-your-Code-Solution-Accelerator
127+
azd init -t microsoft/Modernize-your-Code-Solution-Accelerator/
128128
```
129129

130130
3. Open the project folder in your terminal or editor.
@@ -164,7 +164,7 @@ To adjust quota settings, follow these [steps](../docs/AzureGPTQuotaSettings.md)
164164

165165
<summary><b>Reusing an Existing Log Analytics Workspace</b></summary>
166166

167-
Guide to get your [Existing Workspace ID](./re-use-log-analytics.md)
167+
Guide to get your [Existing Workspace ID](/docs/re-use-log-analytics.md)
168168

169169
</details>
170170

@@ -217,7 +217,7 @@ Rename `azure.yaml` to `azure_original.yaml` and `azure_custom.yaml` to `azure.y
217217
218218
Go to `infra` directory
219219
220-
Rename `main.bicep` to `main_original.bicep` and `main_custom.bicep` to `main.bicep`. Continue with the [deploying steps](#deploying-with-azd).
220+
Rename `main.bicep` to `main_original.bicep` and `main_custom.bicep` to `main.bicep`. Continue with the [deploying steps](https://github.com/microsoft/Modernize-your-code-solution-accelerator/blob/main/docs/DeploymentGuide.md#deploying-with-azd).
221221
222222
### 🛠️ Troubleshooting
223223
If you encounter any issues during the deployment process, please refer [troubleshooting](../docs/TroubleShootingSteps.md) document for detailed steps and solutions.

src/backend/api/api_routes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ async def batch_status_updates(
279279
try:
280280
await websocket.receive_text()
281281
except asyncio.TimeoutError:
282-
# TimeoutError is ignored to keep the WebSocket connection open without receiving data
283282
pass
284283

285284
except WebSocketDisconnect:

src/backend/common/database/cosmosdb.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ async def update_batch_entry(
352352
batch["file_count"] = file_count
353353

354354
await self.batch_container.replace_item(item=batch_id, body=batch)
355+
# if isinstance(status, ProcessStatus):
356+
# self.logger.info(f"Updated batch {batch_id} to status {status.value}")
357+
# else:
358+
# self.logger.info(f"Updated batch {batch_id} to status {status}")
355359

356360
return batch
357361
except Exception as e:

src/backend/common/services/batch_service.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ async def delete_batch(self, batch_id: UUID, user_id: str):
175175

176176
self.logger.info(f"Successfully deleted batch with ID: {batch_id}")
177177
return {"message": "Batch deleted successfully", "batch_id": str(batch_id)}
178-
else:
179-
return {"message": "Batch not found", "batch_id": str(batch_id)}
180178

181179
async def delete_file(self, file_id: UUID, user_id: str):
182180
"""Delete a file and its logs, and update batch file count."""

src/backend/common/storage/blob_azure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def upload_file(
5252
raise
5353
try:
5454
# Upload the file
55-
blob_client.upload_blob(
55+
upload_results = blob_client.upload_blob( # noqa: F841
5656
file_content,
5757
content_type=content_type,
5858
metadata=metadata,

src/backend/sql_agents/convert_script.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ async def convert_script(
6666

6767
# orchestrate the chat
6868
current_migration = "No migration"
69-
while True:
69+
is_complete: bool = False
70+
while not is_complete:
7071
await comms_manager.group_chat.add_chat_message(
7172
ChatMessageContent(role=AuthorRole.USER, content=source_script)
7273
)
@@ -273,7 +274,9 @@ async def convert_script(
273274
break
274275

275276
if comms_manager.group_chat.is_complete:
276-
break
277+
is_complete = True
278+
279+
break
277280

278281
migrated_query = current_migration
279282

src/backend/sql_agents/helpers/comms_manager.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ async def select_agent(self, agents, history):
7979
),
8080
None,
8181
)
82-
# No matching case found, so explicitly return None
83-
return None
8482

8583
# class for termination strategy
8684
class ApprovalTerminationStrategy(TerminationStrategy):
@@ -272,3 +270,17 @@ async def cleanup(self):
272270

273271
except Exception as e:
274272
self.logger.error("Error during cleanup: %s", str(e))
273+
274+
def __del__(self):
275+
"""Destructor to ensure cleanup if not explicitly called."""
276+
try:
277+
# Only attempt cleanup if there's an active event loop
278+
loop = asyncio.get_running_loop()
279+
if loop and not loop.is_closed():
280+
# Schedule cleanup as a task
281+
loop.create_task(self.cleanup())
282+
except RuntimeError:
283+
# No event loop running, can't clean up asynchronously
284+
self.logger.warning("No event loop available for cleanup in destructor")
285+
except Exception as e:
286+
self.logger.error("Error in destructor cleanup: %s", str(e))

src/backend/sql_agents/tools/src/Program.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
54
using Microsoft.SqlServer.TransactSql.ScriptDom;
65
using Newtonsoft.Json;
76

@@ -43,14 +42,18 @@ static void Main(string[] args)
4342

4443
IList<ParseError> errors = ParseSqlQuery(sqlQuery);
4544

46-
var errorList = errors
47-
.Select(error => new Dictionary<string, object>
45+
var errorList = new List<Dictionary<string, object>>();
46+
47+
foreach (var error in errors)
48+
{
49+
var errorDict = new Dictionary<string, object>
4850
{
4951
{ "Line", error.Line },
5052
{ "Column", error.Column },
5153
{ "Error", error.Message }
52-
})
53-
.ToList();
54+
};
55+
errorList.Add(errorDict);
56+
}
5457

5558
string jsonOutput = JsonConvert.SerializeObject(errorList, Formatting.Indented);
5659
Console.WriteLine(jsonOutput);

src/frontend/frontend_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dotenv import load_dotenv
55
from fastapi import FastAPI
66
from fastapi.middleware.cors import CORSMiddleware
7-
from fastapi.responses import FileResponse
7+
from fastapi.responses import FileResponse, HTMLResponse
88
from fastapi.staticfiles import StaticFiles
99

1010
# Load environment variables from .env file

src/frontend/src/api/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export const renderErrorSection = (batchSummary, expandedSections, setExpandedSe
414414

415415
export const renderErrorContent = (batchSummary) => {
416416
// Group errors by file
417-
const errorFiles = batchSummary.files.filter(file => file.error_count);
417+
const errorFiles = batchSummary.files.filter(file => file.error_count && file.error_count);
418418
if (errorFiles.length === 0) {
419419
return (
420420
<div className={useStyles().errorItem}>

0 commit comments

Comments
 (0)