@@ -30,7 +30,13 @@ import (
3030)
3131
3232// Build builds the user materials into the OCI image which follows the Model Spec.
33- func (b * backend ) Build (ctx context.Context , modelfilePath , workDir , target string ) error {
33+ func (b * backend ) Build (ctx context.Context , modelfilePath , workDir , target string , opts ... Option ) error {
34+ // apply options.
35+ options := & Options {}
36+ for _ , opt := range opts {
37+ opt (options )
38+ }
39+
3440 // parse the repo name and tag name from target.
3541 ref , err := ParseReference (target )
3642 if err != nil {
@@ -48,7 +54,7 @@ func (b *backend) Build(ctx context.Context, modelfilePath, workDir, target stri
4854 }
4955
5056 layers := []ocispec.Descriptor {}
51- layerDescs , err := b .process (ctx , workDir , repo , b .getProcessors (modelfile )... )
57+ layerDescs , err := b .process (ctx , workDir , repo , options , b .getProcessors (modelfile )... )
5258 if err != nil {
5359 return fmt .Errorf ("failed to process files: %w" , err )
5460 }
@@ -61,15 +67,15 @@ func (b *backend) Build(ctx context.Context, modelfilePath, workDir, target stri
6167 return fmt .Errorf ("failed to build image config: %w" , err )
6268 }
6369
64- fmt .Printf ("%-15s => %s (%s)\n " , "Built config" , configDesc .Digest , humanize .IBytes (uint64 (configDesc .Size )))
70+ fmt .Printf ("%s => %s (%s)\n " , "Built config" , configDesc .Digest , humanize .IBytes (uint64 (configDesc .Size )))
6571
6672 // build the image manifest.
6773 manifestDesc , err := build .BuildManifest (ctx , b .store , repo , tag , layers , configDesc , manifestAnnotation ())
6874 if err != nil {
6975 return fmt .Errorf ("failed to build image manifest: %w" , err )
7076 }
7177
72- fmt .Printf ("%-15s => %s (%s)\n " , "Built manifest" , manifestDesc .Digest , humanize .IBytes (uint64 (manifestDesc .Size )))
78+ fmt .Printf ("%s => %s (%s)\n " , "Built manifest" , manifestDesc .Digest , humanize .IBytes (uint64 (manifestDesc .Size )))
7379 return nil
7480}
7581
@@ -96,10 +102,10 @@ func (b *backend) getProcessors(modelfile modelfile.Modelfile) []processor.Proce
96102}
97103
98104// process walks the user work directory and process the identified files.
99- func (b * backend ) process (ctx context.Context , workDir string , repo string , processors ... processor.Processor ) ([]ocispec.Descriptor , error ) {
105+ func (b * backend ) process (ctx context.Context , workDir string , repo string , opts * Options , processors ... processor.Processor ) ([]ocispec.Descriptor , error ) {
100106 descriptors := []ocispec.Descriptor {}
101107 for _ , p := range processors {
102- descs , err := p .Process (ctx , workDir , repo )
108+ descs , err := p .Process (ctx , workDir , repo , processor . WithConcurrency ( opts . concurrency ) )
103109 if err != nil {
104110 return nil , err
105111 }
0 commit comments