Skip to content

Commit f99eeda

Browse files
committed
Move cortex verification from serve.py to run.sh (#1180)
(cherry picked from commit 5fb3d65)
1 parent 73a88b0 commit f99eeda

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Diff for: pkg/workloads/cortex/consts.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
CORTEX_VERSION = "0.18.1"
1615
SINGLE_MODEL_NAME = "_cortex_default"
1716
INFERENTIA_NEURON_SOCKET = "/sock/neuron.sock"

Diff for: pkg/workloads/cortex/serve/run.sh

+12
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ if [ -f "/mnt/project/conda-packages.txt" ]; then
6666
fi
6767
fi
6868

69+
# CORTEX_VERSION x1
70+
export EXPECTED_CORTEX_VERSION=0.18.1
71+
72+
if [ "$CORTEX_VERSION" != "$EXPECTED_CORTEX_VERSION" ]; then
73+
if [ "$CORTEX_PROVIDER" == "local" ]; then
74+
echo "your Cortex CLI version ($CORTEX_VERSION) doesn't match your predictor image version ($EXPECTED_CORTEX_VERSION); please update your predictor image by modifying the \`image\` field in your API configuration file (e.g. cortex.yaml) and re-running \`cortex deploy\`, or update your CLI by following the instructions at https://docs.cortex.dev/cluster-management/update#upgrading-to-a-newer-version-of-cortex"
75+
else
76+
echo "your Cortex operator version ($CORTEX_VERSION) doesn't match your predictor image version ($EXPECTED_CORTEX_VERSION); please update your predictor image by modifying the \`image\` field in your API configuration file (e.g. cortex.yaml) and re-running \`cortex deploy\`, or update your cluster by following the instructions at https://docs.cortex.dev/cluster-management/update#upgrading-to-a-newer-version-of-cortex"
77+
fi
78+
exit 1
79+
fi
80+
6981
# install pip packages
7082
if [ -f "/mnt/project/requirements.txt" ]; then
7183
pip --no-cache-dir install -r /mnt/project/requirements.txt

Diff for: pkg/workloads/cortex/serve/serve.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,12 @@
3232
from starlette.background import BackgroundTasks
3333
from starlette.exceptions import HTTPException as StarletteHTTPException
3434

35-
from cortex import consts
3635
from cortex.lib import util
3736
from cortex.lib.type import API, get_spec
3837
from cortex.lib.log import cx_logger
3938
from cortex.lib.storage import S3, LocalStorage, FileLock
4039
from cortex.lib.exceptions import UserRuntimeException
4140

42-
if os.environ["CORTEX_VERSION"] != consts.CORTEX_VERSION:
43-
errMsg = f"your Cortex operator version ({os.environ['CORTEX_VERSION']}) doesn't match your predictor image version ({consts.CORTEX_VERSION}); please update your predictor image by modifying the `image` field in your API configuration file (e.g. cortex.yaml) and re-running `cortex deploy`, or update your cluster by following the instructions at https://docs.cortex.dev/cluster-management/update"
44-
raise ValueError(errMsg)
45-
46-
4741
API_SUMMARY_MESSAGE = (
4842
"make a prediction by sending a post request to this endpoint with a json payload"
4943
)
@@ -285,7 +279,7 @@ def start_fn():
285279
**raw_api_spec,
286280
)
287281
client = api.predictor.initialize_client(
288-
tf_serving_host=tf_serving_host, tf_serving_port=tf_serving_port,
282+
tf_serving_host=tf_serving_host, tf_serving_port=tf_serving_port
289283
)
290284
cx_logger().info("loading the predictor from {}".format(api.predictor.path))
291285
predictor_impl = api.predictor.initialize_impl(project_dir, client)

0 commit comments

Comments
 (0)