Download frameworks/slime/.github/workflows/generate_github_workflows.py from SeanWang0027/rose-opd-implementation: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/SeanWang0027/rose-opd-implementation/resolve/main/frameworks/slime/.github/workflows/generate_github_workflows.py
- Command line
-
hf download hf://SeanWang0027/rose-opd-implementation/frameworks/slime/.github/workflows/generate_github_workflows.py
-
curl -L -o generate_github_workflows.py https://huggingface.co/SeanWang0027/rose-opd-implementation/resolve/main/frameworks/slime/.github/workflows/generate_github_workflows.py
1.06 kB
| from pathlib import Path | |
| import jinja2 | |
| def main(): | |
| """ | |
| Generates GitHub workflow YAML files from Jinja2 templates. | |
| """ | |
| workflows_dir = Path(__file__).parent | |
| print(f"Scan dir: {workflows_dir}") | |
| env = jinja2.Environment( | |
| loader=jinja2.FileSystemLoader(str(workflows_dir)), | |
| block_start_string="<%", | |
| block_end_string="%>", | |
| variable_start_string="<<", | |
| variable_end_string=">>", | |
| ) | |
| for template_path in workflows_dir.glob("*.yml.j2"): | |
| template = env.get_template(template_path.name) | |
| content = template.render() | |
| yaml_path = template_path.with_suffix("") | |
| with open(yaml_path, "w") as f: | |
| f.write( | |
| "#" * 80 | |
| + "\n# This file is auto-generated from the .j2 file via generate_github_workflows.py. Do not edit manually.\n" | |
| + "#" * 80 | |
| + "\n" | |
| ) | |
| f.write(content) | |
| print(f"Generated {yaml_path} from {template_path}") | |
| if __name__ == "__main__": | |
| main() | |