-
Notifications
You must be signed in to change notification settings - Fork 316
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
[vLLM] metadata script #959
Open
mishig25
wants to merge
2
commits into
main
Choose a base branch
from
vllm_metadata
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,89 @@ | ||||||
# Step1: scrape https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/registry.py | ||||||
# Step2: upload to https://huggingface.co/datasets/huggingface/vllm-metadata | ||||||
name: Daily vLLM Metadata Scraper | ||||||
|
||||||
on: | ||||||
schedule: | ||||||
# Runs at 00:00 UTC every day | ||||||
- cron: "0 0 * * *" | ||||||
workflow_dispatch: | ||||||
|
||||||
jobs: | ||||||
run-python-script: | ||||||
runs-on: ubuntu-latest | ||||||
|
||||||
steps: | ||||||
- name: Checkout repository | ||||||
uses: actions/checkout@v3 | ||||||
|
||||||
- name: Set up Python | ||||||
uses: actions/setup-python@v4 | ||||||
with: | ||||||
python-version: "3.10" | ||||||
|
||||||
- name: Install dependencies | ||||||
run: | | ||||||
python -m pip install --upgrade pip | ||||||
pip install requests huggingface-hub | ||||||
|
||||||
- name: Execute Python script | ||||||
env: | ||||||
HF_VLLM_METADATA_PUSH: ${{ secrets.HF_VLLM_METADATA_PUSH }} | ||||||
run: | | ||||||
python -c ' | ||||||
import os | ||||||
import ast | ||||||
import json | ||||||
import requests | ||||||
from huggingface_hub import HfApi | ||||||
|
||||||
def extract_models_sub_dict(parsed_code, sub_dict_name): | ||||||
class MODELS_SUB_LIST_VISITOR(ast.NodeVisitor): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
def __init__(self): | ||||||
self.key = sub_dict_name | ||||||
self.value = None | ||||||
|
||||||
def visit_Assign(self, node): | ||||||
for target in node.targets: | ||||||
if isinstance(target, ast.Name) and target.id == self.key: | ||||||
self.value = ast.literal_eval(node.value) | ||||||
|
||||||
visitor = MODELS_SUB_LIST_VISITOR() | ||||||
visitor.visit(parsed_code) | ||||||
return visitor.value | ||||||
|
||||||
def extract_models_dict(source_code): | ||||||
parsed_code = ast.parse(source_code) | ||||||
class MODELS_LIST_VISITOR(ast.NodeVisitor): | ||||||
def __init__(self): | ||||||
self.key = "_MODELS" | ||||||
self.value = {} | ||||||
def visit_Assign(self, node): | ||||||
for target in node.targets: | ||||||
if not isinstance(target, ast.Name): | ||||||
return | ||||||
if target.id == self.key: | ||||||
for value in node.value.values: | ||||||
dict = extract_models_sub_dict(parsed_code, value.id) | ||||||
self.value.update(dict) | ||||||
visitor = MODELS_LIST_VISITOR() | ||||||
visitor.visit(parsed_code) | ||||||
return visitor.value | ||||||
|
||||||
url = "https://raw.githubusercontent.com/vllm-project/vllm/refs/heads/main/vllm/model_executor/models/registry.py" | ||||||
response = requests.get(url) | ||||||
response.raise_for_status() # Raise an exception for bad status codes | ||||||
source_code = response.text | ||||||
|
||||||
models_dict = extract_models_dict(source_code) | ||||||
architectures = [item for tup in models_dict.values() for item in tup] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Maybe, if we want to remove duplicates and assuming tuple order does not matter (i.e., |
||||||
architectures_json_str = json.dumps(architectures, indent=4) | ||||||
json_bytes = architectures_json_str.encode("utf-8") | ||||||
|
||||||
api = HfApi(token=os.environ["HF_VLLM_METADATA_PUSH"]) | ||||||
mishig25 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
api.upload_file( | ||||||
path_or_fileobj=json_bytes, | ||||||
path_in_repo="architectures.json", | ||||||
repo_id="huggingface/vllm-metadata", | ||||||
repo_type="dataset", | ||||||
)' |
Oops, something went wrong.
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.
Can we move this code to a script rather than having the Python code in the yaml? It will be easier to maintain, update, and review
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.
agree with this point
I think maintaining a separate python script would be painful. We would need to find a place to place this python script and tell the yaml job to download and run this python script (which can introduce other security issues since we are running what's being downloaded)