-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add package query in draft.py (not yet enabled) #1083
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f84999a
feat: add package query in draft.py (not yet enabled)
Jensen246 cc7e607
feat: integrate package query into task_gen and cache runtime environ…
Jensen246 8ff5ba1
some refinement
peteryang1 ccadb49
feat: merge default packages with CLI args in package_info.py
Jensen246 64b00af
fix: code style
Jensen246 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
rdagent/scenarios/data_science/proposal/exp_gen/package_info.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import sys | ||
| from importlib.metadata import distributions | ||
|
|
||
|
|
||
| def get_installed_packages(): | ||
| return {dist.metadata["Name"].lower(): dist.version for dist in distributions()} | ||
|
|
||
|
|
||
| def print_filtered_packages(installed_packages, filtered_packages): | ||
| to_print = [] | ||
| for package_name in filtered_packages: | ||
| version = installed_packages.get(package_name.lower()) | ||
| if version: | ||
| to_print.append((package_name, version)) | ||
| if not to_print: | ||
| print("=== No matching packages found ===") | ||
| else: | ||
| print("=== Installed Packages ===") | ||
| for package_name, version in to_print: | ||
| # Print package name and version in the format "package_name==version" | ||
| print(f"{package_name}=={version}") | ||
|
|
||
|
|
||
| def get_python_packages(): | ||
| # Allow the caller to pass a custom package list via command-line arguments. | ||
| # Example: `python package_info.py pandas torch scikit-learn` | ||
| # If no extra arguments are provided we fall back to the original default list | ||
| # to keep full backward-compatibility. | ||
| filtered_packages = ( | ||
| sys.argv[1:] | ||
| if len(sys.argv) > 1 | ||
| else [ | ||
| "transformers", | ||
| "accelerate", | ||
| "torch", | ||
| "tensorflow", | ||
| "pandas", | ||
| "numpy", | ||
| "scikit-learn", | ||
| "scipy", | ||
| "xgboost", | ||
| "sklearn", | ||
| "lightgbm", | ||
| "vtk", | ||
| "opencv-python", | ||
| "keras", | ||
| "matplotlib", | ||
| "pydicom", | ||
| ] | ||
| ) | ||
|
|
||
| installed_packages = get_installed_packages() | ||
|
|
||
| print_filtered_packages(installed_packages, filtered_packages) | ||
|
|
||
| # TODO: Handle missing packages. | ||
| # Report packages that are requested by the LLM but are not installed. | ||
| missing_pkgs = [pkg for pkg in filtered_packages if pkg.lower() not in installed_packages] | ||
| if missing_pkgs: | ||
| print("\n=== Missing Packages (Avoid using these packages) ===") | ||
| for pkg in missing_pkgs: | ||
| print(pkg) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| get_python_packages() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
list(set(A) + set(B))