flatironinstitute / mcmc-monitor

Monitor MCMC runs in the browser
Other
35 stars 0 forks source link

Improve fallback to http #79

Closed jsoules closed 1 year ago

jsoules commented 1 year ago

Fix issue #66. Obviates (& undoes) #68.

(Git history is a little confusing--I had originally branched this off the branch from PR #78, so there's weirdness.)

There are two main barriers to seamless HTTP fallback:

  1. Broadening the conditions of the postApiRequest function so that it falls back in a wider variety of cases.
  2. Refactoring the connect-first busy-waiting during startup.

Changes

Incidental Changes:

Major changes:

Testing

We haven't really begun automated integration testing, so I don't have anything automated to test this--though the updated unit tests give confidence that everything should still work. The more important test here was practical.

I checked this out in a couple ways, running both the GUI and service on my local machine:

Potential concern: I tested fake slowness, but was not able to hit the case where a connection is pending for a while, then eventually connects. I think this had to do with how I was imposing lag in the service. I am assuming that in an actual longer negotiation process it would eventually connect--after all, connecting clearly works fine--but we may want to find a better way to confirm this case before merging.

GUI changes deployed to dev branch and visible at https://flatironinstitute.github.io/mcmc-monitor/dev/ (though seeing anything interesting will require running and connecting to a local service).

codecov-commenter commented 1 year ago

Codecov Report

Merging #79 (e82be77) into main (2b979c7) will increase coverage by 0.20%. The diff coverage is 42.55%.

@@           Coverage Diff            @@
##            main     #79      +/-   ##
========================================
+ Coverage   9.54%   9.75%   +0.20%     
========================================
  Files         74      74              
  Lines       5677    5640      -37     
  Branches     112     111       -1     
========================================
+ Hits         542     550       +8     
+ Misses      5135    5090      -45     
Flag Coverage Δ
gui_units 12.33% <44.94%> (+0.30%) :arrow_up:
svc_units 2.27% <0.00%> (-0.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
service/src/networking/RemotePeer.ts 0.00% <0.00%> (ø)
service/src/networking/Server.ts 0.00% <0.00%> (ø)
...rc/MCMCMonitorDataManager/MCMCMonitorTypeguards.ts 0.00% <0.00%> (ø)
src/MCMCMonitorDataManager/SetupMCMCMonitor.tsx 0.00% <0.00%> (ø)
src/MCMCMonitorDataManager/useMCMCMonitor.ts 0.00% <ø> (ø)
src/components/ConnectionStatusWidget.tsx 0.00% <0.00%> (ø)
src/config.ts 0.00% <0.00%> (ø)
src/pages/MainWindow.tsx 0.00% <0.00%> (ø)
src/MCMCMonitorDataManager/MCMCMonitorData.ts 100.00% <100.00%> (ø)
src/networking/WebrtcConnectionToService.ts 100.00% <100.00%> (ø)
... and 1 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

magland commented 1 year ago

Looks great to me!

jsoules commented 1 year ago

Glad to hear! Are there any additional checks you think we should do before publishing? I'd love to demonstrate that it picks up a connection after some delay, but I'm not sure how to simulate that in a way that doesn't just result in the connection timing out...

magland commented 1 year ago

Just for a one-off test you could put a delay at the final connection step, like the following (i wouldn't built this in to the test framework necessarily thought)

peer.on('connect', () => {
            console.info('Webrtc connection established')
            this.#status = 'connected'
        })

you could replace by

peer.on('connect', () => {
            console.log('Finalizing connection in 3 seconds')
            setTimeout(() => {
              console.info('Webrtc connection established')
              this.#status = 'connected'
            }, 3000)
        })
jsoules commented 1 year ago

That does behave as expected... I think I'll go ahead and push this. (We can always roll back if we start getting reports of errors or instability.)