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

Flow graphs serialization #14389

Merged
merged 29 commits into from
Oct 12, 2023
Merged

Conversation

carolhmj
Copy link
Contributor

@carolhmj carolhmj commented Oct 4, 2023

Changes

  • This PR adds "serialize" and "parse" functions to the flow graph, which work similarly to the other serialization functions we have in the framework
  • It also standardizes the construction of the blocks, with a generic construction parameters interface (which has a name for all blocks), and a generic "configure" function that configures blocks according to its construction parameters. This is used, for example, in the "multiGate" block to configure how many outputs the block has.
  • It also adds a getClassName function for all blocks (and I'm very sorry for the size the PR ended up with 😢 )
  • It also adds all the blocks to the class register
  • Removed the CustomFunctionBlock since it's not on the spec and I was just using it for tests. Instead now I'm using the Log block and mocking the console.log function

Examples

  • Serialize: #KSTQJU#3
  • Parse: #CVDC94#2

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 4, 2023

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 4, 2023

@bjsplat
Copy link
Collaborator

bjsplat commented Oct 4, 2023

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/14389/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

Copy link
Member

@RaananW RaananW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few general comments regarding architecture -

  1. It seems like every class has the same string repeated 4 times. It could be a const defined outside of the class (that is not exported).
  2. The config = { name: ... } could backfire if someone will pass a different configuration object without a name.
  3. Why is the name needed, why is getClassName not enough?
  4. Something we have discussed a long time ago - to make the classes a little smaller, we could remove the FlowGraph part of those to make them a little shorter.

@carolhmj carolhmj requested a review from RaananW October 6, 2023 14:20
Copy link
Member

@RaananW RaananW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, a few other questions that came out over the weekend

Parse should be, in general, a static function. I noticed that you have a class member parse functions. Is that deliberate? does that mean that you need to first create an instance of this class and only then pass the serialized object to parse it?

Also - the idea with making the name a little smaller was not only for the variable name. Changing FlowGraph to FG (for example, or maybe even FlowGraphBlock = FGB) with many nodes will save a lot of space on the serialized JSON.

Copy link
Member

@RaananW RaananW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions and small nits, otherwise LGTM

packages/dev/core/src/FlowGraph/flowGraphDataConnection.ts Outdated Show resolved Hide resolved
packages/dev/core/src/FlowGraph/flowGraphContext.ts Outdated Show resolved Hide resolved
@carolhmj carolhmj requested a review from RaananW October 11, 2023 15:49
@RaananW RaananW merged commit c762252 into BabylonJS:master Oct 12, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants