-
Notifications
You must be signed in to change notification settings - Fork 13
Merge from GO #455
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
Merge from GO #455
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4b389f3
Added option to skip detect-sudo, support postfix detection
amd-arsuresh dc76ec1
[Automated Commit] Format Codebase [skip ci]
github-actions[bot] ffc4e25
Support installation variations in get,llvm
amd-arsuresh fc772a2
Merge branch 'mlcommons:dev' into dev
arjunsuresh 988924a
Fix tags for nvidia-harness
arjunsuresh 061bf60
Support tar.bz2, 7z and rar in extract-file, export more variables in…
amd-arsuresh 0b55f57
[Automated Commit] Format Codebase [skip ci]
github-actions[bot] 833bb10
Merge branch 'mlcommons:dev' into dev
arjunsuresh a15e989
Added a parser for system-detail.txt
amd-arsuresh 0d9cdd7
[Automated Commit] Format Codebase [skip ci]
github-actions[bot] 9fa857d
Merge branch 'dev' into dev
arjunsuresh 9fc49f6
Added initial support for mlc doc script
amd-arsuresh 4e285c3
[Automated Commit] Format Codebase [skip ci]
github-actions[bot] da579d2
Update build_wheels.yml
arjunsuresh 76268ea
Update list_modified_files.py
arjunsuresh 5115c40
[Automated Commit] Format Codebase [skip ci]
github-actions[bot] 09fd954
Update run-tests-on-modified-meta.yml to handle documentation
arjunsuresh 36aab18
Update meta.yaml
arjunsuresh 77ac5bb
Update run-tests-on-modified-meta.yml
arjunsuresh 1d1da6c
Update run-tests-on-modified-meta.yml
arjunsuresh 1742c84
Update doc.py
arjunsuresh 2b86437
Update run-tests-on-modified-meta.yml
arjunsuresh be6c967
Update run-tests-on-modified-meta.yml
arjunsuresh 8bafe04
Update run-tests-on-modified-meta.yml
arjunsuresh 9c3e29d
Update run-tests-on-modified-meta.yml
arjunsuresh 7e80ef5
Update run-tests-on-modified-meta.yml
arjunsuresh c5f11d2
Update run-tests-on-modified-meta.yml
arjunsuresh a098b93
Create document-scripts.yml
arjunsuresh 3656e78
Update run-tests-on-modified-meta.yml
arjunsuresh 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# This workflow will automatically update the README for any updated MLC script | ||
name: Document script on modified meta | ||
|
||
on: | ||
push: | ||
branches: [ "dev" ] | ||
paths: | ||
- 'script/**meta.yaml' | ||
|
||
jobs: | ||
get_modified_files: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
processed_files: ${{ steps.modified-files.outputs.processed_files }} | ||
|
||
steps: | ||
- name: 'Checkout' | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
pip install pyyaml | ||
|
||
- name: Get changed files | ||
id: modified-files | ||
env: | ||
filter: ${{ github.event.before }} | ||
run: | | ||
changed_files=$(git diff --name-only $filter | grep -E '.*\.yaml$') | ||
echo "$changed_files" | python3 .github/scripts/list_modified_files.py | ||
|
||
document_modified_scripts: | ||
runs-on: ubuntu-latest | ||
needs: get_modified_files | ||
if: ${{ needs.get_modified_files.outputs.processed_files != '[]' && needs.get_modified_files.outputs.processed_files != '' }} | ||
permissions: | ||
contents: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
modified_metas: ${{ fromJSON(needs.get_modified_files.outputs.processed_files).modified_metas }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
path: automation-scripts | ||
|
||
- name: Set up Git for commit | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
|
||
- name: Document meta.yaml file | ||
run: | | ||
echo "Documenting ${{ matrix.modified_metas.file }}" | ||
|
||
pip install mlcflow | ||
mlc add repo automation-scripts | ||
mlc doc script ${{ matrix.modified_metas.uid}} --quiet | ||
cd automation-scripts | ||
find . -type f -name README.md -exec git add {} + | ||
# Use the GitHub actor's name and email | ||
git config --global user.name github-actions[bot] | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
# Commit changes | ||
git commit -m '[Automated Commit] Document ${{ matrix.modified_metas.file}} [skip ci]' | ||
git push | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import os | ||
from mlc import utils | ||
from utils import * | ||
import logging | ||
from pathlib import PureWindowsPath, PurePosixPath | ||
import copy | ||
|
||
|
||
def generate_doc(self_module, input_params): | ||
""" | ||
Generates the documentation of MLC scripts. | ||
|
||
Args: | ||
self_module: Reference to the current module for internal calls. | ||
i: Dictionary containing input parameters. | ||
|
||
Returns: | ||
Dictionary with the result of the operation. Keys: | ||
- 'return': 0 on success, >0 on error. | ||
- 'error': Error message (if any). | ||
""" | ||
|
||
# Extract and handle basic inputs | ||
quiet = input_params.get('quiet', False) | ||
logger = self_module.logger | ||
env = input_params.get('env', {}) | ||
generic_inputs = self_module.input_flags_converted_to_env | ||
|
||
# Step 2: Search for scripts | ||
search_result = self_module.search(input_params.copy()) | ||
if search_result['return'] > 0: | ||
return search_result | ||
|
||
scripts_list = search_result['list'] | ||
if not scripts_list: | ||
return {'return': 1, 'error': 'No scripts were found'} | ||
|
||
env = input_params.get('env', {}) | ||
state_data = input_params.get('state', {}) | ||
constant_vars = input_params.get('const', {}) | ||
constant_state = input_params.get('const_state', {}) | ||
tag_values = input_params.get('tags', '').split(",") | ||
variation_tags = [tag[1:] for tag in tag_values if tag.startswith("_")] | ||
|
||
# Step 4: Iterate over scripts and generate Dockerfile | ||
for script in sorted(scripts_list, key=lambda x: x.meta.get('alias', '')): | ||
metadata = script.meta | ||
script_directory = script.path | ||
script_tags = metadata.get("tags", []) | ||
script_alias = metadata.get('alias', '') | ||
script_uid = metadata.get('uid', '') | ||
script_input_mapping = metadata.get('input_mapping', {}) | ||
script_input_description = metadata.get('input_description', {}) | ||
|
||
r = generate_docs(metadata, script_directory, generic_inputs) | ||
if r['return'] > 0: | ||
continue | ||
|
||
return {'return': 0} | ||
|
||
|
||
def generate_docs(metadata, script_path, generic_inputs): | ||
script_name = metadata.get('alias', metadata['uid']) | ||
readme_prefix = f"""This README is automatically generated. Please follow the [script execution document](https://docs.mlcommons.org/mlcflow/targets/script/execution-flow/) to understand more about the MLC script execution. | ||
""" | ||
doc_content = f"""# README for {script_name} | ||
{readme_prefix} | ||
""" | ||
|
||
readme_dir = os.path.join(script_path, "docs") | ||
|
||
if not os.path.exists(readme_dir): | ||
os.makedirs(readme_dir) | ||
|
||
script_tags = metadata.get("tags", []) | ||
script_tags_help = metadata.get("tags_help", '') | ||
if not script_tags_help: | ||
tags_string = ",".join(script_tags) | ||
else: | ||
tags_string = script_tags_help | ||
|
||
script_input_mapping = metadata.get('input_mapping', {}) | ||
script_input_description = metadata.get('input_description', {}) | ||
|
||
r = get_run_readme( | ||
tags_string, | ||
script_input_mapping, | ||
script_input_description, | ||
generic_inputs) | ||
if r['return'] > 0: | ||
return r | ||
|
||
run_readme = r['run_readme'] | ||
|
||
doc_content += run_readme | ||
|
||
readme_path = os.path.join(readme_dir, "README.md") | ||
with open(readme_path, "w") as f: | ||
f.write(doc_content) | ||
print(f"Readme generated at {readme_path}") | ||
|
||
return {'return': 0} | ||
|
||
|
||
def get_run_readme(tags, input_mapping, input_description, generic_inputs): | ||
run_readme = f"""## Run Commands | ||
|
||
```mlcr {tags} | ||
``` | ||
""" | ||
|
||
if input_description: | ||
input_description_string = generate_markdown( | ||
"Script Inputs", input_description) | ||
else: | ||
input_description_string = "No script specific inputs" | ||
|
||
run_readme += input_description_string | ||
|
||
generic_input_string = generate_markdown( | ||
"Generic Script Inputs", generic_inputs) | ||
|
||
run_readme += generic_input_string | ||
|
||
return {'return': 0, 'run_readme': run_readme} | ||
|
||
|
||
def infer_type(field): | ||
if "dtype" in field: | ||
return field["dtype"] | ||
elif "default" in field: | ||
return type(field["default"]).__name__ | ||
else: | ||
return "str" | ||
|
||
|
||
def generate_markdown(heading, input_dict): | ||
lines = [ | ||
f"### {heading}\n", | ||
"| Name | Description | Default | Type |", | ||
"|------|-------------|---------|------|"] | ||
for key in sorted( | ||
input_dict, key=lambda k: input_dict[k].get("sort", 9999)): | ||
field = input_dict[key] | ||
desc = field.get("desc", "") | ||
default = field.get("default", "") | ||
dtype = infer_type(field) | ||
lines.append(f"| `{key}` | {desc} | `{default}` | {dtype} |") | ||
return "\n".join(lines) |
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
Oops, something went wrong.
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.
Hi @arjunsuresh , would
--skip-old-files
skip the partially written files also if the previous extraction was not clean?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.
tar will not extract even if the file is only partially written.