|
3 | 3 | import secrets |
4 | 4 | import subprocess |
5 | 5 | import sys |
| 6 | +from collections import defaultdict |
6 | 7 |
|
7 | 8 | import docker |
8 | 9 | import toml |
@@ -104,10 +105,28 @@ def start_runner(environment): |
104 | 105 | image_tag = environment.get('RUNNER_IMAGE_TAG', 'main') |
105 | 106 |
|
106 | 107 | # Pull image if not already pulled |
107 | | - for line in client.api.pull(image_name, tag=image_tag, stream=True, decode=True): |
108 | | - if 'progress' in line and 'id' in line: |
109 | | - print( |
110 | | - f'[llmstack-runner] Pulling {line["id"][:12]} {line["progress"]}', end='\r') |
| 108 | + layers_status = defaultdict(dict) |
| 109 | + response = client.api.pull( |
| 110 | + image_name, tag=image_tag, stream=True, decode=True) |
| 111 | + for line in response: |
| 112 | + if 'id' in line: |
| 113 | + layer_id = line['id'] |
| 114 | + # Update the status of this layer |
| 115 | + layers_status[layer_id].update(line) |
| 116 | + |
| 117 | + # Print the current status of all layers |
| 118 | + for layer, status in layers_status.items(): |
| 119 | + print( |
| 120 | + f"[llmstack-runner] Layer {layer}: {status.get('status', '')} {status.get('progress', '')}") |
| 121 | + print() # Add a blank line for better readability |
| 122 | + |
| 123 | + elif 'status' in line and 'id' not in line: |
| 124 | + # Global status messages without a specific layer ID |
| 125 | + print(line['status']) |
| 126 | + |
| 127 | + elif 'error' in line: |
| 128 | + print(f"Error: {line['error']}") |
| 129 | + break |
111 | 130 |
|
112 | 131 | try: |
113 | 132 | runner_container = client.containers.get('llmstack-runner') |
|
0 commit comments