Running a Python interpreter from Rails - python

I have a webapp that is built in Rails, but I'm working with graphs and Python has far better graph libraries (namely, Graph-Tool). There are on the order of 10k lines of code written already, so it would be a hassle to switch to Django. However, the work I'm doing involves querying very, very large graphs, ones that would take a lot of time to load into the interpreter. Is there a way to have a Python interpreter somewhere that Rails controls, with actions like "Load the graph" and "search the graph for x" and "restart the interpreter"? These can be on separate computers. I've heard of the SOA solution, but I'm not sure how to set that up or if the interpreter stays open after calls from Rails. Can someone point me to some guide, or give me advice?

Right now I am using Flask with localtunnel. It works.

Related

Python and Django Source Code Navigation in Emacs

I am wondering if there is a way to to navigate Python(Django) code in Emacs similar to how one can M-. for Common Lisp code when using SLIME.
I have installed ELPY and a mode called python-django. However, they do not seem to provide this functionality.
I am particularly interested in doing this why developing using Django. However, even navigation for standalone Python projects would be nice.
I will give dumb-jump a chance.
It is not as fancy as other go-to-definition methods, as it only searchs for some predefined regex in your project. But it simply works most of the time, and you can add your own regex if you need them.

What is the difference between Spyder and Jupyter?

I am learning Python for data science, but my problem is that I still don't understand the difference between Spyder and Jupyter!
I would like you guys to help me to understand the difference, please; I would appreciate that.
Here's just a basic summary of the two tools.
Jupyter is a very popular application used for data analysis. It's an IPython notebook ("interactive python"). You can run each block of code separately. For example, I can print a graph using matplotlib. Create a new block of code and print another graph. There are also cool functions like %timeit that test the speed of your code.
Spyder is an Integrated Development Environment (IDE) for Python like Atom, Visual Studio, etc. I use VS Code and I suggest you install it as well. It's easier to learn and get running. There's also tons of helpful youtube videos due to its popularity.
I prefer to use Jupyter notebook to analyze data whether it be in pandas dataframes or plots. When I'm developing a program or implementing new code on data I already analyzed, I use a text editor like VS Code.
There's a lot more to it, but I think that's all you need to know for now. As you gain more experience you'll learn more about the tools and find your preferences. If you want to know more, there a ton of information about them online with people who can probably explain this much better than I can.
I hope your journey into data science goes well! Just be patient and remember struggling is part of learning. Good luck!
Spyder Pros:
Code completion
Code cells: You can create code cells using Spyder.
Scientific libraries
PDB debugger
Help feature
cons:
Limited to python only.
Bad layout not customizable
Jupyter pros:
Easy to learn
Secure and free server - The Jupyter server can be utilized free of charge.
Keyboard shortcuts makes it easy and fast
Share Notebook
cons:
Not recommended for running long, nonconcurrent errands.
No IDE integration, no linting, and no code-style adjustment.
Read more in detail https://ssiddique.info/pycharm-vs-spyder-vs-jupyter.html

Create a in-browser Python application with a GUI

I am teaching a class soon and I want to have users try my platform without the need of installing Python in their computers and to run everything online. I have searched for platforms such as Skulpt, CodeMirror and Trinket and they seem ok for what I want to do. However, I want to develop a GUI for the users to input parameters since there are a lot of options and I don't want users with no Python experience to run the programs from the command line like I do and hide the Python code behind the GUI. I have learnt simplegui recently but I think the GUIs you can create are not visually pleasant and for me this is a big no. I also saw in another post that using Tkinker with a in-browser python implementation is not possible.
So, I would like to know what would be the best combination of in-browser Python implementation and GUI module to reach my goal please?
Thank you so much!
I guess Jupyter could meet your needs. Getting started here.
The Jupyter Notebook is a web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, machine learning and much more.
The Notebook has support for over 40 programming languages, including those popular in Data Science such as Python, R, Julia and Scala.

Can I make a GUI with Python without any extraneous software?

I've been looking for ways to make a GUI with a .py file, and have so far only found frameworks and modules like Tkinter. However, my ultimate goal is for this code to run on a lot of computers that don't necessarily have these modules installed. The machines are only guaranteed to have Python on them. Does anyone know a way to make a GUI under these restrictions?
The best way to do this would be to ship your application with those modules as a part of it; the user's computer doesn't need to have the GUI framework installed if you provide it.
What you're asking would essentially require you to write an entire GUI framework, which would give a result that would be similar or worse - with a LOT more work.

MATLAB to web app

Hi I have a MATLAB function that graphs the trajectory of different divers (the Olympic sport diving) depending on the position of a slider at the bottom of the window. The file takes multiple .mat files (with trajectory information in 3 dimensions) as input. I am trying to put this MATLAB app on to the internet. What would be the easiest/most efficient way of doing this? I have experience programming in Python and little experience programming in Java.
Here are the options that I have considered:
1. MATLAB Builder JA (too expensive)
2. Rewrite entire MATLAB function into Java (not experienced enough in Java)
3. Implement MATLAB file using mlabwrapper and using Django to deploy into web app. (having a lot of trouble installing mlabwrapper onto OSX)
4. Rewrite MATLAB function into Python using SciPy, NumPy, and matlibplot and then using Django.
I do not have any experience with Django but I am willing to learn it. Can someone point me in the right direction?
A cheap and somewhat easy way (with limited functionality) would be:
Install MATLAB on your server, or use the MATLAB Compiler to create a stand alone executable (not sure if that comes with your version of MATLAB or not). If you don't have the compiler and can't install MATLAB on your server, you could always go to a freelancing site such as elance.com, and pay someone $20 to compile your code for you into a windows exe file.
Either way, the end goal is to make your MATLAB function callable from the command line (the server will be doing the calling) You could make your input arguments into the slider value, and the .mat files you want to open, and the compiled version of MATLAB will know how to handle this. Once you do that, have the code create a plot and save an image of it. (using getframe or other figure export tools, check out FEX). Have your server output this image to the client.
Tah-dah, you have a crappy low cost work around!
I hope this helps , if not, I apologize!
You could always just host the MATLAB code and sample .mat on a website for people to download and play with on their own machines if they have a MATLAB license. If you are looking at having some sort of embedded app on your website you are going to need to rewrite your code in another language. The project sounds doable in python using the packages you mentioned however hosting it online will not be as simple as running a program from your command line. Django would help you build a website but I do not think that it will allow you to just run a python script in the browser.

Categories

Resources