mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 00:20:18 +01:00
[BE] Add script to keept the runner-determinator scripts in sync (#136794)
Whenever we update runner_determinator.py it needs to be copied over into _runner-determinator.yml. This is a quick utility script to make that process less tedious Pull Request resolved: https://github.com/pytorch/pytorch/pull/136794 Approved by: https://github.com/zxiiro, https://github.com/jeanschmidt
This commit is contained in:
parent
4f93de8951
commit
f0fa460c60
4
.github/scripts/runner_determinator.py
vendored
4
.github/scripts/runner_determinator.py
vendored
|
|
@ -1,5 +1,9 @@
|
|||
# flake8: noqa: G004
|
||||
|
||||
# Note: Copies of this script in runner_determinator.py and _runner-determinator.yml
|
||||
# must be kept in sync. You can do it easily by running the following command:
|
||||
# python .github/scripts/update_runner_determinator.py
|
||||
|
||||
"""
|
||||
This runner determinator is used to determine which set of runners to run a
|
||||
GitHub job on. It uses the first comment of a GitHub issue (by default
|
||||
|
|
|
|||
31
.github/scripts/update_runner_determinator.py
vendored
Executable file
31
.github/scripts/update_runner_determinator.py
vendored
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import re
|
||||
|
||||
|
||||
# Read the contents of runner_determinator.py
|
||||
with open(".github/scripts/runner_determinator.py") as script_file:
|
||||
script_content = script_file.read()
|
||||
|
||||
# Indent the script content by 10 spaces to match destination indentation
|
||||
indented_script_content = "\n".join(
|
||||
[" " * 10 + line if line else line for line in script_content.splitlines()]
|
||||
)
|
||||
|
||||
# Read the contents of _runner-determinator.yml
|
||||
with open(".github/workflows/_runner-determinator.yml") as yml_file:
|
||||
yml_content = yml_file.read()
|
||||
|
||||
# Replace the content between the markers
|
||||
new_yml_content = re.sub(
|
||||
r"(cat <<EOF > runner_determinator.py\n)(.*?)(\n\s+EOF)",
|
||||
lambda match: match.group(1) + indented_script_content + match.group(3),
|
||||
yml_content,
|
||||
flags=re.DOTALL,
|
||||
)
|
||||
|
||||
# Save the modified content back to _runner-determinator.yml
|
||||
with open(".github/workflows/_runner-determinator.yml", "w") as yml_file:
|
||||
yml_file.write(new_yml_content)
|
||||
|
||||
print("Updated _runner-determinator.yml with the contents of runner_determinator.py")
|
||||
4
.github/workflows/_runner-determinator.yml
vendored
4
.github/workflows/_runner-determinator.yml
vendored
|
|
@ -59,6 +59,10 @@ jobs:
|
|||
cat <<EOF > runner_determinator.py
|
||||
# flake8: noqa: G004
|
||||
|
||||
# Note: Copies of this script in runner_determinator.py and _runner-determinator.yml
|
||||
# must be kept in sync. You can do it easily by running the following command:
|
||||
# python .github/scripts/update_runner_determinator.py
|
||||
|
||||
"""
|
||||
This runner determinator is used to determine which set of runners to run a
|
||||
GitHub job on. It uses the first comment of a GitHub issue (by default
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user