Skip to content

Commit 5e02bfb

Browse files
committed
Print image pull info
1 parent 24de395 commit 5e02bfb

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

llmstack/cli.py

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,36 +97,39 @@ def prepare_env():
9797

9898
def start_runner(environment):
9999
"""Start llmstack-runner container"""
100-
print('Starting LLMStack Runner')
100+
print('[llmstack-runner] Starting LLMStack Runner')
101101
client = docker.from_env()
102102
runner_container = None
103103
image_name = environment.get(
104104
'RUNNER_IMAGE_NAME', 'ghcr.io/trypromptly/llmstack-runner')
105105
image_tag = environment.get('RUNNER_IMAGE_TAG', 'main')
106106

107-
# Pull image if not already pulled
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
107+
# Pull image if it is not locally available
108+
if not any(f'{image_name}:{image_tag}' in image.tags for image in client.images.list()):
109+
print(f'[llmstack-runner] Pulling {image_name}:{image_tag}')
110+
111+
layers_status = defaultdict(dict)
112+
response = client.api.pull(
113+
image_name, tag=image_tag, stream=True, decode=True)
114+
for line in response:
115+
if 'id' in line:
116+
layer_id = line['id']
117+
# Update the status of this layer
118+
layers_status[layer_id].update(line)
119+
120+
# Print the current status of all layers
121+
for layer, status in layers_status.items():
122+
print(
123+
f"[llmstack-runner] Layer {layer}: {status.get('status', '')} {status.get('progress', '')}")
124+
print() # Add a blank line for better readability
125+
126+
elif 'status' in line and 'id' not in line:
127+
# Global status messages without a specific layer ID
128+
print(line['status'])
129+
130+
elif 'error' in line:
131+
print(f"Error: {line['error']}")
132+
break
130133

131134
try:
132135
runner_container = client.containers.get('llmstack-runner')

0 commit comments

Comments
 (0)