6060
6161// Attach attaches user materials into the model artifact which follows the Model Spec.
6262func (b * backend ) Attach (ctx context.Context , filepath string , cfg * config.Attach ) error {
63- logrus .Infof ("attaching file %s, cfg : %+v" , filepath , cfg )
63+ logrus .Infof ("attach: starting attach operation for file %s [config : %+v] " , filepath , cfg )
6464 srcManifest , err := b .getManifest (ctx , cfg .Source , cfg .OutputRemote , cfg .PlainHTTP , cfg .Insecure )
6565 if err != nil {
6666 return fmt .Errorf ("failed to get source manifest: %w" , err )
@@ -71,7 +71,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
7171 return fmt .Errorf ("failed to get source model config: %w" , err )
7272 }
7373
74- logrus .Infof ("source model config: %+v" , srcModelConfig )
74+ logrus .Infof ("attach: loaded source model config [ %+v] " , srcModelConfig )
7575
7676 var foundLayer * ocispec.Descriptor
7777 for _ , layer := range srcManifest .Layers {
@@ -87,7 +87,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
8787 }
8888 }
8989
90- logrus .Infof ("found original layer: %+v" , foundLayer )
90+ logrus .Infof ("attach: found existing layer for file %s [%+v]" , filepath , foundLayer )
9191
9292 layers := srcManifest .Layers
9393 if foundLayer != nil {
@@ -100,7 +100,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
100100 }
101101 }
102102
103- proc := b .getProcessor (filepath , cfg )
103+ proc := b .getProcessor (filepath , cfg . Raw )
104104 if proc == nil {
105105 return fmt .Errorf ("failed to get processor for file %s" , filepath )
106106 }
@@ -123,7 +123,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
123123 layers = append (layers , newLayers ... )
124124 sortLayers (layers )
125125
126- logrus .Infof ( "new sorted layers: %+v" , layers )
126+ logrus .Debugf ( "attach: generated sorted layers [layers : %+v] " , layers )
127127
128128 diffIDs := []godigest.Digest {}
129129 for _ , layer := range layers {
@@ -145,7 +145,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
145145 Name : srcModelConfig .Descriptor .Name ,
146146 }
147147
148- logrus .Infof ("new model config: %+v" , modelConfig )
148+ logrus .Infof ("attach: built model config [ %+v] " , modelConfig )
149149
150150 configDesc , err := builder .BuildConfig (ctx , layers , modelConfig , hooks .NewHooks (
151151 hooks .WithOnStart (func (name string , size int64 , reader io.Reader ) io.Reader {
@@ -178,6 +178,7 @@ func (b *backend) Attach(ctx context.Context, filepath string, cfg *config.Attac
178178 return fmt .Errorf ("failed to build model manifest: %w" , err )
179179 }
180180
181+ logrus .Infof ("attach: successfully attached file %s" , filepath )
181182 return nil
182183}
183184
@@ -272,34 +273,34 @@ func (b *backend) getModelConfig(ctx context.Context, reference string, desc oci
272273 return & model , nil
273274}
274275
275- func (b * backend ) getProcessor (filepath string , cfg * config. Attach ) processor.Processor {
276+ func (b * backend ) getProcessor (filepath string , rawMediaType bool ) processor.Processor {
276277 if modelfile .IsFileType (filepath , modelfile .ConfigFilePatterns ) {
277278 mediaType := modelspec .MediaTypeModelWeightConfig
278- if cfg . Raw {
279+ if rawMediaType {
279280 mediaType = modelspec .MediaTypeModelWeightConfigRaw
280281 }
281282 return processor .NewModelConfigProcessor (b .store , mediaType , []string {filepath })
282283 }
283284
284285 if modelfile .IsFileType (filepath , modelfile .ModelFilePatterns ) {
285286 mediaType := modelspec .MediaTypeModelWeight
286- if cfg . Raw {
287+ if rawMediaType {
287288 mediaType = modelspec .MediaTypeModelWeightRaw
288289 }
289290 return processor .NewModelProcessor (b .store , mediaType , []string {filepath })
290291 }
291292
292293 if modelfile .IsFileType (filepath , modelfile .CodeFilePatterns ) {
293294 mediaType := modelspec .MediaTypeModelCode
294- if cfg . Raw {
295+ if rawMediaType {
295296 mediaType = modelspec .MediaTypeModelCodeRaw
296297 }
297298 return processor .NewCodeProcessor (b .store , mediaType , []string {filepath })
298299 }
299300
300301 if modelfile .IsFileType (filepath , modelfile .DocFilePatterns ) {
301302 mediaType := modelspec .MediaTypeModelDoc
302- if cfg . Raw {
303+ if rawMediaType {
303304 mediaType = modelspec .MediaTypeModelDocRaw
304305 }
305306 return processor .NewDocProcessor (b .store , mediaType , []string {filepath })
0 commit comments