Skip to content

Bug: FluidMLPRegressor's .fit method evaluating 'action' before finishing #167

@mccrmck

Description

@mccrmck

Please tell us what you were doing! You can include code and files by drag and dropping them into the text area.

Trying to .dump a DataSet as an action function FluidMLPRegressor's .fit method consistently throws an error:

// create some resources
(
~makeDict = { Dictionary.newFrom(["cols",1,"data",Dictionary.newFrom(200.collect({ |i| [i, [1.0.rand]] }).flatten(1) ) ]) };
~inDS = FluidDataSet(s).load( ~makeDict.value );
~outDS = FluidDataSet(s).load( ~makeDict.value );
~mlp = FluidMLPRegressor(s);
)

// run this:
(
fork{
	2.do{
		~mlp.fit(~inDS,~outDS,{
			~outDS.dump({ |d| d["data"]["0"].dopostln })
		});
		0.01.wait;
	}
}
)

What was the expected result?

The help file describes the action argument as "A function to execute when the server has completed running fit," though it seems it's being executed sooner than that. I ran similar tests on a few other FluidDataObjects and their methods (though not exhaustively) and experienced the same errors.

What was the actual result?

It seems like .dump is trying to access a File that isn't finished writing yet, implying that .dump is being called before .fit has finished.

ERROR: Primitive '_FileLength' failed.
Failed.
RECEIVER:
Instance of File {    (0x1409cfa88, gc=E0, fmt=00, flg=00, set=02)
  instance variables [1]
    fileptr : nil
}

PROTECTED CALL STACK:
	Meta_MethodError:new	0x150922880
		arg this = PrimitiveFailedError
		arg what = Failed.
		arg receiver = a File
	Meta_PrimitiveFailedError:new	0x15092a740
		arg this = PrimitiveFailedError
		arg receiver = a File
	Object:primitiveFailed	0x1602991c0
		arg this = a File
	File:readAllString	0x151c16740
		arg this = a File
		var string = nil
	a FunctionDef	0x151c0f680
		sourceCode = "<an open Function>"
		arg file = a File
	Function:prTry	0x150d53c00
		arg this = a Function
		var result = nil
		var thread = a Thread
		var next = nil
		var wasInProtectedFunc = false
	
CALL STACK:
	MethodError:reportError
		arg this = <instance of PrimitiveFailedError>
	Nil:handleError
		arg this = nil
		arg error = <instance of PrimitiveFailedError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of PrimitiveFailedError>
	Object:throw
		arg this = <instance of PrimitiveFailedError>
	Function:protect
		arg this = <instance of Function>
		arg handler = <instance of Function>
		var result = <instance of PrimitiveFailedError>
	Meta_File:readAllString
		arg this = <instance of Meta_File>
		arg pathName = "/Users/mikemccormick/Library..."
		var string = nil
	< FunctionDef in Method FluidDataObject:dump >  (no arguments or variables)
	OSCFuncAddrMessageMatcher:value
		arg this = <instance of OSCFuncAddrMessageMatcher>
		arg msg = [*2]
		arg time = 2063.391093209
		arg testAddr = <instance of NetAddr>
		arg recvPort = 57120
	Dictionary:keysValuesArrayDo
		arg this = <instance of IdentityDictionary>
		arg argArray = [*32]
		arg function = <instance of Function>
		var i = 20
		var j = 1
		var key = nil
		var val = nil
		var arraySize = nil
	Dictionary:keysValuesDo
		arg this = <instance of IdentityDictionary>
		arg function = <instance of Function>
	FluidOSCPatternInversion:value
		arg this = <instance of FluidOSCPatternInversion>
		arg msg = [*2]
		arg time = 2063.391093209
		arg addr = <instance of NetAddr>
		arg recvPort = 57120
		var msgpath = '/FluidDataSet/write'
	< FunctionDef in Method Collection:collectInPlace >
		arg item = <instance of FluidOSCPatternInversion>
		arg i = 2
	ArrayedCollection:do
		arg this = [*5]
		arg function = <instance of Function>
		var i = 2
	Collection:collectInPlace
		arg this = [*5]
		arg function = <instance of Function>
	FunctionList:value
		arg this = <instance of FunctionList>
		arg args = [*4]
		var res = nil
	Main:recvOSCmessage
		arg this = <instance of Main>
		arg time = 2063.391093209
		arg replyAddr = <instance of NetAddr>
		arg recvPort = 57120
		arg msg = [*2]
^^ The preceding error dump is for ERROR: Primitive '_FileLength' failed.
Failed.
RECEIVER: a File

What operating system were you using?

Mac

Operating system version

macOS 13.5

FluCoMa Version

1.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions