Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Issue with Python Dependencies for a Node.js App

We are in middle of developing an App for MindSphere and facing below issue:

 

  • I am deploying a Node.js App, however it has a Python process that needs to run at the backend for a particular functionality.
  • As I am deploying a Node.js App, I am using nodejs_buildpack hence Python dependencies that are being used by Python code are not getting installed on the CF container.
  • It seems I can’t use multiple buildpacks as it says: The following manifest fields cannot be used with legacy push: buildpacks

 

Please let me know possible solutions for this.

 

Regards,

Parag

28 REPLIES

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
Have you tried following the official documentation?

https://developer.mindsphere.io/howto/howto-cf-single-manifest.html

Re: Issue with Python Dependencies for a Node.js App

Hi dlouzan,

The documentation talks about deploying multiple applications using single manifest. However I am trying to deploy single application that uses Node.js as well as Python dependencies.

Any ideas on that?

Regards,
Parag

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
The application sample shows how to deploy two different apps, one using the java buildpack and another using the staticfile buildpack, which in your case would translate to one app with python buildpack and another with nodejs buildpack.

There's no way for executing two different runtimes in the same application in cloudfoundry (at least that I know of). By design an application in CloudFoundry runs in a virtualized environment where you get the runtime support for the technology used by your backend. If you need to run nodejs and python components, you'll need two different applications communicating with each other.

I guess you are asking for a model similar to kubernetes, where you could run multiple containers in a single pod. That's not how classic cloudfoundry works.

Re: Issue with Python Dependencies for a Node.js App

Hi dlouzan,

There's some misunderstanding. I am not trying to deploy two apps. My app only one is developed using Node.js, however there are few calculations that happen through a python file which I am executing by spawning process within Node.js.

The python file that does the calculation has dependency on numpy.

Now as I am deploying a single application using nodejs_buildpack, naturally my python file throws an error that numpy is not available. So, I am trying to solve this problem.

So this is a single app which has Node.js as well as Python dependencies Smiley Sad

Regards,
Parag

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
It doesn't matter if you try start two different processes in the application from the beginning, or that you dynamically try to spawn the process later, you won't have the python runtime available inside of the nodejs container.

Depending on how your app flow is (is this a one-off task or a dynamic ongoing thing?) you might be able to use cloudfoundry tasks for this. Though I haven't personally tested that functionality:
https://docs.cloudfoundry.org/devguide/using-tasks.html

If you really need to dynamically spawn tasks based on the user activity, then I think your only options are:
- migrate your code to a single runtime and then execute in the same process or spawn another same runtime process (it should be possible but I haven't tried that)
- or launch two backend components that communicate with each other internally via the network.

Re: Issue with Python Dependencies for a Node.js App

Actually, the Python file I am calling via Node.js is running and giving me error message that the dependency was not found. It means it is getting executed.

 

The only problem, I think, is that I am not able to install Python dependencies within a Node.js App.

 

In case it does not work, I'll have to create separte Python app implementing API which Node.js App can call.

 

Regards,

Parag

 

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
I have just executed ssh on one of our nodejs containers, and yes, the python runtime seems to be available on the container. But I think that is just by chance, I guess it is installed by default in the base image used because it might be needed somehow by the internals of cloudfoundry.

You have no control at all over which python version to use, nor dependencies download, etc. It might even go away, or not be available between tenants, there's no guarantee of anything. That's not a route I'd go.
https://docs.cloudfoundry.org/buildpacks/python/index.html

But at least that shows that you can properly spawn processes, if you need that.

Re: Issue with Python Dependencies for a Node.js App

Yes, in fact I also tried to ssh to my container but somehow it is not working

when I use cf ssh, nothing happens for long time
when I use it via putty, nothing happens
and when I use it directly via ssh -p 8443 cf:******, the password I take from cf ssh-code does not work.

I was trying to see if I can ssh and install the dependencies manually for now. Not sure what's the issue there.

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
That might be proxy issues if you are running in a corporate network. I suggest you take a look at the cf-ssh tool in devops-demo:

https://gitlab.com/mindsphere/devops-demo/blob/master/tools/README.md