-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sherif akoush issue/2621/refactor env var retrieval #3420
Sherif akoush issue/2621/refactor env var retrieval #3420
Conversation
… separate functions.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just a few questions
@@ -0,0 +1,35 @@ | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just have these in the utils.py? Is there a particular reason to have a separate utils file/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems to be some circular dependencies if we do that
seldon_core/metrics.py:16: in <module>
from seldon_core.utils import get_image_name, get_model_name, get_deployment_name, get_predictor_name, \
seldon_core/utils.py:16: in <module>
from seldon_core.user_model import (
seldon_core/user_model.py:10: in <module>
from seldon_core.metrics import SeldonMetrics, validate_metrics
I have not investigated a lot into that though. I think that having a separate module to have all env variables handling is ok. isnt it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's already an improvement to have them in one place so if there is no obvious solution to circular dependency let's leave it as it is 👍
logger = logging.getLogger(__name__) | ||
|
||
NONIMPLEMENTED_MSG = "NOT_IMPLEMENTED" | ||
from seldon_core.env_utils import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could just (if we put this into utils)
from seldon_core import utils
and then use utils.get_image_name
wherever needed
Though both works and and usually over-import so does not require a change now.
/test integration |
/test notebooks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @sakoush ! Just had a look and, other than a small typo, everything looks good 👍
python/seldon_core/env_utils.py
Outdated
NONIMPLEMENTED_IMAGE_MSG = f"{NONIMPLEMENTED_MSG}:{NONIMPLEMENTED_MSG}" | ||
|
||
|
||
def get_predictior_version(default_str: str = NONIMPLEMENTED_MSG) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: get_predictor_version
instead of get_predictior_version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch
def get_request_path(): | ||
model_name = get_model_name() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conscious that it falls slightly outside the scope of this PR, but it would make sense to return None
rather than NONIMPLEMENTED_MSG
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some of these are sometimes used for a key in a dictionary. None
cannot be a key as far as I remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually... it can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can but if we read it back it will be "None" and not None
so we need to convert anyway
@@ -348,6 +352,7 @@ def array_to_list_value(array: np.ndarray, lv: Optional[ListValue] = None) -> Li | |||
|
|||
Returns | |||
------- | |||
ListValue protobuf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch 👍
@@ -240,6 +240,22 @@ def send_feedback_grpc(self, request): | |||
logging.info("Feedback called") | |||
|
|||
|
|||
@pytest.fixture(name="mock_get_model_name") | |||
def fixture_get_model_name(mocker): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make more sense to mock the environment variables rather than the methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having said that, I just realised that you are testing the environment as well down below so maybe you're right in that it makes more sense to mock only the methods here.
/test integration |
/test notebooks |
Integration tests
|
…koush_issue/2621/refactor_env_var_retrieval
/retest |
/test integration |
/test notebooks |
1 similar comment
/test notebooks |
The failure is on |
Thanks for the heads up @RafalSkolasinski! In that case, is it alright to merge this one? |
Should be alright but the new tests should finish soon so we can wait a few minutes and see |
/test notebooks |
Consolidate the logic of getting values from enviornment variables as they were duplicated in two places.
What this PR does / why we need it:
Tidy up code.
Which issue(s) this PR fixes:
Fixes #2621
Special notes for your reviewer:
I have introduced
env_utils.py
to contain the refactored logic. Otherwise there will be circular dependencies.Does this PR introduce a user-facing change?: