clarifai 11.5.6__tar.gz → 11.6.1__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.
- {clarifai-11.5.6/clarifai.egg-info → clarifai-11.6.1}/PKG-INFO +3 -3
- clarifai-11.6.1/clarifai/__init__.py +1 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/base.py +2 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/model.py +148 -63
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/pipeline.py +140 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/pipeline_step.py +1 -1
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/__init__.py +2 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/model.py +14 -5
- clarifai-11.6.1/clarifai/client/pipeline.py +312 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/model_builder.py +24 -4
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/server.py +1 -1
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/code_script.py +5 -2
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/constants.py +3 -1
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/misc.py +63 -1
- {clarifai-11.5.6 → clarifai-11.6.1/clarifai.egg-info}/PKG-INFO +3 -3
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai.egg-info/SOURCES.txt +2 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai.egg-info/requires.txt +2 -2
- {clarifai-11.5.6 → clarifai-11.6.1}/requirements.txt +2 -2
- clarifai-11.6.1/tests/test_pipeline_client.py +262 -0
- clarifai-11.5.6/clarifai/__init__.py +0 -1
- {clarifai-11.5.6 → clarifai-11.6.1}/LICENSE +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/MANIFEST.in +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/README.md +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/README.md +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/__main__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/compute_cluster.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/deployment.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/nodepool.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/templates/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/templates/model_templates.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/templates/pipeline_step_templates.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli/templates/pipeline_templates.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/cli.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/app.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/auth/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/auth/helper.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/auth/register.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/auth/stub.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/base.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/compute_cluster.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/dataset.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/deployment.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/input.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/lister.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/model_client.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/module.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/nodepool.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/runner.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/search.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/user.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/client/workflow.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/constants/base.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/constants/dataset.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/constants/input.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/constants/model.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/constants/rag.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/constants/search.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/constants/workflow.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/export/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/export/inputs_annotations.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/base.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/features.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/image.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/loaders/README.md +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/loaders/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/multimodal.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/text.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/datasets/upload/utils.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/errors.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/models/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/models/api.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/modules/README.md +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/modules/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/modules/css.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/modules/pages.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/modules/style.css +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/rag/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/rag/rag.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/rag/utils.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/dockerfile_template/Dockerfile.template +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/dummy_openai_model.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/mcp_class.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/model_class.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/model_run_locally.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/model_runner.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/model_servicer.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/openai_class.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/visual_classifier_class.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/models/visual_detector_class.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/pipeline_steps/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/pipeline_steps/pipeline_step_builder.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/pipelines/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/pipelines/pipeline_builder.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/const.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/data_types/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/data_types/data_types.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/data_utils.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/loader.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/method_signatures.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/model_utils.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/openai_convertor.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/pipeline_validation.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/serializers.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/runners/utils/url_fetcher.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/schema/search.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/urls/helper.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/cli.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/config.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/evaluation/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/evaluation/helpers.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/evaluation/main.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/logging.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/model_train.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/utils/protobuf.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/versions.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/workflows/__init__.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/workflows/export.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/workflows/utils.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai/workflows/validate.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai.egg-info/dependency_links.txt +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai.egg-info/entry_points.txt +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/clarifai.egg-info/top_level.txt +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/pyproject.toml +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/setup.cfg +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/setup.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_app.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_async_stub.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_auth.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_data_upload.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_eval.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_list_models.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_misc.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_model_predict.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_model_train.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_modules.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_rag.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_search.py +0 -0
- {clarifai-11.5.6 → clarifai-11.6.1}/tests/test_stub.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: clarifai
|
3
|
-
Version: 11.
|
3
|
+
Version: 11.6.1
|
4
4
|
Home-page: https://github.com/Clarifai/clarifai-python
|
5
5
|
Author: Clarifai
|
6
6
|
Author-email: support@clarifai.com
|
@@ -19,8 +19,8 @@ Classifier: Operating System :: OS Independent
|
|
19
19
|
Requires-Python: >=3.8
|
20
20
|
Description-Content-Type: text/markdown
|
21
21
|
License-File: LICENSE
|
22
|
-
Requires-Dist: clarifai-grpc>=11.
|
23
|
-
Requires-Dist: clarifai-protocol>=0.0.
|
22
|
+
Requires-Dist: clarifai-grpc>=11.6.0
|
23
|
+
Requires-Dist: clarifai-protocol>=0.0.25
|
24
24
|
Requires-Dist: numpy>=1.22.0
|
25
25
|
Requires-Dist: tqdm>=4.65.0
|
26
26
|
Requires-Dist: PyYAML>=6.0.1
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "11.6.1"
|
@@ -6,6 +6,7 @@ import sys
|
|
6
6
|
import click
|
7
7
|
import yaml
|
8
8
|
|
9
|
+
from clarifai import __version__
|
9
10
|
from clarifai.utils.cli import AliasedGroup, TableFormatter, load_command_modules
|
10
11
|
from clarifai.utils.config import Config, Context
|
11
12
|
from clarifai.utils.constants import DEFAULT_BASE, DEFAULT_CONFIG, DEFAULT_UI
|
@@ -14,6 +15,7 @@ from clarifai.utils.logging import logger
|
|
14
15
|
|
15
16
|
# @click.group(cls=CustomMultiGroup)
|
16
17
|
@click.group(cls=AliasedGroup)
|
18
|
+
@click.version_option(version=__version__)
|
17
19
|
@click.option('--config', default=DEFAULT_CONFIG)
|
18
20
|
@click.pass_context
|
19
21
|
def cli(ctx, config):
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
import shutil
|
3
|
+
import tempfile
|
3
4
|
|
4
5
|
import click
|
5
6
|
|
@@ -16,13 +17,19 @@ from clarifai.utils.constants import (
|
|
16
17
|
DEFAULT_LOCAL_DEV_NODEPOOL_ID,
|
17
18
|
)
|
18
19
|
from clarifai.utils.logging import logger
|
20
|
+
from clarifai.utils.misc import (
|
21
|
+
clone_github_repo,
|
22
|
+
format_github_repo_url,
|
23
|
+
)
|
19
24
|
|
20
25
|
|
21
26
|
@cli.group(
|
22
27
|
['model'], context_settings={'max_content_width': shutil.get_terminal_size().columns - 10}
|
23
28
|
)
|
24
29
|
def model():
|
25
|
-
"""Manage
|
30
|
+
"""Manage & Develop Models: init, download-checkpoints, signatures, upload\n
|
31
|
+
Run & Test Models Locally: local-runner, local-grpc, local-test\n
|
32
|
+
Model Inference: list, predict"""
|
26
33
|
|
27
34
|
|
28
35
|
@model.command()
|
@@ -38,7 +45,22 @@ def model():
|
|
38
45
|
required=False,
|
39
46
|
help='Model type: "mcp" for MCPModelClass, "openai" for OpenAIModelClass, or leave empty for default ModelClass.',
|
40
47
|
)
|
41
|
-
|
48
|
+
@click.option(
|
49
|
+
'--github-pat',
|
50
|
+
required=False,
|
51
|
+
help='GitHub Personal Access Token for authentication when cloning private repositories.',
|
52
|
+
)
|
53
|
+
@click.option(
|
54
|
+
'--github-repo',
|
55
|
+
required=False,
|
56
|
+
help='GitHub repository URL or "user/repo" format to clone a repository from. If provided, the entire repository contents will be copied to the target directory instead of using default templates.',
|
57
|
+
)
|
58
|
+
@click.option(
|
59
|
+
'--branch',
|
60
|
+
required=False,
|
61
|
+
help='Git branch to clone from the GitHub repository. If not specified, the default branch will be used.',
|
62
|
+
)
|
63
|
+
def init(model_path, model_type_id, github_pat, github_repo, branch):
|
42
64
|
"""Initialize a new model directory structure.
|
43
65
|
|
44
66
|
Creates the following structure in the specified directory:
|
@@ -47,65 +69,113 @@ def init(model_path, model_type_id):
|
|
47
69
|
├── requirements.txt
|
48
70
|
└── config.yaml
|
49
71
|
|
72
|
+
If --github-repo is provided, the entire repository contents will be copied to the target
|
73
|
+
directory instead of using default templates. The --github-pat option can be used for authentication
|
74
|
+
when cloning private repositories. The --branch option can be used to specify a specific
|
75
|
+
branch to clone from.
|
76
|
+
|
50
77
|
MODEL_PATH: Path where to create the model directory structure. If not specified, the current directory is used by default.
|
51
78
|
"""
|
52
|
-
from clarifai.cli.templates.model_templates import (
|
53
|
-
get_config_template,
|
54
|
-
get_model_template,
|
55
|
-
get_requirements_template,
|
56
|
-
)
|
57
|
-
|
58
79
|
# Resolve the absolute path
|
59
80
|
model_path = os.path.abspath(model_path)
|
60
81
|
|
61
82
|
# Create the model directory if it doesn't exist
|
62
83
|
os.makedirs(model_path, exist_ok=True)
|
63
84
|
|
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
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
85
|
+
# Handle GitHub repository cloning if provided
|
86
|
+
if github_repo:
|
87
|
+
logger.info(f"Initializing model from GitHub repository: {github_repo}")
|
88
|
+
|
89
|
+
# Check if it's a local path or normalize the GitHub repo URL
|
90
|
+
if os.path.exists(github_repo):
|
91
|
+
repo_url = github_repo
|
92
|
+
else:
|
93
|
+
repo_url = format_github_repo_url(github_repo)
|
94
|
+
|
95
|
+
# Create a temporary directory for cloning
|
96
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
97
|
+
clone_dir = os.path.join(temp_dir, "repo")
|
98
|
+
|
99
|
+
# Clone the repository
|
100
|
+
if not clone_github_repo(repo_url, clone_dir, github_pat, branch):
|
101
|
+
logger.error(
|
102
|
+
"Failed to clone repository. Falling back to template-based initialization."
|
103
|
+
)
|
104
|
+
github_repo = None # Fall back to template mode
|
105
|
+
else:
|
106
|
+
# Copy the entire repository content to target directory (excluding .git)
|
107
|
+
for item in os.listdir(clone_dir):
|
108
|
+
if item == '.git':
|
109
|
+
continue
|
110
|
+
|
111
|
+
source_path = os.path.join(clone_dir, item)
|
112
|
+
target_path = os.path.join(model_path, item)
|
113
|
+
|
114
|
+
if os.path.isdir(source_path):
|
115
|
+
shutil.copytree(source_path, target_path, dirs_exist_ok=True)
|
116
|
+
else:
|
117
|
+
shutil.copy2(source_path, target_path)
|
118
|
+
|
119
|
+
logger.info("Model initialization complete with GitHub repository")
|
120
|
+
logger.info("Next steps:")
|
121
|
+
logger.info("1. Review the model configuration")
|
122
|
+
logger.info("2. Install any required dependencies manually")
|
123
|
+
logger.info("3. Test the model locally using 'clarifai model local-test'")
|
124
|
+
return
|
125
|
+
|
126
|
+
# Fall back to template-based initialization if no GitHub repo or if GitHub repo failed
|
127
|
+
if not github_repo:
|
128
|
+
from clarifai.cli.templates.model_templates import (
|
129
|
+
get_config_template,
|
130
|
+
get_model_template,
|
131
|
+
get_requirements_template,
|
132
|
+
)
|
107
133
|
|
108
|
-
|
134
|
+
# Create the 1/ subdirectory
|
135
|
+
model_version_dir = os.path.join(model_path, "1")
|
136
|
+
os.makedirs(model_version_dir, exist_ok=True)
|
137
|
+
|
138
|
+
# Create model.py
|
139
|
+
model_py_path = os.path.join(model_version_dir, "model.py")
|
140
|
+
if os.path.exists(model_py_path):
|
141
|
+
logger.warning(f"File {model_py_path} already exists, skipping...")
|
142
|
+
else:
|
143
|
+
model_template = get_model_template(model_type_id)
|
144
|
+
with open(model_py_path, 'w') as f:
|
145
|
+
f.write(model_template)
|
146
|
+
logger.info(f"Created {model_py_path}")
|
147
|
+
|
148
|
+
# Create requirements.txt
|
149
|
+
requirements_path = os.path.join(model_path, "requirements.txt")
|
150
|
+
if os.path.exists(requirements_path):
|
151
|
+
logger.warning(f"File {requirements_path} already exists, skipping...")
|
152
|
+
else:
|
153
|
+
requirements_template = get_requirements_template(model_type_id)
|
154
|
+
with open(requirements_path, 'w') as f:
|
155
|
+
f.write(requirements_template)
|
156
|
+
logger.info(f"Created {requirements_path}")
|
157
|
+
|
158
|
+
# Create config.yaml
|
159
|
+
config_path = os.path.join(model_path, "config.yaml")
|
160
|
+
if os.path.exists(config_path):
|
161
|
+
logger.warning(f"File {config_path} already exists, skipping...")
|
162
|
+
else:
|
163
|
+
config_model_type_id = "text-to-text" # default
|
164
|
+
|
165
|
+
config_template = get_config_template(config_model_type_id)
|
166
|
+
with open(config_path, 'w') as f:
|
167
|
+
f.write(config_template)
|
168
|
+
logger.info(f"Created {config_path}")
|
169
|
+
|
170
|
+
logger.info(f"Model initialization complete in {model_path}")
|
171
|
+
logger.info("Next steps:")
|
172
|
+
logger.info("1. Search for '# TODO: please fill in' comments in the generated files")
|
173
|
+
logger.info("2. Update the model configuration in config.yaml")
|
174
|
+
logger.info("3. Add your model dependencies to requirements.txt")
|
175
|
+
logger.info("4. Implement your model logic in 1/model.py")
|
176
|
+
|
177
|
+
|
178
|
+
@model.command(help="Upload a trained model.")
|
109
179
|
@click.argument("model_path", type=click.Path(exists=True), required=False, default=".")
|
110
180
|
@click.option(
|
111
181
|
'--stage',
|
@@ -120,17 +190,25 @@ def init(model_path, model_type_id):
|
|
120
190
|
is_flag=True,
|
121
191
|
help='Flag to skip generating a dockerfile so that you can manually edit an already created dockerfile.',
|
122
192
|
)
|
123
|
-
|
193
|
+
@click.pass_context
|
194
|
+
def upload(ctx, model_path, stage, skip_dockerfile):
|
124
195
|
"""Upload a model to Clarifai.
|
125
196
|
|
126
197
|
MODEL_PATH: Path to the model directory. If not specified, the current directory is used by default.
|
127
198
|
"""
|
128
199
|
from clarifai.runners.models.model_builder import upload_model
|
129
200
|
|
130
|
-
|
201
|
+
validate_context(ctx)
|
202
|
+
upload_model(
|
203
|
+
model_path,
|
204
|
+
stage,
|
205
|
+
skip_dockerfile,
|
206
|
+
pat=ctx.obj.current.pat,
|
207
|
+
base_url=ctx.obj.current.api_base,
|
208
|
+
)
|
131
209
|
|
132
210
|
|
133
|
-
@model.command()
|
211
|
+
@model.command(help="Download model checkpoint files.")
|
134
212
|
@click.argument(
|
135
213
|
"model_path",
|
136
214
|
type=click.Path(exists=True),
|
@@ -164,7 +242,7 @@ def download_checkpoints(model_path, out_path, stage):
|
|
164
242
|
builder.download_checkpoints(stage=stage, checkpoint_path_override=out_path)
|
165
243
|
|
166
244
|
|
167
|
-
@model.command()
|
245
|
+
@model.command(help="Generate model method signatures.")
|
168
246
|
@click.argument(
|
169
247
|
"model_path",
|
170
248
|
type=click.Path(exists=True),
|
@@ -195,7 +273,7 @@ def signatures(model_path, out_path):
|
|
195
273
|
click.echo(signatures)
|
196
274
|
|
197
275
|
|
198
|
-
@model.command()
|
276
|
+
@model.command(name="local-test", help="Execute all model unit tests locally.")
|
199
277
|
@click.argument(
|
200
278
|
"model_path",
|
201
279
|
type=click.Path(exists=True),
|
@@ -254,7 +332,7 @@ def test_locally(model_path, keep_env=False, keep_image=False, mode='env', skip_
|
|
254
332
|
click.echo(f"Failed to test model locally: {e}", err=True)
|
255
333
|
|
256
334
|
|
257
|
-
@model.command()
|
335
|
+
@model.command(name="local-grpc", help="Run the model locally via a gRPC server.")
|
258
336
|
@click.argument(
|
259
337
|
"model_path",
|
260
338
|
type=click.Path(exists=True),
|
@@ -322,7 +400,7 @@ def run_locally(model_path, port, mode, keep_env, keep_image, skip_dockerfile=Fa
|
|
322
400
|
click.echo(f"Failed to starts model server locally: {e}", err=True)
|
323
401
|
|
324
402
|
|
325
|
-
@model.command()
|
403
|
+
@model.command(name="local-runner", help="Run the model locally for dev, debug, or local compute.")
|
326
404
|
@click.argument(
|
327
405
|
"model_path",
|
328
406
|
type=click.Path(exists=True),
|
@@ -486,7 +564,13 @@ def local_dev(ctx, model_path):
|
|
486
564
|
)
|
487
565
|
if y.lower() != 'y':
|
488
566
|
raise click.Abort()
|
489
|
-
|
567
|
+
try:
|
568
|
+
model_type_id = ctx.obj.current.model_type_id
|
569
|
+
except AttributeError:
|
570
|
+
model_type_id = DEFAULT_LOCAL_DEV_MODEL_TYPE
|
571
|
+
|
572
|
+
model = app.create_model(model_id, model_type_id=model_type_id)
|
573
|
+
ctx.obj.current.CLARIFAI_MODEL_TYPE_ID = model_type_id
|
490
574
|
ctx.obj.current.CLARIFAI_MODEL_ID = model_id
|
491
575
|
ctx.obj.to_yaml() # save to yaml file.
|
492
576
|
|
@@ -605,6 +689,7 @@ def local_dev(ctx, model_path):
|
|
605
689
|
f"config.yaml not found in {model_path}. Please ensure you are passing the correct directory."
|
606
690
|
)
|
607
691
|
config = ModelBuilder._load_config(config_file)
|
692
|
+
model_type_id = config.get('model', {}).get('model_type_id', DEFAULT_LOCAL_DEV_MODEL_TYPE)
|
608
693
|
# The config.yaml doens't match what we created above.
|
609
694
|
if 'model' in config and model_id != config['model'].get('id'):
|
610
695
|
logger.info(f"Current model section of config.yaml: {config.get('model', {})}")
|
@@ -614,7 +699,7 @@ def local_dev(ctx, model_path):
|
|
614
699
|
if y.lower() != 'y':
|
615
700
|
raise click.Abort()
|
616
701
|
config = ModelBuilder._set_local_dev_model(
|
617
|
-
config, user_id, app_id, model_id,
|
702
|
+
config, user_id, app_id, model_id, model_type_id
|
618
703
|
)
|
619
704
|
ModelBuilder._backup_config(config_file)
|
620
705
|
ModelBuilder._save_config(config_file, config)
|
@@ -655,7 +740,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|
655
740
|
)
|
656
741
|
|
657
742
|
|
658
|
-
@model.command()
|
743
|
+
@model.command(help="Perform a prediction using the model.")
|
659
744
|
@click.option(
|
660
745
|
'--config',
|
661
746
|
type=click.Path(exists=True),
|
@@ -837,7 +922,7 @@ def predict(
|
|
837
922
|
)
|
838
923
|
@click.pass_context
|
839
924
|
def list_model(ctx, user_id, app_id):
|
840
|
-
"""List models of user/community
|
925
|
+
"""List models of user/community.
|
841
926
|
|
842
927
|
USER_ID: User id. If not specified, the current user is used by default. Set "all" to get all public models in Clarifai platform.
|
843
928
|
"""
|
@@ -27,6 +27,146 @@ def upload(path):
|
|
27
27
|
upload_pipeline(path)
|
28
28
|
|
29
29
|
|
30
|
+
@pipeline.command()
|
31
|
+
@click.option(
|
32
|
+
'--config',
|
33
|
+
type=click.Path(exists=True),
|
34
|
+
required=False,
|
35
|
+
help='Path to the pipeline run config file.',
|
36
|
+
)
|
37
|
+
@click.option('--pipeline_id', required=False, help='Pipeline ID to run.')
|
38
|
+
@click.option('--pipeline_version_id', required=False, help='Pipeline Version ID to run.')
|
39
|
+
@click.option(
|
40
|
+
'--pipeline_version_run_id',
|
41
|
+
required=False,
|
42
|
+
help='Pipeline Version Run ID. If not provided, a UUID will be generated.',
|
43
|
+
)
|
44
|
+
@click.option('--user_id', required=False, help='User ID of the pipeline.')
|
45
|
+
@click.option('--app_id', required=False, help='App ID that contains the pipeline.')
|
46
|
+
@click.option('--nodepool_id', required=False, help='Nodepool ID to run the pipeline on.')
|
47
|
+
@click.option(
|
48
|
+
'--compute_cluster_id', required=False, help='Compute Cluster ID to run the pipeline on.'
|
49
|
+
)
|
50
|
+
@click.option('--pipeline_url', required=False, help='Pipeline URL to run.')
|
51
|
+
@click.option(
|
52
|
+
'--timeout',
|
53
|
+
type=int,
|
54
|
+
default=3600,
|
55
|
+
help='Maximum time to wait for completion in seconds. Default 3600 (1 hour).',
|
56
|
+
)
|
57
|
+
@click.option(
|
58
|
+
'--monitor_interval',
|
59
|
+
type=int,
|
60
|
+
default=10,
|
61
|
+
help='Interval between status checks in seconds. Default 10.',
|
62
|
+
)
|
63
|
+
@click.option(
|
64
|
+
'--log_file',
|
65
|
+
type=click.Path(),
|
66
|
+
required=False,
|
67
|
+
help='Path to file where logs should be written. If not provided, logs are displayed on console.',
|
68
|
+
)
|
69
|
+
@click.option(
|
70
|
+
'--monitor',
|
71
|
+
is_flag=True,
|
72
|
+
default=False,
|
73
|
+
help='Monitor an existing pipeline run instead of starting a new one. Requires pipeline_version_run_id.',
|
74
|
+
)
|
75
|
+
@click.pass_context
|
76
|
+
def run(
|
77
|
+
ctx,
|
78
|
+
config,
|
79
|
+
pipeline_id,
|
80
|
+
pipeline_version_id,
|
81
|
+
pipeline_version_run_id,
|
82
|
+
user_id,
|
83
|
+
app_id,
|
84
|
+
nodepool_id,
|
85
|
+
compute_cluster_id,
|
86
|
+
pipeline_url,
|
87
|
+
timeout,
|
88
|
+
monitor_interval,
|
89
|
+
log_file,
|
90
|
+
monitor,
|
91
|
+
):
|
92
|
+
"""Run a pipeline and monitor its progress."""
|
93
|
+
import json
|
94
|
+
|
95
|
+
from clarifai.client.pipeline import Pipeline
|
96
|
+
from clarifai.utils.cli import from_yaml, validate_context
|
97
|
+
|
98
|
+
validate_context(ctx)
|
99
|
+
|
100
|
+
if config:
|
101
|
+
config_data = from_yaml(config)
|
102
|
+
pipeline_id = config_data.get('pipeline_id', pipeline_id)
|
103
|
+
pipeline_version_id = config_data.get('pipeline_version_id', pipeline_version_id)
|
104
|
+
pipeline_version_run_id = config_data.get(
|
105
|
+
'pipeline_version_run_id', pipeline_version_run_id
|
106
|
+
)
|
107
|
+
user_id = config_data.get('user_id', user_id)
|
108
|
+
app_id = config_data.get('app_id', app_id)
|
109
|
+
nodepool_id = config_data.get('nodepool_id', nodepool_id)
|
110
|
+
compute_cluster_id = config_data.get('compute_cluster_id', compute_cluster_id)
|
111
|
+
pipeline_url = config_data.get('pipeline_url', pipeline_url)
|
112
|
+
timeout = config_data.get('timeout', timeout)
|
113
|
+
monitor_interval = config_data.get('monitor_interval', monitor_interval)
|
114
|
+
log_file = config_data.get('log_file', log_file)
|
115
|
+
monitor = config_data.get('monitor', monitor)
|
116
|
+
|
117
|
+
# compute_cluster_id and nodepool_id are mandatory regardless of whether pipeline_url is provided
|
118
|
+
if not compute_cluster_id or not nodepool_id:
|
119
|
+
raise ValueError("--compute_cluster_id and --nodepool_id are mandatory parameters.")
|
120
|
+
|
121
|
+
# When monitor flag is used, pipeline_version_run_id is mandatory
|
122
|
+
if monitor and not pipeline_version_run_id:
|
123
|
+
raise ValueError("--pipeline_version_run_id is required when using --monitor flag.")
|
124
|
+
|
125
|
+
if pipeline_url:
|
126
|
+
# When using pipeline_url, other parameters are optional (will be parsed from URL)
|
127
|
+
required_params_provided = True
|
128
|
+
else:
|
129
|
+
# When not using pipeline_url, all individual parameters are required
|
130
|
+
required_params_provided = all([pipeline_id, user_id, app_id, pipeline_version_id])
|
131
|
+
|
132
|
+
if not required_params_provided:
|
133
|
+
raise ValueError(
|
134
|
+
"Either --user_id & --app_id & --pipeline_id & --pipeline_version_id or --pipeline_url must be provided."
|
135
|
+
)
|
136
|
+
|
137
|
+
if pipeline_url:
|
138
|
+
pipeline = Pipeline(
|
139
|
+
url=pipeline_url,
|
140
|
+
pat=ctx.obj.current.pat,
|
141
|
+
base_url=ctx.obj.current.api_base,
|
142
|
+
pipeline_version_run_id=pipeline_version_run_id,
|
143
|
+
nodepool_id=nodepool_id,
|
144
|
+
compute_cluster_id=compute_cluster_id,
|
145
|
+
log_file=log_file,
|
146
|
+
)
|
147
|
+
else:
|
148
|
+
pipeline = Pipeline(
|
149
|
+
pipeline_id=pipeline_id,
|
150
|
+
pipeline_version_id=pipeline_version_id,
|
151
|
+
pipeline_version_run_id=pipeline_version_run_id,
|
152
|
+
user_id=user_id,
|
153
|
+
app_id=app_id,
|
154
|
+
nodepool_id=nodepool_id,
|
155
|
+
compute_cluster_id=compute_cluster_id,
|
156
|
+
pat=ctx.obj.current.pat,
|
157
|
+
base_url=ctx.obj.current.api_base,
|
158
|
+
log_file=log_file,
|
159
|
+
)
|
160
|
+
|
161
|
+
if monitor:
|
162
|
+
# Monitor existing pipeline run instead of starting new one
|
163
|
+
result = pipeline.monitor_only(timeout=timeout, monitor_interval=monitor_interval)
|
164
|
+
else:
|
165
|
+
# Start new pipeline run and monitor it
|
166
|
+
result = pipeline.run(timeout=timeout, monitor_interval=monitor_interval)
|
167
|
+
click.echo(json.dumps(result, indent=2, default=str))
|
168
|
+
|
169
|
+
|
30
170
|
@pipeline.command()
|
31
171
|
@click.argument(
|
32
172
|
"pipeline_path",
|
@@ -7,6 +7,7 @@ from clarifai.client.input import Inputs
|
|
7
7
|
from clarifai.client.lister import Lister
|
8
8
|
from clarifai.client.model import Model
|
9
9
|
from clarifai.client.module import Module
|
10
|
+
from clarifai.client.pipeline import Pipeline
|
10
11
|
from clarifai.client.search import Search
|
11
12
|
from clarifai.client.user import User
|
12
13
|
from clarifai.client.workflow import Workflow
|
@@ -18,6 +19,7 @@ __all__ = [
|
|
18
19
|
'App',
|
19
20
|
'Model',
|
20
21
|
'Workflow',
|
22
|
+
'Pipeline',
|
21
23
|
'Module',
|
22
24
|
'Lister',
|
23
25
|
'Dataset',
|
@@ -66,6 +66,7 @@ class Model(Lister, BaseClient):
|
|
66
66
|
compute_cluster_id: str = None,
|
67
67
|
nodepool_id: str = None,
|
68
68
|
deployment_id: str = None,
|
69
|
+
deployment_user_id: str = None,
|
69
70
|
**kwargs,
|
70
71
|
):
|
71
72
|
"""Initializes a Model object.
|
@@ -78,6 +79,10 @@ class Model(Lister, BaseClient):
|
|
78
79
|
pat (str): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
|
79
80
|
token (str): A session token for authentication. Accepts either a session token or a pat. Can be set as env var CLARIFAI_SESSION_TOKEN
|
80
81
|
root_certificates_path (str): Path to the SSL root certificates file, used to establish secure gRPC connections.
|
82
|
+
compute_cluster_id (str): Compute cluster ID for runner selector.
|
83
|
+
nodepool_id (str): Nodepool ID for runner selector.
|
84
|
+
deployment_id (str): Deployment ID for runner selector.
|
85
|
+
deployment_user_id (str): User ID to use for runner selector (organization or user). If not provided, defaults to PAT owner user_id.
|
81
86
|
**kwargs: Additional keyword arguments to be passed to the Model.
|
82
87
|
"""
|
83
88
|
if url and model_id:
|
@@ -115,10 +120,13 @@ class Model(Lister, BaseClient):
|
|
115
120
|
)
|
116
121
|
Lister.__init__(self)
|
117
122
|
|
123
|
+
self.deployment_user_id = deployment_user_id
|
124
|
+
|
118
125
|
self._set_runner_selector(
|
119
126
|
compute_cluster_id=compute_cluster_id,
|
120
127
|
nodepool_id=nodepool_id,
|
121
128
|
deployment_id=deployment_id,
|
129
|
+
deployment_user_id=deployment_user_id,
|
122
130
|
)
|
123
131
|
|
124
132
|
@classmethod
|
@@ -633,9 +641,13 @@ class Model(Lister, BaseClient):
|
|
633
641
|
compute_cluster_id: str = None,
|
634
642
|
nodepool_id: str = None,
|
635
643
|
deployment_id: str = None,
|
644
|
+
deployment_user_id: str = None,
|
636
645
|
):
|
637
|
-
# Get UserID
|
638
|
-
|
646
|
+
# Get UserID for runner selector
|
647
|
+
user_id = None
|
648
|
+
if deployment_user_id:
|
649
|
+
user_id = deployment_user_id
|
650
|
+
elif any([deployment_id, nodepool_id, compute_cluster_id]):
|
639
651
|
from clarifai.client.user import User
|
640
652
|
|
641
653
|
user_id = (
|
@@ -643,13 +655,11 @@ class Model(Lister, BaseClient):
|
|
643
655
|
.get_user_info(user_id='me')
|
644
656
|
.user.id
|
645
657
|
)
|
646
|
-
|
647
658
|
runner_selector = None
|
648
659
|
if deployment_id and (compute_cluster_id or nodepool_id):
|
649
660
|
raise UserError(
|
650
661
|
"You can only specify one of deployment_id or compute_cluster_id and nodepool_id."
|
651
662
|
)
|
652
|
-
|
653
663
|
if deployment_id:
|
654
664
|
runner_selector = Deployment.get_runner_selector(
|
655
665
|
user_id=user_id, deployment_id=deployment_id
|
@@ -658,7 +668,6 @@ class Model(Lister, BaseClient):
|
|
658
668
|
runner_selector = Nodepool.get_runner_selector(
|
659
669
|
user_id=user_id, compute_cluster_id=compute_cluster_id, nodepool_id=nodepool_id
|
660
670
|
)
|
661
|
-
|
662
671
|
# set the runner selector
|
663
672
|
self._runner_selector = runner_selector
|
664
673
|
|