Search code examples
pythonflaskpipibm-cloudrequirements

Local dependencies requeriments.txt for Bluemix server


I want to upload a flask server to bluemix. The structure of my project is something like this

  • Classes
    • functions.py
  • Watson
    • bot.py
  • requirements.txt
  • runtime.txt
  • Procfile
  • manifest.yml

my bot.py has this dependency:

from classes import functions

I have tried to include it in the manifest using things like this:
./classes or ./classes/functions

but I have had no luck, it keeps saying either that module is not found or things like pip.exceptions.InstallationError: Invalid requirement: './classes/functions'

I dont know how to add the dependency

manifest.yml

---
applications:
- name: chatbotstest
  random-route: true
  memory: 256M

Procfile (the file that I use to run the app)

web: python watson/bot.py

when I print my sys.path I get this:

    ['..', '/home/vcap/app/watson', '/home/vcap/deps/0/python/lib/python36.zip', '/home/vcap/deps/0/py
e/vcap/deps/0/python/lib/python3.6/lib-dynload', '/home/vcap/deps/0/python/lib/python3.6/site-packages', '/home/vcap/deps/0/python/lib/python3.6/site-
-py3.6.egg', '/home/vcap/deps/0/python/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg']

I have tried to add the folder parent to my script using

Thanks a lot for your help!!!


Solution

  • You don't need to include it into the manifest file. Your entire app directory and its subdirectories are uploaded as part of the push command. Thereafter, it is possible to reference the file as shown.

    This imports a file in the current directory:

    import myfile
    

    This should work for your functions.py:

    from classes import functions