Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace dynamic hacks with generics or delegates #20

Open
radumg opened this issue Feb 27, 2018 · 0 comments
Open

Replace dynamic hacks with generics or delegates #20

radumg opened this issue Feb 27, 2018 · 0 comments

Comments

@radumg
Copy link
Owner

radumg commented Feb 27, 2018

Description

I'm using lots of dynamic types to marshall input data from a Machine.Predict() to its associated Algorithm.Predict() method.
The input ends up malformed in Algorithm.Predict()

Why do it this way

The Predict method is defined on the IAlgorithm interface but since each algorithm has a different return type, it declares its inputs/outputs as dynamic.

Limitations

That wouldn't be a problem in C# land, but Dynamo doesn't like an input port with dynamic as type and unwraps lists to feed individual values - madenning ! Solved with [Arbitrary...] tag in the end so Dynamo leaves lists alone.

Dynamo also can't resolve nodes that take interfaces as inputs to ports, despite feeding it classes that implement those interfaces.

Also can't use generics like `IAlgorithm<Tinput, Toutput> as they're not known and the algorithm is stored on the machine.

What to do about it

  • potentially find a way to use generics - i wasted several hours on it already but Dynamo won't play ball
  • use delegates instead of generics
  • not return the value from Predict directly, but you'd still have the data types conversion issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant