clarifai 11.1.7rc1__py3-none-any.whl → 11.1.7rc3__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/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/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 +0 -1
- clarifai/client/model_client.py +23 -24
- 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-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/__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/dockerfile_template/Dockerfile.template +0 -3
- 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 +56 -4
- clarifai/runners/models/model_class.py +40 -17
- clarifai/runners/models/model_class_refract.py +80 -0
- 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/data_handler.py +271 -210
- clarifai/runners/utils/data_handler_refract.py +213 -0
- clarifai/runners/utils/logger.py +0 -0
- clarifai/runners/utils/method_signatures.py +108 -131
- 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/evaluation/__pycache__/__init__.cpython-39.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-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.1.7rc1.dist-info → clarifai-11.1.7rc3.dist-info}/METADATA +15 -15
- clarifai-11.1.7rc3.dist-info/RECORD +237 -0
- {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc3.dist-info}/WHEEL +1 -1
- clarifai/cli/__main__.py~ +0 -4
- clarifai/cli/__pycache__/__main__.cpython-310.pyc +0 -0
- clarifai/client/#model_client.py# +0 -430
- clarifai/client/__pycache__/runner.cpython-310.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-310.pyc +0 -0
- clarifai/models/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/__pycache__/constants.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/_utils.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/build.cpython-310.pyc +0 -0
- clarifai/models/model_serving/cli/__pycache__/create.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/base.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/config.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/inference_parameter.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/__pycache__/output.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/triton/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/triton/__pycache__/serializer.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/triton/__pycache__/triton_config.cpython-310.pyc +0 -0
- clarifai/models/model_serving/model_config/triton/__pycache__/wrappers.cpython-310.pyc +0 -0
- clarifai/models/model_serving/repo_build/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/models/model_serving/repo_build/__pycache__/build.cpython-310.pyc +0 -0
- clarifai/models/model_serving/repo_build/static_files/__pycache__/base_test.cpython-310-pytest-7.2.0.pyc +0 -0
- clarifai/runners/__pycache__/server.cpython-310.pyc +0 -0
- clarifai/runners/dockerfile_template/Dockerfile.debug +0 -11
- clarifai/runners/dockerfile_template/Dockerfile.debug~ +0 -9
- clarifai/runners/models/__pycache__/model_builder.cpython-310.pyc +0 -0
- clarifai/runners/models/__pycache__/model_servicer.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/data_types.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/method_signatures.cpython-310.pyc +0 -0
- clarifai/runners/utils/__pycache__/serializers.cpython-310.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/__init__.cpython-310.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/helpers.cpython-310.pyc +0 -0
- clarifai/utils/evaluation/__pycache__/main.cpython-310.pyc +0 -0
- clarifai-11.1.7rc1.dist-info/RECORD +0 -205
- {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc3.dist-info}/LICENSE +0 -0
- {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc3.dist-info}/entry_points.txt +0 -0
- {clarifai-11.1.7rc1.dist-info → clarifai-11.1.7rc3.dist-info}/top_level.txt +0 -0
clarifai/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "11.1.
|
1
|
+
__version__ = "11.1.7rc3"
|
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
|
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
|
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
|
+
|
clarifai/client/model.py
CHANGED
@@ -84,7 +84,6 @@ class Model(Lister, BaseClient):
|
|
84
84
|
compute_cluster_id=compute_cluster_id,
|
85
85
|
nodepool_id=nodepool_id,
|
86
86
|
deployment_id=deployment_id,
|
87
|
-
user_id=self.user_id, # FIXME the deployment's user_id can be different than the model's.
|
88
87
|
)
|
89
88
|
BaseClient.__init__(
|
90
89
|
self,
|
clarifai/client/model_client.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
import inspect
|
2
|
-
import json
|
3
1
|
import time
|
4
2
|
from typing import Any, Dict, Iterator, List
|
5
3
|
|
@@ -98,18 +96,19 @@ class ModelClient:
|
|
98
96
|
'''
|
99
97
|
for method_name, method_signature in self._method_signatures.items():
|
100
98
|
# define the function in this client instance
|
101
|
-
if method_signature.method_type == '
|
99
|
+
if resources_pb2.RunnerMethodType.Name(method_signature.method_type) == 'UNARY_UNARY':
|
102
100
|
call_func = self._predict
|
103
|
-
elif method_signature.method_type == '
|
101
|
+
elif resources_pb2.RunnerMethodType.Name(method_signature.method_type) == 'UNARY_STREAMING':
|
104
102
|
call_func = self._generate
|
105
|
-
elif
|
103
|
+
elif resources_pb2.RunnerMethodType.Name(
|
104
|
+
method_signature.method_type) == 'STREAMING_STREAMING':
|
106
105
|
call_func = self._stream
|
107
106
|
else:
|
108
107
|
raise ValueError(f"Unknown method type {method_signature.method_type}")
|
109
108
|
|
110
109
|
# method argnames, in order, collapsing nested keys to corresponding user function args
|
111
110
|
method_argnames = []
|
112
|
-
for var in method_signature.
|
111
|
+
for var in method_signature.input_fields:
|
113
112
|
outer = var.name.split('.', 1)[0]
|
114
113
|
if outer in method_argnames:
|
115
114
|
continue
|
@@ -136,18 +135,18 @@ class ModelClient:
|
|
136
135
|
# set names, annotations and docstrings
|
137
136
|
f.__name__ = method_name
|
138
137
|
f.__qualname__ = f'{self.__class__.__name__}.{method_name}'
|
139
|
-
|
140
|
-
input_annotations = json.loads(method_signature.annotations_json)
|
141
|
-
return_annotation = input_annotations.pop('return', None)
|
142
|
-
sig = inspect.signature(f).replace(
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
)
|
149
|
-
f.__signature__ = sig
|
150
|
-
f.__doc__ = method_signature.
|
138
|
+
# TODO: set signature from annotations to the function, currently MethodSignature don't have `annotations_json` field
|
139
|
+
# input_annotations = json.loads(method_signature.annotations_json)
|
140
|
+
# return_annotation = input_annotations.pop('return', None)
|
141
|
+
# sig = inspect.signature(f).replace(
|
142
|
+
# parameters=[
|
143
|
+
# inspect.Parameter(k, inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=v)
|
144
|
+
# for k, v in input_annotations.items()
|
145
|
+
# ],
|
146
|
+
# return_annotation=return_annotation,
|
147
|
+
# )
|
148
|
+
# f.__signature__ = sig
|
149
|
+
f.__doc__ = method_signature.description
|
151
150
|
setattr(self, method_name, f)
|
152
151
|
|
153
152
|
def _define_compatability_functions(self):
|
@@ -177,8 +176,8 @@ class ModelClient:
|
|
177
176
|
inputs, # TODO set up functions according to fetched signatures?
|
178
177
|
method_name: str = 'predict',
|
179
178
|
) -> Any:
|
180
|
-
input_signature = self._method_signatures[method_name].
|
181
|
-
output_signature = self._method_signatures[method_name].
|
179
|
+
input_signature = self._method_signatures[method_name].input_fields
|
180
|
+
output_signature = self._method_signatures[method_name].output_fields
|
182
181
|
|
183
182
|
batch_input = True
|
184
183
|
if isinstance(inputs, dict):
|
@@ -260,8 +259,8 @@ class ModelClient:
|
|
260
259
|
inputs, # TODO set up functions according to fetched signatures?
|
261
260
|
method_name: str = 'generate',
|
262
261
|
) -> Any:
|
263
|
-
input_signature = self._method_signatures[method_name].
|
264
|
-
output_signature = self._method_signatures[method_name].
|
262
|
+
input_signature = self._method_signatures[method_name].input_fields
|
263
|
+
output_signature = self._method_signatures[method_name].output_fields
|
265
264
|
|
266
265
|
batch_input = True
|
267
266
|
if isinstance(inputs, dict):
|
@@ -350,8 +349,8 @@ class ModelClient:
|
|
350
349
|
inputs,
|
351
350
|
method_name: str = 'stream',
|
352
351
|
) -> Any:
|
353
|
-
input_signature = self._method_signatures[method_name].
|
354
|
-
output_signature = self._method_signatures[method_name].
|
352
|
+
input_signature = self._method_signatures[method_name].input_fields
|
353
|
+
output_signature = self._method_signatures[method_name].output_fields
|
355
354
|
|
356
355
|
if isinstance(inputs, list):
|
357
356
|
assert len(inputs) == 1, 'streaming methods do not support batched calls'
|
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
|
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
|
@@ -0,0 +1,31 @@
|
|
1
|
+
ARG BASE_IMAGE=${BASE_IMAGE}
|
2
|
+
FROM ${BASE_IMAGE} as build
|
3
|
+
|
4
|
+
# Set the working directory to /app
|
5
|
+
WORKDIR /app
|
6
|
+
|
7
|
+
COPY requirements.txt .
|
8
|
+
# Install requirements and cleanup before leaving this line.
|
9
|
+
# Note(zeiler): this could be in a future template as {{model_python_deps}}
|
10
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
11
|
+
|
12
|
+
# Install Clarifai SDK
|
13
|
+
RUN pip install --no-cache-dir clarifai
|
14
|
+
|
15
|
+
# These will be set by the templaing system.
|
16
|
+
ENV CLARIFAI_PAT=${CLARIFAI_PAT}
|
17
|
+
ENV CLARIFAI_USER_ID=${CLARIFAI_USER_ID}
|
18
|
+
ENV CLARIFAI_RUNNER_ID=${CLARIFAI_RUNNER_ID}
|
19
|
+
ENV CLARIFAI_NODEPOOL_ID=${CLARIFAI_NODEPOOL_ID}
|
20
|
+
ENV CLARIFAI_COMPUTE_CLUSTER_ID=${CLARIFAI_COMPUTE_CLUSTER_ID}
|
21
|
+
ENV CLARIFAI_API_BASE=${CLARIFAI_API_BASE}
|
22
|
+
|
23
|
+
# Copy the current folder into /app/model_dir that the SDK will expect.
|
24
|
+
COPY . /app/model_dir/${name}
|
25
|
+
|
26
|
+
# Add the model directory to the python path.
|
27
|
+
ENV PYTHONPATH "${PYTHONPATH}:/app/model_dir/${name}"
|
28
|
+
|
29
|
+
# Finally run the clarifai entrypoint to start the runner loop and local dev server.
|
30
|
+
# Note(zeiler): we may want to make this a clarifai CLI call.
|
31
|
+
CMD ["-m", "clarifai.runners.server", "--model_path", "/app/model_dir/${name}"]
|
@@ -0,0 +1,42 @@
|
|
1
|
+
ARG TARGET_PLATFORM=linux/amd64
|
2
|
+
FROM --platform=$TARGET_PLATFORM ${BASE_IMAGE} as build
|
3
|
+
|
4
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
5
|
+
|
6
|
+
#############################
|
7
|
+
# User specific requirements
|
8
|
+
#############################
|
9
|
+
COPY requirements.txt .
|
10
|
+
|
11
|
+
# Install requirements and cleanup before leaving this line.
|
12
|
+
# Note(zeiler): this could be in a future template as {{model_python_deps}}
|
13
|
+
RUN pip install --no-cache-dir -r requirements.txt
|
14
|
+
|
15
|
+
# Install Clarifai SDK
|
16
|
+
RUN pip install --no-cache-dir clarifai
|
17
|
+
|
18
|
+
# These will be set by the templaing system.
|
19
|
+
ENV CLARIFAI_PAT=${CLARIFAI_PAT}
|
20
|
+
ENV CLARIFAI_USER_ID=${CLARIFAI_USER_ID}
|
21
|
+
ENV CLARIFAI_RUNNER_ID=${CLARIFAI_RUNNER_ID}
|
22
|
+
ENV CLARIFAI_NODEPOOL_ID=${CLARIFAI_NODEPOOL_ID}
|
23
|
+
ENV CLARIFAI_COMPUTE_CLUSTER_ID=${CLARIFAI_COMPUTE_CLUSTER_ID}
|
24
|
+
ENV CLARIFAI_API_BASE=${CLARIFAI_API_BASE}
|
25
|
+
|
26
|
+
# Set the NUMBA cache dir to /tmp
|
27
|
+
ENV NUMBA_CACHE_DIR=/tmp/numba_cache
|
28
|
+
ENV HOME=/tmp
|
29
|
+
|
30
|
+
# Set the working directory to /app
|
31
|
+
WORKDIR /app
|
32
|
+
|
33
|
+
# Copy the current folder into /app/model_dir that the SDK will expect.
|
34
|
+
# Note(zeiler): would be nice to exclude checkpoints in case they were pre-downloaded.
|
35
|
+
COPY . /app/model_dir/${name}
|
36
|
+
|
37
|
+
# Add the model directory to the python path.
|
38
|
+
ENV PYTHONPATH=${PYTHONPATH}:/app/model_dir/${name}
|
39
|
+
|
40
|
+
# Finally run the clarifai entrypoint to start the runner loop and local dev server.
|
41
|
+
# Note(zeiler): we may want to make this a clarifai CLI call.
|
42
|
+
CMD ["-m", "clarifai.runners.server", "--model_path", "/app/model_dir/${name}"]
|
@@ -0,0 +1,71 @@
|
|
1
|
+
FROM nvcr.io/nim/meta/llama-3.1-8b-instruct:1.1.2 as build
|
2
|
+
|
3
|
+
FROM gcr.io/distroless/python3-debian12:debug
|
4
|
+
|
5
|
+
|
6
|
+
COPY --from=build /bin/bash /bin/rbash
|
7
|
+
COPY --from=build /bin/sh /bin/sh
|
8
|
+
COPY --from=build /bin/rsh /bin/rsh
|
9
|
+
|
10
|
+
# we have to overwrite the python3 binary that the distroless image uses
|
11
|
+
COPY --from=build /opt/nim/llm/.venv/bin/python3.10 /usr/bin/python3
|
12
|
+
COPY --from=build /opt/nim/llm/.venv/bin/python3.10 /usr/local/bin/python3.10
|
13
|
+
|
14
|
+
# also copy in all the lib files for it.
|
15
|
+
COPY --from=build /lib /lib
|
16
|
+
COPY --from=build /lib64 /lib64
|
17
|
+
COPY --from=build /usr/lib/ /usr/lib/
|
18
|
+
COPY --from=build /usr/local/lib/ /usr/local/lib/
|
19
|
+
# ldconfig is needed to update the shared library cache so system libraries (like CUDA) can be found
|
20
|
+
COPY --from=build /usr/sbin/ldconfig /sbin/ldconfig
|
21
|
+
COPY --from=build /usr/sbin/ldconfig.real /sbin/ldconfig.real
|
22
|
+
COPY --from=build /etc/ld.so.conf /etc/ld.so.conf
|
23
|
+
COPY --from=build /etc/ld.so.cache /etc/ld.so.cache
|
24
|
+
COPY --from=build /etc/ld.so.conf.d/ /etc/ld.so.conf.d/
|
25
|
+
|
26
|
+
# COPY NIM files
|
27
|
+
COPY --from=build /opt /opt
|
28
|
+
COPY --from=build /etc/nim /etc/nim
|
29
|
+
|
30
|
+
# Set environment variables to use the nim libraries and python
|
31
|
+
ENV PYTHONPATH=${PYTHONPATH}:/opt/nim/llm/.venv/lib/python3.10/site-packages:/opt/nim/llm
|
32
|
+
ENV PATH="/opt/nim/llm/.venv/bin:/opt/hpcx/ucc/bin:/opt/hpcx/ucx/bin:/opt/hpcx/ompi/bin:$PATH"
|
33
|
+
|
34
|
+
ENV LD_LIBRARY_PATH="/opt/hpcx/ucc/lib/ucc:/opt/hpcx/ucc/lib:/opt/hpcx/ucx/lib/ucx:/opt/hpcx/ucx/lib:/opt/hpcx/ompi/lib:/opt/hpcx/ompi/lib/openmpi:/opt/nim/llm/.venv/lib/python3.10/site-packages/tensorrt_llm/libs:/opt/nim/llm/.venv/lib/python3.10/site-packages/nvidia/cublas/lib:/opt/nim/llm/.venv/lib/python3.10/site-packages/tensorrt_libs:/opt/nim/llm/.venv/lib/python3.10/site-packages/nvidia/nccl/lib:$LD_LIBRARY_PATH"
|
35
|
+
|
36
|
+
ENV LIBRARY_PATH=/opt/hpcx/ucc/lib:/opt/hpcx/ucx/lib:/opt/hpcx/ompi/lib:$LIBRARY_PATH
|
37
|
+
|
38
|
+
ENV CPATH=/opt/hpcx/ompi/include:/opt/hpcx/ucc/include:/opt/hpcx/ucx/include:$CPATH
|
39
|
+
ENV LLM_PROJECT_DIR=/opt/nim/llm
|
40
|
+
|
41
|
+
# Set environment variables for MPI
|
42
|
+
ENV OMPI_HOME=/opt/hpcx/ompi
|
43
|
+
ENV HPCX_MPI_DIR=/opt/hpcx/ompi
|
44
|
+
ENV MPIf_HOME=/opt/hpcx/ompi
|
45
|
+
ENV OPAL_PREFIX=/opt/hpcx/ompi
|
46
|
+
|
47
|
+
# Set environment variables for UCC
|
48
|
+
ENV UCC_DIR=/opt/hpcx/ucc/lib/cmake/ucc
|
49
|
+
ENV UCC_HOME=/opt/hpcx/ucc
|
50
|
+
ENV HPCX_UCC_DIR=/opt/hpcx/ucc
|
51
|
+
ENV USE_UCC=1
|
52
|
+
ENV USE_SYSTEM_UCC=1
|
53
|
+
|
54
|
+
# Set environment variables for HPC-X
|
55
|
+
ENV HPCX_DIR=/opt/hpcx
|
56
|
+
ENV HPCX_UCX_DIR=/opt/hpcx/ucx
|
57
|
+
ENV HPCX_MPI_DIR=/opt/hpcx/ompi
|
58
|
+
|
59
|
+
# Set environment variables for UCX
|
60
|
+
ENV UCX_DIR=/opt/hpcx/ucx/lib/cmake/ucx
|
61
|
+
ENV UCX_HOME=/opt/hpcx/ucx
|
62
|
+
|
63
|
+
ENV HOME=/opt/nim/llm
|
64
|
+
|
65
|
+
# ln is needed to create symbolic links (needed by nvidia-container-runtime)
|
66
|
+
COPY --from=build /usr/bin/ln /usr/bin/ln
|
67
|
+
|
68
|
+
# Run ldconfig in the build stage to update the library cache else CUDA libraries won't be found
|
69
|
+
RUN ldconfig -v
|
70
|
+
|
71
|
+
SHELL ["/bin/rbash", "-c"]
|
@@ -44,9 +44,6 @@ ENV PYTHONPATH=${PYTHONPATH}:/home/nonroot/main \
|
|
44
44
|
CLARIFAI_COMPUTE_CLUSTER_ID=${CLARIFAI_COMPUTE_CLUSTER_ID} \
|
45
45
|
CLARIFAI_API_BASE=${CLARIFAI_API_BASE:-https://api.clarifai.com}
|
46
46
|
|
47
|
-
# # Write out the model function signatures
|
48
|
-
# RUN ["python", "-m", "clarifai.cli", "model", "signatures", "--model_path", "/home/nonroot/main", "--out_path", "/home/nonroot/main/signatures.yaml"]
|
49
|
-
|
50
47
|
# Finally run the clarifai entrypoint to start the runner loop and local dev server.
|
51
48
|
# Note(zeiler): we may want to make this a clarifai CLI call.
|
52
49
|
ENTRYPOINT ["python", "-m", "clarifai.runners.server"]
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|