11import inspect
2+ import os .path
23import queue
34import threading
45from abc import ABC
@@ -150,12 +151,16 @@ def __init__(self, model_name: Optional[str]) -> None:
150151
151152 @rank_zero_only
152153 def _upload_model (self , filepath : str , metadata : Optional [dict ] = None ) -> None :
153- # todo: use filename as version but need to validate that such version does not exists yet
154154 if not self .model_registry :
155155 raise RuntimeError (
156156 "Model name is not specified neither updated by `setup` method via Trainer."
157157 " Please set the model name before uploading or ensure that `setup` method is called."
158158 )
159+ model_registry = self .model_registry
160+ if os .path .isfile (filepath ):
161+ # parse the file name as version
162+ version , _ = os .path .splitext (os .path .basename (filepath ))
163+ model_registry += f":{ version } "
159164 if not metadata :
160165 metadata = {}
161166 # Add the integration name to the metadata
@@ -164,7 +169,7 @@ def _upload_model(self, filepath: str, metadata: Optional[dict] = None) -> None:
164169 ckpt_class = mro [abc_index - 1 ]
165170 metadata .update ({"litModels_integration" : ckpt_class .__name__ })
166171 # Add to queue instead of uploading directly
167- get_model_manager ().queue_upload (registry_name = self . model_registry , filepath = filepath , metadata = metadata )
172+ get_model_manager ().queue_upload (registry_name = model_registry , filepath = filepath , metadata = metadata )
168173
169174 @rank_zero_only
170175 def _remove_model (self , trainer : "pl.Trainer" , filepath : str ) -> None :
0 commit comments