Skip to content
Closed
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
14 changes: 10 additions & 4 deletions backend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
import io
import sys
from contextlib import redirect_stdout, redirect_stderr
import logging

Check warning

Code scanning / Pylint (reported by Codacy)

standard import "import logging" should be placed before "from fastapi import FastAPI" Warning

standard import "import logging" should be placed before "from fastapi import FastAPI"

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

standard import "import logging" should be placed before "from fastapi import FastAPI" Warning

standard import "import logging" should be placed before "from fastapi import FastAPI"

logging.basicConfig(level=logging.ERROR, format="%(asctime)s - %(levelname)s - %(message)s")
app = FastAPI()

app.add_middleware(
Expand Down Expand Up @@ -123,7 +125,8 @@
result = subprocess.run(args, capture_output=True, text=True)
return (result.returncode == 0, result.stderr if result.stderr else "")
except Exception as e:
return (False, f"Error running {tool}: {str(e)}")
logging.error(f"Error running {tool}: {str(e)}")

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
return (False, "An internal error occurred while running the tool.")


# Utility for custom pipeline.
Expand Down Expand Up @@ -181,7 +184,8 @@
prev_path, flags, tool_path, out_path
)
if not success:
output += f"\n\n===== {tool} failed =====\n{stderr}"
logging.error(f"{tool} failed with error: {stderr}")

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
output += "\n\n===== An internal error occurred while processing the tool. ====="
break

if dump_each:
Expand Down Expand Up @@ -211,7 +215,8 @@
traced_model = torch.jit.trace(model, example_input)
return apply_optional_passes(str(traced_model.graph), pipeline, dump_each)
except Exception as e:
return f"Error generating TorchScript Graph IR: {str(e)}"
logging.error(f"Error generating TorchScript Graph IR: {str(e)}")

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions
return "An internal error occurred while generating the TorchScript Graph IR."


# Torch MLIR dialect.
Expand Down Expand Up @@ -476,7 +481,8 @@
captured, build_pipeline(request), request.dump_after_each_opt
)
except Exception as e:
return f"Error executing user code: {str(e)}"
logging.error(f"Error executing user code: {str(e)}")

Check notice

Code scanning / Pylintpython3 (reported by Codacy)

Use lazy % formatting in logging functions Note

Use lazy % formatting in logging functions

Check warning

Code scanning / Prospector (reported by Codacy)

Use lazy % formatting in logging functions (logging-fstring-interpolation) Warning

Use lazy % formatting in logging functions (logging-fstring-interpolation)
return "An internal error occurred while executing the user code."

if request.ir_type == "raw_ir":
return apply_optional_passes(
Expand Down