|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | 3 | import yaml |
| 4 | +import re |
4 | 5 | from pathlib import Path |
5 | 6 |
|
6 | 7 |
|
7 | 8 | REPO_ROOT = Path(__file__).parent.parent |
8 | 9 |
|
9 | 10 |
|
| 11 | +def extract_llama_stack_version(): |
| 12 | + """Extract Llama Stack version from the Containerfile.""" |
| 13 | + containerfile_path = REPO_ROOT / "distribution" / "Containerfile" |
| 14 | + |
| 15 | + if not containerfile_path.exists(): |
| 16 | + print(f"Error: {containerfile_path} not found") |
| 17 | + exit(1) |
| 18 | + |
| 19 | + try: |
| 20 | + with open(containerfile_path, "r") as file: |
| 21 | + content = file.read() |
| 22 | + |
| 23 | + # Look for llama-stack version in pip install commands |
| 24 | + # Pattern matches: llama-stack==X.Y.Z |
| 25 | + pattern = r"llama-stack==([0-9]+\.[0-9]+\.[0-9]+)" |
| 26 | + match = re.search(pattern, content) |
| 27 | + |
| 28 | + if match: |
| 29 | + return match.group(1) |
| 30 | + else: |
| 31 | + print("Error: Could not find llama-stack version in Containerfile") |
| 32 | + exit(1) |
| 33 | + |
| 34 | + except Exception as e: |
| 35 | + print(f"Error reading Containerfile: {e}") |
| 36 | + exit(1) |
| 37 | + |
| 38 | + |
10 | 39 | def gen_distro_table(providers_data): |
11 | 40 | # Start with table header |
12 | 41 | table_lines = ["| API | Provider |", "|-----|----------|"] |
@@ -37,18 +66,23 @@ def gen_distro_docs(): |
37 | 66 | run_yaml_path = REPO_ROOT / "distribution" / "run.yaml" |
38 | 67 | readme_path = REPO_ROOT / "distribution" / "README.md" |
39 | 68 |
|
40 | | - # Check if run.yaml exists |
| 69 | + # check if run.yaml exists |
41 | 70 | if not run_yaml_path.exists(): |
42 | 71 | print(f"Error: {run_yaml_path} not found") |
43 | 72 | return 1 |
44 | 73 |
|
| 74 | + # extract Llama Stack version from Containerfile |
| 75 | + version = extract_llama_stack_version() |
| 76 | + |
45 | 77 | # header section |
46 | | - header = """<!-- This file is automatically generated by scripts/gen_distro_doc.py - do not update manually --> |
| 78 | + header = f"""<!-- This file is automatically generated by scripts/gen_distro_doc.py - do not update manually --> |
47 | 79 |
|
48 | 80 | # Open Data Hub Llama Stack Distribution Image |
49 | 81 |
|
50 | 82 | This image contains the official Open Data Hub Llama Stack distribution, with all the packages and configuration needed to run a Llama Stack server in a containerized environment. |
51 | 83 |
|
| 84 | +The image is currently shipping with upstream Llama Stack version [{version}](https://github.com/llamastack/llama-stack/releases/tag/v{version}) |
| 85 | +
|
52 | 86 | You can see an overview of the APIs and Providers the image ships with in the table below. |
53 | 87 |
|
54 | 88 | """ |
|
0 commit comments