File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 11import json
22import os
3+ import shutil
34import urllib .error
45from typing import Optional
56
@@ -42,7 +43,7 @@ class OllamaRepository:
4243 def __init__ (self , name : str , namespace : str = "library" ):
4344 self .name = name
4445 self .namespace = namespace
45- self .registry_head = f"{ OllamaRepository .REGISTRY_URL } /{ namespace } /{ name } "
46+ self .registry_head = f"{ OllamaRepository .REGISTRY_URL } /{ self . namespace } /{ self . name } "
4647 self .blob_url = f"{ self .registry_head } /blobs"
4748 self .headers = {"Accept" : OllamaRepository .ACCEPT }
4849
@@ -159,6 +160,20 @@ def pull(self, args):
159160 perror (f"Using cached ollama://{ organization } /{ name } :{ tag } ..." )
160161 return
161162
163+ #
164+ # Temporary migration routine to prevent pulling non-namespaced models again due to
165+ # https://github.com/containers/ramalama/pull/1721
166+ #
167+ _ , _ , org = super ().extract_model_identifiers ()
168+ if not org :
169+ o = Ollama (f"{ self .model_name } /{ self .model_name } " , self ._model_store_path )
170+ if o .exists ():
171+ try :
172+ shutil .move (o .model_store .model_base_directory , self .model_store .model_base_directory )
173+ return
174+ except Exception :
175+ pass
176+
162177 ollama_repo = OllamaRepository (name , organization )
163178 manifest = ollama_repo .fetch_manifest (tag )
164179 ollama_cache_path = in_existing_cache (self .model_name , tag )
You can’t perform that action at this time.
0 commit comments