Skip to content

"async" is a reserved keyword in Python 3.7+ #2052

Closed
@tamnnn

Description

@tamnnn

Version

0.32.0

Description

Attempting to deploy an Async API w/ a custom Docker image running on Python 3.7+ will result in a SyntaxError.

Configuration

Dockerfile

FROM quay.io/cortexlabs/python-predictor-gpu:0.32.0-cuda11.1-cudnn8

RUN apt update \
    && apt install libgl1-mesa-glx -y \
    && apt install libgtk2.0-dev -y

# upgrade python runtime version
RUN conda update -n base -c defaults conda
RUN conda install -n env python=3.8.5

# re-install cortex core dependencies
RUN /usr/local/cortex/install-core-dependencies.sh

COPY requirements.txt .
RUN pip install -r requirements.txt

cortex.yaml

- name: predict
  kind: AsyncAPI
  predictor:
    image: <private image>
    type: python
    path: api/async/predict.py
    dependencies:
        shell: startup.sh
    config:
      device: gpu
      input_shape: [512, 512]
  compute:
    gpu: 1
    cpu: 1

Steps to reproduce

  1. cortex deploy cortex.yaml

Expected behavior

Module should not be named async.

Actual behavior

Module is named async, which is a reserved keyword starting from Python 3.7.

Screenshots

(optional)

Stack traces

error output from cortex logs predict

...
[services.d] starting services
[services.d] done.
  File "/src/cortex/serve/start/async.py", line 24
    from cortex_internal.lib.api.async import AsyncAPI
                                 ^
SyntaxError: invalid syntax
[finish-manager] service async exiting with exit code 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

Additional context

I found the same issue addressed in an different package: celery/celery#4849

Suggested solution

Rename the async module

Metadata

Metadata

Assignees

No one assigned

    Labels

    AsyncAPISomething related to the AsyncAPI kindbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions