qwak-core 0.4.271__py3-none-any.whl → 0.4.273__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. _qwak_proto/qwak/model_group/model_group_repository_details_pb2.py +86 -0
  2. _qwak_proto/qwak/model_group/model_group_repository_details_pb2.pyi +107 -0
  3. _qwak_proto/qwak/model_group/model_group_repository_details_pb2_grpc.py +4 -0
  4. _qwak_proto/qwak/models/models_pb2.py +102 -81
  5. _qwak_proto/qwak/models/models_pb2.pyi +57 -0
  6. _qwak_proto/qwak/models/models_pb2_grpc.py +34 -0
  7. _qwak_proto/qwak/models/models_query_pb2.py +77 -0
  8. _qwak_proto/qwak/models/models_query_pb2.pyi +157 -0
  9. _qwak_proto/qwak/models/models_query_pb2_grpc.py +4 -0
  10. frogml_storage/__init__.py +1 -0
  11. frogml_storage/artifactory/__init__.py +1 -0
  12. frogml_storage/artifactory/_artifactory_api.py +315 -0
  13. frogml_storage/authentication/login/__init__.py +1 -0
  14. frogml_storage/authentication/login/_login_cli.py +239 -0
  15. frogml_storage/authentication/login/_login_command.py +74 -0
  16. frogml_storage/authentication/models/__init__.py +3 -0
  17. frogml_storage/authentication/models/_auth.py +24 -0
  18. frogml_storage/authentication/models/_auth_config.py +70 -0
  19. frogml_storage/authentication/models/_login.py +22 -0
  20. frogml_storage/authentication/utils/__init__.py +17 -0
  21. frogml_storage/authentication/utils/_authentication_utils.py +281 -0
  22. frogml_storage/authentication/utils/_login_checks_utils.py +114 -0
  23. frogml_storage/base_storage.py +140 -0
  24. frogml_storage/constants.py +56 -0
  25. frogml_storage/exceptions/checksum_verification_error.py +3 -0
  26. frogml_storage/exceptions/validation_error.py +4 -0
  27. frogml_storage/frog_ml.py +668 -0
  28. frogml_storage/http/__init__.py +1 -0
  29. frogml_storage/http/http_client.py +83 -0
  30. frogml_storage/logging/__init__.py +1 -0
  31. frogml_storage/logging/_log_config.py +45 -0
  32. frogml_storage/logging/log_utils.py +21 -0
  33. frogml_storage/models/__init__.py +1 -0
  34. frogml_storage/models/_download_context.py +54 -0
  35. frogml_storage/models/dataset_manifest.py +13 -0
  36. frogml_storage/models/entity_manifest.py +93 -0
  37. frogml_storage/models/frogml_dataset_version.py +21 -0
  38. frogml_storage/models/frogml_entity_type_info.py +50 -0
  39. frogml_storage/models/frogml_entity_version.py +34 -0
  40. frogml_storage/models/frogml_model_version.py +21 -0
  41. frogml_storage/models/model_manifest.py +60 -0
  42. frogml_storage/models/serialization_metadata.py +15 -0
  43. frogml_storage/utils/__init__.py +12 -0
  44. frogml_storage/utils/_environment.py +21 -0
  45. frogml_storage/utils/_input_checks_utility.py +104 -0
  46. frogml_storage/utils/_storage_utils.py +15 -0
  47. frogml_storage/utils/_url_utils.py +27 -0
  48. qwak/__init__.py +1 -1
  49. qwak/clients/instance_template/client.py +6 -4
  50. qwak/clients/prompt_manager/model_descriptor_mapper.py +21 -19
  51. qwak/feature_store/_common/artifact_utils.py +3 -3
  52. qwak/feature_store/data_sources/base.py +4 -4
  53. qwak/feature_store/data_sources/batch/athena.py +3 -3
  54. qwak/feature_store/feature_sets/streaming.py +3 -3
  55. qwak/feature_store/feature_sets/streaming_backfill.py +1 -1
  56. qwak/feature_store/online/client.py +6 -6
  57. qwak/feature_store/sinks/streaming/factory.py +1 -1
  58. qwak/inner/build_logic/phases/phase_010_fetch_model/fetch_strategy_manager/strategy/git/git_strategy.py +3 -3
  59. qwak/inner/di_configuration/account.py +23 -24
  60. qwak/inner/tool/auth.py +2 -2
  61. qwak/llmops/provider/openai/provider.py +3 -3
  62. qwak/model/tools/adapters/output.py +1 -1
  63. qwak/model/utils/feature_utils.py +12 -8
  64. qwak/model_loggers/artifact_logger.py +7 -7
  65. qwak/tools/logger/logger.py +1 -1
  66. qwak_core-0.4.273.dist-info/METADATA +415 -0
  67. {qwak_core-0.4.271.dist-info → qwak_core-0.4.273.dist-info}/RECORD +68 -26
  68. _qwak_proto/__init__.py +0 -0
  69. _qwak_proto/qwak/__init__.py +0 -0
  70. qwak_core-0.4.271.dist-info/METADATA +0 -53
  71. {qwak_core-0.4.271.dist-info → qwak_core-0.4.273.dist-info}/WHEEL +0 -0
@@ -0,0 +1,239 @@
1
+ from typing import List, Optional, Union
2
+
3
+ import typer
4
+
5
+ from frogml_storage.utils import assemble_artifact_url, join_url
6
+ from frogml_storage.authentication.login._login_command import run as run_login
7
+ from frogml_storage.authentication.models import AuthConfig, LoginArguments
8
+ from frogml_storage.authentication.utils import (
9
+ get_frogml_configuration,
10
+ parse_cli_config_server,
11
+ read_jfrog_cli_config,
12
+ )
13
+ from frogml_storage.authentication.utils import (
14
+ get_list_of_servers_from_config,
15
+ login_input_checks,
16
+ is_login_without_params,
17
+ )
18
+ from frogml_storage.constants import CONFIG_FILE_PATH, JFROG_CLI_CONFIG_FILE_PATH
19
+
20
+
21
+ def login(
22
+ url: Optional[str],
23
+ username: Optional[str],
24
+ password: Optional[str],
25
+ token: Optional[str],
26
+ anonymous: Optional[bool],
27
+ is_interactive: Optional[bool],
28
+ ) -> bool:
29
+ if anonymous is None:
30
+ anonymous = False
31
+ if is_login_without_params(url, username, password, token, anonymous):
32
+ if not is_interactive:
33
+ return __login_by_frogml_configuration_file_flow()
34
+ else:
35
+ return __interactive_flow()
36
+ elif login_input_checks(url, username, password, token, anonymous):
37
+ url = assemble_artifact_url(url)
38
+ return __login_by_command_line_params(url, username, password, token, anonymous)
39
+ else:
40
+ typer.echo(
41
+ f"{__get_failed_reason(url, username, password, token, anonymous)}Login failed"
42
+ )
43
+ return False
44
+
45
+
46
+ def __get_failed_reason(
47
+ url: Optional[str],
48
+ username: Optional[str],
49
+ password: Optional[str],
50
+ token: Optional[str],
51
+ anonymous: Optional[bool],
52
+ ) -> str:
53
+ details = ""
54
+ if url is None:
55
+ details += "Url is required.\n"
56
+ if token is not None and (
57
+ any(params is not None for params in [username, password])
58
+ ):
59
+ details += "Token is specified when username/password is specified.\n"
60
+ if anonymous is True and any(
61
+ params is not None for params in [username, password, token]
62
+ ):
63
+ details += "Anonymous is specified with authentication details.\n"
64
+ if username is None and password is not None:
65
+ details += "Username is required when password is specified.\n"
66
+ elif username is not None and password is None:
67
+ details += "Password is required when username is specified.\n"
68
+ return details
69
+
70
+
71
+ def __run_interactive_mode() -> Union[LoginArguments, None]:
72
+ jfrog_cli_config = read_jfrog_cli_config()
73
+
74
+ if jfrog_cli_config is not None:
75
+ jfrog_cli_servers = get_list_of_servers_from_config(jfrog_cli_config)
76
+ if jfrog_cli_servers is not None and len(jfrog_cli_servers) > 0:
77
+ login_method_id = typer.prompt(
78
+ f"Please select from the following options:\n" # nosec B608
79
+ f"1.Login by jfrog-cli configuration file: {JFROG_CLI_CONFIG_FILE_PATH}\n"
80
+ f"2.Connecting to a new server\n"
81
+ )
82
+
83
+ while (
84
+ not login_method_id.isdigit()
85
+ or int(login_method_id) > 2
86
+ or int(login_method_id) <= 0
87
+ ):
88
+ login_method_id = typer.prompt(
89
+ "Bad Input. Choose your preferred login option"
90
+ )
91
+
92
+ login_method_id = int(login_method_id)
93
+ if login_method_id == 1:
94
+ return __prompt_jfrog_cli_configuration_list(
95
+ jfrog_cli_config, jfrog_cli_servers
96
+ )
97
+
98
+ return __prompt_manual_details()
99
+
100
+ return None
101
+
102
+
103
+ def __prompt_manual_details() -> Union[LoginArguments, None]:
104
+ login_args = LoginArguments()
105
+ login_args.artifactory_url = typer.prompt("Enter artifactory base url")
106
+
107
+ if login_args.artifactory_url is not None:
108
+ login_args.artifactory_url = join_url(login_args.artifactory_url, "artifactory")
109
+
110
+ auth_options = ["Username and Password", "Access Token", "Anonymous Access"]
111
+ authentication_types = ""
112
+ for index, item in enumerate(auth_options):
113
+ authentication_types += f"{index}: {item} \n"
114
+ selected_auth_type = typer.prompt(
115
+ f"Choose your preferred authentication option:\n{authentication_types}"
116
+ )
117
+ while (
118
+ not selected_auth_type.isdigit()
119
+ or int(selected_auth_type) >= len(auth_options)
120
+ or int(selected_auth_type) < 0
121
+ ):
122
+ selected_auth_type = typer.prompt(
123
+ "Bad Input. Choose your preferred authentication"
124
+ )
125
+ selected_auth_type = int(selected_auth_type)
126
+ if selected_auth_type == 0:
127
+ return __prompt_username_password(login_args)
128
+ elif selected_auth_type == 1:
129
+ return __prompt_access_token(login_args)
130
+ elif selected_auth_type == 2:
131
+ login_args.isAnonymous = True
132
+ return login_args
133
+ return None
134
+
135
+
136
+ def __prompt_username_password(login_args: LoginArguments) -> LoginArguments:
137
+ username = typer.prompt("Enter JFrog user name")
138
+ password = typer.prompt("Enter JFrog password", hide_input=True)
139
+ login_args.username = username
140
+ login_args.password = password
141
+ return login_args
142
+
143
+
144
+ def __prompt_access_token(login_args: LoginArguments) -> LoginArguments:
145
+ token = typer.prompt("Enter JFrog access token", hide_input=True)
146
+ login_args.access_token = token
147
+ return login_args
148
+
149
+
150
+ def __prompt_jfrog_cli_configuration_list(
151
+ jfrog_cli_config: dict, jfrog_cli_servers: List[str]
152
+ ) -> Union[LoginArguments, None]:
153
+ list_server_options = ""
154
+ for index, item in enumerate(jfrog_cli_servers):
155
+ list_server_options += f"{index}: {item}\n"
156
+ server_index_cli_conf = typer.prompt(
157
+ f"Found the following servers in your JFrog CLI configuration, "
158
+ f"choose one of the following:\n{list_server_options}"
159
+ )
160
+ while (
161
+ not server_index_cli_conf.isdigit()
162
+ or int(server_index_cli_conf) < 0
163
+ or int(server_index_cli_conf) >= len(jfrog_cli_servers)
164
+ ):
165
+ server_index_cli_conf = typer.prompt(
166
+ "Invalid choice. Please choose a number from the list"
167
+ )
168
+ server_index_cli_conf = int(server_index_cli_conf)
169
+ typer.echo(f"{jfrog_cli_servers[server_index_cli_conf]} was chosen")
170
+ servers = jfrog_cli_config.get("servers")
171
+ if servers is not None:
172
+ return parse_cli_config_server(servers[server_index_cli_conf])
173
+ else:
174
+ raise ValueError("No servers found in the JFrog CLI configuration.")
175
+
176
+
177
+ def __execute_login(auth_config: AuthConfig, anonymous: bool) -> bool:
178
+ if run_login(auth_config, anonymous):
179
+ success_message = "Logged in successfully"
180
+ if auth_config.artifactory_url is not None:
181
+ success_message += (
182
+ f" to: {auth_config.artifactory_url.replace('/artifactory', '')}"
183
+ )
184
+ typer.echo(success_message)
185
+ return True
186
+ else:
187
+ typer.echo("Failed to login, bad authentication")
188
+ return False
189
+
190
+
191
+ def __login_by_frogml_configuration_file_flow() -> bool:
192
+ login_args = get_frogml_configuration()
193
+ auth_config = None
194
+ if login_args is not None:
195
+ typer.echo(
196
+ f"Using existing frogml authentication config file: {CONFIG_FILE_PATH}"
197
+ )
198
+ auth_config = AuthConfig(
199
+ artifactory_url=login_args.artifactory_url,
200
+ user=login_args.username,
201
+ password=login_args.password,
202
+ access_token=login_args.access_token,
203
+ )
204
+
205
+ if (
206
+ auth_config is not None
207
+ and login_args is not None
208
+ and __execute_login(auth_config, login_args.isAnonymous)
209
+ ):
210
+ return True
211
+
212
+ return __interactive_flow()
213
+
214
+
215
+ def __interactive_flow() -> bool:
216
+ login_args = __run_interactive_mode()
217
+ if login_args is not None:
218
+ auth_config = AuthConfig(
219
+ artifactory_url=login_args.artifactory_url,
220
+ user=login_args.username,
221
+ password=login_args.password,
222
+ access_token=login_args.access_token,
223
+ )
224
+ return __execute_login(auth_config, login_args.isAnonymous)
225
+ return False
226
+
227
+
228
+ def __login_by_command_line_params(
229
+ url: str,
230
+ username: Optional[str],
231
+ password: Optional[str],
232
+ token: Optional[str],
233
+ anonymous: Optional[bool],
234
+ ) -> bool:
235
+ anonymous_value = anonymous if anonymous is not None else False
236
+ auth_config = AuthConfig(
237
+ artifactory_url=url, user=username, password=password, access_token=token
238
+ )
239
+ return __execute_login(auth_config, anonymous_value)
@@ -0,0 +1,74 @@
1
+ import http
2
+ from typing import Optional
3
+
4
+ import requests
5
+ from requests.auth import AuthBase, HTTPBasicAuth
6
+
7
+ from frogml_storage.artifactory import ArtifactoryApi
8
+ from frogml_storage.logging import logger
9
+ from frogml_storage.authentication.models import BearerAuth, EmptyAuth
10
+ from frogml_storage.authentication.utils import (
11
+ get_encrypted_password,
12
+ save_auth_config,
13
+ )
14
+ from frogml_storage.authentication.models import AuthConfig
15
+ from frogml_storage.authentication.utils import (
16
+ is_username_password_login,
17
+ is_access_token_login,
18
+ is_anonymous_login,
19
+ )
20
+
21
+
22
+ def run(auth_config: AuthConfig, anonymous: Optional[bool] = False) -> bool:
23
+ if is_username_password_login(auth_config, anonymous):
24
+ connection_validation_result = __login_by_username_password(auth_config)
25
+ elif is_access_token_login(auth_config, anonymous):
26
+ connection_validation_result = __validate_server_connection(
27
+ auth_config, BearerAuth(auth_config.access_token)
28
+ )
29
+ elif is_anonymous_login(auth_config, anonymous):
30
+ connection_validation_result = __validate_server_connection(
31
+ auth_config, EmptyAuth()
32
+ )
33
+ else:
34
+ connection_validation_result = False
35
+
36
+ if connection_validation_result:
37
+ save_auth_config(auth_config)
38
+ return connection_validation_result
39
+
40
+
41
+ def __login_by_username_password(auth_config: AuthConfig) -> bool:
42
+ if auth_config.user is not None and auth_config.password is not None:
43
+ auth_token = HTTPBasicAuth(auth_config.user, auth_config.password)
44
+ connection_validation_result = __validate_server_connection(
45
+ auth_config, auth_token
46
+ )
47
+ if connection_validation_result:
48
+ encrypted_password = get_encrypted_password(auth_config, auth_token)
49
+ if encrypted_password is not None:
50
+ auth_config.password = encrypted_password
51
+ return True
52
+ return False
53
+
54
+
55
+ def __validate_server_connection(auth_config: AuthConfig, auth_token: AuthBase) -> bool:
56
+ success = False
57
+ try:
58
+ logger.debug("Attempting to ping artifactory")
59
+ response = ArtifactoryApi(auth_config.artifactory_url, auth_token).ping()
60
+ if response.status_code == http.HTTPStatus.OK:
61
+ success = True
62
+ else:
63
+ logger.debug(
64
+ f"Expected {http.HTTPStatus.OK} status but got {response.status_code} "
65
+ f"when using url {auth_config.artifactory_url}"
66
+ )
67
+ except requests.exceptions.ConnectionError as e:
68
+ logger.debug(f"Unable to connect to the provided url :{e}.")
69
+ except requests.exceptions.MissingSchema as e:
70
+ logger.debug(f"Invalid Artifactory URL provided: {e}.")
71
+ except requests.exceptions.RequestException as e:
72
+ logger.debug(f"Unexpected request exception: {e}.")
73
+
74
+ return success
@@ -0,0 +1,3 @@
1
+ from ._auth_config import AuthConfig
2
+ from ._auth import BearerAuth, EmptyAuth
3
+ from ._login import LoginArguments
@@ -0,0 +1,24 @@
1
+ from typing import Any
2
+
3
+ from requests import PreparedRequest
4
+ from requests.auth import AuthBase
5
+
6
+
7
+ class BearerAuth(AuthBase):
8
+ def __init__(self, token: str):
9
+ self.token: str = token
10
+
11
+ def __call__(self, r: PreparedRequest) -> PreparedRequest:
12
+ r.headers["Authorization"] = f"Bearer {self.token}"
13
+ return r
14
+
15
+ def __eq__(self, other: Any) -> bool:
16
+ if not isinstance(other, BearerAuth):
17
+ return False
18
+
19
+ return self.token == other.token
20
+
21
+
22
+ class EmptyAuth(AuthBase):
23
+ def __call__(self, r: PreparedRequest) -> PreparedRequest:
24
+ return r
@@ -0,0 +1,70 @@
1
+ from typing import Optional
2
+
3
+ from frogml_storage.constants import (
4
+ FROG_ML_CONFIG_ACCESS_TOKEN,
5
+ FROG_ML_CONFIG_ARTIFACTORY_URL,
6
+ FROG_ML_CONFIG_PASSWORD,
7
+ FROG_ML_CONFIG_USER,
8
+ SERVER_ID,
9
+ )
10
+
11
+
12
+ class AuthConfig(object):
13
+ def __init__(
14
+ self,
15
+ artifactory_url: Optional[str] = None,
16
+ access_token: Optional[str] = None,
17
+ user: Optional[str] = None,
18
+ password: Optional[str] = None,
19
+ server_id: Optional[str] = None,
20
+ ) -> None:
21
+ self.artifactory_url = artifactory_url
22
+ self.user = user
23
+ self.password = password
24
+ self.access_token = access_token
25
+ self.server_id = server_id
26
+
27
+ def to_json(self):
28
+ include_keys = [
29
+ FROG_ML_CONFIG_ARTIFACTORY_URL,
30
+ FROG_ML_CONFIG_USER,
31
+ FROG_ML_CONFIG_PASSWORD,
32
+ FROG_ML_CONFIG_ACCESS_TOKEN,
33
+ SERVER_ID,
34
+ ]
35
+ return {
36
+ key: getattr(self, key)
37
+ for key in include_keys
38
+ if getattr(self, key) is not None
39
+ }
40
+
41
+ @classmethod
42
+ def by_access_token(cls, artifactory_url: str, access_token: str) -> "AuthConfig":
43
+ return cls(
44
+ artifactory_url=artifactory_url,
45
+ access_token=access_token,
46
+ )
47
+
48
+ @classmethod
49
+ def by_basic_auth(
50
+ cls, artifactory_url: str, user: str, password: str
51
+ ) -> "AuthConfig":
52
+ return cls(
53
+ artifactory_url=artifactory_url,
54
+ user=user,
55
+ password=password,
56
+ )
57
+
58
+ @classmethod
59
+ def by_server_id(cls, server_id: str) -> "AuthConfig":
60
+ return cls(server_id=server_id)
61
+
62
+ @classmethod
63
+ def from_dict(cls, data: dict) -> "AuthConfig":
64
+ return cls(
65
+ artifactory_url=data.get(FROG_ML_CONFIG_ARTIFACTORY_URL),
66
+ access_token=data.get(FROG_ML_CONFIG_ACCESS_TOKEN),
67
+ server_id=data.get(SERVER_ID),
68
+ user=data.get(FROG_ML_CONFIG_USER),
69
+ password=data.get(FROG_ML_CONFIG_PASSWORD),
70
+ )
@@ -0,0 +1,22 @@
1
+ from typing import Optional
2
+
3
+
4
+ class LoginArguments(object):
5
+ isAnonymous: bool = False
6
+ server_id: Optional[str] = None
7
+ username: Optional[str] = None
8
+ password: Optional[str] = None
9
+ access_token: Optional[str] = None
10
+ artifactory_url: Optional[str] = None
11
+
12
+ def __eq__(self, other):
13
+ if not isinstance(other, LoginArguments):
14
+ return False
15
+ return (
16
+ self.isAnonymous == other.isAnonymous
17
+ and self.server_id == other.server_id
18
+ and self.username == other.username
19
+ and self.password == other.password
20
+ and self.access_token == other.access_token
21
+ and self.artifactory_url == other.artifactory_url
22
+ )
@@ -0,0 +1,17 @@
1
+ from ._authentication_utils import (
2
+ get_credentials,
3
+ get_frogml_configuration,
4
+ parse_cli_config_server,
5
+ read_jfrog_cli_config,
6
+ get_encrypted_password,
7
+ save_auth_config,
8
+ get_list_of_servers_from_config,
9
+ read_frogml_config,
10
+ )
11
+ from ._login_checks_utils import (
12
+ login_input_checks,
13
+ is_login_without_params,
14
+ is_username_password_login,
15
+ is_access_token_login,
16
+ is_anonymous_login,
17
+ )