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

File upload not working when waved run separately. #2225

Closed
mturoci opened this issue Dec 13, 2023 · 3 comments · Fixed by #2232
Closed

File upload not working when waved run separately. #2225

mturoci opened this issue Dec 13, 2023 · 3 comments · Fixed by #2232
Assignees
Labels
bug Bug in code py Related to Python Driver

Comments

@mturoci
Copy link
Collaborator

mturoci commented Dec 13, 2023

Wave SDK Version, OS

1.0.0

Actual behavior

Files uploaded via q.site.upload are returning 404

Expected behavior

(A clear and concise description of what you expected to happen.)

Steps To Reproduce

Could not reproduce myself. @marek-mihok please connect to @JohnM-H2O and @kaz-Anova to get a proper repro.

@mturoci mturoci added bug Bug in code py Related to Python Driver labels Dec 13, 2023
@marek-mihok
Copy link
Contributor

marek-mihok commented Dec 19, 2023

The issue is present for file downloads as well and it was not reported when copy upload is disabled: H2O_WAVE_NO_COPY_UPLOAD=1.

The problem is that in some scenarios, H2O_WAVE_WAVED_DIR has a wrong value and therefore files are uploaded into a wrong folder. When waved is run separately, we set H2O_WAVE_WAVED_DIR value from sys.exec_prefix here which points to location where python executable files are located and this location does not always correspond to actual location from which ./waved was run from.

When I run waved separately from venv folder and I don't have virtual environment activated, it points to /Users/my_user_name/anaconda3. When I activate virtual environment, it works as it should. Please see the following behavior:

Screen.Recording.2023-12-19.at.11.17.35.mov

However if waved is run from other than virtual environment folder, it does not work in any of these cases:

Screen.Recording.2023-12-19.at.11.24.06.mov

The solution could be always specifying H2O_WAVE_WAVED_DIR manually to enable copy upload but this solution lacks user convenience.

Another solution could be for go server to create a temporary file on startup with its working dir location and this file can later be accessed by the wave app (os.TempDir() on the go side and tempfile.gettempdir() on the python side - it should work consistently across all platforms, however go warns that The directory is neither guaranteed to exist nor have accessible permissions.).

The third option can be a network request from python asking go for waved location.

@mturoci please let me know which one you think is the best. I've already tried a second option at least on macOS and it's looking good.

@mturoci
Copy link
Collaborator Author

mturoci commented Jan 4, 2024

Thanks for the investigation @marek-mihok!

Could we set H2O_WAVE_WAVED_DIR only during autostart? Wouldn't it be enough? That way, separate waved would mean HTTP uploads/downloads, which is fine. Alternatively, if we want to be too smart, we could maybe find the waved cwd by looking at its process id (or something along those lines), but I am not sure whether would work on Windows.

When I run waved separately from venv folder and I don't have virtual environment activated, it points to /Users/my_user_name/anaconda3. When I activate virtual environment, it works as it should. Please see the following behavior:

This is expected. It should point to current active python, which in your case is activated conda env.

@marek-mihok
Copy link
Contributor

Alternatively, if we want to be too smart, we could maybe find the waved cwd by looking at its process id (or something along those lines), but I am not sure whether would work on Windows.

@mturoci yes, it works, psutil does the job! Successfully tested on my Windows machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in code py Related to Python Driver
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants