Skip to content

Commit

Permalink
fix: fail to import on armv8 (#2506)
Browse files Browse the repository at this point in the history
* fix: reorder the import to make grpc run on armv8
  • Loading branch information
hanxiao committed May 29, 2021
1 parent a11c3ed commit da68531
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
with:
context: .
file: Dockerfiles/debianx.Dockerfile
platforms: linux/armhf,linux/amd64,linux/arm/v6
platforms: linux/armhf,linux/amd64,linux/arm/v6,linux/arm64
push: true
tags: jinaai/jina:master${{ matrix.tag_pyversion }}${{ matrix.tag_stage }}, ${{env.TAG_ALIAS}}
build-args: BUILD_DATE, JINA_VERSION, VCS_REF, PY_VERSION
Expand Down
37 changes: 32 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,42 @@ jobs:
docker-image-test:
needs: commit-lint
runs-on: ubuntu-20.04
services:
registry:
image: registry:2
ports:
- 5000:5000
strategy:
fail-fast: false
matrix:
test-arch: ["linux/amd64", "linux/arm64"]
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
driver-opts: network=host
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_DEVBOT_USER }}
password: ${{ secrets.DOCKERHUB_DEVBOT_TOKEN }}
- run: |
echo "PIP_TAG='[devel]'" >> $GITHUB_ENV
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Build and test
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfiles/debianx.Dockerfile
platforms: ${{ matrix.test-arch }}
push: true
tags: localhost:5000/jina/multiarch:latest
target: jina_devel
build-args: BUILD_DATE, JINA_VERSION, VCS_REF, PY_VERSION
- run: |
docker build -f Dockerfiles/pip.Dockerfile -t jinaai/jina:test-pip .
docker run jinaai/jina:test-pip hello fashion
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
docker run --platform ${{ matrix.test-arch }} localhost:5000/jina/multiarch:latest -v
core-test:
needs: [prep-testbed, commit-lint, lint-flake-8]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/force-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
with:
context: .
file: Dockerfiles/debianx.Dockerfile
platforms: linux/armhf,linux/amd64,linux/arm/v6
platforms: linux/armhf,linux/amd64,linux/arm/v6,linux/arm64
push: true
tags: jinaai/jina:${{env.JINA_VERSION}}${{ matrix.tag_pyversion }}${{ matrix.tag_stage }}, ${{env.TAG_ALIAS}}
build-args: BUILD_DATE, JINA_VERSION, VCS_REF, PY_VERSION
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ jobs:
with:
context: .
file: Dockerfiles/debianx.Dockerfile
platforms: linux/armhf,linux/amd64,linux/arm/v6
platforms: linux/armhf,linux/amd64,linux/arm/v6,linux/arm64
push: true
tags: jinaai/jina:latest${{ matrix.tag_pyversion }}${{ matrix.tag_stage }}, jinaai/jina:${{env.JINA_VERSION}}${{ matrix.tag_pyversion }}${{ matrix.tag_stage }}, jinaai/jina:${{env.JINA_MINOR_VERSION}}${{ matrix.tag_pyversion }}${{ matrix.tag_stage }}, ${{env.TAG_ALIAS}}
build-args: BUILD_DATE, JINA_VERSION, VCS_REF, PY_VERSION
Expand Down
4 changes: 4 additions & 0 deletions Dockerfiles/debianx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ARG BUILD_DATE
ARG JINA_VERSION
ARG PIP_TAG
ARG PIP_EXTRA_INDEX_URL="https://www.piwheels.org/simple"
ARG TARGETPLATFORM

LABEL org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.authors="dev-team@jina.ai" \
Expand All @@ -41,9 +42,12 @@ ENV JINA_COMPILERS="gcc libc-dev make" \
COPY . /jina/

RUN ln -s locale.h /usr/include/xlocale.h && \
if [ "${TARGETPLATFORM}" = "linux/arm64" ] || [ "${TARGETPLATFORM}" = "linux/arm/v8" ]; then apt-get update && apt-get install --no-install-recommends -y ${JINA_COMPILERS}; fi && \
if [ "${TARGETPLATFORM}" = "linux/armhf" ] || [ "${TARGETPLATFORM}" = "linux/arm/v6" ]; then apt-get update && apt-get install --no-install-recommends -y libatlas-base-dev; fi && \
cd /jina && \
pip install . --compile --extra-index-url ${PIP_EXTRA_INDEX_URL} && \
if [ -n "${PIP_TAG}" ]; then pip install ".[${PIP_TAG}]" --compile --extra-index-url $PIP_EXTRA_INDEX_URL; fi && \
if [ "${TARGETPLATFORM}" = "linux/arm64" ] || [ "${TARGETPLATFORM}" = "linux/arm/v8" ]; then apt-get remove -y --auto-remove ${JINA_COMPILERS}; fi && \
apt-get autoremove && apt-get clean && rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* && rm -rf /jina && rm /usr/include/xlocale.h

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ $ docker run jinaai/jina:master -v
<details>
<summary>📦 More installation options</summary>

| <br><sub><sup>x86/64,arm/v6,v7,[v8 (Apple M1)](https://github.com/jina-ai/jina/issues/1781)</sup></sub> | On Linux/macOS & Python 3.7/3.8/3.9 | Docker Users|
| <br><sub><sup>x86/64,arm64,v6,v7,Apple M1</sup></sub> | On Linux/macOS & Python 3.7/3.8/3.9 | Docker Users|
| --- | --- | --- |
| Standard | `pip install --pre jina` | `docker run jinaai/jina:master` |
| <sub><a href="https://api.jina.ai/daemon/">Daemon</a></sub> | <sub>`pip install --pre "jina[daemon]"`</sub> | <sub>`docker run --network=host jinaai/jina:master-daemon`</sub> |
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The following example shows how Jina is released from 0.9 to 0.9.2 according to

## Docker image versioning

Our univeral Docker image is ready-to-use on linux/amd64, linux/armv7+, linux/arm/v6. The Docker image name always starts with `jinaai/jina` followed by a tag composed of three parts:
Our univeral Docker image is ready-to-use on linux/amd64, linux/armv7+, linux/arm/v6, linux/arm64. The Docker image name always starts with `jinaai/jina` followed by a tag composed of three parts:

```text
jinaai/jina:{version}{python_version}{extra}
Expand Down
6 changes: 3 additions & 3 deletions jina/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def _set_nofile(nofile_atleast=4096):

# ONLY FIRST CLASS CITIZENS ARE ALLOWED HERE, namely Document, Executor Flow

# Client
from jina.clients import Client

# Document
from jina.types.document import Document
from jina.types.arrays.document import DocumentArray
Expand All @@ -166,8 +169,5 @@ def _set_nofile(nofile_atleast=4096):
from jina.flow import Flow
from jina.flow.asyncio import AsyncFlow

# Client
from jina.clients import Client

__all__ = [_s for _s in dir() if not _s.startswith('_')]
__all__.extend(_names_with_underscore)
2 changes: 1 addition & 1 deletion jina/clients/request/helper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Module for helper functions for clients."""
from typing import Tuple

from ... import Document
from ...enums import DataInputType
from ...excepts import BadDocType, BadRequestType
from ...types.request import Request
from ...types.document import Document


def _new_data_request_from_batch(
Expand Down
2 changes: 1 addition & 1 deletion jina/executors/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)

from .metas import get_default_metas
from .. import DocumentArray
from ..types.arrays import DocumentArray
from ..helper import convert_tuple_to_list


Expand Down
13 changes: 0 additions & 13 deletions jina/helloworld/fashion/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from pathlib import Path

from jina import Flow
from jina.helper import countdown
from jina.parsers.helloworld import set_hw_parser

if __name__ == '__main__':
Expand All @@ -12,7 +11,6 @@
download_data,
index_generator,
query_generator,
colored,
)
from executors import MyEncoder, MyIndexer, MyEvaluator
else:
Expand All @@ -22,7 +20,6 @@
download_data,
index_generator,
query_generator,
colored,
)
from .executors import MyEncoder, MyIndexer, MyEvaluator

Expand Down Expand Up @@ -85,16 +82,6 @@ def hello_world(args):
request_size=args.request_size,
)

# wait for couple of seconds
countdown(
3,
reason=colored(
'behold! im going to switch to query mode',
'cyan',
attrs=['underline', 'bold', 'reverse'],
),
)

# f.search(
# query_generator(
# num_docs=args.num_query, target=targets, with_groundtruth=True
Expand Down
2 changes: 1 addition & 1 deletion jina/types/arrays/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def load_json(cls, file: Union[str, TextIO]) -> 'DocumentArray':
file_ctx = open(file)

with file_ctx as fp:
from jina import Document
from ..document import Document

da = DocumentArray()
for v in fp:
Expand Down
8 changes: 4 additions & 4 deletions jina/types/document/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def from_ndarray(
This function should not be directly used, use :meth:`Flow.index_ndarray`, :meth:`Flow.search_ndarray` instead
"""

from jina import Document
from ..document import Document

if shuffle:
# shuffle for random query
Expand Down Expand Up @@ -65,7 +65,7 @@ def from_files(
.. note::
This function should not be directly used, use :meth:`Flow.index_files`, :meth:`Flow.search_files` instead
"""
from jina import Document
from ..document import Document

if read_mode not in {'r', 'rb', None}:
raise RuntimeError(f'read_mode should be "r", "rb" or None, got {read_mode}')
Expand Down Expand Up @@ -107,7 +107,7 @@ def from_csv(
:yield: documents
"""
from jina import Document
from ..document import Document

lines = csv.DictReader(fp)
for value in _subsample(lines, size, sampling_rate):
Expand Down Expand Up @@ -136,7 +136,7 @@ def from_ndjson(
:yield: documents
"""
from jina import Document
from ..document import Document

for line in _subsample(fp, size, sampling_rate):
value = json.loads(line)
Expand Down

0 comments on commit da68531

Please sign in to comment.