clarifai 11.2.3rc1__py3-none-any.whl → 11.2.3rc3__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/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/__pycache__/errors.cpython-310.pyc +0 -0
- clarifai/__pycache__/versions.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/base.cpython-310.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__/deployment.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
- clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
- clarifai/cli/base.py +81 -228
- clarifai/cli/compute_cluster.py +17 -25
- clarifai/cli/deployment.py +41 -67
- clarifai/cli/model.py +39 -26
- clarifai/cli/nodepool.py +40 -59
- clarifai/client/__pycache__/__init__.cpython-310.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-39.pyc +0 -0
- clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/compute_cluster.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/deployment.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/nodepool.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
- clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
- clarifai/client/app.py +1 -1
- clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
- clarifai/client/auth/__pycache__/stub.cpython-310.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 +88 -0
- clarifai/client/cli/model_cli.py +29 -0
- clarifai/client/model.py +159 -393
- clarifai/client/model_client.py +502 -0
- clarifai/constants/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/input.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/{model.cpython-312.pyc → model.cpython-310.pyc} +0 -0
- clarifai/constants/__pycache__/rag.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/constants/__pycache__/workflow.cpython-310.pyc +0 -0
- clarifai/datasets/__pycache__/__init__.cpython-310.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-39.pyc +0 -0
- clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/__init__.cpython-310.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__/features.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/multimodal.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
- clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-39.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-39.pyc +0 -0
- clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
- clarifai/rag/__pycache__/rag.cpython-39.pyc +0 -0
- clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/runners/__init__.py +2 -7
- clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/runners/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/runners/dockerfile_template/Dockerfile.cpu.template +31 -0
- clarifai/runners/dockerfile_template/Dockerfile.cuda.template +42 -0
- clarifai/runners/dockerfile_template/Dockerfile.nim +71 -0
- clarifai/runners/models/__pycache__/__init__.cpython-310.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-39.pyc +0 -0
- clarifai/runners/models/__pycache__/model_class.cpython-310.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_runner.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
- clarifai/runners/models/model_builder.py +138 -51
- clarifai/runners/models/model_class.py +441 -28
- clarifai/runners/models/model_class_refract.py +80 -0
- clarifai/runners/models/model_run_locally.py +25 -89
- clarifai/runners/models/model_runner.py +8 -0
- clarifai/runners/models/model_servicer.py +11 -2
- clarifai/runners/models/model_upload.py +607 -0
- clarifai/runners/models/temp.py +25 -0
- clarifai/runners/utils/__pycache__/__init__.cpython-310.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__/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-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-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__/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-38.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-39.pyc +0 -0
- clarifai/runners/utils/code_script.py +217 -0
- clarifai/runners/utils/const.py +8 -9
- clarifai/runners/utils/data_handler.py +271 -210
- clarifai/runners/utils/data_handler_refract.py +213 -0
- clarifai/runners/utils/data_types.py +473 -0
- clarifai/runners/utils/data_utils.py +165 -0
- clarifai/runners/utils/loader.py +6 -36
- clarifai/runners/utils/logger.py +0 -0
- clarifai/runners/utils/method_signatures.py +518 -0
- clarifai/runners/utils/serializers.py +222 -0
- clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
- clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/utils/__pycache__/cli.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/constants.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
- clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
- clarifai/utils/cli.py +33 -132
- clarifai/utils/constants.py +0 -4
- clarifai/utils/evaluation/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/main.cpython-39.pyc +0 -0
- clarifai/utils/misc.py +0 -2
- clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/__init__.cpython-39.pyc +0 -0
- clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
- clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
- {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/METADATA +14 -3
- clarifai-11.2.3rc3.dist-info/RECORD +238 -0
- {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/WHEEL +1 -1
- clarifai/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/__pycache__/errors.cpython-312.pyc +0 -0
- clarifai/__pycache__/versions.cpython-312.pyc +0 -0
- clarifai/cli/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/cli/__pycache__/base.cpython-312.pyc +0 -0
- clarifai/cli/__pycache__/compute_cluster.cpython-312.pyc +0 -0
- clarifai/cli/__pycache__/deployment.cpython-312.pyc +0 -0
- clarifai/cli/__pycache__/model.cpython-312.pyc +0 -0
- clarifai/cli/__pycache__/nodepool.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/app.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/base.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/compute_cluster.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/dataset.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/deployment.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/input.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/lister.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/model.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/model_client.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/module.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/nodepool.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/search.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/user.cpython-312.pyc +0 -0
- clarifai/client/__pycache__/workflow.cpython-312.pyc +0 -0
- clarifai/client/auth/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/client/auth/__pycache__/helper.cpython-312.pyc +0 -0
- clarifai/client/auth/__pycache__/register.cpython-312.pyc +0 -0
- clarifai/client/auth/__pycache__/stub.cpython-312.pyc +0 -0
- clarifai/constants/__pycache__/base.cpython-312.pyc +0 -0
- clarifai/constants/__pycache__/dataset.cpython-312.pyc +0 -0
- clarifai/constants/__pycache__/input.cpython-312.pyc +0 -0
- clarifai/constants/__pycache__/search.cpython-312.pyc +0 -0
- clarifai/constants/__pycache__/workflow.cpython-312.pyc +0 -0
- clarifai/datasets/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/datasets/export/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/datasets/export/__pycache__/inputs_annotations.cpython-312.pyc +0 -0
- clarifai/datasets/upload/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/datasets/upload/__pycache__/base.cpython-312.pyc +0 -0
- clarifai/datasets/upload/__pycache__/features.cpython-312.pyc +0 -0
- clarifai/datasets/upload/__pycache__/image.cpython-312.pyc +0 -0
- clarifai/datasets/upload/__pycache__/multimodal.cpython-312.pyc +0 -0
- clarifai/datasets/upload/__pycache__/text.cpython-312.pyc +0 -0
- clarifai/datasets/upload/__pycache__/utils.cpython-312.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-312.pyc +0 -0
- clarifai/modules/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/modules/__pycache__/css.cpython-312.pyc +0 -0
- clarifai/runners/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/runners/__pycache__/server.cpython-312.pyc +0 -0
- clarifai/runners/models/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/runners/models/__pycache__/base_typed_model.cpython-312.pyc +0 -0
- clarifai/runners/models/__pycache__/model_builder.cpython-312.pyc +0 -0
- clarifai/runners/models/__pycache__/model_class.cpython-312.pyc +0 -0
- clarifai/runners/models/__pycache__/model_run_locally.cpython-312.pyc +0 -0
- clarifai/runners/models/__pycache__/model_runner.cpython-312.pyc +0 -0
- clarifai/runners/models/__pycache__/model_servicer.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/const.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_handler.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_types.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_utils.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/loader.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/method_signatures.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/serializers.cpython-312.pyc +0 -0
- clarifai/runners/utils/__pycache__/url_fetcher.cpython-312.pyc +0 -0
- clarifai/schema/__pycache__/search.cpython-312.pyc +0 -0
- clarifai/urls/__pycache__/helper.cpython-312.pyc +0 -0
- clarifai/utils/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/utils/__pycache__/cli.cpython-312.pyc +0 -0
- clarifai/utils/__pycache__/config.cpython-312.pyc +0 -0
- clarifai/utils/__pycache__/constants.cpython-312.pyc +0 -0
- clarifai/utils/__pycache__/logging.cpython-312.pyc +0 -0
- clarifai/utils/__pycache__/misc.cpython-312.pyc +0 -0
- clarifai/utils/__pycache__/model_train.cpython-312.pyc +0 -0
- clarifai/utils/config.py +0 -105
- clarifai/utils/config.py~ +0 -145
- clarifai/utils/evaluation/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/helpers.cpython-312.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/main.cpython-312.pyc +0 -0
- clarifai/workflows/__pycache__/__init__.cpython-312.pyc +0 -0
- clarifai/workflows/__pycache__/export.cpython-312.pyc +0 -0
- clarifai/workflows/__pycache__/utils.cpython-312.pyc +0 -0
- clarifai/workflows/__pycache__/validate.cpython-312.pyc +0 -0
- clarifai-11.2.3rc1.dist-info/RECORD +0 -185
- {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/LICENSE +0 -0
- {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/entry_points.txt +0 -0
- {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/top_level.txt +0 -0
clarifai/cli/model.py
CHANGED
@@ -5,7 +5,7 @@ from clarifai.cli.base import cli
|
|
5
5
|
|
6
6
|
@cli.group(['model'])
|
7
7
|
def model():
|
8
|
-
"""Manage models: upload, test,
|
8
|
+
"""Manage models: upload, test locally, run locally, predict, and more"""
|
9
9
|
|
10
10
|
|
11
11
|
@model.command()
|
@@ -76,6 +76,31 @@ def download_checkpoints(model_path, out_path, stage):
|
|
76
76
|
required=False,
|
77
77
|
default=".",
|
78
78
|
)
|
79
|
+
@click.option(
|
80
|
+
'--out_path',
|
81
|
+
type=click.Path(exists=False),
|
82
|
+
required=False,
|
83
|
+
default=None,
|
84
|
+
help='Path to write the method signature defitions to. If not provided, use stdout.')
|
85
|
+
def signatures(model_path, out_path):
|
86
|
+
"""Generate method signatures for the model."""
|
87
|
+
|
88
|
+
from clarifai.runners.models.model_builder import ModelBuilder
|
89
|
+
builder = ModelBuilder(model_path, download_validation_only=True)
|
90
|
+
signatures = builder.method_signatures_yaml()
|
91
|
+
if out_path:
|
92
|
+
with open(out_path, 'w') as f:
|
93
|
+
f.write(signatures)
|
94
|
+
else:
|
95
|
+
click.echo(signatures)
|
96
|
+
|
97
|
+
|
98
|
+
@model.command()
|
99
|
+
@click.option(
|
100
|
+
'--model_path',
|
101
|
+
type=click.Path(exists=True),
|
102
|
+
required=True,
|
103
|
+
help='Path to the model directory.')
|
79
104
|
@click.option(
|
80
105
|
'--mode',
|
81
106
|
type=click.Choice(['env', 'container'], case_sensitive=False),
|
@@ -96,14 +121,11 @@ def download_checkpoints(model_path, out_path, stage):
|
|
96
121
|
help=
|
97
122
|
'Keep the Docker image after testing the model locally (applicable for container mode). Defaults to False.'
|
98
123
|
)
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
)
|
105
|
-
def test_locally(model_path, keep_env=False, keep_image=False, mode='env', skip_dockerfile=False):
|
106
|
-
"""Test model locally."""
|
124
|
+
def test_locally(model_path, keep_env=False, keep_image=False, mode='env'):
|
125
|
+
"""Test model locally.
|
126
|
+
|
127
|
+
MODEL_PATH: Path to the model directory. If not specified, the current directory is used by default.
|
128
|
+
"""
|
107
129
|
try:
|
108
130
|
from clarifai.runners.models import model_run_locally
|
109
131
|
if mode == 'env' and keep_image:
|
@@ -117,11 +139,7 @@ def test_locally(model_path, keep_env=False, keep_image=False, mode='env', skip_
|
|
117
139
|
elif mode == "container":
|
118
140
|
click.echo("Testing model locally inside a container...")
|
119
141
|
model_run_locally.main(
|
120
|
-
model_path,
|
121
|
-
inside_container=True,
|
122
|
-
run_model_server=False,
|
123
|
-
keep_image=keep_image,
|
124
|
-
skip_dockerfile=skip_dockerfile)
|
142
|
+
model_path, inside_container=True, run_model_server=False, keep_image=keep_image)
|
125
143
|
click.echo("Model tested successfully.")
|
126
144
|
except Exception as e:
|
127
145
|
click.echo(f"Failed to test model locally: {e}", err=True)
|
@@ -161,14 +179,11 @@ def test_locally(model_path, keep_env=False, keep_image=False, mode='env', skip_
|
|
161
179
|
help=
|
162
180
|
'Keep the Docker image after testing the model locally (applicable for container mode). Defaults to False.'
|
163
181
|
)
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
)
|
170
|
-
def run_locally(model_path, port, mode, keep_env, keep_image, skip_dockerfile=False):
|
171
|
-
"""Run the model locally and start a gRPC server to serve the model."""
|
182
|
+
def run_locally(model_path, port, mode, keep_env, keep_image):
|
183
|
+
"""Run the model locally and start a gRPC server to serve the model.
|
184
|
+
|
185
|
+
MODEL_PATH: Path to the model directory. If not specified, the current directory is used by default.
|
186
|
+
"""
|
172
187
|
try:
|
173
188
|
from clarifai.runners.models import model_run_locally
|
174
189
|
if mode == 'env' and keep_image:
|
@@ -186,8 +201,7 @@ def run_locally(model_path, port, mode, keep_env, keep_image, skip_dockerfile=Fa
|
|
186
201
|
inside_container=True,
|
187
202
|
run_model_server=True,
|
188
203
|
port=port,
|
189
|
-
keep_image=keep_image
|
190
|
-
skip_dockerfile=skip_dockerfile)
|
204
|
+
keep_image=keep_image)
|
191
205
|
click.echo(f"Model server started locally from {model_path} in {mode} mode.")
|
192
206
|
except Exception as e:
|
193
207
|
click.echo(f"Failed to starts model server locally: {e}", err=True)
|
@@ -241,8 +255,7 @@ def predict(ctx, config, model_id, user_id, app_id, model_url, file_path, url, b
|
|
241
255
|
import json
|
242
256
|
|
243
257
|
from clarifai.client.model import Model
|
244
|
-
from clarifai.utils.cli import from_yaml
|
245
|
-
validate_context(ctx)
|
258
|
+
from clarifai.utils.cli import from_yaml
|
246
259
|
if config:
|
247
260
|
config = from_yaml(config)
|
248
261
|
model_id, user_id, app_id, model_url, file_path, url, bytes, input_type, compute_cluster_id, nodepool_id, deployment_id, inference_params, output_config = (
|
clarifai/cli/nodepool.py
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
import click
|
2
|
-
|
3
2
|
from clarifai.cli.base import cli
|
4
3
|
from clarifai.client.compute_cluster import ComputeCluster
|
5
|
-
from clarifai.
|
6
|
-
from clarifai.utils.cli import (AliasedGroup, display_co_resources, dump_yaml, from_yaml,
|
7
|
-
validate_context)
|
4
|
+
from clarifai.utils.cli import display_co_resources, dump_yaml, from_yaml
|
8
5
|
|
9
6
|
|
10
|
-
@cli.group(['nodepool', 'np']
|
7
|
+
@cli.group(['nodepool', 'np'])
|
11
8
|
def nodepool():
|
12
9
|
"""Manage Nodepools: create, delete, list"""
|
10
|
+
pass
|
13
11
|
|
14
12
|
|
15
|
-
@nodepool.command(
|
16
|
-
@click.
|
17
|
-
|
13
|
+
@nodepool.command()
|
14
|
+
@click.option(
|
15
|
+
'-cc_id',
|
16
|
+
'--compute_cluster_id',
|
17
|
+
required=False,
|
18
|
+
help='Compute Cluster ID for the compute cluster to interact with.')
|
18
19
|
@click.option(
|
19
20
|
'--config',
|
20
21
|
type=click.Path(exists=True),
|
21
22
|
required=True,
|
22
23
|
help='Path to the nodepool config file.')
|
24
|
+
@click.option(
|
25
|
+
'-np_id', '--nodepool_id', required=False, help='New Nodepool ID for the nodepool to create.')
|
23
26
|
@click.pass_context
|
24
|
-
def create(ctx, compute_cluster_id,
|
27
|
+
def create(ctx, compute_cluster_id, config, nodepool_id):
|
25
28
|
"""Create a new Nodepool with the given config file."""
|
26
29
|
|
27
|
-
validate_context(ctx)
|
28
30
|
nodepool_config = from_yaml(config)
|
29
31
|
if not compute_cluster_id:
|
30
32
|
if 'compute_cluster' not in nodepool_config['nodepool']:
|
@@ -40,71 +42,50 @@ def create(ctx, compute_cluster_id, nodepool_id, config):
|
|
40
42
|
|
41
43
|
compute_cluster = ComputeCluster(
|
42
44
|
compute_cluster_id=compute_cluster_id,
|
43
|
-
user_id=ctx.obj
|
44
|
-
pat=ctx.obj
|
45
|
-
base_url=ctx.obj
|
45
|
+
user_id=ctx.obj['user_id'],
|
46
|
+
pat=ctx.obj['pat'],
|
47
|
+
base_url=ctx.obj['base_url'])
|
46
48
|
if nodepool_id:
|
47
49
|
compute_cluster.create_nodepool(config, nodepool_id=nodepool_id)
|
48
50
|
else:
|
49
51
|
compute_cluster.create_nodepool(config)
|
50
52
|
|
51
53
|
|
52
|
-
@nodepool.command(
|
53
|
-
@click.
|
54
|
+
@nodepool.command()
|
55
|
+
@click.option(
|
56
|
+
'-cc_id',
|
57
|
+
'--compute_cluster_id',
|
58
|
+
required=True,
|
59
|
+
help='Compute Cluster ID for the compute cluster to interact with.')
|
54
60
|
@click.option('--page_no', required=False, help='Page number to list.', default=1)
|
55
|
-
@click.option('--per_page', required=False, help='Number of items per page.', default=
|
61
|
+
@click.option('--per_page', required=False, help='Number of items per page.', default=16)
|
56
62
|
@click.pass_context
|
57
63
|
def list(ctx, compute_cluster_id, page_no, per_page):
|
58
|
-
"""List all nodepools for the user
|
59
|
-
it will list only within that compute cluster. """
|
60
|
-
|
61
|
-
validate_context(ctx)
|
62
|
-
|
63
|
-
cc_id = compute_cluster_id
|
64
|
+
"""List all nodepools for the user."""
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
else:
|
73
|
-
user = User(
|
74
|
-
user_id=ctx.obj.current.user_id,
|
75
|
-
pat=ctx.obj.current.pat,
|
76
|
-
base_url=ctx.obj.current.api_base)
|
77
|
-
ccs = user.list_compute_clusters(page_no, per_page)
|
78
|
-
response = []
|
79
|
-
for cc in ccs:
|
80
|
-
compute_cluster = ComputeCluster(
|
81
|
-
compute_cluster_id=cc.id,
|
82
|
-
user_id=ctx.obj.current.user_id,
|
83
|
-
pat=ctx.obj.current.pat,
|
84
|
-
base_url=ctx.obj.current.api_base)
|
85
|
-
response.extend([i for i in compute_cluster.list_nodepools(page_no, per_page)])
|
86
|
-
|
87
|
-
display_co_resources(
|
88
|
-
response,
|
89
|
-
custom_columns={
|
90
|
-
'ID': lambda c: c.id,
|
91
|
-
'USER_ID': lambda c: c.compute_cluster.user_id,
|
92
|
-
'COMPUTE_CLUSTER_ID': lambda c: c.compute_cluster.id,
|
93
|
-
'DESCRIPTION': lambda c: c.description,
|
94
|
-
})
|
66
|
+
compute_cluster = ComputeCluster(
|
67
|
+
compute_cluster_id=compute_cluster_id,
|
68
|
+
user_id=ctx.obj['user_id'],
|
69
|
+
pat=ctx.obj['pat'],
|
70
|
+
base_url=ctx.obj['base_url'])
|
71
|
+
response = compute_cluster.list_nodepools(page_no, per_page)
|
72
|
+
display_co_resources(response, "Nodepool")
|
95
73
|
|
96
74
|
|
97
|
-
@nodepool.command(
|
98
|
-
@click.
|
99
|
-
|
75
|
+
@nodepool.command()
|
76
|
+
@click.option(
|
77
|
+
'-cc_id',
|
78
|
+
'--compute_cluster_id',
|
79
|
+
required=True,
|
80
|
+
help='Compute Cluster ID for the compute cluster to interact with.')
|
81
|
+
@click.option('-np_id', '--nodepool_id', help='Nodepool ID of the user to delete.')
|
100
82
|
@click.pass_context
|
101
83
|
def delete(ctx, compute_cluster_id, nodepool_id):
|
102
84
|
"""Deletes a nodepool for the user."""
|
103
85
|
|
104
|
-
validate_context(ctx)
|
105
86
|
compute_cluster = ComputeCluster(
|
106
87
|
compute_cluster_id=compute_cluster_id,
|
107
|
-
user_id=ctx.obj
|
108
|
-
pat=ctx.obj
|
109
|
-
base_url=ctx.obj
|
88
|
+
user_id=ctx.obj['user_id'],
|
89
|
+
pat=ctx.obj['pat'],
|
90
|
+
base_url=ctx.obj['base_url'])
|
110
91
|
compute_cluster.delete_nodepools([nodepool_id])
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
clarifai/client/app.py
CHANGED
@@ -629,7 +629,7 @@ class App(Lister, BaseClient):
|
|
629
629
|
|
630
630
|
Args:
|
631
631
|
model_id (str): The model ID for the model to interact with.
|
632
|
-
|
632
|
+
model_version_id (str): The model version ID for the model version to interact with.
|
633
633
|
|
634
634
|
Returns:
|
635
635
|
Model: A Model object for the existing model ID.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import click
|
2
|
+
import os
|
3
|
+
import yaml
|
4
|
+
|
5
|
+
@click.group()
|
6
|
+
@click.pass_context
|
7
|
+
def cli(ctx):
|
8
|
+
"""Clarifai CLI"""
|
9
|
+
ctx.ensure_object(dict)
|
10
|
+
config_path = 'config.yaml'
|
11
|
+
if os.path.exists(config_path):
|
12
|
+
ctx.obj = _from_yaml(config_path)
|
13
|
+
print("Loaded config from file.")
|
14
|
+
print(f"Config: {ctx.obj}")
|
15
|
+
else:
|
16
|
+
ctx.obj = {}
|
17
|
+
|
18
|
+
def _from_yaml(filename: str):
|
19
|
+
try:
|
20
|
+
with open(filename, 'r') as f:
|
21
|
+
return yaml.safe_load(f)
|
22
|
+
except yaml.YAMLError as e:
|
23
|
+
click.echo(f"Error reading YAML file: {e}", err=True)
|
24
|
+
return {}
|
25
|
+
|
26
|
+
def _dump_yaml(data, filename: str):
|
27
|
+
try:
|
28
|
+
with open(filename, 'w') as f:
|
29
|
+
yaml.dump(data, f)
|
30
|
+
except Exception as e:
|
31
|
+
click.echo(f"Error writing YAML file: {e}", err=True)
|
32
|
+
|
33
|
+
def _set_base_url(env):
|
34
|
+
environments = {'prod': 'https://api.clarifai.com', 'staging': 'https://api-staging.clarifai.com', 'dev': 'https://api-dev.clarifai.com'}
|
35
|
+
return environments.get(env, 'https://api.clarifai.com')
|
36
|
+
|
37
|
+
|
38
|
+
@cli.command()
|
39
|
+
@click.option('--config', type=click.Path(), required=False, help='Path to the config file')
|
40
|
+
@click.option('-e', '--env', required=False, help='Environment', type=click.Choice(['prod', 'staging', 'dev']))
|
41
|
+
@click.option('--user_id', required=False, help='User ID')
|
42
|
+
@click.pass_context
|
43
|
+
def login(ctx, config, env, user_id):
|
44
|
+
"""Login command to set PAT and other configurations."""
|
45
|
+
|
46
|
+
if config and os.path.exists(config):
|
47
|
+
ctx.obj = _from_yaml(config)
|
48
|
+
|
49
|
+
if 'pat' in ctx.obj:
|
50
|
+
os.environ["CLARIFAI_PAT"] = ctx.obj['pat']
|
51
|
+
click.echo("Loaded PAT from config file.")
|
52
|
+
elif 'CLARIFAI_PAT' in os.environ:
|
53
|
+
ctx.obj['pat'] = os.environ["CLARIFAI_PAT"]
|
54
|
+
click.echo("Loaded PAT from environment variable.")
|
55
|
+
else:
|
56
|
+
_pat = click.prompt("Get your PAT from https://clarifai.com/settings/security and pass it here", type=str)
|
57
|
+
os.environ["CLARIFAI_PAT"] = _pat
|
58
|
+
ctx.obj['pat'] = _pat
|
59
|
+
click.echo("PAT saved successfully.")
|
60
|
+
|
61
|
+
if user_id:
|
62
|
+
ctx.obj['user_id'] = user_id
|
63
|
+
os.environ["CLARIFAI_USER_ID"] = ctx.obj['user_id']
|
64
|
+
elif 'user_id' in ctx.obj or 'CLARIFAI_USER_ID' in os.environ:
|
65
|
+
ctx.obj['user_id'] = ctx.obj.get('user_id', os.environ["CLARIFAI_USER_ID"])
|
66
|
+
os.environ["CLARIFAI_USER_ID"] = ctx.obj['user_id']
|
67
|
+
|
68
|
+
if env:
|
69
|
+
ctx.obj['env'] = env
|
70
|
+
ctx.obj['base_url'] = _set_base_url(env)
|
71
|
+
os.environ["CLARIFAI_API_BASE"] = ctx.obj['base_url']
|
72
|
+
elif 'env' in ctx.obj:
|
73
|
+
ctx.obj['env'] = ctx.obj.get('env', "prod")
|
74
|
+
ctx.obj['base_url'] = _set_base_url(ctx.obj['env'])
|
75
|
+
os.environ["CLARIFAI_API_BASE"] = ctx.obj['base_url']
|
76
|
+
elif 'CLARIFAI_API_BASE' in os.environ:
|
77
|
+
ctx.obj['base_url'] = os.environ["CLARIFAI_API_BASE"]
|
78
|
+
|
79
|
+
_dump_yaml(ctx.obj, 'config.yaml')
|
80
|
+
|
81
|
+
click.echo("Login successful.")
|
82
|
+
|
83
|
+
# Import the model CLI commands to register them
|
84
|
+
from clarifai.client.cli.model_cli import model # Ensure this is the correct import path
|
85
|
+
|
86
|
+
|
87
|
+
if __name__ == '__main__':
|
88
|
+
cli()
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import click
|
2
|
+
from clarifai.client.cli.base_cli import cli
|
3
|
+
|
4
|
+
@cli.group()
|
5
|
+
def model():
|
6
|
+
"""Manage models: upload, test locally"""
|
7
|
+
pass
|
8
|
+
|
9
|
+
@model.command()
|
10
|
+
@click.argument('model_path', type=click.Path(exists=True))
|
11
|
+
@click.option('--download_checkpoints', is_flag=True, help='Flag to download checkpoints before uploading and including them in the tar file that is uploaded. Defaults to False, which will attempt to download them at docker build time.', )
|
12
|
+
@click.option('--skip_dockerfile', is_flag =True, help='Flag to skip generating a dockerfile so that you can manually edit an already created dockerfile.', )
|
13
|
+
def upload(model_path, download_checkpoints, skip_dockerfile):
|
14
|
+
"""Upload a model to Clarifai."""
|
15
|
+
from clarifai.runners.models import model_upload
|
16
|
+
|
17
|
+
model_upload.main(model_path, download_checkpoints, skip_dockerfile)
|
18
|
+
|
19
|
+
@model.command()
|
20
|
+
@click.argument('model_path', type=click.Path(exists=True))
|
21
|
+
def test_locally(model_path):
|
22
|
+
"""Test model locally."""
|
23
|
+
try:
|
24
|
+
from clarifai.runners.models import run_test_locally
|
25
|
+
run_test_locally.main(model_path)
|
26
|
+
click.echo(f"Model tested locally from {model_path}.")
|
27
|
+
except Exception as e:
|
28
|
+
click.echo(f"Failed to test model locally: {e}", err=True)
|
29
|
+
|