Skip to content

Conversation

@ultmaster
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings November 12, 2025 18:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors LightningStoreServer to use the PythonServerLauncher utility class instead of directly managing uvicorn server lifecycle. This unifies server launching logic and adds support for multiple launch modes (asyncio, thread, multiprocessing).

Key changes:

  • Replaces direct uvicorn server management with PythonServerLauncher
  • Adds launch_mode parameter to control how the server is started (thread, asyncio, mp)
  • Adds launcher_args parameter for advanced configuration
  • Implements pickling support for both LightningStoreServer and PythonServerLauncher to enable multiprocessing
  • Updates error handling and logging to use dedicated loggers

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
agentlightning/store/client_server.py Refactored to use PythonServerLauncher, added launch_mode support, updated pickling logic, changed to dedicated loggers
agentlightning/utils/server_launcher.py Added access_log parameter, improved pickling with initialize() method, fixed error messages, better error handling
tests/store/test_client_server.py Added tests for launch modes, custom launcher args, and mp mode validation; updated existing tests
agentlightning/cli/store.py Added launch_mode="asyncio" to CLI server instantiation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.launcher_args = launcher_args
else:
if port is None:
server_logger.warning("No port provided, using default port 4747.")
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning message claims port 4747 will be used as default, but port is actually None and will be passed to PythonServerLauncherArgs. The actual default behavior in PythonServerLauncher._ensure_port() is to call pick_unused_port(), not use 4747. Either set port=4747 here or update the warning message to say 'using a random available port'.

Suggested change
server_logger.warning("No port provided, using default port 4747.")
server_logger.warning("No port provided, using a random available port.")
Copilot uses AI. Check for mistakes.
Comment on lines +617 to +621
def initialize(self):
# ensure the host/port/access_host are set
self._ensure_host()
self._ensure_port()
self._ensure_access_host()
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initialize() method calls _ensure_* methods but doesn't document that these methods have side effects (setting self._host, self._port, self._access_host). Consider adding a docstring explaining this method is used to initialize/reinitialize server state, especially after unpickling.

Copilot uses AI. Check for mistakes.
Comment on lines 89 to 91
import logging

caplog.set_level(logging.INFO)
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import logging statement should be moved to the top of the file with other imports rather than being placed within the test function. This follows Python best practices and is consistent with the rest of the codebase.

Copilot uses AI. Check for mistakes.
Comment on lines +390 to +391
self.app = None
self.store = None
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting self.app and self.store to None in __setstate__ means unpickled LightningStoreServer instances are in a partially initialized state and will fail if methods requiring these attributes are called. Consider documenting this limitation more explicitly in the docstring or adding a runtime check that raises a clear error if operations requiring the store are attempted on unpickled instances.

Copilot uses AI. Check for mistakes.
Comment on lines +161 to +163
raise RuntimeError(
f"Server did not start up within {time.time() - start_time:.2f} seconds."
) from server_start_exception
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable timeout is referenced in the original code but replaced with time.time() - start_time in the error message. However, the variable timeout is no longer available in scope after this change. While the new calculation correctly shows actual elapsed time, ensure that start_time is defined in the enclosing scope. Review the full function context to verify start_time is accessible here.

Copilot uses AI. Check for mistakes.
@ultmaster
Copy link
Contributor Author

/ci

@github-actions
Copy link

github-actions bot commented Nov 12, 2025

🚀 CI Watcher for correlation id-3523351403-mhwc0xfp triggered by comment 3523351403
🏃‍♀️ Tracking 6 workflow run(s):

✅ All runs completed.

@ultmaster
Copy link
Contributor Author

/ci

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

🚀 CI Watcher for correlation id-3524631436-mhwqbykl triggered by comment 3524631436
🏃‍♀️ Tracking 6 workflow run(s):

✅ All runs completed.

@ultmaster ultmaster merged commit b986ae1 into main Nov 13, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants