Skip to content

Commit 47e39bc

Browse files
author
Taniya Mathur
committed
Fix code formatting in publish.py
- Applied Ruff formatting to resolve CI/CD pipeline failure - All code quality checks now pass - Resolves 'Code formatting check failed' error
1 parent be45515 commit 47e39bc

File tree

1 file changed

+52
-25
lines changed

1 file changed

+52
-25
lines changed

publish.py

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,37 @@ def log_verbose(self, message, style="dim"):
5858

5959
def log_error_details(self, component, error_output):
6060
"""Log detailed error information and store for summary"""
61-
error_info = {
62-
"component": component,
63-
"error": error_output
64-
}
61+
error_info = {"component": component, "error": error_output}
6562
self.build_errors.append(error_info)
66-
63+
6764
if self.verbose:
6865
self.console.print(f"[red]❌ {component} build failed:[/red]")
6966
self.console.print(f"[red]{error_output}[/red]")
7067
else:
71-
self.console.print(f"[red]❌ {component} build failed (use --verbose for details)[/red]")
68+
self.console.print(
69+
f"[red]❌ {component} build failed (use --verbose for details)[/red]"
70+
)
7271

7372
def print_error_summary(self):
7473
"""Print summary of all build errors"""
7574
if not self.build_errors:
7675
return
77-
76+
7877
self.console.print("\n[red]❌ Build Error Summary:[/red]")
7978
for i, error_info in enumerate(self.build_errors, 1):
8079
self.console.print(f"\n[red]{i}. {error_info['component']}:[/red]")
8180
if self.verbose:
8281
self.console.print(f"[red]{error_info['error']}[/red]")
8382
else:
8483
# Show first few lines of error for non-verbose mode
85-
error_lines = error_info['error'].strip().split('\n')
84+
error_lines = error_info["error"].strip().split("\n")
8685
preview_lines = error_lines[:3] # Show first 3 lines
8786
for line in preview_lines:
8887
self.console.print(f"[red] {line}[/red]")
8988
if len(error_lines) > 3:
90-
self.console.print(f"[dim] ... ({len(error_lines) - 3} more lines, use --verbose for full output)[/dim]")
89+
self.console.print(
90+
f"[dim] ... ({len(error_lines) - 3} more lines, use --verbose for full output)[/dim]"
91+
)
9192
self.public_sample_udop_model = ""
9293
self.public = False
9394
self.main_template = "idp-main.yaml"
@@ -627,21 +628,29 @@ def build_and_package_template(self, directory):
627628

628629
if result.returncode != 0:
629630
# If cached build fails, try without cache
630-
self.log_verbose(f"Cached build failed for {directory}, retrying without cache")
631+
self.log_verbose(
632+
f"Cached build failed for {directory}, retrying without cache"
633+
)
631634
self.console.print(
632635
f"[yellow]Cached build failed for {directory}, retrying without cache[/yellow]"
633636
)
634637
cmd_no_cache = [c for c in cmd if c != "--cached"]
635638
sam_build_start = time.time()
636-
self.log_verbose(f"Running SAM build command (no cache): {' '.join(cmd_no_cache)}")
639+
self.log_verbose(
640+
f"Running SAM build command (no cache): {' '.join(cmd_no_cache)}"
641+
)
637642
result = subprocess.run(
638643
cmd_no_cache, cwd=abs_directory, capture_output=True, text=True
639644
)
640645
sam_build_time = time.time() - sam_build_start
641646
if result.returncode != 0:
642647
# Log detailed error information
643-
error_output = f"STDOUT:\n{result.stdout}\n\nSTDERR:\n{result.stderr}"
644-
self.log_error_details(f"SAM build for {directory}", error_output)
648+
error_output = (
649+
f"STDOUT:\n{result.stdout}\n\nSTDERR:\n{result.stderr}"
650+
)
651+
self.log_error_details(
652+
f"SAM build for {directory}", error_output
653+
)
645654
return False
646655

647656
# Package the template
@@ -674,7 +683,9 @@ def build_and_package_template(self, directory):
674683

675684
if result.returncode != 0:
676685
# Log detailed error information
677-
error_output = f"STDOUT:\n{result.stdout}\n\nSTDERR:\n{result.stderr}"
686+
error_output = (
687+
f"STDOUT:\n{result.stdout}\n\nSTDERR:\n{result.stderr}"
688+
)
678689
self.log_error_details(f"SAM package for {directory}", error_output)
679690
return False
680691

@@ -778,9 +789,12 @@ def build_patterns_concurrently(self, max_workers=None):
778789
except Exception as e:
779790
# Log detailed error information
780791
import traceback
792+
781793
error_output = f"Exception: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
782-
self.log_error_details(f"Pattern {pattern} build exception", error_output)
783-
794+
self.log_error_details(
795+
f"Pattern {pattern} build exception", error_output
796+
)
797+
784798
progress.update(
785799
pattern_tasks[pattern],
786800
description=f"[red]{pattern}[/red] - Error: {str(e)[:30]}...",
@@ -872,9 +886,12 @@ def build_options_concurrently(self, max_workers=None):
872886
except Exception as e:
873887
# Log detailed error information
874888
import traceback
889+
875890
error_output = f"Exception: {str(e)}\n\nTraceback:\n{traceback.format_exc()}"
876-
self.log_error_details(f"Option {option} build exception", error_output)
877-
891+
self.log_error_details(
892+
f"Option {option} build exception", error_output
893+
)
894+
878895
progress.update(
879896
option_tasks[option],
880897
description=f"[red]{option}[/red] - Error: {str(e)[:30]}...",
@@ -1080,10 +1097,14 @@ def build_main_template(self, webui_zipfile):
10801097
self.prefix_and_version,
10811098
]
10821099

1083-
self.log_verbose(f"Running main template SAM package command: {' '.join(cmd)}")
1100+
self.log_verbose(
1101+
f"Running main template SAM package command: {' '.join(cmd)}"
1102+
)
10841103
result = subprocess.run(cmd, capture_output=True, text=True)
10851104
if result.returncode != 0:
1086-
error_output = f"STDOUT:\n{result.stdout}\n\nSTDERR:\n{result.stderr}"
1105+
error_output = (
1106+
f"STDOUT:\n{result.stdout}\n\nSTDERR:\n{result.stderr}"
1107+
)
10871108
self.log_error_details("Main template SAM package", error_output)
10881109
self.console.print("[red]Error packaging main template[/red]")
10891110
sys.exit(1)
@@ -1239,7 +1260,9 @@ def run(self, args):
12391260
"[red]❌ Error: Failed to build one or more patterns[/red]"
12401261
)
12411262
if not self.verbose:
1242-
self.console.print("[dim]Use --verbose flag for detailed error information[/dim]")
1263+
self.console.print(
1264+
"[dim]Use --verbose flag for detailed error information[/dim]"
1265+
)
12431266
sys.exit(1)
12441267

12451268
# Build options concurrently
@@ -1256,7 +1279,9 @@ def run(self, args):
12561279
"[red]❌ Error: Failed to build one or more options[/red]"
12571280
)
12581281
if not self.verbose:
1259-
self.console.print("[dim]Use --verbose flag for detailed error information[/dim]")
1282+
self.console.print(
1283+
"[dim]Use --verbose flag for detailed error information[/dim]"
1284+
)
12601285
sys.exit(1)
12611286

12621287
total_build_time = time.time() - start_time
@@ -1335,10 +1360,12 @@ def main(
13351360
args.extend(["--max-workers", str(max_workers)])
13361361

13371362
publisher = IDPPublisher(verbose=verbose)
1338-
1363+
13391364
if verbose:
1340-
console.print("[dim]Verbose mode enabled - detailed error output will be shown[/dim]")
1341-
1365+
console.print(
1366+
"[dim]Verbose mode enabled - detailed error output will be shown[/dim]"
1367+
)
1368+
13421369
publisher.run(args)
13431370

13441371
except KeyboardInterrupt:

0 commit comments

Comments
 (0)