esd-services-api-client 2.7.3a167.dev2__tar.gz → 3.0.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.
- esd_services_api_client-3.0.0/PKG-INFO +30 -0
- esd_services_api_client-3.0.0/README.md +5 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/__init__.py +1 -1
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/pyproject.toml +3 -5
- esd_services_api_client-2.7.3a167.dev2/PKG-INFO +0 -38
- esd_services_api_client-2.7.3a167.dev2/README.md +0 -13
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/_version.py +0 -1
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/crystal/__init__.py +0 -20
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/crystal/_api_versions.py +0 -28
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/crystal/_connector.py +0 -380
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/crystal/_models.py +0 -159
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/README.md +0 -351
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/__init__.py +0 -18
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/abstractions/__init__.py +0 -18
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/abstractions/algrorithm_cache.py +0 -108
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/abstractions/input_object.py +0 -63
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/abstractions/logger_factory.py +0 -122
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/abstractions/metrics_provider_factory.py +0 -103
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/abstractions/nexus_object.py +0 -110
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/abstractions/socket_provider.py +0 -60
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/algorithms/__init__.py +0 -24
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/algorithms/_baseline_algorithm.py +0 -95
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/algorithms/_remote_algorithm.py +0 -121
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/algorithms/distributed.py +0 -56
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/algorithms/forked_algorithm.py +0 -176
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/algorithms/minimalistic.py +0 -52
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/algorithms/recursive.py +0 -63
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/configurations/__init__.py +0 -0
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/configurations/algorithm_configuration.py +0 -37
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/core/__init__.py +0 -18
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/core/app_core.py +0 -504
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/core/app_dependencies.py +0 -294
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/core/serializers.py +0 -78
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/exceptions/__init__.py +0 -20
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/exceptions/_nexus_error.py +0 -30
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/exceptions/cache_errors.py +0 -49
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/exceptions/input_reader_error.py +0 -51
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/exceptions/startup_error.py +0 -63
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/input/__init__.py +0 -22
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/input/input_processor.py +0 -97
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/input/input_reader.py +0 -105
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/input/payload_reader.py +0 -83
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/modules/__init__.py +0 -24
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/modules/astra_client_module.py +0 -63
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/modules/mlflow_module.py +0 -43
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/telemetry/__init__.py +0 -0
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/telemetry/recorder.py +0 -146
- esd_services_api_client-2.7.3a167.dev2/esd_services_api_client/nexus/telemetry/user_telemetry_recorder.py +0 -178
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/LICENSE +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/beast/__init__.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/beast/v3/__init__.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/beast/v3/_connector.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/beast/v3/_models.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/boxer/README.md +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/boxer/__init__.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/boxer/_auth.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/boxer/_base.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/boxer/_connector.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/boxer/_models.py +0 -0
- {esd_services_api_client-2.7.3a167.dev2 → esd_services_api_client-3.0.0}/esd_services_api_client/common/__init__.py +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: esd-services-api-client
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Python clients for ESD services
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: ECCO Sneaks & Data
|
|
8
|
+
Author-email: esdsupport@ecco.com
|
|
9
|
+
Maintainer: ECCO Sneaks & Data
|
|
10
|
+
Maintainer-email: esdsupport@ecco.com
|
|
11
|
+
Requires-Python: >=3.11,<3.12
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Provides-Extra: azure
|
|
16
|
+
Provides-Extra: nexus
|
|
17
|
+
Requires-Dist: adapta[datadog,storage] (>=3.5,<4.0)
|
|
18
|
+
Requires-Dist: azure-identity (>=1.7,<1.8) ; extra == "azure"
|
|
19
|
+
Requires-Dist: dataclasses-json (>=0.6.0,<0.7.0)
|
|
20
|
+
Requires-Dist: pycryptodome (>=3.15,<3.16)
|
|
21
|
+
Requires-Dist: pyjwt (>=2.4.0,<2.5.0)
|
|
22
|
+
Project-URL: Repository, https://github.com/SneaksAndData/esd-services-api-client
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# ESD services Api client
|
|
26
|
+
|
|
27
|
+
This repository contains connectors to internal services:
|
|
28
|
+
- Beast
|
|
29
|
+
- Boxer
|
|
30
|
+
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "esd-services-api-client"
|
|
3
|
-
version = "
|
|
3
|
+
version = "3.0.0"
|
|
4
4
|
description = "Python clients for ESD services"
|
|
5
5
|
authors = ["ECCO Sneaks & Data <esdsupport@ecco.com>"]
|
|
6
|
-
maintainers = [
|
|
6
|
+
maintainers = ["ECCO Sneaks & Data <esdsupport@ecco.com>"]
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
license = 'Apache-2.0'
|
|
9
9
|
repository = 'https://github.com/SneaksAndData/esd-services-api-client'
|
|
10
10
|
|
|
11
11
|
[tool.poetry.dependencies]
|
|
12
12
|
python = ">=3.11,<3.12"
|
|
13
|
-
adapta = { version = "
|
|
13
|
+
adapta = { version = "^3.5", extras = ["storage", "datadog"] }
|
|
14
14
|
dataclasses-json = "^0.6.0"
|
|
15
15
|
pycryptodome = "~3.15"
|
|
16
16
|
azure-identity = { version = "~1.7", optional = true }
|
|
17
|
-
injector = { version = "~0.22.0", optional = true }
|
|
18
|
-
httpx = { version = "^0.27.0", optional = true }
|
|
19
17
|
pyjwt = "~2.4.0"
|
|
20
18
|
|
|
21
19
|
[tool.poetry.group.dev.dependencies]
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: esd-services-api-client
|
|
3
|
-
Version: 2.7.3a167.dev2
|
|
4
|
-
Summary: Python clients for ESD services
|
|
5
|
-
License: Apache-2.0
|
|
6
|
-
Author: ECCO Sneaks & Data
|
|
7
|
-
Author-email: esdsupport@ecco.com
|
|
8
|
-
Maintainer: GZU
|
|
9
|
-
Maintainer-email: gzu@ecco.com
|
|
10
|
-
Requires-Python: >=3.11,<3.12
|
|
11
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Provides-Extra: azure
|
|
15
|
-
Provides-Extra: nexus
|
|
16
|
-
Requires-Dist: adapta[datadog,storage] (==v3.5.2a548.dev2)
|
|
17
|
-
Requires-Dist: azure-identity (>=1.7,<1.8) ; extra == "azure"
|
|
18
|
-
Requires-Dist: dataclasses-json (>=0.6.0,<0.7.0)
|
|
19
|
-
Requires-Dist: httpx (>=0.27.0,<0.28.0) ; extra == "nexus"
|
|
20
|
-
Requires-Dist: injector (>=0.22.0,<0.23.0) ; extra == "nexus"
|
|
21
|
-
Requires-Dist: pycryptodome (>=3.15,<3.16)
|
|
22
|
-
Requires-Dist: pyjwt (>=2.4.0,<2.5.0)
|
|
23
|
-
Project-URL: Repository, https://github.com/SneaksAndData/esd-services-api-client
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
|
|
26
|
-
# ESD services Api client
|
|
27
|
-
|
|
28
|
-
This repository contains connectors to internal services:
|
|
29
|
-
- Beast
|
|
30
|
-
- Boxer
|
|
31
|
-
- Crystal
|
|
32
|
-
|
|
33
|
-
## Nexus OSS Release - IMPORTANT NOTICE
|
|
34
|
-
|
|
35
|
-
Nexus is a lightweight framework for running and executing ML/AI workloads on any Kubernetes cluster. For some time, Nexus was developed as a side-project in ECCO Data & AI and only worked with the proprietary execution framework. With the release of [Nexus Scheduler](https://github.com/sneaksanddata/nexus)
|
|
36
|
-
for Golang, Nexus Python framework transitions to true open-source. Code in `nexus` subpackage here will be in maintenance mode until the end of 2025, and no new features will be added. Once Nexus v1 is released, please consider upgrading to a new [Nexus SDK Python](https://github.com/SneaksAndData/nexus-sdk-py).
|
|
37
|
-
|
|
38
|
-
All feature requests raised for Nexus in this repository will be automatically transferred to `nexus-sdk-py`. On January 31st, 2026, `nexus` and `crystal` packages will be removed from this library.
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# ESD services Api client
|
|
2
|
-
|
|
3
|
-
This repository contains connectors to internal services:
|
|
4
|
-
- Beast
|
|
5
|
-
- Boxer
|
|
6
|
-
- Crystal
|
|
7
|
-
|
|
8
|
-
## Nexus OSS Release - IMPORTANT NOTICE
|
|
9
|
-
|
|
10
|
-
Nexus is a lightweight framework for running and executing ML/AI workloads on any Kubernetes cluster. For some time, Nexus was developed as a side-project in ECCO Data & AI and only worked with the proprietary execution framework. With the release of [Nexus Scheduler](https://github.com/sneaksanddata/nexus)
|
|
11
|
-
for Golang, Nexus Python framework transitions to true open-source. Code in `nexus` subpackage here will be in maintenance mode until the end of 2025, and no new features will be added. Once Nexus v1 is released, please consider upgrading to a new [Nexus SDK Python](https://github.com/SneaksAndData/nexus-sdk-py).
|
|
12
|
-
|
|
13
|
-
All feature requests raised for Nexus in this repository will be automatically transferred to `nexus-sdk-py`. On January 31st, 2026, `nexus` and `crystal` packages will be removed from this library.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = 'v2.7.3a167.dev2'
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"""init file"""
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2023-2024. ECCO Sneaks & Data
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
from esd_services_api_client.crystal._connector import *
|
|
19
|
-
from esd_services_api_client.crystal._models import *
|
|
20
|
-
from esd_services_api_client.crystal._api_versions import *
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
API versioning for arcane connector
|
|
3
|
-
"""
|
|
4
|
-
# Copyright (c) 2023-2024. ECCO Sneaks & Data
|
|
5
|
-
#
|
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
# you may not use this file except in compliance with the License.
|
|
8
|
-
# You may obtain a copy of the License at
|
|
9
|
-
#
|
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
# See the License for the specific language governing permissions and
|
|
16
|
-
# limitations under the License.
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
from enum import Enum
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class ApiVersion(Enum):
|
|
23
|
-
"""
|
|
24
|
-
API Versions
|
|
25
|
-
V1_2 - Boxer token authentication and updated API for run submission and result read
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
V1_2 = "v1.2"
|
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Connector for Crystal Job Runtime (AKS)
|
|
3
|
-
"""
|
|
4
|
-
# Copyright (c) 2023-2024. ECCO Sneaks & Data
|
|
5
|
-
#
|
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
-
# you may not use this file except in compliance with the License.
|
|
8
|
-
# You may obtain a copy of the License at
|
|
9
|
-
#
|
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
-
# See the License for the specific language governing permissions and
|
|
16
|
-
# limitations under the License.
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
import json
|
|
20
|
-
import os
|
|
21
|
-
from argparse import Namespace, ArgumentParser
|
|
22
|
-
from datetime import timedelta
|
|
23
|
-
from typing import Dict, Optional, Type, TypeVar, List
|
|
24
|
-
|
|
25
|
-
from adapta.logs import SemanticLogger
|
|
26
|
-
from adapta.storage.models.format import SerializationFormat
|
|
27
|
-
from adapta.utils import session_with_retries, doze
|
|
28
|
-
from adapta.utils.concurrent_task_runner import ConcurrentTaskRunner, Executable
|
|
29
|
-
from requests.auth import AuthBase
|
|
30
|
-
|
|
31
|
-
from esd_services_api_client.boxer import BoxerTokenAuth
|
|
32
|
-
from esd_services_api_client.crystal._api_versions import ApiVersion
|
|
33
|
-
from esd_services_api_client.crystal._models import (
|
|
34
|
-
RequestResult,
|
|
35
|
-
AlgorithmRunResult,
|
|
36
|
-
CrystalEntrypointArguments,
|
|
37
|
-
AlgorithmRequest,
|
|
38
|
-
AlgorithmConfiguration,
|
|
39
|
-
RequestLifeCycleStage,
|
|
40
|
-
ParentRequest,
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
T = TypeVar("T") # pylint: disable=C0103
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def add_crystal_args(parser: Optional[ArgumentParser] = None) -> ArgumentParser:
|
|
47
|
-
"""
|
|
48
|
-
Add Crystal arguments to the command line argument parser.
|
|
49
|
-
Notice that you need to add these arguments before calling `parse_args`.
|
|
50
|
-
If no parser is provided, a new will be instantiated.
|
|
51
|
-
|
|
52
|
-
:param parser: Existing argument parser.
|
|
53
|
-
:return: The existing argument parser (if provided) with Crystal arguments added.
|
|
54
|
-
"""
|
|
55
|
-
if parser is None:
|
|
56
|
-
parser = ArgumentParser()
|
|
57
|
-
|
|
58
|
-
parser.add_argument(
|
|
59
|
-
"--sas-uri", required=True, type=str, help="SAS URI for input data"
|
|
60
|
-
)
|
|
61
|
-
parser.add_argument("--request-id", required=True, type=str, help="ID of the task")
|
|
62
|
-
parser.add_argument(
|
|
63
|
-
"--sign-result", dest="sign_result", required=False, action="store_true"
|
|
64
|
-
)
|
|
65
|
-
parser.set_defaults(sign_result=False)
|
|
66
|
-
|
|
67
|
-
return parser
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def extract_crystal_args(args: Namespace) -> CrystalEntrypointArguments:
|
|
71
|
-
"""
|
|
72
|
-
Extracts parsed Crystal arguments and returns as a dataclass.
|
|
73
|
-
:param args: Parsed arguments.
|
|
74
|
-
:return: CrystalArguments object
|
|
75
|
-
"""
|
|
76
|
-
return CrystalEntrypointArguments(
|
|
77
|
-
sas_uri=args.sas_uri, request_id=args.request_id, sign_result=args.sign_result
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
class CrystalConnector:
|
|
82
|
-
"""
|
|
83
|
-
Crystal API connector
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
def __init__(
|
|
87
|
-
self,
|
|
88
|
-
*,
|
|
89
|
-
scheduler_base_url: Optional[str] = None,
|
|
90
|
-
receiver_base_url: Optional[str] = None,
|
|
91
|
-
logger: Optional[SemanticLogger] = None,
|
|
92
|
-
auth: Optional[AuthBase] = None,
|
|
93
|
-
api_version: ApiVersion = ApiVersion.V1_2,
|
|
94
|
-
default_timeout: timedelta = timedelta(seconds=300),
|
|
95
|
-
default_retry_count: int = 10,
|
|
96
|
-
):
|
|
97
|
-
# keeping CRYSTAL_URL for backwards-compatibility
|
|
98
|
-
self._scheduler_base_url = (
|
|
99
|
-
scheduler_base_url
|
|
100
|
-
or os.getenv("ESDAPI__CRYSTAL_SCHEDULER_URL")
|
|
101
|
-
or os.getenv("CRYSTAL_URL")
|
|
102
|
-
)
|
|
103
|
-
self._receiver_base_url = (
|
|
104
|
-
receiver_base_url
|
|
105
|
-
or os.getenv("ESDAPI__CRYSTAL_RECEIVER_URL")
|
|
106
|
-
or os.getenv("CRYSTAL_URL")
|
|
107
|
-
)
|
|
108
|
-
self._http = session_with_retries(
|
|
109
|
-
status_list=(400, 429, 500, 502, 503, 504, 404),
|
|
110
|
-
retry_count=default_retry_count,
|
|
111
|
-
request_timeout=default_timeout.total_seconds(),
|
|
112
|
-
)
|
|
113
|
-
if auth and isinstance(auth, BoxerTokenAuth):
|
|
114
|
-
self._http.hooks["response"].append(auth.get_refresh_hook(self._http))
|
|
115
|
-
self._api_version = api_version
|
|
116
|
-
self._logger = logger
|
|
117
|
-
if isinstance(auth, BoxerTokenAuth):
|
|
118
|
-
assert (
|
|
119
|
-
api_version == ApiVersion.V1_2
|
|
120
|
-
), "Cannot use BoxerTokenAuth with Crystal API versions prior to 1.2."
|
|
121
|
-
|
|
122
|
-
self._http.auth = auth
|
|
123
|
-
self._finished_statuses = [
|
|
124
|
-
RequestLifeCycleStage.COMPLETED,
|
|
125
|
-
RequestLifeCycleStage.FAILED,
|
|
126
|
-
RequestLifeCycleStage.SCHEDULING_TIMEOUT,
|
|
127
|
-
RequestLifeCycleStage.DEADLINE_EXCEEDED,
|
|
128
|
-
RequestLifeCycleStage.CANCELLED,
|
|
129
|
-
]
|
|
130
|
-
|
|
131
|
-
@classmethod
|
|
132
|
-
def create_anonymous(
|
|
133
|
-
cls,
|
|
134
|
-
scheduler_base_url: Optional[str] = None,
|
|
135
|
-
receiver_base_url: Optional[str] = None,
|
|
136
|
-
logger: Optional[SemanticLogger] = None,
|
|
137
|
-
api_version: ApiVersion = ApiVersion.V1_2,
|
|
138
|
-
) -> "CrystalConnector":
|
|
139
|
-
"""Creates Crystal connector with no authentication.
|
|
140
|
-
This should be use for accessing Crystal from inside a hosting cluster."""
|
|
141
|
-
return cls(
|
|
142
|
-
scheduler_base_url=scheduler_base_url,
|
|
143
|
-
receiver_base_url=receiver_base_url,
|
|
144
|
-
logger=logger,
|
|
145
|
-
api_version=api_version,
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
def __enter__(self):
|
|
149
|
-
return self
|
|
150
|
-
|
|
151
|
-
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
152
|
-
self.dispose()
|
|
153
|
-
|
|
154
|
-
def create_run(
|
|
155
|
-
self,
|
|
156
|
-
algorithm: str,
|
|
157
|
-
payload: Dict,
|
|
158
|
-
custom_config: Optional[AlgorithmConfiguration] = None,
|
|
159
|
-
parent_request: Optional[ParentRequest] = None,
|
|
160
|
-
tag: Optional[str] = None,
|
|
161
|
-
) -> str:
|
|
162
|
-
"""
|
|
163
|
-
Creates a Crystal job run against the latest API version.
|
|
164
|
-
|
|
165
|
-
:param algorithm: Name of a connected algorithm.
|
|
166
|
-
:param payload: Algorithm payload.
|
|
167
|
-
:param custom_config: Customized config for this run.
|
|
168
|
-
:param parent_request: Parent request for this run.
|
|
169
|
-
:param tag: Client-side submission identifier.
|
|
170
|
-
:return: Request identifier assigned to the job by Crystal.
|
|
171
|
-
"""
|
|
172
|
-
|
|
173
|
-
def get_api_path() -> str:
|
|
174
|
-
if self._api_version == ApiVersion.V1_2:
|
|
175
|
-
return f"{self._scheduler_base_url}/algorithm/{self._api_version.value}/run/{algorithm}"
|
|
176
|
-
|
|
177
|
-
raise ValueError(f"Unsupported API version {self._api_version}")
|
|
178
|
-
|
|
179
|
-
run_body = AlgorithmRequest(
|
|
180
|
-
algorithm_name=algorithm,
|
|
181
|
-
algorithm_parameters=payload,
|
|
182
|
-
custom_configuration=custom_config,
|
|
183
|
-
parent_request=parent_request,
|
|
184
|
-
tag=tag,
|
|
185
|
-
).to_json()
|
|
186
|
-
|
|
187
|
-
run_response = self._http.post(get_api_path(), json=json.loads(run_body))
|
|
188
|
-
|
|
189
|
-
# raise if not successful
|
|
190
|
-
run_response.raise_for_status()
|
|
191
|
-
|
|
192
|
-
run_id = run_response.json()["requestId"]
|
|
193
|
-
|
|
194
|
-
if self._logger:
|
|
195
|
-
self._logger.debug(
|
|
196
|
-
"Run initiated for algorithm {algorithm}: {run_id}",
|
|
197
|
-
algorithm=algorithm,
|
|
198
|
-
run_id=run_id,
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
return run_id
|
|
202
|
-
|
|
203
|
-
def retrieve_run(
|
|
204
|
-
self, run_id: str, algorithm: Optional[str] = None
|
|
205
|
-
) -> RequestResult:
|
|
206
|
-
"""
|
|
207
|
-
Retrieves a submitted Crystal job.
|
|
208
|
-
|
|
209
|
-
:param run_id: Request identifier assigned to the job by Crystal.
|
|
210
|
-
:param algorithm: Name of an algorithm.
|
|
211
|
-
"""
|
|
212
|
-
|
|
213
|
-
return self._retrieve_run(run_id=run_id, algorithm=algorithm)
|
|
214
|
-
|
|
215
|
-
def _retrieve_run(
|
|
216
|
-
self, run_id: str, algorithm: Optional[str] = None
|
|
217
|
-
) -> RequestResult:
|
|
218
|
-
def get_api_path() -> str:
|
|
219
|
-
if self._api_version == ApiVersion.V1_2:
|
|
220
|
-
return f"{self._scheduler_base_url}/algorithm/{self._api_version.value}/results/{algorithm}/requests/{run_id}"
|
|
221
|
-
|
|
222
|
-
raise ValueError(f"Unsupported API version {self._api_version}")
|
|
223
|
-
|
|
224
|
-
response = self._http.get(url=get_api_path())
|
|
225
|
-
|
|
226
|
-
# raise if not successful
|
|
227
|
-
response.raise_for_status()
|
|
228
|
-
|
|
229
|
-
crystal_result = RequestResult.from_dict(response.json())
|
|
230
|
-
|
|
231
|
-
return crystal_result
|
|
232
|
-
|
|
233
|
-
def retrieve_runs(
|
|
234
|
-
self, tag: str, algorithm: Optional[str] = None
|
|
235
|
-
) -> List[RequestResult]:
|
|
236
|
-
"""
|
|
237
|
-
Retrieves all submitted Crystal jobs with matching tags.
|
|
238
|
-
|
|
239
|
-
:param tag: A request tag assigned by a client.
|
|
240
|
-
:param algorithm: Name of an algorithm.
|
|
241
|
-
"""
|
|
242
|
-
|
|
243
|
-
return self._retrieve_runs(tag=tag, algorithm=algorithm)
|
|
244
|
-
|
|
245
|
-
def _retrieve_runs(
|
|
246
|
-
self, tag: str, algorithm: Optional[str] = None
|
|
247
|
-
) -> List[RequestResult]:
|
|
248
|
-
def get_api_path() -> str:
|
|
249
|
-
if self._api_version == ApiVersion.V1_2:
|
|
250
|
-
return f"{self._scheduler_base_url}/algorithm/{self._api_version.value}/results/{algorithm}/tags/{tag}"
|
|
251
|
-
|
|
252
|
-
raise ValueError(f"Unsupported API version {self._api_version}")
|
|
253
|
-
|
|
254
|
-
response = self._http.get(url=get_api_path())
|
|
255
|
-
|
|
256
|
-
# raise if not successful
|
|
257
|
-
response.raise_for_status()
|
|
258
|
-
|
|
259
|
-
return [RequestResult.from_dict(run_result) for run_result in response.json()]
|
|
260
|
-
|
|
261
|
-
def submit_result(
|
|
262
|
-
self,
|
|
263
|
-
result: AlgorithmRunResult,
|
|
264
|
-
run_id: str,
|
|
265
|
-
algorithm: Optional[str] = None,
|
|
266
|
-
debug: bool = False,
|
|
267
|
-
) -> None:
|
|
268
|
-
"""
|
|
269
|
-
Submit a result of an algorithm back to Crystal.
|
|
270
|
-
Notice, this method is only intended to be used within Crystal, as it doesn't use authentication.
|
|
271
|
-
|
|
272
|
-
:param result: The result of the algorithm.
|
|
273
|
-
:param algorithm: Name of a connected algorithm.
|
|
274
|
-
:param run_id: Request identifier assigned to the job by Crystal.
|
|
275
|
-
:param debug: If True, print the submission URL and body, but do not send the http request.
|
|
276
|
-
"""
|
|
277
|
-
|
|
278
|
-
def get_api_path() -> str:
|
|
279
|
-
if self._api_version == ApiVersion.V1_2:
|
|
280
|
-
return f"{self._receiver_base_url}/algorithm/{self._api_version.value}/complete/{algorithm}/requests/{run_id}"
|
|
281
|
-
|
|
282
|
-
raise ValueError(f"Unsupported API version {self._api_version}")
|
|
283
|
-
|
|
284
|
-
payload = {
|
|
285
|
-
"cause": result.cause,
|
|
286
|
-
"message": result.message,
|
|
287
|
-
"sasUri": result.sas_uri,
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if not debug:
|
|
291
|
-
run_response = self._http.post(url=get_api_path(), json=payload)
|
|
292
|
-
# raise if not successful
|
|
293
|
-
run_response.raise_for_status()
|
|
294
|
-
return
|
|
295
|
-
|
|
296
|
-
if self._logger is not None:
|
|
297
|
-
self._logger.debug(
|
|
298
|
-
"Submitting result to {submission_url}, payload {payload}",
|
|
299
|
-
submission_url=get_api_path(),
|
|
300
|
-
payload=json.dumps(payload),
|
|
301
|
-
)
|
|
302
|
-
|
|
303
|
-
@staticmethod
|
|
304
|
-
def read_input(
|
|
305
|
-
*,
|
|
306
|
-
crystal_arguments: CrystalEntrypointArguments,
|
|
307
|
-
serialization_format: Type[SerializationFormat[T]],
|
|
308
|
-
) -> T:
|
|
309
|
-
"""
|
|
310
|
-
Read Crystal input given in the SAS URI provided in the CrystalEntrypointArguments
|
|
311
|
-
:param crystal_arguments: The arguments given to the Crystal job.
|
|
312
|
-
:param serialization_format: The format used to deserialize the contents of the SAS URI.
|
|
313
|
-
:return: The deserialized input data.
|
|
314
|
-
"""
|
|
315
|
-
http_session = session_with_retries()
|
|
316
|
-
http_response = http_session.get(url=crystal_arguments.sas_uri)
|
|
317
|
-
http_response.raise_for_status()
|
|
318
|
-
http_session.close()
|
|
319
|
-
return serialization_format().deserialize(http_response.content)
|
|
320
|
-
|
|
321
|
-
def dispose(self) -> None:
|
|
322
|
-
"""
|
|
323
|
-
Gracefully dispose object.
|
|
324
|
-
"""
|
|
325
|
-
self._http.close()
|
|
326
|
-
|
|
327
|
-
def await_tagged_runs(
|
|
328
|
-
self, algorithm: str, tags: List[str]
|
|
329
|
-
) -> Dict[str, RequestResult]:
|
|
330
|
-
"""
|
|
331
|
-
Await for a list of tagged Crystal jobs to finish.
|
|
332
|
-
|
|
333
|
-
:param algorithm: Name of an algorithm.
|
|
334
|
-
:param tags: Request tags assigned to the jobs by a client.
|
|
335
|
-
"""
|
|
336
|
-
|
|
337
|
-
results = {}
|
|
338
|
-
unfinished_tasks = []
|
|
339
|
-
runs = [self._retrieve_runs(tag=tag, algorithm=algorithm) for tag in tags]
|
|
340
|
-
for tag_runs in runs:
|
|
341
|
-
for run in tag_runs:
|
|
342
|
-
if run.status not in self._finished_statuses:
|
|
343
|
-
unfinished_tasks.append(run.run_id)
|
|
344
|
-
else:
|
|
345
|
-
results[run.run_id] = run
|
|
346
|
-
|
|
347
|
-
return {
|
|
348
|
-
**results,
|
|
349
|
-
**self._await_runs(algorithm=algorithm, run_ids=unfinished_tasks),
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
def await_runs(
|
|
353
|
-
self, algorithm: str, run_ids: List[str]
|
|
354
|
-
) -> Dict[str, RequestResult]:
|
|
355
|
-
"""
|
|
356
|
-
Await for a list of submitted Crystal jobs to finish.
|
|
357
|
-
|
|
358
|
-
:param algorithm: Name of an algorithm.
|
|
359
|
-
:param run_ids: Request identifiers assigned to the jobs by Crystal.
|
|
360
|
-
"""
|
|
361
|
-
return self._await_runs(algorithm=algorithm, run_ids=run_ids)
|
|
362
|
-
|
|
363
|
-
def _await_runs(
|
|
364
|
-
self, algorithm: str, run_ids: List[str]
|
|
365
|
-
) -> Dict[str, RequestResult]:
|
|
366
|
-
def await_run(run_id: str) -> RequestResult:
|
|
367
|
-
while True:
|
|
368
|
-
result = self._retrieve_run(run_id=run_id, algorithm=algorithm)
|
|
369
|
-
if result.status in self._finished_statuses:
|
|
370
|
-
return result
|
|
371
|
-
doze(1)
|
|
372
|
-
|
|
373
|
-
ctr = ConcurrentTaskRunner(
|
|
374
|
-
func_list=[
|
|
375
|
-
Executable(func=await_run, alias=run_id, args=[run_id])
|
|
376
|
-
for run_id in run_ids
|
|
377
|
-
]
|
|
378
|
-
)
|
|
379
|
-
|
|
380
|
-
return ctr.eager()
|