I am working on an app that uses machine learning, and recently run into a problem. I found out that Expo and Python do not really work together.
I thought that a solution would be to host and run my machine learning model (Python) on a server, and then make requests from my JS Expo app, and I thought this would also have the hidden bonus of faster processing compared to just on my laptop.
So, can people confirm whether firstly this is possible (to call python code running on a server, from a JS Expo app) and if so, then provide some recommendations as to where I can host this?
This is for a university project, so I am hoping to find something either free or cheap, thanks.
I thought this would also have the hidden bonus of faster processing compared to just on my laptop.
If you want to do it for free then lowest tier instances on any cloud will have 1 or 2 cores plus 1-2 GB of RAM, it won't be stronger than your local device and it won't have any hardware acceleration, but if you planned to run that on your phone then it might be enough
So, can people confirm whether firstly this is possible (to call python code running on a server, from a JS Expo app)
Short answer yes, but
The way you formulated this question does suggest that you don't know how this communication would work. You would need to
send http request from expo app to some endpoint on your server
implement server code that could accept that request, in your case it's probably best to do that in python(with sth like django or flask)
in your server code execute tensorflow code
if tensorflow code executes quickly you can send results in the response if not you will need to have second endpoint to check results
This is for a university project, so I am hoping to find something either free or cheap, thanks.
for local development you will need to host it locally either way, for university project it should be enough, but if you want to have it on public server you can get free tier or some starting credits on almost any cloud service e.g. digital ocean gives 100$ credit for students
Alternatively you can use tensorflow in react-native app, you just can't do it in python, https://blog.tensorflow.org/2020/02/tensorflowjs-for-react-native-is-here.html?m=1
Related
I've made a very simple Twitter-like web app to teach myself how to work with React, and how to actually get something working in practice. I've deployed it on a digital ocean droplet and it works just fine.
Now, I am currently studying distributed systems and I've become very interested in them (i could see myself working with them after I graduate). So I figured how to make my app "distributed" by running it on several servers simultaneously and have clients connect to different ones based on some arbitrary criteria. Obviously, this is all very overkill for what my app does, this is purely out of interest and because it sounds like a challenge.
The problem is that I don't really know how to start. I guess I would have to set up some sort of redirection service/replica manager that clients connect to at first, before their requests are sent to the chosen replica?
Any hints/tips for starting out would be greatly appreciated!
You could use a load balancer like the one digital ocean has. If you want to create your own:
I would create a server which would act as the balancer end. This server would keep track of the other servers and redirect clients to them. All the requests would go to that server and it could pass them on with some kind of logic. For example, you could pass the requests in a circle, one to each server and from the start again. You could also account for the response time of each server and give weights to them.
You can find many tutorials in google too:
How to Build a Load Balancer with Express
I'm creating a personal project, an Android application, where user sign ins via a server are essentially. Also users will be able to share important "updates" in both a data stream that all users can have access to, and potentially down the line a data stream that will be specific to local users.
Unfortunately I have basically no idea of how to implement the server for this application. I'm confident that I'll be able to create a solution though, I just need to be pointed in the right direction. Are there any existing servers/api's that I could access that will allow me to handle my "connected" tasks? If I were to make a server myself for this application where should I start?
If you have absolutely no experience with server side coding, you should start with PHP and MySQL to create a simple API for your app.
For getting started download the XAMPP bundle that has everything you need.
SQL and PHP are fairly easy for beginners. On the client(Android) side use Volley as it is simple to understand.
However if you want to get started with Node.js, your server can be up in a few minutes with express.js
I'm developing a web application with Symfony2. I need to create a push notifications sysmte (like Facebook). When an user publish something, I need some of another users receive a notification.
I saw that Node.js it's the easiest manner to do this. But, I did some simple examples and all works fine, but I don't know how can I integrate this node.js application with my Symfony2 application, or really with a PHP application.
Anybody can help me?
Thanks in advance!
Please note that you've not given enough details, so I will respond as a front-end developer and not as a mobile developer
Integrating NodeJS and PHP (in general) is not a good way since you need to launch both servers separatly, create the websocket server in JS while your application is in PHP and finally create a request (GET or POST) from your PHP to you JS server. Well, a big mess, so I'll expose my solution here under.
Quick insight for mobile apps. Well, technically, there's no easy way. You can use the Push "protocol" (http://www.wikiwand.com/en/Push_technology) with NotificationPusher (https://github.com/Ph3nol/NotificationPusher). I didn't used it before so I can't help you with it.
In general.
Most of the time when people thinks of Push, long polling will do the trick. For starters it means that the request is made client-side and the server don't send data & close connection until there's new data.
How do you implement this ?!?
Basically, you change the max_execution_time using ini_set or set_time_limit to a very long time for the current script and launch a loop (like a do..while) with a sleep and the check to your data inside. From your Javascript just make an Ajax call, for example with jquery: $.get. Just remember to remove the timeout and stay in asynchronous mode.
The only drawback of this solution is that you will always have a connection opened to your server which will consume a bit more of battery on a mobile device. If you have multiple types of data to receive do not hesitate to merge the calls and publish a type in your response data, since most of the browsers allows only 2 or 3 simultaneous connections to the same server.
I sounds like your describing WebSockets.
Take a look at Socket.io, its a module for node.js.
Also there is a example at GitHub https://github.com/Automattic/socket.io/tree/master/examples/chat
Interesting files for you should be the index.js and the public/main.js.
You can see the example live at http://socket.io/demos/chat/
I am a designer interested in making a shift to iPhone App Development. I am looking to spend the weeks after my exams studying how backend and frontend iPhone development works.
If I want to ultimately build an app which requires a frontend work in ObjectiveC/Xcode environment will I be able to use Node.js for example to compile user data and databases for backend data?
As I understand it (please correct me if I am wrong) to do an app which connects to servers for data requests you need a backend development. I have been reading about node.js and it seems very fast and its javascript which I like.
What would be the easiest combo to get into. I really am not technical and want to limit the pain for compatibility issues.
Will Objective C and Node.js be compatible?
Do you have any outside recommendations with experience you like to share?
Thank you
At a high level, any web server that has the ability to accept http requests and respond with some content (JSON, XML, HTML, string...) will work, you just have to use the correct methods for submitting the request and parsing the response.
Personally, I've been using node.js for an API that I created and host it on AWS. It's lightning fast and I've had no issues. As with most programming languages today, objective-c has libraries that allow you to submit http requests and parse JSON responses.
Node.js supply web interface just like any other backend stack you can choose, so it is suitable for iPhone backend development.
You can also skip the entire backend development, hosting solution and DNS boilerplate if you wish, by using backend as a service solutions like Parse or Stackmob
I new to Amazon AWS and want to create a cloud-based REST API in Node.js.
Usually I develop the program along with testing it. It means I write some tests, and then write the code that makes those tests run successfully. So in a typical programming session, I may run the tests or the app tens of times.
When I do this locally it is easy and quick. But what if I want to do the whole process on Amazon cloud? How does this code-test-code cycle look like? Should I upload my code to AWS every time I make a change? And then run it against some server address?
I read somewhere in the documentation that when I run a task for a few minutes (for example 15min), Amazon rounds it up to 1hour. So if in a typical development session I run my program 100 times in an hour, do I end up paying for 100 hours? If yes, then what will be the solution to avoid these huge costs?
When I do this locally it is easy and quick.
You can continue to do so. Deploying in the cloud is does not require developing in the cloud.
But what if I want to do the whole process on Amazon cloud?
When I do this, usually edit the code locally, the rsync my git directory up to the server and restart the service. It's super-quick.
Most people develop locally, and occasionally test on a real AWS server to make sure they haven't broken any assumptions (i.e. forgot something at boot/install time).
There are tools like Vagrant that can help you keep your server installation separate from your development environment.
As you grow (and you've got more money), you'll want to spin up staging/QA servers. These don't have to be run all the time, just when changes happen. (i.e. have Jenkins spin them up.) But it's not worth automating everything from the start. Make sure you're building the right thing (what people want) before you build it right (full automation, etc.)
So if in a typical development session I run my program 100 times in an hour, do I end up paying for 100 hours?
Only if you launch a new instance every time. Generally, you want to continue to edit-upload-run on the same server until it works, then occasionally kill and relaunch that server to make sure that you haven't screwed up the boot process.