h2oai / wave

Realtime Web Apps and Dashboards for Python and R
https://wave.h2o.ai
Apache License 2.0
3.9k stars 323 forks source link

fix: Make file upload work when waved run separately #2225 #2232

Closed marek-mihok closed 5 months ago

marek-mihok commented 5 months ago

The PR fulfills these requirements: (check all the apply)


This PR fixes the issue when H2O_WAVE_WAVED_DIR has a wrong value in some scenarios. The fix is accomplished by finding the PID of the waved/waved.exe and getting its CWD which is then set to H2O_WAVE_WAVED_DIR env variable.

Successfully tested on both Mac and Windows.

Closes #2225

marek-mihok commented 5 months ago

Can we do without external lib though?

@mturoci my research shows there is no pythonic (or other simple) way of getting process cwd by its name on Windows. Libs like psutil or win32com use complex solutions for this simple problem.

Maybe we could include psutil as the os specific dependency? For Windows only? And use external lib free solution otherwise?

mturoci commented 5 months ago

there is no pythonic (or other simple) way of getting process cwd by its name on Windows

In that case, you can either implement for UNIX systems only and defer to HTTP on err and Windows or go for HTTP everywhere and keep using H2O_WAVE_WAVED_DIR for speedup if needed.

mturoci commented 5 months ago

Edit: Let's just go for HTTP uploads when waved is run separately and local uploads when waved is started automatically. This would be the safest and simplest option.

mturoci commented 5 months ago

Added a small refactor. @marek-mihok please verify if works. If it does, good to merge. Thanks!

marek-mihok commented 5 months ago

@mturoci works, it's good to go.