Skip to content

Commit 6e0448f

Browse files
authored
Merge pull request #180 from awslabs/chore/dead-code-and-print-cleanup
chore: remove dead application/base files and replace bare print() calls
2 parents 1796a36 + 5df23eb commit 6e0448f

9 files changed

Lines changed: 22 additions & 57 deletions

File tree

.github/pull_request_template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ Fixes #
7171

7272
## Reviewers
7373
<!-- @ mention specific team members who should review this -->
74+
@awslabs/orb-maintainers

src/orb/application/base/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@
88
PaginatedResponse,
99
)
1010

11-
from .commands import CommandBus, CommandHandler
12-
from .queries import QueryBus
13-
1411
__all__: list[str] = [
1512
"BaseCommand",
1613
"BaseDTO",
1714
"BaseQuery",
1815
"BaseResponse",
19-
"CommandBus",
20-
"CommandHandler",
2116
"PaginatedResponse",
22-
"QueryBus",
2317
]

src/orb/application/base/commands.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/orb/application/base/queries.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/orb/bootstrap/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
set_container_factory(register_all_services)
1818

1919
# Import configuration
20-
from orb.config.schemas.app_schema import AppConfig
21-
2220
# Import logging
21+
from orb.cli.console import print_console
22+
from orb.config.schemas.app_schema import AppConfig
2323
from orb.infrastructure.logging.logger import get_logger, setup_logging
2424

2525

@@ -403,7 +403,7 @@ async def main() -> None:
403403
config_path = os.getenv("ORB_CONFIG_FILE")
404404

405405
# Only print before app creation - no logger available yet
406-
print("Starting Open Host Factory...")
406+
print_console("Starting Open Host Factory...")
407407

408408
try:
409409
async with await create_application(config_path) as app:
@@ -431,7 +431,7 @@ async def main() -> None:
431431

432432
except Exception as e:
433433
# Keep print here - app creation failed, no logger available
434-
print(f"Application failed: {e}")
434+
print_console(f"Application failed: {e}")
435435
sys.exit(1)
436436

437437

src/orb/cli/console.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ def print_newline():
109109
_console.print()
110110

111111

112+
@_console_output
113+
def print_console(message: str):
114+
"""Print plain text message with no colour formatting."""
115+
_console.print(message)
116+
117+
112118
def print_json(data: dict):
113119
"""Print JSON data (always outputs, ignores LOG_CONSOLE_ENABLED)."""
114120
import json

src/orb/cli/main.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Re-export for backward compatibility
1616
from orb.cli.args import parse_args
17+
from orb.cli.console import print_error, print_info, print_success, print_warning
1718
from orb.cli.router import execute_command
1819
from orb.infrastructure.logging.logger import get_logger
1920

@@ -69,7 +70,7 @@ async def main() -> None:
6970
sys.argv = original_argv
7071

7172
if error_output.strip():
72-
print(error_output.strip(), file=sys.stderr)
73+
print_error(error_output.strip())
7374
raise
7475

7576
# Setup environment after arg parse — skip for init (it calls get_config_location() directly)
@@ -183,7 +184,7 @@ async def main() -> None:
183184
if result.get("status") == "success":
184185
sys.exit(0)
185186
else:
186-
print(f"Error: {result.get('message')}", file=sys.stderr)
187+
print_error(f"Error: {result.get('message')}")
187188
sys.exit(1)
188189
except Exception:
189190
import traceback
@@ -227,9 +228,9 @@ async def main() -> None:
227228
with open(args.output, "w") as f:
228229
f.write(formatted_output)
229230
if not args.quiet:
230-
print(f"Output written to {args.output}")
231+
print_success(f"Output written to {args.output}")
231232
else:
232-
print(formatted_output)
233+
print_info(formatted_output)
233234

234235
if exit_code != 0:
235236
sys.exit(exit_code)
@@ -252,7 +253,7 @@ async def main() -> None:
252253
error_output, exit_code = formatter.format_error(e, output_format)
253254

254255
if not args.quiet:
255-
print(error_output)
256+
print_error(error_output)
256257
sys.exit(exit_code)
257258
finally:
258259
if scheduler_override_active:
@@ -267,10 +268,10 @@ async def main() -> None:
267268
logger.warning("Failed to restore scheduler strategy: %s", e, exc_info=True)
268269

269270
except KeyboardInterrupt:
270-
print("\nOperation cancelled by user.")
271+
print_warning("\nOperation cancelled by user.")
271272
sys.exit(130)
272273
except Exception as e:
273-
print(f"Fatal error: {e}")
274+
print_error(f"Fatal error: {e}")
274275
sys.exit(1)
275276

276277

src/orb/sdk/middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class SDKMiddleware(ABC):
1818
Example:
1919
class LoggingMiddleware(SDKMiddleware):
2020
async def process(self, method_name, args, kwargs, next_handler):
21-
print(f"Calling {method_name}")
21+
logger.debug("Calling %s", method_name)
2222
result = await next_handler(args, kwargs)
23-
print(f"{method_name} returned: {result}")
23+
logger.debug("%s returned: %s", method_name, result)
2424
return result
2525
"""
2626

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)