Skip to content

Commit 9a6c373

Browse files
committed
Fix handling of not started runner because of failing finecode.sh . Log RunnerFailedToStart message instead of exception object
1 parent a87f31a commit 9a6c373

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

finecode/workspace_manager/cli_app/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ async def run_actions(
3838
try:
3939
try:
4040
await runner_manager.update_runners(ws_context)
41-
except runner_manager.RunnerFailedToStart:
41+
except runner_manager.RunnerFailedToStart as exception:
4242
raise RunFailed(
4343
f"One or more projects are misconfigured, runners for them didn't"
44-
" start. Check logs for details."
44+
f" start: {exception.message}. Check logs for details."
4545
)
4646

4747
actions_by_projects: dict[pathlib.Path, list[str]] = {}

finecode/workspace_manager/runner/manager.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
)
2525

2626

27-
class RunnerFailedToStart(Exception): ...
27+
class RunnerFailedToStart(Exception):
28+
def __init__(self, message: str) -> None:
29+
self.message = message
2830

2931

3032
async def notify_project_changed(project: domain.Project) -> None:
@@ -181,6 +183,9 @@ async def update_runners(ws_context: context.WorkspaceContext) -> None:
181183
#
182184
# during initialization of new runners it also reads their configurations and
183185
# actions
186+
#
187+
# this function should handle all possible statuses of projects and they either
188+
# start of fail to start, only projects without finecode are ignored
184189
extension_runners = list(ws_context.ws_projects_extension_runners.values())
185190
new_dirs, deleted_dirs = dirs_utils.find_changed_dirs(
186191
[*ws_context.ws_projects.keys()],
@@ -198,20 +203,20 @@ async def update_runners(ws_context: context.WorkspaceContext) -> None:
198203
await stop_extension_runner(runner_to_delete)
199204
extension_runners.remove(runner_to_delete)
200205

201-
new_runners_coros = [
202-
start_extension_runner(runner_dir=new_dir, ws_context=ws_context)
203-
for new_dir in new_dirs
204-
if ws_context.ws_projects[new_dir].status == domain.ProjectStatus.READY
205-
]
206206
new_runners_tasks: list[asyncio.Task] = []
207207
try:
208208
async with asyncio.TaskGroup() as tg:
209-
for coro in new_runners_coros:
210-
runner_task = tg.create_task(coro)
211-
new_runners_tasks.append(runner_task)
209+
for new_dir in new_dirs:
210+
project = ws_context.ws_projects[new_dir]
211+
project_status = project.status
212+
if project_status == domain.ProjectStatus.READY:
213+
runner_task = tg.create_task(start_extension_runner(runner_dir=new_dir, ws_context=ws_context))
214+
new_runners_tasks.append(runner_task)
215+
elif project_status != domain.ProjectStatus.NO_FINECODE:
216+
raise RunnerFailedToStart(f"Runner for project '{project.name}' failed to start, status: {project_status.name}")
212217
except ExceptionGroup as eg:
213218
for exception in eg.exceptions:
214-
if isinstance(exception, runner_client.BaseRunnerRequestException):
219+
if isinstance(exception, runner_client.BaseRunnerRequestException) or isinstance(exception, RunnerFailedToStart):
215220
logger.error(exception.message)
216221
else:
217222
logger.exception(exception)

finecode/workspace_manager/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def on_shutdown(ws_context: context.WorkspaceContext):
4848
if ws_context.ws_projects[runner.working_dir_path].status
4949
== domain.ProjectStatus.RUNNING
5050
]
51-
logger.info(f"Stop all {len(running_runners)} running extension runners")
51+
logger.trace(f"Stop all {len(running_runners)} running extension runners")
5252

5353
for runner in running_runners:
5454
runner_manager.stop_extension_runner_sync(runner=runner)

0 commit comments

Comments
 (0)