Making a model in MLLinearRegressor works with Sonoma, but on upgrading to 15.3.1 it no longer does "anything"

I was generating models using the code:-

import Foundation
import CreateML
import TabularData
import CoreML

....

func makeTheModel(columntopredict:String,training:DataFrame,colstouse:[String],numberofmodels:Int) -> [MLLinearRegressor] {
        
        var returnmodels = [MLLinearRegressor]()
        
        
        var result = 0.0
        for i in 0...numberofmodels {
           
            
            let pms = MLLinearRegressor.ModelParameters(validation: .split(strategy: .automatic))

            do {
                let tm = try MLLinearRegressor(trainingData: training, targetColumn: columntopredict)
             
                returnmodels.append(tm)
             
            }
            catch let error as NSError {
                print("Error: \(error.localizedDescription)")
            }
        }
        
        return returnmodels
        
    }

Which worked absolutely fine with Sonoma, but upon upgrading the OS to 15.3.1, it does absolutely nothing.

I get no error messages, I get nothing, the code just pauses. If I look at CPU usage, as soon as it hits the line let tm = try MLLinearRegressor(trainingData: training, targetColumn: columntopredict) the CPU usage drops to 0%

What am I doing wrong? Is there a flag I need to set somewhere in Xcode?

This is on an M1 MacBook Pro

Any help would be greatly appreciated

OK, I have learnt why it was failing to do anything.

I had set it up within a Task, using

Task {
            await withTaskGroup(of: Void.self) { group in
                for i in 0...numberoftasks - 1 {
                    group.addTask {
                        autoreleasepool {
                            self.functiontomakemodel()
                        }
                    }
                }
            }
            
        }


If I remove the Task, and just keep the loop it works.

Now I just need to learn how to adjust this to use multiple cores with the new OS, any help would be much appreciated.

Making a model in MLLinearRegressor works with Sonoma, but on upgrading to 15.3.1 it no longer does "anything"
 
 
Q