Skip to content

Commit

Permalink
Merge pull request #3104 from nadinet/remove_redis_persistence
Browse files Browse the repository at this point in the history
Depricate persistence
  • Loading branch information
axsaucedo authored Apr 22, 2021
2 parents 0152ef1 + 2e485ec commit 2a09a8d
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 125 deletions.
6 changes: 1 addition & 5 deletions doc/source/python/python_wrapping_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ EXPOSE 5000
# Define environment variable
ENV MODEL_NAME MyModel
ENV SERVICE_TYPE MODEL
ENV PERSISTENCE 0

CMD exec seldon-core-microservice $MODEL_NAME --service-type $SERVICE_TYPE --persistence $PERSISTENCE
CMD exec seldon-core-microservice $MODEL_NAME --service-type $SERVICE_TYPE
```


Expand Down Expand Up @@ -96,9 +95,6 @@ The service type being created. Available options are:
* COMBINER
* OUTLIER_DETECTOR

### PERSISTENCE

Set either to 0 or 1. Default is 0. If set to 1 then your model will be saved periodically to redis and loaded from redis (if exists) or created fresh if not.

### Flask Settings

Expand Down
4 changes: 0 additions & 4 deletions doc/source/python/python_wrapping_s2i.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ Define the core parameters needed by our python builder image to wrap your model
```bash
MODEL_NAME=MyModel
SERVICE_TYPE=MODEL
PERSISTENCE=0
```

These values can also be provided or overridden on the command line when building the image.
Expand Down Expand Up @@ -161,9 +160,6 @@ The service type being created. Available options are:
* COMBINER
* OUTLIER_DETECTOR

### PERSISTENCE

Set either to 0 or 1. Default is 0. If set to 1 then your model will be saved periodically to redis and loaded from redis (if exists) or created fresh if not.

### EXTRA_INDEX_URL

Expand Down
1 change: 0 additions & 1 deletion python/conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ requirements:
- protobuf
- flask
- flask-cors
- redis-py
- tornado
- requests
- numpy
Expand Down
1 change: 0 additions & 1 deletion python/licenses/license_info.csv
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"pyasn1-modules","0.2.8","BSD License"
"pycparser","2.20","BSD License"
"pyrsistent","0.17.3","MIT License"
"redis","3.5.3","MIT License"
"requests","2.25.1","Apache Software License"
"requests-oauthlib","1.3.0","BSD License"
"rsa","4.7.2","Apache Software License"
Expand Down
1 change: 0 additions & 1 deletion python/licenses/license_info.no_versions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"pyasn1-modules","BSD License"
"pycparser","BSD License"
"pyrsistent","MIT License"
"redis","MIT License"
"requests","Apache Software License"
"requests-oauthlib","BSD License"
"rsa","Apache Software License"
Expand Down
18 changes: 11 additions & 7 deletions python/seldon_core/microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from functools import partial
from typing import Callable, Dict

from seldon_core import __version__, persistence
from seldon_core import __version__
from seldon_core import wrapper as seldon_microservice
from seldon_core.flask_utils import ANNOTATIONS_FILE, SeldonMicroserviceException
from seldon_core.gunicorn_utils import (
Expand Down Expand Up @@ -213,7 +213,14 @@ def main():
choices=["MODEL", "ROUTER", "TRANSFORMER", "COMBINER", "OUTLIER_DETECTOR"],
default="MODEL",
)
parser.add_argument("--persistence", nargs="?", default=0, const=1, type=int)
parser.add_argument(
"--persistence",
nargs="?",
default=0,
const=1,
type=int,
help="deprecated argument ",
)
parser.add_argument(
"--parameters", type=str, default=os.environ.get(PARAMETERS_ENV_NAME, "[]")
)
Expand Down Expand Up @@ -351,11 +358,8 @@ def main():
user_class = getattr(interface_file, parts[1])

if args.persistence:
logger.info("Restoring persisted component")
user_object = persistence.restore(user_class, parameters)
persistence.persist(user_object, parameters.get("push_frequency"))
else:
user_object = user_class(**parameters)
logger.error(f"Persistence: ignored, persistence is deprecated")
user_object = user_class(**parameters)

http_port = args.http_port
grpc_port = args.grpc_port
Expand Down
86 changes: 0 additions & 86 deletions python/seldon_core/persistence.py

This file was deleted.

1 change: 0 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"Flask<2.0.0",
"jsonschema<4.0.0",
"Flask-cors<4.0.0",
"redis<4.0.0",
"requests<3.0.0",
"numpy<2.0.0",
"flatbuffers<2.0.0",
Expand Down
24 changes: 12 additions & 12 deletions python/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ def __init__(self, app_location, envs={}, tracing=False):

def _env_vars(self, envs):
env_vars = dict(os.environ)
s2i_env_file = os.path.join(self.app_location, ".s2i", "environment")
with open(s2i_env_file) as fh:
for line in fh.readlines():
line = line.strip()
if line:
key, value = line.split("=", 1)
key, value = key.strip(), value.strip()
if key and value:
env_vars[key] = value

env_vars.update(envs)
env_vars.update(
{
Expand All @@ -36,16 +46,6 @@ def _env_vars(self, envs):
}
)

s2i_env_file = os.path.join(self.app_location, ".s2i", "environment")
with open(s2i_env_file) as fh:
for line in fh.readlines():
line = line.strip()
if line:
key, value = line.split("=", 1)
key, value = key.strip(), value.strip()
if key and value:
env_vars[key] = value

return env_vars

def _get_cmd(self, tracing):
Expand All @@ -54,9 +54,9 @@ def _get_cmd(self, tracing):
self.env_vars["MODEL_NAME"],
"--service-type",
self.env_vars["SERVICE_TYPE"],
"--persistence",
self.env_vars["PERSISTENCE"],
)
if "PERSISTENCE" in self.env_vars:
cmd += ("--persistence", self.env_vars["PERSISTENCE"])

if tracing:
cmd += ("--tracing",)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
MODEL_NAME=MyModel
API_TYPE=REST
SERVICE_TYPE=MODEL
PERSISTENCE=0
1 change: 0 additions & 1 deletion python/tests/resources/model-template-app/.s2i/environment
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
MODEL_NAME=MyModel
API_TYPE=REST
SERVICE_TYPE=MODEL
PERSISTENCE=0
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
MODEL_NAME=mymodule.my_model.MyModel
API_TYPE=REST
SERVICE_TYPE=MODEL
PERSISTENCE=0
9 changes: 9 additions & 0 deletions python/tests/test_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,12 @@ def test_load_annotations(mock_isfile):
def test_health_status(microservice):
response = requests.get("http://127.0.0.1:9000/health/status")
response.raise_for_status()


@pytest.mark.parametrize(
"microservice", [{"envs": {"PERSISTENCE": "1"}}], indirect=True
)
def test_persistence_flag_exist(microservice):
response = requests.get("http://127.0.0.1:9000/health/status")
# This just tests that persistence flag was not removed ("soft" deprecation)
response.raise_for_status()
11 changes: 7 additions & 4 deletions wrappers/s2i/python/s2i/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function _is_env_present() {
}

#check environment vars
if [[ -z "$MODEL_NAME" || -z "$SERVICE_TYPE" || -z "$PERSISTENCE" ]]; then
if [[ -z "$MODEL_NAME" || -z "$SERVICE_TYPE" ]]; then

echo "Failed to find required env vars MODEL_NAME, SERVICE_TYPE, PERSISTENCE"
echo "Failed to find required env vars MODEL_NAME, SERVICE_TYPE"
exit 1

else
Expand All @@ -44,6 +44,9 @@ else
fi

echo "starting microservice"
exec seldon-core-microservice $MODEL_NAME --service-type $SERVICE_TYPE --persistence $PERSISTENCE

if [ -n "$PERSISTENCE" ]; then
exec seldon-core-microservice $MODEL_NAME --service-type $SERVICE_TYPE --persistence $PERSISTENCE
else
exec seldon-core-microservice $MODEL_NAME --service-type $SERVICE_TYPE
fi
fi

0 comments on commit 2a09a8d

Please sign in to comment.