-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FSTORE-1479] Deduplicate hsml client (#243)
* Move hsml/client/istio * Adapt the moved hsml client * Fix istio.__init__ * Fix client.__init__ * Fix hsml client so that it is possible to do hsml.connection(...) * Add aliases to hsml.client
- Loading branch information
Showing
39 changed files
with
1,705 additions
and
1,891 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Copyright 2022 Logical Clocks AB | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Union | ||
|
||
import hopsworks_common.client as _main | ||
from hopsworks_common.client.istio import external, hopsworks | ||
|
||
|
||
_client: Union[hopsworks.Client, external.Client, None] = None | ||
|
||
|
||
def init(host, port, project=None, api_key_value=None): | ||
global _client | ||
|
||
if _client: | ||
return | ||
if isinstance(_main._client, _main.hopsworks.Client): | ||
_client = hopsworks.Client(host, port) | ||
elif isinstance(_main, _main.external.Client): | ||
_client = external.Client(host, port, project, api_key_value) | ||
|
||
|
||
def get_instance() -> Union[hopsworks.Client, external.Client, None]: | ||
global _client | ||
return _client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# | ||
# Copyright 2022 Logical Clocks AB | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
import requests | ||
from hopsworks_common.client import auth | ||
from hopsworks_common.client.istio import base as istio | ||
|
||
|
||
class Client(istio.Client): | ||
def __init__( | ||
self, | ||
host, | ||
port, | ||
project, | ||
api_key_value, | ||
hostname_verification=None, | ||
trust_store_path=None, | ||
): | ||
"""Initializes a client in an external environment such as AWS Sagemaker.""" | ||
self._host = host | ||
self._port = port | ||
self._base_url = "http://" + self._host + ":" + str(self._port) | ||
self._project_name = project | ||
|
||
self._auth = auth.ApiKeyAuth(api_key_value) | ||
|
||
self._session = requests.session() | ||
self._connected = True | ||
self._verify = self._get_verify(hostname_verification, trust_store_path) | ||
|
||
self._cert_key = None | ||
|
||
def _close(self): | ||
"""Closes a client.""" | ||
self._connected = False | ||
|
||
def _replace_public_host(self, url): | ||
"""no need to replace as we are already in external client""" | ||
return url | ||
|
||
@property | ||
def host(self): | ||
return self._host |
File renamed without changes.
Oops, something went wrong.