Repository: sql-machine-learning/elasticdl

Issue:
Copy the user defined model zoo files into root  in the docker image.
Sometimes, we need to define multiple files for a model. For example:
```
model_zoo
    |----mnist_model
        |----__init__.py
        |----mnist_model_functional.py
        |----custom_layer.py
```
We can import the module from `custom_layer.py` in `mnist_model_functional.py` using
`from model_zoo.custom_layer import CustomLayer`.  

However, we copy the `model_zoo` directory into `model_zoo/model_zoo` when we build the image. And the directory structure is
```
model_zoo
    |----model_zoo
        |----mnist_model
            |----__init__.py
            |----mnist_model_functional.py
            |----custom_layer.py
```
So, the user must use `from model_zoo.model_zoo.custom_layer import CustomLayer` to import.  


Discussion:

Resolving patch:
diff --git a/elasticdl/python/elasticdl/api.py b/elasticdl/python/elasticdl/api.py
--- a/elasticdl/python/elasticdl/api.py
+++ b/elasticdl/python/elasticdl/api.py
@@ -201,7 +201,7 @@ def _model_zoo_in_docker(model_zoo, image_pre_built):
     if image_pre_built:
         return model_zoo
 
-    MODEL_ROOT_PATH = "/model_zoo"
+    MODEL_ROOT_PATH = "/"
     return os.path.join(MODEL_ROOT_PATH, os.path.basename(model_zoo))
 
 
diff --git a/elasticdl/python/elasticdl/image_builder.py b/elasticdl/python/elasticdl/image_builder.py
--- a/elasticdl/python/elasticdl/image_builder.py
+++ b/elasticdl/python/elasticdl/image_builder.py
@@ -139,7 +139,7 @@ def _create_dockerfile(
 ):
     HEAD = """
 FROM {BASE_IMAGE} as base
-ENV PYTHONPATH=/:/model_zoo
+ENV PYTHONPATH=/
 """
     if elasticdl:
         HEAD = """
@@ -154,14 +154,14 @@ def _create_dockerfile(
 RUN pip install -r /elasticdl/requirements.txt \
   --extra-index-url="${EXTRA_PYPI_INDEX}"
 RUN make -f /elasticdl/Makefile
-COPY {MODEL_ZOO} /model_zoo/{MODEL_ZOO}
+COPY {MODEL_ZOO} /{MODEL_ZOO}
 """
     REMOTE_ZOO = """
 RUN pip install -r /elasticdl/requirements.txt \
   --extra-index-url="${EXTRA_PYPI_INDEX}"
 RUN make -f /elasticdl/Makefile
 RUN apt-get update && apt-get install -y git
-RUN git clone --recursive {MODEL_ZOO} /model_zoo
+RUN git clone --recursive {MODEL_ZOO} /
 """
     pr = urlparse(model_zoo)
     if not pr.path:
@@ -187,7 +187,7 @@ def _create_dockerfile(
     tmpl = (
         """
 %s
-ARG REQS=/model_zoo/{MODEL_ZOO}/requirements.txt
+ARG REQS=/{MODEL_ZOO}/requirements.txt
 RUN if [ -f $REQS ]; then \
       pip install -r $REQS --extra-index-url="${EXTRA_PYPI_INDEX}"; \
     fi


Test patch:
diff --git a/scripts/client_test.sh b/scripts/client_test.sh
--- a/scripts/client_test.sh
+++ b/scripts/client_test.sh
@@ -42,7 +42,7 @@ elif [[ "$JOB_TYPE" == "evaluate" ]]; then
       --image_base=elasticdl:ci \
       --model_zoo=model_zoo \
       --model_def=mnist_functional_api.mnist_functional_api.custom_model \
-      --checkpoint_dir_for_init=model_zoo/${MNIST_CKPT_DIR}/version-100  \
+      --checkpoint_dir_for_init=/${MNIST_CKPT_DIR}/version-100  \
       --validation_data=/data/mnist/test \
       --num_epochs=1 \
       --master_resource_request="cpu=0.3,memory=1024Mi" \
@@ -65,7 +65,7 @@ elif [[ "$JOB_TYPE" == "predict" ]]; then
       --image_base=elasticdl:ci \
       --model_zoo=model_zoo \
       --model_def=mnist_functional_api.mnist_functional_api.custom_model \
-      --checkpoint_dir_for_init=model_zoo/${MNIST_CKPT_DIR}/version-100 \
+      --checkpoint_dir_for_init=/${MNIST_CKPT_DIR}/version-100 \
       --prediction_data=/data/mnist/test \
       --master_resource_request="cpu=0.2,memory=1024Mi" \
       --master_resource_limit="cpu=1,memory=2048Mi" \