winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.68k stars 181 forks source link

fix: missing UI connections in console #6509

Closed Chriscbr closed 2 weeks ago

Chriscbr commented 2 weeks ago

Fixes #6458

Some UI connections were missing in the Wing Console because when generating information about different resource nodes, inflight closures created in Winglang were treated as resources while inflight closures created using the TypeScript framework were not. To fix this discrepancy, this PR changes how connections are generated so that all intermediate inflight closures are no longer modeled as nodes. Instead, inflight closures (both those created in Winglang and in TypeScript) are explored until resource-like nodes are reached.

Taking this app as an example:

let b = new cloud.Bucket();

let listData = inflight () => {
    b.list();
};

new cloud.Function(inflight () => {
    listData();
    b.put("hello.txt", "world");
});

Previously the SDK generated this connection data:

{
  "source": "root/Default/$Closure1_0",
  "sourceOp": "handle",
  "target": "root/Default/Bucket",
  "targetOp": "list",
  "name": "list"
},
{
  "source": "root/Default/$Closure2_0",
  "sourceOp": "handle",
  "target": "root/Default/Bucket",
  "targetOp": "put",
  "name": "put"
},
{
  "source": "root/Default/$Closure2_0",
  "sourceOp": "handle",
  "target": "root/Default/$Closure1_0",
  "targetOp": "handle",
  "name": "handle"
},
{
  "source": "root/Default/Function",
  "sourceOp": "invoke",
  "target": "root/Default/$Closure2_0",
  "targetOp": "handle",
  "name": "handle"
},
{
  "source": "root/Default/Function",
  "sourceOp": "invokeAsync",
  "target": "root/Default/$Closure2_0",
  "targetOp": "handle",
  "name": "handle"
}

Now it generates this connection data (note that all "closure" nodes are gone - we just emit relationships between real resources):

{
  "source": "root/Default/Function",
  "sourceOp": "invoke",
  "target": "root/Default/Bucket",
  "targetOp": "put",
  "name": "put"
},
{
  "source": "root/Default/Function",
  "sourceOp": "invoke",
  "target": "root/Default/Bucket",
  "targetOp": "list",
  "name": "list"
},
{
  "source": "root/Default/Function",
  "sourceOp": "invokeAsync",
  "target": "root/Default/Bucket",
  "targetOp": "put",
  "name": "put"
},
{
  "source": "root/Default/Function",
  "sourceOp": "invokeAsync",
  "target": "root/Default/Bucket",
  "targetOp": "list",
  "name": "list"
}

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

github-actions[bot] commented 2 weeks ago

Thanks for opening this pull request! :tada: Please consult the contributing guidelines for details on how to contribute to this project. If you need any assistance, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @chriscbr
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon
monadabot commented 2 weeks ago

Console preview environment is available at https://wing-console-pr-6509.fly.dev :rocket:

Last Updated (UTC) 2024-05-17 03:59
Chriscbr commented 2 weeks ago

The map for the code in #6458 now looks like:

Screenshot 2024-05-16 at 5 51 25 PM
monadabot commented 2 weeks ago

Benchmarks

Comparison to Baseline ⬜⬜⬜🟥⬜⬜⬜⬜⬜🟥⬜⬜⬜ | Benchmark | Before | After | Change | | :-- | --: | --: | --: | | version | 59ms±2.75 | 57ms±0.84 | -2ms (-3%)⬜ | | functions_10.test.w -t sim | 498ms±24.01 | 484ms±12.65 | -14ms (-2.82%)⬜ | | functions_10.test.w -t tf-aws | 2062ms±38.61 | 2084ms±43.95 | +22ms (+1.08%)⬜ | | hello_world.test.w -t sim | 403ms±3.52 | 419ms±9.9 | +16ms (+4.08%)🟥 | | hello_world.test.w -t tf-aws | 1532ms±9.76 | 1539ms±24.41 | +6ms (+0.41%)⬜ | | functions_1.test.w -t sim | 402ms±10.43 | 402ms±5.74 | -1ms (-0.16%)⬜ | | functions_1.test.w -t tf-aws | 842ms±18.71 | 828ms±10.77 | -14ms (-1.68%)⬜ | | jsii_big.test.w -t sim | 2812ms±17.16 | 2809ms±12.81 | -2ms (-0.09%)⬜ | | jsii_big.test.w -t tf-aws | 3032ms±21.98 | 3036ms±41.51 | +4ms (+0.14%)⬜ | | empty.test.w -t sim | 359ms±2.31 | 371ms±7.74 | +12ms (+3.45%)🟥 | | empty.test.w -t tf-aws | 598ms±6.07 | 611ms±8.19 | +13ms (+2.18%)⬜ | | jsii_small.test.w -t sim | 380ms±6.67 | 376ms±5.07 | -4ms (-1.1%)⬜ | | jsii_small.test.w -t tf-aws | 614ms±6.86 | 612ms±6.3 | -2ms (-0.38%)⬜ | ⬜ Within 1.5 standard deviations 🟩 Faster, Above 1.5 standard deviations 🟥 Slower, Above 1.5 standard deviations _Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI._
Results |name|mean|min|max|moe|sd| |----|----|----|----|----|----| |version|57ms|55ms|59ms|1ms|1ms| |functions_10.test.w -t sim|484ms|458ms|513ms|13ms|18ms| |functions_10.test.w -t tf-aws|2084ms|1992ms|2209ms|44ms|61ms| |hello_world.test.w -t sim|419ms|399ms|444ms|10ms|14ms| |hello_world.test.w -t tf-aws|1539ms|1516ms|1631ms|24ms|34ms| |functions_1.test.w -t sim|402ms|384ms|412ms|6ms|8ms| |functions_1.test.w -t tf-aws|828ms|812ms|854ms|11ms|15ms| |jsii_big.test.w -t sim|2809ms|2787ms|2838ms|13ms|18ms| |jsii_big.test.w -t tf-aws|3036ms|2983ms|3151ms|42ms|58ms| |empty.test.w -t sim|371ms|358ms|394ms|8ms|11ms| |empty.test.w -t tf-aws|611ms|596ms|627ms|8ms|11ms| |jsii_small.test.w -t sim|376ms|368ms|389ms|5ms|7ms| |jsii_small.test.w -t tf-aws|612ms|601ms|630ms|6ms|9ms|
Last Updated (UTC) 2024-05-16 22:14
mergify[bot] commented 2 weeks ago

Thanks for contributing, @Chriscbr! This PR will now be added to the merge queue, or immediately merged if rybickic/fix-connections is up-to-date with main and the queue is empty.

monadabot commented 2 weeks ago

Congrats! :rocket: This was released in Wing 0.73.52.