h2o-workflows 0.2.0__tar.gz
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.
- h2o_workflows-0.2.0/.gitignore +8 -0
- h2o_workflows-0.2.0/Makefile +14 -0
- h2o_workflows-0.2.0/PKG-INFO +10 -0
- h2o_workflows-0.2.0/pyproject.toml +82 -0
- h2o_workflows-0.2.0/requirements.txt +8 -0
- h2o_workflows-0.2.0/src/.openapi-generator-ignore +4 -0
- h2o_workflows-0.2.0/src/h2o_workflows/__init__.py +3 -0
- h2o_workflows-0.2.0/src/h2o_workflows/_version.py +3 -0
- h2o_workflows-0.2.0/src/h2o_workflows/auth/__init__.py +0 -0
- h2o_workflows-0.2.0/src/h2o_workflows/auth/token_api_client.py +25 -0
- h2o_workflows-0.2.0/src/h2o_workflows/connection_config.py +116 -0
- h2o_workflows-0.2.0/src/h2o_workflows/exception.py +28 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/__init__.py +27 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api/__init__.py +3 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api/job_service_api.py +342 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api/run_attempt_service_api.py +330 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api/run_service_api.py +772 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api/runner_service_api.py +789 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api/step_service_api.py +616 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api/workflow_revision_service_api.py +482 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api/workflow_service_api.py +1233 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/api_client.py +896 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/apis/__init__.py +23 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/configuration.py +446 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/exceptions.py +158 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/__init__.py +5 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/job_job_failure_reason.py +285 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/protobuf_any.py +263 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/required_the_runner_to_update.py +303 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/required_the_workflow_to_update.py +325 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/retry_run_request_retry_mode.py +283 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/rpc_status.py +277 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/run_attempt_run_attempt_failure_reason.py +285 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/run_run_failure_reason.py +285 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/run_service_retry_run_request.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/run_trigger.py +284 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/step_step_failure_reason.py +285 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/stream_result_of_v1_stream_step_logs_response.py +275 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_activate_workflow_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_bool_input_definition.py +281 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_bool_input_value.py +275 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_cancel_run_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_create_runner_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_create_workflow_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_deactivate_workflow_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_get_job_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_get_run_attempt_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_get_run_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_get_runner_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_get_step_logs_response.py +268 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_get_step_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_get_workflow_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_get_workflow_revision_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_input_definitions.py +281 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_input_values.py +281 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_int_input_definition.py +281 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_int_input_value.py +275 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_job.py +335 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_job_state.py +286 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_job_type.py +283 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_list_jobs_response.py +273 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_list_run_attempts_response.py +273 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_list_runners_response.py +273 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_list_runs_response.py +273 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_list_steps_response.py +273 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_list_workflow_revisions_response.py +273 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_list_workflows_response.py +273 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_retry_run_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_run.py +326 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_run_attempt.py +304 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_run_attempt_state.py +285 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_run_state.py +286 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_run_workflow_revision_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_runner.py +307 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_step.py +315 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_step_state.py +286 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_step_type.py +284 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_stream_step_logs_response.py +274 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_string_input_definition.py +285 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_string_input_value.py +275 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_update_runner_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_update_workflow_response.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_validate_workflow_response.py +273 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_validation_error.py +285 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_workflow.py +329 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_workflow_revision.py +304 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_workflow_revision_state.py +283 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/v1_workflow_state.py +283 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/validation_error_severity.py +284 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/workflow_revision_service_run_workflow_revision_request.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model/workflow_service_validate_workflow_request.py +269 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/model_utils.py +2056 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/models/__init__.py +76 -0
- h2o_workflows-0.2.0/src/h2o_workflows/gen/rest.py +352 -0
- h2o_workflows-0.2.0/src/h2o_workflows/inputs.py +195 -0
- h2o_workflows-0.2.0/src/h2o_workflows/job/__init__.py +0 -0
- h2o_workflows-0.2.0/src/h2o_workflows/job/client.py +92 -0
- h2o_workflows-0.2.0/src/h2o_workflows/job/job.py +142 -0
- h2o_workflows-0.2.0/src/h2o_workflows/job/page.py +33 -0
- h2o_workflows-0.2.0/src/h2o_workflows/login.py +182 -0
- h2o_workflows-0.2.0/src/h2o_workflows/run/__init__.py +0 -0
- h2o_workflows-0.2.0/src/h2o_workflows/run/client.py +136 -0
- h2o_workflows-0.2.0/src/h2o_workflows/run/page.py +33 -0
- h2o_workflows-0.2.0/src/h2o_workflows/run/run.py +141 -0
- h2o_workflows-0.2.0/src/h2o_workflows/run_attempt/__init__.py +0 -0
- h2o_workflows-0.2.0/src/h2o_workflows/run_attempt/client.py +80 -0
- h2o_workflows-0.2.0/src/h2o_workflows/run_attempt/page.py +37 -0
- h2o_workflows-0.2.0/src/h2o_workflows/run_attempt/run_attempt.py +95 -0
- h2o_workflows-0.2.0/src/h2o_workflows/runner/__init__.py +0 -0
- h2o_workflows-0.2.0/src/h2o_workflows/runner/client.py +196 -0
- h2o_workflows-0.2.0/src/h2o_workflows/runner/page.py +33 -0
- h2o_workflows-0.2.0/src/h2o_workflows/runner/runner.py +76 -0
- h2o_workflows-0.2.0/src/h2o_workflows/runner/runner_config.py +24 -0
- h2o_workflows-0.2.0/src/h2o_workflows/step/__init__.py +0 -0
- h2o_workflows-0.2.0/src/h2o_workflows/step/client.py +129 -0
- h2o_workflows-0.2.0/src/h2o_workflows/step/page.py +33 -0
- h2o_workflows-0.2.0/src/h2o_workflows/step/step.py +122 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow/__init__.py +0 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow/client.py +205 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow/page.py +33 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow/validate_response.py +79 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow/workflow.py +98 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow_revision/__init__.py +0 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow_revision/client.py +116 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow_revision/page.py +40 -0
- h2o_workflows-0.2.0/src/h2o_workflows/workflow_revision/workflow_revision.py +67 -0
- h2o_workflows-0.2.0/tests/__init__.py +0 -0
- h2o_workflows-0.2.0/tests/e2e/__init__.py +0 -0
- h2o_workflows-0.2.0/tests/e2e/conftest.py +136 -0
- h2o_workflows-0.2.0/tests/e2e/test_run.py +107 -0
- h2o_workflows-0.2.0/tests/e2e/test_runner.py +141 -0
- h2o_workflows-0.2.0/tests/e2e/test_workflow.py +90 -0
- h2o_workflows-0.2.0/tests/e2e/test_workflow_revision.py +51 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: h2o-workflows
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python client for H2O Workflows
|
|
5
|
+
Author-email: "H2O.ai" <support@h2o.ai>
|
|
6
|
+
Requires-Python: >=3.8
|
|
7
|
+
Requires-Dist: h2o-authn>=1.0.0
|
|
8
|
+
Requires-Dist: h2o-cloud-discovery>=2.1.0
|
|
9
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
10
|
+
Requires-Dist: requests>=2.32.4
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling", "hatch-requirements-txt"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "h2o-workflows"
|
|
7
|
+
dynamic = ["version", "dependencies"]
|
|
8
|
+
description = 'Python client for H2O Workflows'
|
|
9
|
+
requires-python = ">=3.8"
|
|
10
|
+
keywords = []
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "H2O.ai", email = "support@h2o.ai" },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[tool.hatch.metadata.hooks.requirements_txt]
|
|
16
|
+
files = ["requirements.txt"]
|
|
17
|
+
|
|
18
|
+
[tool.hatch.build.targets.wheel]
|
|
19
|
+
packages = ["src/h2o_workflows"]
|
|
20
|
+
|
|
21
|
+
[tool.hatch.version]
|
|
22
|
+
path = "../../VERSION"
|
|
23
|
+
pattern = "(?P<version>.*)"
|
|
24
|
+
|
|
25
|
+
[tool.hatch.envs.test]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"pytest==8.1.1",
|
|
28
|
+
"pytest-timeout==2.3.1",
|
|
29
|
+
"pytest-xdist==3.5.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[tool.hatch.envs.test.scripts]
|
|
33
|
+
e2e = [
|
|
34
|
+
"python -m pytest -n 1 tests/e2e",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[tool.pytest.ini_options]
|
|
38
|
+
timeout = 10
|
|
39
|
+
|
|
40
|
+
[tool.hatch.envs.lint]
|
|
41
|
+
python = "3.10"
|
|
42
|
+
dependencies = [
|
|
43
|
+
"autoflake==2.3.3",
|
|
44
|
+
"black==23.1.0",
|
|
45
|
+
"isort==5.12.0",
|
|
46
|
+
"mypy==1.6.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.hatch.envs.lint.scripts]
|
|
50
|
+
check = [
|
|
51
|
+
"black --check --diff .",
|
|
52
|
+
"isort --check --diff .",
|
|
53
|
+
"mypy --install-types --non-interactive src"
|
|
54
|
+
]
|
|
55
|
+
fix = [
|
|
56
|
+
"autoflake .",
|
|
57
|
+
"black .",
|
|
58
|
+
"isort ."
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[tool.black]
|
|
62
|
+
exclude = ["src/h2o_workflows/gen"]
|
|
63
|
+
skip-magic-trailing-comma = true
|
|
64
|
+
|
|
65
|
+
[tool.isort]
|
|
66
|
+
skip = ["src/h2o_workflows/gen"]
|
|
67
|
+
force_single_line = true
|
|
68
|
+
known_application = ["h2o_workflows"]
|
|
69
|
+
profile = "black"
|
|
70
|
+
|
|
71
|
+
[tool.autoflake]
|
|
72
|
+
remove-all-unused-imports = true
|
|
73
|
+
in-place = true
|
|
74
|
+
recursive = true
|
|
75
|
+
exclude = "gen"
|
|
76
|
+
|
|
77
|
+
[tool.mypy]
|
|
78
|
+
exclude = [
|
|
79
|
+
"src/h2o_workflows/gen",
|
|
80
|
+
]
|
|
81
|
+
follow_imports = "silent"
|
|
82
|
+
check_untyped_defs = true
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Snyk for python does not support hatch package manager.
|
|
2
|
+
# Workaround: defining runtime project dependencies in requirements.txt file
|
|
3
|
+
# and adding this file dynamically to hatch via hatch-requirements-txt plugin.
|
|
4
|
+
|
|
5
|
+
python-dateutil>=2.8.2
|
|
6
|
+
h2o-authn>=1.0.0
|
|
7
|
+
h2o-cloud-discovery>=2.1.0
|
|
8
|
+
requests>=2.32.4
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from typing import Callable
|
|
2
|
+
|
|
3
|
+
from h2o_workflows.gen.api_client import ApiClient
|
|
4
|
+
from h2o_workflows.gen.api_client import Configuration
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TokenApiClient(ApiClient):
|
|
8
|
+
"""Overrides update_params_for_auth method of the generated ApiClient classes"""
|
|
9
|
+
|
|
10
|
+
def __init__(self, configuration: Configuration, token_provider: Callable[[], str]):
|
|
11
|
+
self._token_provider = token_provider
|
|
12
|
+
super().__init__(configuration=configuration)
|
|
13
|
+
|
|
14
|
+
def update_params_for_auth(
|
|
15
|
+
self,
|
|
16
|
+
headers,
|
|
17
|
+
queries,
|
|
18
|
+
auth_settings,
|
|
19
|
+
resource_path,
|
|
20
|
+
method,
|
|
21
|
+
body,
|
|
22
|
+
request_auths=None,
|
|
23
|
+
):
|
|
24
|
+
token = self._token_provider()
|
|
25
|
+
headers["Authorization"] = f"Bearer {token}"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import ssl
|
|
2
|
+
from typing import NamedTuple
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
import h2o_authn
|
|
6
|
+
import h2o_discovery
|
|
7
|
+
from h2o_authn import TokenProvider
|
|
8
|
+
|
|
9
|
+
# Name of the platform client in the discovery response.
|
|
10
|
+
PLATFORM_CLIENT_NAME = "platform"
|
|
11
|
+
# Name of the Workflows service in the discovery response.
|
|
12
|
+
WORKFLOWS_SERVICE_NAME = "workflows"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ConnectionConfig(NamedTuple):
|
|
16
|
+
"""Object holding connection configuration for the Workflows server."""
|
|
17
|
+
|
|
18
|
+
workflows_url: str
|
|
19
|
+
token_provider: TokenProvider
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_connection(
|
|
23
|
+
workflows_url: str,
|
|
24
|
+
refresh_token: str,
|
|
25
|
+
issuer_url: str,
|
|
26
|
+
client_id: str,
|
|
27
|
+
client_secret: Optional[str],
|
|
28
|
+
verify_ssl: bool,
|
|
29
|
+
ssl_ca_cert: Optional[str],
|
|
30
|
+
) -> ConnectionConfig:
|
|
31
|
+
"""Creates ConnectionConfig object. Initializes and tests token provider."""
|
|
32
|
+
ssl_context = ssl.create_default_context(cafile=ssl_ca_cert) # Will use system store if None
|
|
33
|
+
if not verify_ssl:
|
|
34
|
+
ssl_context.check_hostname = False
|
|
35
|
+
ssl_context.verify_mode = ssl.CERT_NONE
|
|
36
|
+
|
|
37
|
+
# init token provider
|
|
38
|
+
tp = h2o_authn.TokenProvider(
|
|
39
|
+
issuer_url=issuer_url,
|
|
40
|
+
refresh_token=refresh_token,
|
|
41
|
+
client_id=client_id,
|
|
42
|
+
client_secret=client_secret,
|
|
43
|
+
http_ssl_context=ssl_context,
|
|
44
|
+
)
|
|
45
|
+
# test token refresh
|
|
46
|
+
tp()
|
|
47
|
+
|
|
48
|
+
return ConnectionConfig(workflows_url=workflows_url, token_provider=tp)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def discover_platform_connection(
|
|
52
|
+
environment_url: Optional[str] = None,
|
|
53
|
+
config_path: Optional[str] = None,
|
|
54
|
+
platform_token: Optional[str] = None,
|
|
55
|
+
token_provider: Optional[TokenProvider] = None,
|
|
56
|
+
ssl_context: Optional[ssl.SSLContext] = None,
|
|
57
|
+
) -> ConnectionConfig:
|
|
58
|
+
"""Creates ConnectionConfig object by discovering platform connection configuration using h2o_discovery.
|
|
59
|
+
|
|
60
|
+
:param environment_url: Override for the URL of the environment passed to the discovery service.
|
|
61
|
+
:param config_path: Override path to the h2o cli config file passed to the discovery service.
|
|
62
|
+
:param platform_token: Platform token. If not provided, the token will be discovered.
|
|
63
|
+
:param token_provider: Token provider. If not provided, the provider will be constructed from the discovered config.
|
|
64
|
+
:param ssl_context: SSL context to use for the discovery client.
|
|
65
|
+
"""
|
|
66
|
+
# Discover the Workflows server URL
|
|
67
|
+
d = h2o_discovery.discover(environment=environment_url, config_path=config_path, ssl_context=ssl_context)
|
|
68
|
+
|
|
69
|
+
workflows_service = d.services.get(WORKFLOWS_SERVICE_NAME)
|
|
70
|
+
if workflows_service is None:
|
|
71
|
+
raise Exception("Workflows service is not registered in discovery service")
|
|
72
|
+
|
|
73
|
+
workflows_url = workflows_service.uri
|
|
74
|
+
if not workflows_url:
|
|
75
|
+
raise ConnectionError("Unable to discover Workflows server URL connection value.")
|
|
76
|
+
|
|
77
|
+
# If the token provider is provided, use it to construct the connection config.
|
|
78
|
+
if token_provider is not None:
|
|
79
|
+
# Test token refresh
|
|
80
|
+
token_provider()
|
|
81
|
+
return ConnectionConfig(workflows_url=workflows_url, token_provider=token_provider)
|
|
82
|
+
|
|
83
|
+
# If the token provider is not provided, construct it from the discovered config.
|
|
84
|
+
if not platform_token:
|
|
85
|
+
platform_client_credentials = d.credentials[PLATFORM_CLIENT_NAME]
|
|
86
|
+
if platform_client_credentials is None:
|
|
87
|
+
raise Exception("Platform client credentials are not available in discovery service")
|
|
88
|
+
|
|
89
|
+
platform_token = platform_client_credentials.refresh_token
|
|
90
|
+
|
|
91
|
+
if not platform_token:
|
|
92
|
+
raise ValueError(
|
|
93
|
+
"Please set the 'platform_token' argument or configure the H2O CLI."
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Discover client id
|
|
97
|
+
platform_client = d.clients.get(PLATFORM_CLIENT_NAME)
|
|
98
|
+
if platform_client is None:
|
|
99
|
+
raise Exception("platform client is not registered in discovery service")
|
|
100
|
+
|
|
101
|
+
client_id = platform_client.oauth2_client_id
|
|
102
|
+
if not client_id:
|
|
103
|
+
raise ConnectionError(
|
|
104
|
+
"Unable to discover platform oauth2_client_id connection value."
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
tp = h2o_authn.TokenProvider(
|
|
108
|
+
issuer_url=d.environment.issuer_url,
|
|
109
|
+
client_id=client_id,
|
|
110
|
+
refresh_token=platform_token,
|
|
111
|
+
http_ssl_context=ssl_context,
|
|
112
|
+
)
|
|
113
|
+
# Test token refresh
|
|
114
|
+
tp()
|
|
115
|
+
|
|
116
|
+
return ConnectionConfig(workflows_url=workflows_url, token_provider=tp)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from h2o_workflows.gen import ApiException
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class CustomApiException(ApiException):
|
|
7
|
+
"""ApiException with simplified error message."""
|
|
8
|
+
|
|
9
|
+
def __init__(self, e: ApiException):
|
|
10
|
+
self.status = e.status
|
|
11
|
+
self.reason = e.reason
|
|
12
|
+
self.body = e.body
|
|
13
|
+
self.headers = e.headers
|
|
14
|
+
|
|
15
|
+
def __str__(self):
|
|
16
|
+
status_reason = f"{self.status} ({self.reason})"
|
|
17
|
+
message = self.body
|
|
18
|
+
|
|
19
|
+
if message is None:
|
|
20
|
+
return status_reason
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
body_json = json.loads(self.body)
|
|
24
|
+
message = body_json["message"]
|
|
25
|
+
except (ValueError, KeyError):
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
return f"{status_reason}: {message}"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# flake8: noqa
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
ai/h2o/workflows/v1/input.proto
|
|
5
|
+
|
|
6
|
+
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: version not set
|
|
9
|
+
Generated by: https://openapi-generator.tech
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
__version__ = "0.2.0"
|
|
14
|
+
|
|
15
|
+
# import ApiClient
|
|
16
|
+
from h2o_workflows.gen.api_client import ApiClient
|
|
17
|
+
|
|
18
|
+
# import Configuration
|
|
19
|
+
from h2o_workflows.gen.configuration import Configuration
|
|
20
|
+
|
|
21
|
+
# import exceptions
|
|
22
|
+
from h2o_workflows.gen.exceptions import OpenApiException
|
|
23
|
+
from h2o_workflows.gen.exceptions import ApiAttributeError
|
|
24
|
+
from h2o_workflows.gen.exceptions import ApiTypeError
|
|
25
|
+
from h2o_workflows.gen.exceptions import ApiValueError
|
|
26
|
+
from h2o_workflows.gen.exceptions import ApiKeyError
|
|
27
|
+
from h2o_workflows.gen.exceptions import ApiException
|