-
Notifications
You must be signed in to change notification settings - Fork 164
refactor(BA-2136): Replace deprecated pkg_resources
with importlib
#5609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
.fix.md -> 5609.fix.md Co-authored-by: octodog <[email protected]>
There was a problem hiding this 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 withfiles().joinpath()
pattern fromimportlib.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.
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"))) |
There was a problem hiding this comment.
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.
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.
There was a problem hiding this 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.
resolves #5525 (BA-2136)