Skip to content

Conversation

achimnol
Copy link
Member

resolves #5525 (BA-2136)

@Copilot Copilot AI review requested due to automatic review settings August 23, 2025 15:21
@github-actions github-actions bot added size:L 100~500 LoC comp:agent Related to Agent component labels Aug 23, 2025
.fix.md -> 5609.fix.md

Co-authored-by: octodog <[email protected]>
Copy link
Contributor

@Copilot 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 replaces the deprecated pkg_resources module with importlib.resources to modernize resource access in the Backend.AI agent codebase, addressing compatibility with Python 3.12+ where pkg_resources is deprecated.

Key changes:

  • Replace pkg_resources.resource_filename() calls with files().joinpath() pattern from importlib.resources
  • Add from importlib.resources import files imports across affected modules
  • Remove import pkg_resources statements

Reviewed Changes

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

Show a summary per file
File Description
src/ai/backend/agent/stage/kernel_lifecycle/docker/scratch.py Updated dotfile cloning to use importlib for resource access
src/ai/backend/agent/stage/kernel_lifecycle/docker/mount/krunner.py Migrated krunner artifact path resolution and file access
src/ai/backend/agent/kubernetes/utils.py Updated container image path resolution
src/ai/backend/agent/kubernetes/kernel.py Migrated krunner environment preparation and file copying
src/ai/backend/agent/kubernetes/agent.py Updated dotfile cloning in Kubernetes agent
src/ai/backend/agent/docker/utils.py Updated container image path resolution
src/ai/backend/agent/docker/kernel.py Migrated krunner environment and metadata handling
src/ai/backend/agent/docker/agent.py Updated dotfile cloning and krunner file resolution
src/ai/backend/agent/agent.py Updated krunner info retrieval and artifact path resolution
changes/.fix.md Added changelog entry

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +484 to +486
artifact_path = Path(str(files("ai.backend.agent").joinpath("../runner")))
kernel_path = Path(str(files("ai.backend.agent").joinpath("../kernel")))
helpers_path = Path(str(files("ai.backend.agent").joinpath("../helpers")))
Copy link
Preview

Copilot AI Aug 23, 2025

Choose a reason for hiding this comment

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

The relative path navigation using "../runner" could be fragile. Consider using a more explicit package reference or verify this path structure is guaranteed to remain stable.

Suggested change
artifact_path = Path(str(files("ai.backend.agent").joinpath("../runner")))
kernel_path = Path(str(files("ai.backend.agent").joinpath("../kernel")))
helpers_path = Path(str(files("ai.backend.agent").joinpath("../helpers")))
base_path = Path(__file__).parent.parent # ai/backend/agent/
artifact_path = base_path / "runner"
kernel_path = base_path / "kernel"
helpers_path = base_path / "helpers"

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@Copilot 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:agent Related to Agent component size:L 100~500 LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace deprecated usage of pkg_resources with importlib
1 participant