How to use TA-Lib with Google App Engine Flexible Python? - google-app-engine

From my research you can't use Google App Engine Standard Environment for TA-Lib python wrapper because it uses C-Extensions? You have to use Flexible Environment.
To use TA-Lib python wrapper, you would add it to the dependency file requirements.txt in your app engine flexible project. The documentation however says "To use TA-Lib for python, you need to have the main TA-Lib already installed"
How would you add this main TA-Lib to your app engine flexible project so you can use the TA-Lib python wrapper?

I simply added the main TA-Lib to my flexible project and added the TA-Lib python wrapper to requirements file. I also had to add numpy to requirements:
flexible_project
|
+--ta-lib
+--app.yaml
+--main.py
+--requirements.txt
Not sure if this is the best way to do this so please answer with better way if you have one

Related

How to move Java 8 App Engine Flexible to App Engine Standard?

I have made a basic App Engine Flexible Rest API that uses Cloud endpoints for authentication and uses Spring for the MVC framework.
Does anyone have any recommendations on how to switch this over to App Engine Standard?
I thought to change the app.yaml file would work but I am a bit lost.
Thanks
Modifying your app.yaml is the primary method of changing from flexible to standard environment, or vice versa. Barring any other special configuration for your particular project, this could be all you need to do.
To deploy to standard environment, instead of flexible:
Try simply commenting out the env property in your app.yaml:
#env: flex
By default, you'd deploy to the standard environment if env is not defined (is what my experience has been).
Beyond this, you'd have to look at individual properties in your app.yaml, as perhaps some of them may only apply to a specific deployment type. For example, instance_class is not a property used in flexible environment, whereas you can define that in standard environment. In theory, I would remove or comment-out instance_class if deploying to flexible environment, or just maintain a second app.yaml (e.g. named app_standard.yaml).
On a side note, one thing I did stumble upon recently (for Go, anyways):
For a flexible deployment, this failed...
# This failed for flexible deployment, but it's what Google docs states to use (no period in the number)
runtime: go111
Meanwhile, I had to define the period for flexible deployment...
# This worked on a flexible deployment (had to include the period in the number)
runtime: go1.11
However, for the exact same app, with no code changes, simply going to standard environment, I defined runtime version WITHOUT A PERIOD, as Google's docs say to do, and it worked:
# This worked for standard environment (no period in the number)
runtime: go112
Just illustrating how fine details in the app.yaml matter.

Google App Engine Flex Python 3.4 - *Pull Queues* are not supported in documentation nor code examples

Using Python 3.4 Google App Engine Flex.
Google documentation on using pull queues with Python says to "from google.appengine.api import taskqueue", but does not explain how to make taskqueue available to Python runtime.
They do link to "Easily Access Google API's from Python", where it explains how to install the api client via "pip install google-api-python-client"
This does not install the taskqueue lib.
From the previous doc, there is a link to "Installation", where it says:
Because the Python client libraries are not installed in the App Engine Python runtime environment, they must be vendored into your application just like third-party libraries.
This links to another page "Using third-party libraries", which states you need to either install a lib to /lib or use requirements.txt. Neither of these make taskueue available.
Searching for taskqueue.py in Google's github shows only an example module with the same name.
There is a documentation page on the module, but no information on how to install it.
There is a Python 2.7 example that google points to here, but it doesn't work. There is no setup of taskqueue, no requirements.txt, no instructions.
There is a stack overflow question on this topic here, and the checked answer says to install the SDK. That takes you to here, which takes you to here, which takes you here, which takes you to here, which provides the gcloud SDK download for deploying and managing gcloud. This does not include the python lib for taskqueue.
There is another similar stackoverflow question here, which says:
... this is now starting to feel like an infinite loop. Yes, it's been made crystal clear you need to import the taskqueue. But how do you make it available?
I've asked the question to Google Support and they haven't been able to answer for 4 days.
I've opened two issues, one here and another here. No answers yet.
Do not want to use Python < 3.4.
Do not want to use HTTP REST API.
Just want a simple pull queue.
Many of the docs you mentioned are standard environment docs and do not apply to the flexible environment.
From the Task Queue section in Migrating Services from the Standard Environment to the Flexible Environment:
The Task Queue service has limited availability outside of the
standard environment. If you want to use the service outside of the
standard environment, you can sign up for the Cloud Tasks alpha.
Outside of the standard environment, you can't add tasks to push
queues, but a service running in the flexible environment can be
the target of a push task. You can specify this using the
target parameter when adding a task to queue or by specifying
the default target for the queue in queue.yaml.
In many cases where you might use pull queues, such as queuing up
tasks or messages that will be pulled and processed by separate
workers, Cloud Pub/Sub can be a good alternative as it offers
similar functionality and delivery guarantees.

cannot find package "appengine/cloudsql"

I develop some GO libraries using Google Cloud SQL and MySQL server. When I imported `appengine/cloudsql, an error below occured.
cloud.go:20:2: cannot find package "appengine/cloudsql" in any of:
/usr/local/Cellar/go/1.1.2/src/pkg/appengine/cloudsql (from $GOROOT)
/Users/lameduck/myGo/src/appengine/cloudsql (from $GOPATH)
I know this package, appengine/cloudsql, is only for Google App Engine and it doesn't exist on everywhere else.
I'm wondering how can I use it for GAE and standard sql library for other environments in a single library.
PS: I can setup Google App Engine SDK correctly. My question is not relevant to it. I hope my library runs on Google App Engine and standalone environment together. (I already made a code for GAE and a code for other dabatases.) It is Ok that users have to setup some configurations. But I don't want that users have to modify a library source code.
Thanks for any help.
I solved the problem. I used a build constraint to use the proper routine and avoid an error. There is a build constraint for App Engine, appengine.
The App Engine SDK introduces a new build constraint term:
"appengine". Files that specify
// +build appengine will be built by the App Engine SDK and ignored by
the go tool. Conversely, files that specify
// +build !appengine are ignored by the App Engine SDK, while the go
tool will happily build them.
PS:
Anway, I upvoted other answers. Thank you.
Package import is done during compile/link time. And Go doesn't support runtime conditional imports in distinction from Python.
Feature you are looking for is dynamic library loading (like in C/C++ you can load .so/.dll in runtime), but Go currently doesn't support it.

Importing C python module in Google App Engine

I am developing an application on Google app engine using Python. I want to use editdist feature of Python and for that reason I am importing editdist C python module in my program, but it is showing that module editdist does not exist.
When I import editdist for my local application it is working fine but not for Google app engine application.
Can anyone suggest me a method to import this module?
App Engine is a "pure python" environment, and you cannot use any C extensions or other code that must be compiled.
There is therefore no way to use this program on App Engine, and all of the competing "production quality" python libraries I found were implemented as C modules.
There do exist alternate implementations of the Levenshtein distance algorithm, though none are as nearly as fast as editdist. These more naïve implementations might still be acceptable depending upon your needs.
Here could be couple alternatives that are implemented with Python (I haven't tested them myself):
http://www.korokithakis.net/node/87
http://code.activestate.com/recipes/576874-levenshtein-distance/

Google app engine to run executable files

Is it possible to run executable files in google app engine? Like by using Runtime.exec?
There is whitelist on google app engine documentation which list classes that can be used but functions/ inside the classes are not specified.
No, absolutely not.
The only thing that make AppEngine possible is that both the Python and Java environments are controlled by Google so that performance/scability and security issues are minimized. They don't even allow to use all the standard Java/Python classes, so imagine the problems that could arise if they let people run any executable file. One may even be a virus!

Resources