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
Import files to script #188
Comments
Hi @toert, Local files have long been an open question for Wooey -- from scripts that have relative imports, to this use case now. There are a few complicating factors that doesn't make this trivial -- notably that there is no guarantee of where the script is being run having the same environment of where the worker is. The worker only downloads the script to execute locally. The easiest solution I can think of would be using a NFS to store common data files (if you are using a server setup), or giving more information about the location of your files and where wooey/celery are running. |
Make sure to use absolute paths into your script. In my case I'm using multiple modules and even other programs, and I specified everything relative to the absolute path of the script itself, so that I can copy it anywhere, as long as the relative location of the extra files is maintained. |
@Chris7 , "from scripts that have relative imports" , I am trying this out and failing. Whats the best work around for this ? Will a python zip work ? |
The python zip idea is interesting. I'll look into what that may entail. |
Here is some info I just read up on. |
@Chris7 , thanks for considering this ! OK So here is what I did : the lib folder has all libs specific to my project. I then zip the contents up into reportgen.zip and now I can execute this directly as such : python reportgen.py locally.
|
Thanks for the trail run! I haven't tested this yet, but I thought it would probably fail because there is no detection routine currently to detect if an uploaded file is a zip. This support needs to be added to clinto and Wooey may "just work" after that. |
@Chris7 this zip feature is most sought after in the team i am working with. Please let me know if I can help test the fix / change you may have for clinto. |
There is support for this in clinto via wooey/clinto#31, but it is blocked until the subparser bugs are sorted out. |
I should be able to take on the patch and test locally ? |
It's a gate for a stable package release. So to use this, you would need to run off the master branch of Wooey and the patch branch of clinto. I would only do that if you are ok with your database possibly becoming invalid for the next official release. |
@pymenow This should be testable now , but I would still backup your database first. |
wooey/clinto#31 Is closed. Does this mean zip support will work now? |
Zip support is in now. I would love a docs PR. Having docs updated by someone new to the project is always the best I've found. I tend to forget what things aren't obvious :) |
Added in v0.10 |
Just ran into this on the 0.12 using docker -
|
Hey! Can someone point me to the relevant documentation where this "zip" thing is mentioned? I can't seem to find it and it's a necessary use case of my script to have relative file imports. |
How can I import my custom files?
I need to use my files inside the script.
print(os.path.dirname(sys.argv[0]))
gives me/opt/DO_wooey/media/wooey_scripts
, I decided to put my custom files in this directory, but it does not work, the script still gives me this error:OSError: SavedModel file does not exist at: test_build/{saved_model.pbtxt|saved_model.pb}
.The text was updated successfully, but these errors were encountered: