{"action":"created","issue":{"url":"https://api.github.com/repos/wooey/Wooey/issues/32","labels_url":"https://api.github.com/repos/wooey/Wooey/issues/32/labels{/name}","comments_url":"https://api.github.com/repos/wooey/Wooey/issues/32/comments","events_url":"https://api.github.com/repos/wooey/Wooey/issues/32/events","html_url":"https://github.com/wooey/Wooey/issues/32","id":100543384,"number":32,"title":"imports in scripts","user":{"login":"hottwaj","id":5629061,"avatar_url":"https://avatars.githubusercontent.com/u/5629061?v=3","gravatar_id":"","url":"https://api.github.com/users/hottwaj","html_url":"https://github.com/hottwaj","followers_url":"https://api.github.com/users/hottwaj/followers","following_url":"https://api.github.com/users/hottwaj/following{/other_user}","gists_url":"https://api.github.com/users/hottwaj/gists{/gist_id}","starred_url":"https://api.github.com/users/hottwaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hottwaj/subscriptions","organizations_url":"https://api.github.com/users/hottwaj/orgs","repos_url":"https://api.github.com/users/hottwaj/repos","events_url":"https://api.github.com/users/hottwaj/events{/privacy}","received_events_url":"https://api.github.com/users/hottwaj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-08-12T13:30:40Z","updated_at":"2015-09-03T15:09:15Z","closed_at":null,"body":"This is possible a documentation issue for the most part...\r\n\r\nIt took me a while to realise that scripts are expected to be \"standalone\".  \r\n\r\nAs things stand a script that imports local modules within the same folder will fail when \"addscript\" is used.  This is because the script is parsed, doctored to only include ArgumentParser related code, and then saved in /tmp/.  The doctored script is then executed, but the other python modules you import are not in the same \"/tmp/\" folder, so these imports fail and so \"addscript\" ultimately fails.\r\n\r\nTo get around this I made sure my scripts were using import paths relative to my django installation e.g.\r\n`import my_app.my_library`.  This allows \"addscript\" to successfully process my script, however the script will then not run when I use it via the Wooey interface, because a copy of the original script (placed in a different folder) is executed \"standalone\" without reference to the Django/Celery installation.\r\n\r\nSo my temporary solution so far has been to add the appropriate folder to my PYTHONPATH, but this is also a bit awkward...  If you have suggestions for better solutions they'd be appreciated.\r\n\r\nI realise that the script parsing/copying elsewhere process is perfectly sensible and is done this way to solve other issues, so perhaps the current setup is just the way things will have to be.\r\n\r\nAnyway, thanks for the amazing work you've done on this project!  "},"comment":{"url":"https://api.github.com/repos/wooey/Wooey/issues/comments/137479550","html_url":"https://github.com/wooey/Wooey/issues/32#issuecomment-137479550","issue_url":"https://api.github.com/repos/wooey/Wooey/issues/32","id":137479550,"user":{"login":"hottwaj","id":5629061,"avatar_url":"https://avatars.githubusercontent.com/u/5629061?v=3","gravatar_id":"","url":"https://api.github.com/users/hottwaj","html_url":"https://github.com/hottwaj","followers_url":"https://api.github.com/users/hottwaj/followers","following_url":"https://api.github.com/users/hottwaj/following{/other_user}","gists_url":"https://api.github.com/users/hottwaj/gists{/gist_id}","starred_url":"https://api.github.com/users/hottwaj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hottwaj/subscriptions","organizations_url":"https://api.github.com/users/hottwaj/orgs","repos_url":"https://api.github.com/users/hottwaj/repos","events_url":"https://api.github.com/users/hottwaj/events{/privacy}","received_events_url":"https://api.github.com/users/hottwaj/received_events","type":"User","site_admin":false},"created_at":"2015-09-03T15:09:15Z","updated_at":"2015-09-03T15:09:15Z","body":"I'm now getting around this problem by putting any modules I'm using in my scripts in a library on my PYTHONPATH.  This seems cleaner than messing around with symlinks etc.  \r\n\r\nSo perhaps the only thing to do is to add documentation explaining that a script can only import modules on the PYTHONPATH or in libraries in the Virtualenv Celery is running in?"}}