Add CPS raw2Sv realtime processing flow - #188
Conversation
| entrypoint="echodataflow/flows/flows_simulation.py:flow_copy_trawl", | ||
| ), | ||
| "simulate_transects": FlowRegistration( | ||
| entrypoint="echodataflow/flows/flows_simulation.py:flow_simulate_transects", |
There was a problem hiding this comment.
is a duplicate
There was a problem hiding this comment.
not sure what you mean - it's the only entry in the registry?
There was a problem hiding this comment.
there’s another one at L85! Not sure when it was added, my bad.. I think I added it at some point!
|
|
||
| def _transect_number(path: Path) -> int: | ||
| return int( | ||
| path.name | ||
| .replace("transect_", "") | ||
| .replace("_CPS.zarr", "") | ||
| ) | ||
|
|
||
|
|
||
| cps_files = sorted( | ||
| path_CPS.glob("transect_*_CPS.zarr"), | ||
| key=lambda path: path.stat().st_mtime, | ||
| key=_transect_number, |
There was a problem hiding this comment.
maybe collapse lines like these throughout the codebase to a single line to avoid excessive vertical splitting
leewujung
left a comment
There was a problem hiding this comment.
Hey @LOCEANlloydizard : I went through the raw monitor behavior and made a couple small patches -- one of them is to prevent a single write to send event multiple times.
I think that there's a philosophical difference that would have practical consequences that we should discuss:
- if I understand correctly, the raw monitor right now would emit an event to trigger
flow_raw2Sv_CPSevery time when a.rawfile is created, changed, or moved in to the watched directory - my original thought is for the raw monitor to emit an event to only update the ledger but not trigger the
flow_raw2Sv_CPSorflow_raw2Sv, this is because:- if we operate out of the back-up server (which we have been on all 3 vessels we have deployed the workflow on), this is fine, because the back-up server is only synced at a specified interval, so the event emission would be infrequent
- however if we operate out of the actual drive that the EK80 software is writing data into (which is probably a bad practice), since the latest
.rawfile would be written into continuously until it is closed when reaching the configured file size limit,flow_raw2Sv_*will keep on getting triggered, which would cause a lot of collision and probably would crash - in addition, in
flow_raw2Sv_*the.rawfile conversion can be configured to executed in parallel or sequentially (right now we just do sequential conversion for the NRT deployment since that op is very fast, and we will likely switch to a much slimmer machine later). In the scheme of the current code, there would always only be 1.rawfile getting converted/processed to Sv. - updating the database ledger is a much more simplistic operation than the whole raw to Sv conversion
We can restrict the event emission only when a .raw is no longer changing (done via some ledger record logics), but this means that for shallow regions when each ping is short, we would miss a large chunk of most recent data, especially if the configured file size limit is large (for example, SWFSC used to produce 2GB files...).
It seems to me that it is more straightforward to go with the route to only update the ledger when watchdog detects changes, and run flow_raw2Sv_* at N min intervals. This does mean that we could have a lag of up to N mins in the workflow, but I think to make the "real" real-time workflow, we would have to allow echopype to accept real-time streams of the datagrams, or subscribe to the EK80 REST API to get the Sv values from the EK80 software directly.
Thoughts? Happy to discuss! I may have misunderstood the code or missed other considerations you have.
|
hey @leewujung thank you very much for the inputs! yes agreed: i changed the RAW monitor so it only updates the ledger and no longer emits RAW events. raw2Sv_CPS now runs on a 5 min interval and checks the ledger for new files. I also tested the updated workflow end-to-end locally and it behaved as expected! i'm merging this now to check the deployment! cheers! |
raw2Svflow for NRT processingraw2Svflow through the deployment frameworkraw2Svprocessingraw2Svprocessing with the existing CPS transect-processing workflowraw2Svflow, and transect simulation