New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 720186 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

numpy 1.11.0 in infra/ENV is not supported by GAE?

Project Member Reported by st...@chromium.org, May 10 2017

Issue description

Based on https://cloud.google.com/appengine/docs/standard/python/tools/built-in-libraries-27, it seems GAE only supports numpy 1.6.1, but we have 1.11.0

Findit app has a dependency on numpy, and we can't run it locally with
/b/cr2/infra/ENV/bin/python /b/cr2/google_appengine/dev_appserver.py path/to/app

I got following errors:
Traceback (most recent call last):
  File "/b/cr2/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/b/cr2/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/b/cr2/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/b/cr2/infra/appengine/findit/main.py", line 13, in <module>
    from handlers import auto_revert_metrics
  File "/b/cr2/infra/appengine/findit/handlers/auto_revert_metrics.py", line 6, in <module>
    import numpy
  File "/b/cr2/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 706, in load_module
    module = self._find_and_load_module(fullname, fullname, [module_path])
  File "/b/cr2/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 447, in _find_and_load_module
    return imp.load_module(fullname, source_file, path_name, description)
  File "/b/cr2/infra/ENV/local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
    from . import add_newdocs
  File "/b/cr2/infra/ENV/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/b/cr2/infra/ENV/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/b/cr2/infra/ENV/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/b/cr2/infra/ENV/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import _internal  # for freeze programs
  File "/b/cr2/infra/ENV/local/lib/python2.7/site-packages/numpy/core/_internal.py", line 14, in <module>
    import ctypes
  File "/usr/lib/python2.7/ctypes/__init__.py", line 10, in <module>
    from _ctypes import Union, Structure, Array
  File "/b/cr2/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 964, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named _ctypes
 
Components: -Infra>Platform>CIPD Infra>Platform
(CIPD is not related at all)

numpy version was updated to the latest version in crbug.com/674305 because SciPy version used depends on numpy >= 1.7.1 (see "Requires Distributions" in https://pypi.python.org/pypi/scipy/0.18.1).

We can try to rollback scipy and numpy versions to old ones, but this is unstable solution (eventually someone will need a feature not available in prehistoric versions).

I don't know a better non-hacky solution.

Comment 2 by st...@chromium.org, May 10 2017

(sorry, I thought those packages are managed by CIPD)
Cc: d...@chromium.org
One possible non-hacky solution is to use different set of pinned python packages for GAE environment (or even for each individual GAE app), and pin numpy to 1.6.1 there. Perhaps using new vpython tool dnj@ is developing.

This will require some work to hook this up to test.py, tryjobs, CI bots, etc.

Comment 4 by d...@chromium.org, May 10 2017

Where is this code being run? Is it run on bots, or on developer systems?

One possible plan would be:
1) Define a VirtualEnv spec w/ the same set of libraries that GAE has.
2) Bootstrap all Infra GAE tests through this VirtualEnv.

This would actually be really cool precursor to:
*) Bootstrap all Infra tests through some sort of VirtualEnv :)

Comment 5 by st...@chromium.org, May 10 2017

The code is running on my local workstation when I try to launch Findit app with google_appengine/dev_appserver.py

For unittests run with test.py, there is no such error locally on my workstation or on tryjobs/CI.
It seems GAE dev_appserver has some restriction to not load ctypes or _ctypes at runtime.

Findit only depends on numpy.percentile, and I have a workaround for it.
So please feel free to consider this low priority if too much work is needed.

Comment 6 by st...@chromium.org, May 10 2017

I like the idea of vPython through VirtualEnv here. It is really cool!
Project Member

Comment 7 by bugdroid1@chromium.org, May 10 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/infra/infra/+/2ae7c546f4e3c038d3157ac69be7ca70552c323f

commit 2ae7c546f4e3c038d3157ac69be7ca70552c323f
Author: Shuotao Gao <stgao@chromium.org>
Date: Wed May 10 18:39:12 2017

[Findit] Workaround numpy import to run Findit app locally on dev_appserver.

BUG=720186

Change-Id: Iafa7acd6c60a5669ed500b5b2f53e7d6d92c7ffd
Reviewed-on: https://chromium-review.googlesource.com/501353
Commit-Queue: Shuotao Gao <stgao@chromium.org>
Reviewed-by: Jeffrey Li <lijeffrey@chromium.org>
Reviewed-by: Chan Li <chanli@chromium.org>
Reviewed-by: Roberto Carrillo <robertocn@chromium.org>

[modify] https://crrev.com/2ae7c546f4e3c038d3157ac69be7ca70552c323f/appengine/findit/handlers/auto_revert_metrics.py
[modify] https://crrev.com/2ae7c546f4e3c038d3157ac69be7ca70552c323f/appengine/findit/util_scripts/run.sh

Project Member

Comment 8 by sheriffbot@chromium.org, May 11 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 9 by st...@chromium.org, May 11 2018

Cc: -d...@chromium.org -vadimsh@chromium.org
Labels: -Pri-3 Pri-2
Due to the version mismatch between numpy in infra/ENV and the one in GAE, it is quite easy to use a function in 1.11.0 which is not available in the version in GAE.
Labels: -Hotlist-Recharge-Cold
Owner: st...@chromium.org
Status: Assigned (was: Untriaged)
Does numpy require a C extension or can it run as a pure python module? Because if it's pure python, you could "unmap" the GAE provided version and use yours.

Comment 11 by st...@chromium.org, May 21 2018

Owner: ----
Status: Untriaged (was: Assigned)
We checked and found that numpy requires C extension. So we could not go with an "unmap".
Components: -Infra>Platform Tools>Test>FindIt
I'm afraid there isn't much FOundations team can do for you here:
Theoretically, you could configure your own .vpython file and stick it into your root of your appengine app AND:
 * ensure that devappserver runs with PYTHONPATH set to .vpython's virtual env.
 * modify infra/infra repo TRY and CI recipe to:
   * exclude appengine/findit from Python appengine apps tested normally
   * add special invocation for tests inside appengine/findit
 * keep your own .vpython up to date with whatever is in root infra/infra .vpython so you don't miss out on updates to infra_libs and other packages.

Cc: iannucci@chromium.org
+iannucci to confirm/deny/offer better suggestions.
Cc: -iannucci@chromium.org iannu...@google.com

Sign in to add a comment