speckle-sharp icon indicating copy to clipboard operation
speckle-sharp copied to clipboard

SendReceiveTransport - Force Flatten Params

Open d3ssy opened this issue 3 years ago • 3 comments
trafficstars

https://github.com/specklesystems/speckle-sharp/blob/ca31096d045131d35b120b84fa672b56b284b78a/ConnectorGrasshopper/ConnectorGrasshopper/Transports/SendReceiveTransport.cs#L37

Is it better to set param data mapping in BeforeSolveInstance() as a general approach to enforcing a particular GH_DataMapping type?

    protected override void BeforeSolveInstance()
    {
      //Enforce flattened inputs.
        Params.Input[0].DataMapping = GH_DataMapping.Flatten;

    }

d3ssy avatar Apr 15 '22 14:04 d3ssy

Hey @d3ssy!

Nice to have you around :) This is a nice suggestion, to be honest I'm not sure it would have any negative repercussions so I'm open to this, although I find that doing data tree operations behind the user is sometimes counter-intuitive.

I find it nicer report any limitations on the user and let the user decide, instead of modifying the input/output behaviour of GH altogether.

If a user inputs a data tree but gets a single list out, I fear it may be more confusing that just telling them what they're trying to do cannot be done.

We'd also love to know where this is coming from. Are you finding yourself constantly flattening that input? 😅

AlanRynne avatar Apr 19 '22 11:04 AlanRynne

Hey @AlanRynne !

Yeah it's certainly a forceful approach and, to your point, could be confusing when you click on the flatten option and nothing happens.

An alternative, and I suppose the best of both worlds, is to at least flatten the input on RegisterInputParameters offering the user a default flattened state, and throw the warning if they so happen to change it in BeforeInstance.

Came across this by chance digging through the code; the test on the number of iterations in SolveInstance stumped me... bit of ocd kicked in lol.

d3ssy avatar Apr 19 '22 11:04 d3ssy

Oh, that could be quite a nice solution indeed! Would be worth a shot, and seems like a 3 line change in the code 👍🏻

Anyway thanks for lurking through our code and pointing out weird stuff! We're always happy to re-visit old decisions if/when they make sense 😄

AlanRynne avatar Apr 19 '22 18:04 AlanRynne

Closing for now! Feel free to reopen if you feel its required for you ;)

AlanRynne avatar Mar 09 '23 10:03 AlanRynne