clarifai 11.3.0rc2__py3-none-any.whl → 11.4.0__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.
- clarifai/__init__.py +1 -1
- clarifai/cli/__main__.py +1 -1
- clarifai/cli/base.py +144 -136
- clarifai/cli/compute_cluster.py +45 -31
- clarifai/cli/deployment.py +93 -76
- clarifai/cli/model.py +578 -180
- clarifai/cli/nodepool.py +100 -82
- clarifai/client/__init__.py +12 -2
- clarifai/client/app.py +973 -911
- clarifai/client/auth/helper.py +345 -342
- clarifai/client/auth/register.py +7 -7
- clarifai/client/auth/stub.py +107 -106
- clarifai/client/base.py +185 -178
- clarifai/client/compute_cluster.py +214 -180
- clarifai/client/dataset.py +793 -698
- clarifai/client/deployment.py +55 -50
- clarifai/client/input.py +1223 -1088
- clarifai/client/lister.py +47 -45
- clarifai/client/model.py +1939 -1717
- clarifai/client/model_client.py +525 -502
- clarifai/client/module.py +82 -73
- clarifai/client/nodepool.py +358 -213
- clarifai/client/runner.py +58 -0
- clarifai/client/search.py +342 -309
- clarifai/client/user.py +419 -414
- clarifai/client/workflow.py +294 -274
- clarifai/constants/dataset.py +11 -17
- clarifai/constants/model.py +8 -2
- clarifai/datasets/export/inputs_annotations.py +233 -217
- clarifai/datasets/upload/base.py +63 -51
- clarifai/datasets/upload/features.py +43 -38
- clarifai/datasets/upload/image.py +237 -207
- clarifai/datasets/upload/loaders/coco_captions.py +34 -32
- clarifai/datasets/upload/loaders/coco_detection.py +72 -65
- clarifai/datasets/upload/loaders/imagenet_classification.py +57 -53
- clarifai/datasets/upload/loaders/xview_detection.py +274 -132
- clarifai/datasets/upload/multimodal.py +55 -46
- clarifai/datasets/upload/text.py +55 -47
- clarifai/datasets/upload/utils.py +250 -234
- clarifai/errors.py +51 -50
- clarifai/models/api.py +260 -238
- clarifai/modules/css.py +50 -50
- clarifai/modules/pages.py +33 -33
- clarifai/rag/rag.py +312 -288
- clarifai/rag/utils.py +91 -84
- clarifai/runners/models/model_builder.py +906 -802
- clarifai/runners/models/model_class.py +370 -331
- clarifai/runners/models/model_run_locally.py +459 -419
- clarifai/runners/models/model_runner.py +170 -162
- clarifai/runners/models/model_servicer.py +78 -70
- clarifai/runners/server.py +111 -101
- clarifai/runners/utils/code_script.py +225 -187
- clarifai/runners/utils/const.py +4 -1
- clarifai/runners/utils/data_types/__init__.py +12 -0
- clarifai/runners/utils/data_types/data_types.py +598 -0
- clarifai/runners/utils/data_utils.py +387 -440
- clarifai/runners/utils/loader.py +247 -227
- clarifai/runners/utils/method_signatures.py +411 -386
- clarifai/runners/utils/openai_convertor.py +108 -109
- clarifai/runners/utils/serializers.py +175 -179
- clarifai/runners/utils/url_fetcher.py +35 -35
- clarifai/schema/search.py +56 -63
- clarifai/urls/helper.py +125 -102
- clarifai/utils/cli.py +129 -123
- clarifai/utils/config.py +127 -87
- clarifai/utils/constants.py +49 -0
- clarifai/utils/evaluation/helpers.py +503 -466
- clarifai/utils/evaluation/main.py +431 -393
- clarifai/utils/evaluation/testset_annotation_parser.py +154 -144
- clarifai/utils/logging.py +324 -306
- clarifai/utils/misc.py +60 -56
- clarifai/utils/model_train.py +165 -146
- clarifai/utils/protobuf.py +126 -103
- clarifai/versions.py +3 -1
- clarifai/workflows/export.py +48 -50
- clarifai/workflows/utils.py +39 -36
- clarifai/workflows/validate.py +55 -43
- {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/METADATA +16 -6
- clarifai-11.4.0.dist-info/RECORD +109 -0
- {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/WHEEL +1 -1
- clarifai/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/__pycache__/errors.cpython-310.pyc +0 -0
- clarifai/__pycache__/errors.cpython-311.pyc +0 -0
- clarifai/__pycache__/versions.cpython-310.pyc +0 -0
- clarifai/__pycache__/versions.cpython-311.pyc +0 -0
- clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/cli/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/base.cpython-311.pyc +0 -0
- clarifai/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/compute_cluster.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/compute_cluster.cpython-311.pyc +0 -0
- clarifai/cli/__pycache__/deployment.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/deployment.cpython-311.pyc +0 -0
- clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/model.cpython-311.pyc +0 -0
- clarifai/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/nodepool.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/client/__pycache__/app.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/app.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/app.cpython-39.pyc +0 -0
- clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/base.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/compute_cluster.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/compute_cluster.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/dataset.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/deployment.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/deployment.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/input.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/lister.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/model.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/module.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/nodepool.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/nodepool.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/search.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/user.cpython-311.pyc +0 -0
- clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/workflow.cpython-311.pyc +0 -0
- clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/helper.cpython-311.pyc +0 -0
- clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/register.cpython-311.pyc +0 -0
- clarifai/client/auth/__pycache__/stub.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/stub.cpython-311.pyc +0 -0
- clarifai/client/cli/__init__.py +0 -0
- clarifai/client/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/client/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
- clarifai/client/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
- clarifai/client/cli/base_cli.py +0 -88
- clarifai/client/cli/model_cli.py +0 -29
- clarifai/constants/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/base.cpython-311.pyc +0 -0
- clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/dataset.cpython-311.pyc +0 -0
- clarifai/constants/__pycache__/input.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/input.cpython-311.pyc +0 -0
- clarifai/constants/__pycache__/model.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/model.cpython-311.pyc +0 -0
- clarifai/constants/__pycache__/rag.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/rag.cpython-311.pyc +0 -0
- clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/search.cpython-311.pyc +0 -0
- clarifai/constants/__pycache__/workflow.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/workflow.cpython-311.pyc +0 -0
- clarifai/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/datasets/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/datasets/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/datasets/export/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/datasets/export/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/datasets/export/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
- clarifai/datasets/export/__pycache__/inputs_annotations.cpython-311.pyc +0 -0
- clarifai/datasets/upload/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/datasets/upload/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/datasets/upload/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/base.cpython-311.pyc +0 -0
- clarifai/datasets/upload/__pycache__/features.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/features.cpython-311.pyc +0 -0
- clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/image.cpython-311.pyc +0 -0
- clarifai/datasets/upload/__pycache__/multimodal.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/multimodal.cpython-311.pyc +0 -0
- clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/text.cpython-311.pyc +0 -0
- clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/utils.cpython-311.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-311.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/imagenet_classification.cpython-311.pyc +0 -0
- clarifai/models/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/modules/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/rag/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/rag/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/rag/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
- clarifai/rag/__pycache__/rag.cpython-311.pyc +0 -0
- clarifai/rag/__pycache__/rag.cpython-39.pyc +0 -0
- clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/rag/__pycache__/utils.cpython-311.pyc +0 -0
- clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/runners/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/runners/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/runners/dockerfile_template/Dockerfile.cpu.template +0 -31
- clarifai/runners/dockerfile_template/Dockerfile.cuda.template +0 -42
- clarifai/runners/dockerfile_template/Dockerfile.nim +0 -71
- clarifai/runners/models/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/runners/models/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/runners/models/__pycache__/base_typed_model.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/base_typed_model.cpython-311.pyc +0 -0
- clarifai/runners/models/__pycache__/base_typed_model.cpython-39.pyc +0 -0
- clarifai/runners/models/__pycache__/model_builder.cpython-311.pyc +0 -0
- clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_class.cpython-311.pyc +0 -0
- clarifai/runners/models/__pycache__/model_run_locally.cpython-310-pytest-7.1.2.pyc +0 -0
- clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_run_locally.cpython-311.pyc +0 -0
- clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_runner.cpython-311.pyc +0 -0
- clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
- clarifai/runners/models/base_typed_model.py +0 -238
- clarifai/runners/models/model_class_refract.py +0 -80
- clarifai/runners/models/model_upload.py +0 -607
- clarifai/runners/models/temp.py +0 -25
- clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/runners/utils/__pycache__/__init__.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/buffered_stream.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/buffered_stream.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/buffered_stream.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/const.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/const.cpython-311.pyc +0 -0
- clarifai/runners/utils/__pycache__/constants.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/constants.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/constants.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_handler.cpython-311.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_handler.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_handler.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_utils.cpython-311.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_utils.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_utils.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/grpc_server.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/grpc_server.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/grpc_server.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/health.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/health.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/health.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/loader.cpython-311.pyc +0 -0
- clarifai/runners/utils/__pycache__/logging.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/logging.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/logging.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/stream_source.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/stream_source.cpython-39.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-311.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-39.pyc +0 -0
- clarifai/runners/utils/data_handler.py +0 -231
- clarifai/runners/utils/data_handler_refract.py +0 -213
- clarifai/runners/utils/data_types.py +0 -469
- clarifai/runners/utils/logger.py +0 -0
- clarifai/runners/utils/openai_format.py +0 -87
- clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/schema/__pycache__/search.cpython-311.pyc +0 -0
- clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
- clarifai/urls/__pycache__/helper.cpython-311.pyc +0 -0
- clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/utils/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/utils/__pycache__/cli.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/cli.cpython-311.pyc +0 -0
- clarifai/utils/__pycache__/config.cpython-311.pyc +0 -0
- clarifai/utils/__pycache__/constants.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/constants.cpython-311.pyc +0 -0
- clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/logging.cpython-311.pyc +0 -0
- clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/misc.cpython-311.pyc +0 -0
- clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/model_train.cpython-311.pyc +0 -0
- clarifai/utils/__pycache__/protobuf.cpython-311.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/helpers.cpython-311.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/main.cpython-311.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/main.cpython-39.pyc +0 -0
- clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/__init__.cpython-311.pyc +0 -0
- clarifai/workflows/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/export.cpython-311.pyc +0 -0
- clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/utils.cpython-311.pyc +0 -0
- clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/validate.cpython-311.pyc +0 -0
- clarifai-11.3.0rc2.dist-info/RECORD +0 -322
- {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/entry_points.txt +0 -0
- {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info/licenses}/LICENSE +0 -0
- {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/top_level.txt +0 -0
@@ -14,184 +14,218 @@ from clarifai.utils.logging import logger
|
|
14
14
|
|
15
15
|
|
16
16
|
class ComputeCluster(Lister, BaseClient):
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
17
|
+
"""ComputeCluster is a class that provides access to Clarifai API endpoints related to Compute Cluster information."""
|
18
|
+
|
19
|
+
def __init__(
|
20
|
+
self,
|
21
|
+
compute_cluster_id: str = None,
|
22
|
+
user_id: str = None,
|
23
|
+
base_url: str = "https://api.clarifai.com",
|
24
|
+
pat: str = None,
|
25
|
+
token: str = None,
|
26
|
+
root_certificates_path: str = None,
|
27
|
+
**kwargs,
|
28
|
+
):
|
29
|
+
"""Initializes an ComputeCluster object.
|
30
|
+
|
31
|
+
Args:
|
32
|
+
compute_cluster_id (str): The ComputeCluster ID for the ComputeCluster to interact with.
|
33
|
+
user_id (str): The user ID of the user.
|
34
|
+
base_url (str): Base API url. Default "https://api.clarifai.com"
|
35
|
+
pat (str): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
|
36
|
+
token (str): A session token for authentication. Accepts either a session token or a pat. Can be set as env var CLARIFAI_SESSION_TOKEN
|
37
|
+
root_certificates_path (str): Path to the SSL root certificates file, used to establish secure gRPC connections.
|
38
|
+
**kwargs: Additional keyword arguments to be passed to the compute cluster.
|
39
|
+
"""
|
40
|
+
self.kwargs = {**kwargs, 'id': compute_cluster_id, 'user_id': user_id}
|
41
|
+
self.compute_cluster_info = resources_pb2.ComputeCluster(**self.kwargs)
|
42
|
+
self.logger = logger
|
43
|
+
BaseClient.__init__(
|
44
|
+
self,
|
45
|
+
user_id=self.user_id,
|
46
|
+
base=base_url,
|
47
|
+
pat=pat,
|
48
|
+
token=token,
|
49
|
+
root_certificates_path=root_certificates_path,
|
50
|
+
)
|
51
|
+
Lister.__init__(self)
|
52
|
+
|
53
|
+
def list_nodepools(
|
54
|
+
self, page_no: int = None, per_page: int = None
|
55
|
+
) -> Generator[Nodepool, None, None]:
|
56
|
+
"""Lists all the available nodepools of the compute cluster.
|
57
|
+
|
58
|
+
Args:
|
59
|
+
compute_cluster_id (str): The compute cluster ID to list the nodepools.
|
60
|
+
page_no (int): The page number to list.
|
61
|
+
per_page (int): The number of items per page.
|
62
|
+
|
63
|
+
Yields:
|
64
|
+
Nodepool: Nodepool objects for the nodepools in the compute cluster.
|
65
|
+
|
66
|
+
Example:
|
67
|
+
>>> from clarifai.client.compute_cluster import ComputeCluster
|
68
|
+
>>> compute_cluster = ComputeCluster(compute_cluster_id="compute_cluster_id", user_id="user_id")
|
69
|
+
>>> all_nodepools = list(compute_cluster.list_nodepools())
|
70
|
+
|
71
|
+
Note:
|
72
|
+
Defaults to 16 per page if page_no is specified and per_page is not specified.
|
73
|
+
If both page_no and per_page are None, then lists all the resources.
|
74
|
+
"""
|
75
|
+
request_data = dict(user_app_id=self.user_app_id, compute_cluster_id=self.id)
|
76
|
+
all_nodepools_info = self.list_pages_generator(
|
77
|
+
self.STUB.ListNodepools,
|
78
|
+
service_pb2.ListNodepoolsRequest,
|
79
|
+
request_data,
|
80
|
+
per_page=per_page,
|
81
|
+
page_no=page_no,
|
82
|
+
)
|
83
|
+
|
84
|
+
for nodepool_info in all_nodepools_info:
|
85
|
+
yield Nodepool.from_auth_helper(auth=self.auth_helper, **nodepool_info)
|
86
|
+
|
87
|
+
def _process_nodepool_config(self, nodepool_config: str) -> Dict[str, Any]:
|
88
|
+
assert "nodepool" in nodepool_config, "nodepool info not found in the config file"
|
89
|
+
nodepool = nodepool_config['nodepool']
|
90
|
+
assert "instance_types" in nodepool, "instance_types not found in the config file"
|
91
|
+
assert "node_capacity_type" in nodepool, "node_capacity_type not found in the config file"
|
92
|
+
assert "min_instances" in nodepool, "min_instances not found in the config file"
|
93
|
+
assert "max_instances" in nodepool, "max_instances not found in the config file"
|
94
|
+
nodepool['compute_cluster'] = resources_pb2.ComputeCluster(
|
95
|
+
id=self.id, user_id=self.user_id
|
96
|
+
)
|
97
|
+
nodepool['node_capacity_type'] = resources_pb2.NodeCapacityType(
|
98
|
+
capacity_types=[
|
99
|
+
capacity_type for capacity_type in nodepool['node_capacity_type']['capacity_types']
|
100
|
+
]
|
101
|
+
)
|
102
|
+
instance_types = []
|
103
|
+
for instance_type in nodepool['instance_types']:
|
104
|
+
if 'compute_info' in instance_type:
|
105
|
+
instance_type['compute_info'] = resources_pb2.ComputeInfo(
|
106
|
+
**instance_type['compute_info']
|
107
|
+
)
|
108
|
+
instance_types.append(resources_pb2.InstanceType(**instance_type))
|
109
|
+
nodepool['instance_types'] = instance_types
|
110
|
+
if "visibility" in nodepool:
|
111
|
+
nodepool["visibility"] = resources_pb2.Visibility(**nodepool["visibility"])
|
112
|
+
return nodepool
|
113
|
+
|
114
|
+
def create_nodepool(
|
42
115
|
self,
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
nodepool
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
if response.status.code != status_code_pb2.SUCCESS:
|
160
|
-
raise Exception(response.status)
|
161
|
-
dict_response = MessageToDict(response, preserving_proto_field_name=True)
|
162
|
-
kwargs = self.process_response_keys(dict_response[list(dict_response.keys())[1]],
|
163
|
-
list(dict_response.keys())[1])
|
164
|
-
|
165
|
-
return Nodepool.from_auth_helper(auth=self.auth_helper, **kwargs)
|
166
|
-
|
167
|
-
def delete_nodepools(self, nodepool_ids: List[str]) -> None:
|
168
|
-
"""Deletes list of nodepools for the compute cluster.
|
169
|
-
|
170
|
-
Args:
|
171
|
-
nodepool_ids (List[str]): The nodepool IDs of the compute cluster to delete.
|
172
|
-
|
173
|
-
Example:
|
174
|
-
>>> from clarifai.client.compute_cluster import ComputeCluster
|
175
|
-
>>> compute_cluster = ComputeCluster(compute_cluster_id="compute_cluster_id", user_id="user_id")
|
176
|
-
>>> compute_cluster.delete_nodepools(nodepool_ids=["nodepool_id1", "nodepool_id2"])
|
177
|
-
"""
|
178
|
-
assert isinstance(nodepool_ids, list), "nodepool_ids param should be a list"
|
179
|
-
|
180
|
-
request = service_pb2.DeleteNodepoolsRequest(
|
181
|
-
user_app_id=self.user_app_id, compute_cluster_id=self.id, ids=nodepool_ids)
|
182
|
-
response = self._grpc_request(self.STUB.DeleteNodepools, request)
|
183
|
-
|
184
|
-
if response.status.code != status_code_pb2.SUCCESS:
|
185
|
-
raise Exception(response.status)
|
186
|
-
self.logger.info("\nNodepools Deleted\n%s", response.status)
|
187
|
-
|
188
|
-
def __getattr__(self, name):
|
189
|
-
return getattr(self.compute_cluster_info, name)
|
190
|
-
|
191
|
-
def __str__(self):
|
192
|
-
init_params = [param for param in self.kwargs.keys()]
|
193
|
-
attribute_strings = [
|
194
|
-
f"{param}={getattr(self.compute_cluster_info, param)}" for param in init_params
|
195
|
-
if hasattr(self.compute_cluster_info, param)
|
196
|
-
]
|
197
|
-
return f"Clarifai Compute Cluster Details: \n{', '.join(attribute_strings)}\n"
|
116
|
+
config_filepath: str = None,
|
117
|
+
nodepool_id: str = None,
|
118
|
+
nodepool_config: Dict[str, Any] = None,
|
119
|
+
) -> Nodepool:
|
120
|
+
"""Creates a nodepool for the compute cluster.
|
121
|
+
|
122
|
+
Args:
|
123
|
+
config_filepath (str): The path to the nodepool config file.
|
124
|
+
nodepool_id (str): New nodepool ID for the nodepool to create.
|
125
|
+
nodepool_config (Dict[str, Any]) = nodepool_config or {}
|
126
|
+
|
127
|
+
Returns:
|
128
|
+
Nodepool: A Nodepool object for the specified nodepool ID.
|
129
|
+
|
130
|
+
Example:
|
131
|
+
>>> from clarifai.client.compute_cluster import ComputeCluster
|
132
|
+
>>> compute_cluster = ComputeCluster(compute_cluster_id="compute_cluster_id", user_id="user_id")
|
133
|
+
>>> nodepool = compute_cluster.create_nodepool(config_filepath="config.yml")
|
134
|
+
"""
|
135
|
+
|
136
|
+
if config_filepath is not None:
|
137
|
+
assert nodepool_config is None, (
|
138
|
+
"nodepool_config has to be None if config_filepath is provided"
|
139
|
+
)
|
140
|
+
|
141
|
+
if not os.path.exists(config_filepath):
|
142
|
+
raise UserError(f"Nodepool config file not found at {config_filepath}")
|
143
|
+
with open(config_filepath, "r") as file:
|
144
|
+
nodepool_config = yaml.safe_load(file)
|
145
|
+
elif nodepool_config is not None:
|
146
|
+
assert isinstance(nodepool_config, dict), (
|
147
|
+
"nodepool_config should be a dictionary if provided."
|
148
|
+
)
|
149
|
+
else:
|
150
|
+
raise AssertionError("Either config_filepath or nodepool_config must be provided.")
|
151
|
+
|
152
|
+
nodepool_config = self._process_nodepool_config(nodepool_config)
|
153
|
+
|
154
|
+
if 'id' in nodepool_config:
|
155
|
+
if nodepool_id is None:
|
156
|
+
nodepool_id = nodepool_config['id']
|
157
|
+
nodepool_config.pop('id')
|
158
|
+
|
159
|
+
request = service_pb2.PostNodepoolsRequest(
|
160
|
+
user_app_id=self.user_app_id,
|
161
|
+
compute_cluster_id=self.id,
|
162
|
+
nodepools=[resources_pb2.Nodepool(id=nodepool_id, **nodepool_config)],
|
163
|
+
)
|
164
|
+
response = self._grpc_request(self.STUB.PostNodepools, request)
|
165
|
+
if response.status.code != status_code_pb2.SUCCESS:
|
166
|
+
raise Exception(response.status)
|
167
|
+
self.logger.info("\nNodepool created\n%s", response.status)
|
168
|
+
|
169
|
+
dict_response = MessageToDict(response.nodepools[0], preserving_proto_field_name=True)
|
170
|
+
kwargs = self.process_response_keys(dict_response, 'nodepool')
|
171
|
+
return Nodepool.from_auth_helper(auth=self.auth_helper, **kwargs)
|
172
|
+
|
173
|
+
def nodepool(self, nodepool_id: str) -> Nodepool:
|
174
|
+
"""Returns a Nodepool object for the existing nodepool ID.
|
175
|
+
|
176
|
+
Args:
|
177
|
+
nodepool_id (str): The nodepool ID for the nodepool to interact with.
|
178
|
+
|
179
|
+
Returns:
|
180
|
+
Nodepool: A Nodepool object for the existing nodepool ID.
|
181
|
+
|
182
|
+
Example:
|
183
|
+
>>> from clarifai.client.compute_cluster import ComputeCluster
|
184
|
+
>>> compute_cluster = ComputeCluster(compute_cluster_id="compute_cluster_id", user_id="user_id")
|
185
|
+
>>> nodepool = compute_cluster.nodepool(nodepool_id="nodepool_id")
|
186
|
+
"""
|
187
|
+
request = service_pb2.GetNodepoolRequest(
|
188
|
+
user_app_id=self.user_app_id, compute_cluster_id=self.id, nodepool_id=nodepool_id
|
189
|
+
)
|
190
|
+
response = self._grpc_request(self.STUB.GetNodepool, request)
|
191
|
+
|
192
|
+
if response.status.code != status_code_pb2.SUCCESS:
|
193
|
+
raise Exception(response.status)
|
194
|
+
dict_response = MessageToDict(response, preserving_proto_field_name=True)
|
195
|
+
|
196
|
+
kwargs = self.process_response_keys(dict_response['nodepool'], 'nodepool')
|
197
|
+
return Nodepool.from_auth_helper(auth=self.auth_helper, **kwargs)
|
198
|
+
|
199
|
+
def delete_nodepools(self, nodepool_ids: List[str]) -> None:
|
200
|
+
"""Deletes list of nodepools for the compute cluster.
|
201
|
+
|
202
|
+
Args:
|
203
|
+
nodepool_ids (List[str]): The nodepool IDs of the compute cluster to delete.
|
204
|
+
|
205
|
+
Example:
|
206
|
+
>>> from clarifai.client.compute_cluster import ComputeCluster
|
207
|
+
>>> compute_cluster = ComputeCluster(compute_cluster_id="compute_cluster_id", user_id="user_id")
|
208
|
+
>>> compute_cluster.delete_nodepools(nodepool_ids=["nodepool_id1", "nodepool_id2"])
|
209
|
+
"""
|
210
|
+
assert isinstance(nodepool_ids, list), "nodepool_ids param should be a list"
|
211
|
+
|
212
|
+
request = service_pb2.DeleteNodepoolsRequest(
|
213
|
+
user_app_id=self.user_app_id, compute_cluster_id=self.id, ids=nodepool_ids
|
214
|
+
)
|
215
|
+
response = self._grpc_request(self.STUB.DeleteNodepools, request)
|
216
|
+
|
217
|
+
if response.status.code != status_code_pb2.SUCCESS:
|
218
|
+
raise Exception(response.status)
|
219
|
+
self.logger.info("\nNodepools Deleted\n%s", response.status)
|
220
|
+
|
221
|
+
def __getattr__(self, name):
|
222
|
+
return getattr(self.compute_cluster_info, name)
|
223
|
+
|
224
|
+
def __str__(self):
|
225
|
+
init_params = [param for param in self.kwargs.keys()]
|
226
|
+
attribute_strings = [
|
227
|
+
f"{param}={getattr(self.compute_cluster_info, param)}"
|
228
|
+
for param in init_params
|
229
|
+
if hasattr(self.compute_cluster_info, param)
|
230
|
+
]
|
231
|
+
return f"Clarifai Compute Cluster Details: \n{', '.join(attribute_strings)}\n"
|