clarifai 10.9.4__py3-none-any.whl → 10.10.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- clarifai/__init__.py +1 -1
- clarifai/cli/README.md +87 -0
- clarifai/cli/base.py +41 -3
- clarifai/cli/compute_cluster.py +51 -0
- clarifai/cli/deployment.py +84 -0
- clarifai/cli/model.py +1 -1
- clarifai/cli/nodepool.py +91 -0
- clarifai/client/auth/helper.py +1 -0
- clarifai/client/compute_cluster.py +5 -4
- clarifai/client/nodepool.py +5 -4
- clarifai/client/user.py +6 -5
- clarifai/utils/cli.py +25 -0
- {clarifai-10.9.4.dist-info → clarifai-10.10.0.dist-info}/METADATA +1 -1
- {clarifai-10.9.4.dist-info → clarifai-10.10.0.dist-info}/RECORD +18 -14
- {clarifai-10.9.4.dist-info → clarifai-10.10.0.dist-info}/WHEEL +1 -1
- {clarifai-10.9.4.dist-info → clarifai-10.10.0.dist-info}/LICENSE +0 -0
- {clarifai-10.9.4.dist-info → clarifai-10.10.0.dist-info}/entry_points.txt +0 -0
- {clarifai-10.9.4.dist-info → clarifai-10.10.0.dist-info}/top_level.txt +0 -0
clarifai/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "10.
|
1
|
+
__version__ = "10.10.0"
|
clarifai/cli/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Clarifai CLI
|
2
|
+
|
3
|
+
## Overview
|
4
|
+
|
5
|
+
Clarifai offers a user-friendly interface for deploying your local model into production with Clarifai, featuring:
|
6
|
+
|
7
|
+
* A convenient command-line interface (CLI)
|
8
|
+
* Easy implementation and testing in Python
|
9
|
+
* No need for MLops expertise.
|
10
|
+
|
11
|
+
## Compute Orchestration
|
12
|
+
|
13
|
+
Quick example for deploying a `visual-classifier` model
|
14
|
+
|
15
|
+
### Login
|
16
|
+
|
17
|
+
First, login to cli using clarifai account details in a config file as shown below:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ clarifai login --config <config-filepath>
|
21
|
+
```
|
22
|
+
|
23
|
+
### Setup
|
24
|
+
|
25
|
+
To prepare for deployment step, we have to setup a Compute Cluster with Nodepool of required server config to deploy the model.
|
26
|
+
|
27
|
+
So, First, create a new Compute Cluster
|
28
|
+
```bash
|
29
|
+
$ clarifai computecluster create --config <compute-cluster-config-filepath>
|
30
|
+
```
|
31
|
+
|
32
|
+
Then, create a new Nodepool in the created Compute Cluster
|
33
|
+
```bash
|
34
|
+
$ clarifai nodepool create --config <nodepool-config-filepath>
|
35
|
+
```
|
36
|
+
|
37
|
+
### Deployment
|
38
|
+
|
39
|
+
After setup, we can deploy the `visual-classifier` model using a deployment config file as shown below:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
$ clarifai deployment create --config <deployment-config-filepath>
|
43
|
+
```
|
44
|
+
|
45
|
+
### List Resources
|
46
|
+
|
47
|
+
List out existing Compute Clusters:
|
48
|
+
|
49
|
+
```bash
|
50
|
+
$ clarifai computecluster list
|
51
|
+
```
|
52
|
+
|
53
|
+
List out existing Nodepools:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
$ clarifai nodepool list --compute_cluster_id <compute-cluster-id>
|
57
|
+
```
|
58
|
+
|
59
|
+
List out existing Deployments:
|
60
|
+
|
61
|
+
```bash
|
62
|
+
$ clarifai deployment list --nodepool_id <nodepool-id>
|
63
|
+
```
|
64
|
+
|
65
|
+
### Delete Resources
|
66
|
+
|
67
|
+
Delete existing Deployment:
|
68
|
+
|
69
|
+
```bash
|
70
|
+
$ clarifai deployment delete --nodepool_id <nodepool-id> --deployment_id <deployment-id>
|
71
|
+
```
|
72
|
+
|
73
|
+
Delete existing Nodepool:
|
74
|
+
|
75
|
+
```bash
|
76
|
+
$ clarifai nodepool delete --compute_cluster_id <compute-cluster-id> --nodepool_id <nodepool-id>
|
77
|
+
```
|
78
|
+
|
79
|
+
Delete existing Compute Clusters:
|
80
|
+
|
81
|
+
```bash
|
82
|
+
$ clarifai computecluster delete --compute_cluster_id <compute-cluster-id>
|
83
|
+
```
|
84
|
+
|
85
|
+
## Learn More
|
86
|
+
|
87
|
+
* [Example Configs](https://github.com/Clarifai/examples/tree/main/ComputeOrchestration/configs)
|
clarifai/cli/base.py
CHANGED
@@ -5,7 +5,38 @@ import click
|
|
5
5
|
from ..utils.cli import dump_yaml, from_yaml, load_command_modules, set_base_url
|
6
6
|
|
7
7
|
|
8
|
-
|
8
|
+
class CustomMultiGroup(click.Group):
|
9
|
+
|
10
|
+
def group(self, *args, **kwargs):
|
11
|
+
"""Behaves the same as `click.Group.group()` except if passed
|
12
|
+
a list of names, all after the first will be aliases for the first.
|
13
|
+
"""
|
14
|
+
|
15
|
+
def decorator(f):
|
16
|
+
aliased_group = []
|
17
|
+
if isinstance(args[0], list):
|
18
|
+
# we have a list so create group aliases
|
19
|
+
_args = [args[0][0]] + list(args[1:])
|
20
|
+
for alias in args[0][1:]:
|
21
|
+
grp = super(CustomMultiGroup, self).group(alias, *args[1:], **kwargs)(f)
|
22
|
+
grp.short_help = "Alias for '{}'".format(_args[0])
|
23
|
+
aliased_group.append(grp)
|
24
|
+
else:
|
25
|
+
_args = args
|
26
|
+
|
27
|
+
# create the main group
|
28
|
+
grp = super(CustomMultiGroup, self).group(*_args, **kwargs)(f)
|
29
|
+
|
30
|
+
# for all of the aliased groups, share the main group commands
|
31
|
+
for aliased in aliased_group:
|
32
|
+
aliased.commands = grp.commands
|
33
|
+
|
34
|
+
return grp
|
35
|
+
|
36
|
+
return decorator
|
37
|
+
|
38
|
+
|
39
|
+
@click.group(cls=CustomMultiGroup)
|
9
40
|
@click.pass_context
|
10
41
|
def cli(ctx):
|
11
42
|
"""Clarifai CLI"""
|
@@ -49,9 +80,16 @@ def login(ctx, config, env, user_id):
|
|
49
80
|
if user_id:
|
50
81
|
ctx.obj['user_id'] = user_id
|
51
82
|
os.environ["CLARIFAI_USER_ID"] = ctx.obj['user_id']
|
52
|
-
elif 'user_id' in ctx.obj
|
53
|
-
ctx.obj['user_id'] = ctx.obj.get('user_id',
|
83
|
+
elif 'user_id' in ctx.obj:
|
84
|
+
ctx.obj['user_id'] = ctx.obj.get('user_id', "")
|
54
85
|
os.environ["CLARIFAI_USER_ID"] = ctx.obj['user_id']
|
86
|
+
elif 'CLARIFAI_USER_ID' in os.environ:
|
87
|
+
ctx.obj['user_id'] = os.environ["CLARIFAI_USER_ID"]
|
88
|
+
else:
|
89
|
+
user_id = click.prompt("Pass the User ID here", type=str)
|
90
|
+
os.environ["CLARIFAI_USER_ID"] = user_id
|
91
|
+
ctx.obj['user_id'] = user_id
|
92
|
+
click.echo("User ID saved successfully.")
|
55
93
|
|
56
94
|
if env:
|
57
95
|
ctx.obj['env'] = env
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import click
|
2
|
+
from clarifai.cli.base import cli
|
3
|
+
from clarifai.client.user import User
|
4
|
+
from clarifai.utils.cli import display_co_resources
|
5
|
+
|
6
|
+
|
7
|
+
@cli.group(['computecluster', 'cc'])
|
8
|
+
def computecluster():
|
9
|
+
"""Manage Compute Clusters: create, delete, list"""
|
10
|
+
pass
|
11
|
+
|
12
|
+
|
13
|
+
@computecluster.command()
|
14
|
+
@click.option(
|
15
|
+
'--config',
|
16
|
+
type=click.Path(exists=True),
|
17
|
+
required=True,
|
18
|
+
help='Path to the compute cluster config file.')
|
19
|
+
@click.option(
|
20
|
+
'-cc_id',
|
21
|
+
'--compute_cluster_id',
|
22
|
+
required=False,
|
23
|
+
help='New Compute Cluster ID for the compute cluster to create.')
|
24
|
+
@click.pass_context
|
25
|
+
def create(ctx, config, compute_cluster_id):
|
26
|
+
"""Create a new Compute Cluster with the given config file."""
|
27
|
+
user = User(user_id=ctx.obj['user_id'], pat=ctx.obj['pat'], base_url=ctx.obj['base_url'])
|
28
|
+
if compute_cluster_id:
|
29
|
+
user.create_compute_cluster(config, compute_cluster_id=compute_cluster_id)
|
30
|
+
else:
|
31
|
+
user.create_compute_cluster(config)
|
32
|
+
|
33
|
+
|
34
|
+
@computecluster.command()
|
35
|
+
@click.option('--page_no', required=False, help='Page number to list.', default=1)
|
36
|
+
@click.option('--per_page', required=False, help='Number of items per page.', default=16)
|
37
|
+
@click.pass_context
|
38
|
+
def list(ctx, page_no, per_page):
|
39
|
+
"""List all compute clusters for the user."""
|
40
|
+
user = User(user_id=ctx.obj['user_id'], pat=ctx.obj['pat'], base_url=ctx.obj['base_url'])
|
41
|
+
response = user.list_compute_clusters(page_no, per_page)
|
42
|
+
display_co_resources(response, "Compute Cluster")
|
43
|
+
|
44
|
+
|
45
|
+
@computecluster.command()
|
46
|
+
@click.option('-cc_id', '--compute_cluster_id', help='Compute Cluster ID of the user to delete.')
|
47
|
+
@click.pass_context
|
48
|
+
def delete(ctx, compute_cluster_id):
|
49
|
+
"""Deletes a compute cluster for the user."""
|
50
|
+
user = User(user_id=ctx.obj['user_id'], pat=ctx.obj['pat'], base_url=ctx.obj['base_url'])
|
51
|
+
user.delete_compute_clusters([compute_cluster_id])
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import click
|
2
|
+
from clarifai.cli.base import cli
|
3
|
+
from clarifai.client.nodepool import Nodepool
|
4
|
+
from clarifai.utils.cli import display_co_resources, from_yaml
|
5
|
+
|
6
|
+
|
7
|
+
@cli.group(['deployment', 'dpl'])
|
8
|
+
def deployment():
|
9
|
+
"""Manage Deployments: create, delete, list"""
|
10
|
+
pass
|
11
|
+
|
12
|
+
|
13
|
+
@deployment.command()
|
14
|
+
@click.option(
|
15
|
+
'-np_id',
|
16
|
+
'--nodepool_id',
|
17
|
+
required=False,
|
18
|
+
help='Nodepool ID for the Nodepool to interact with.')
|
19
|
+
@click.option(
|
20
|
+
'--config',
|
21
|
+
type=click.Path(exists=True),
|
22
|
+
required=True,
|
23
|
+
help='Path to the deployment config file.')
|
24
|
+
@click.option(
|
25
|
+
'-dpl_id',
|
26
|
+
'--deployment_id',
|
27
|
+
required=False,
|
28
|
+
help='New deployment ID for the deployment to create.')
|
29
|
+
@click.pass_context
|
30
|
+
def create(ctx, nodepool_id, config, deployment_id):
|
31
|
+
"""Create a new Deployment with the given config file."""
|
32
|
+
if not nodepool_id:
|
33
|
+
deployment_config = from_yaml(config)
|
34
|
+
nodepool_id = deployment_config['deployment']['nodepools'][0]['id']
|
35
|
+
|
36
|
+
nodepool = Nodepool(
|
37
|
+
nodepool_id=nodepool_id,
|
38
|
+
user_id=ctx.obj['user_id'],
|
39
|
+
pat=ctx.obj['pat'],
|
40
|
+
base_url=ctx.obj['base_url'])
|
41
|
+
if deployment_id:
|
42
|
+
nodepool.create_deployment(config, deployment_id=deployment_id)
|
43
|
+
else:
|
44
|
+
nodepool.create_deployment(config)
|
45
|
+
|
46
|
+
|
47
|
+
@deployment.command()
|
48
|
+
@click.option(
|
49
|
+
'-np_id',
|
50
|
+
'--nodepool_id',
|
51
|
+
required=True,
|
52
|
+
help='Nodepool ID for the Nodepool to interact with.')
|
53
|
+
@click.option('--page_no', required=False, help='Page number to list.', default=1)
|
54
|
+
@click.option('--per_page', required=False, help='Number of items per page.', default=16)
|
55
|
+
@click.pass_context
|
56
|
+
def list(ctx, nodepool_id, page_no, per_page):
|
57
|
+
"""List all deployments for the nodepool."""
|
58
|
+
|
59
|
+
nodepool = Nodepool(
|
60
|
+
nodepool_id=nodepool_id,
|
61
|
+
user_id=ctx.obj['user_id'],
|
62
|
+
pat=ctx.obj['pat'],
|
63
|
+
base_url=ctx.obj['base_url'])
|
64
|
+
response = nodepool.list_deployments(page_no=page_no, per_page=per_page)
|
65
|
+
display_co_resources(response, "Deployment")
|
66
|
+
|
67
|
+
|
68
|
+
@deployment.command()
|
69
|
+
@click.option(
|
70
|
+
'-np_id',
|
71
|
+
'--nodepool_id',
|
72
|
+
required=True,
|
73
|
+
help='Nodepool ID for the Nodepool to interact with.')
|
74
|
+
@click.option('-dpl_id', '--deployment_id', help='Deployment ID of the nodepool to delete.')
|
75
|
+
@click.pass_context
|
76
|
+
def delete(ctx, nodepool_id, deployment_id):
|
77
|
+
"""Deletes a deployment for the nodepool."""
|
78
|
+
|
79
|
+
nodepool = Nodepool(
|
80
|
+
nodepool_id=nodepool_id,
|
81
|
+
user_id=ctx.obj['user_id'],
|
82
|
+
pat=ctx.obj['pat'],
|
83
|
+
base_url=ctx.obj['base_url'])
|
84
|
+
nodepool.delete_deployments([deployment_id])
|
clarifai/cli/model.py
CHANGED
clarifai/cli/nodepool.py
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
import click
|
2
|
+
from clarifai.cli.base import cli
|
3
|
+
from clarifai.client.compute_cluster import ComputeCluster
|
4
|
+
from clarifai.utils.cli import display_co_resources, dump_yaml, from_yaml
|
5
|
+
|
6
|
+
|
7
|
+
@cli.group(['nodepool', 'np'])
|
8
|
+
def nodepool():
|
9
|
+
"""Manage Nodepools: create, delete, list"""
|
10
|
+
pass
|
11
|
+
|
12
|
+
|
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.')
|
19
|
+
@click.option(
|
20
|
+
'--config',
|
21
|
+
type=click.Path(exists=True),
|
22
|
+
required=True,
|
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.')
|
26
|
+
@click.pass_context
|
27
|
+
def create(ctx, compute_cluster_id, config, nodepool_id):
|
28
|
+
"""Create a new Nodepool with the given config file."""
|
29
|
+
|
30
|
+
nodepool_config = from_yaml(config)
|
31
|
+
if not compute_cluster_id:
|
32
|
+
if 'compute_cluster' not in nodepool_config['nodepool']:
|
33
|
+
click.echo(
|
34
|
+
"Please provide a compute cluster ID either in the config file or using --compute_cluster_id flag",
|
35
|
+
err=True)
|
36
|
+
return
|
37
|
+
compute_cluster_id = nodepool_config['nodepool']['compute_cluster']['id']
|
38
|
+
else:
|
39
|
+
if 'compute_cluster' not in nodepool_config['nodepool']:
|
40
|
+
nodepool_config['nodepool']['compute_cluster']['id'] = compute_cluster_id
|
41
|
+
dump_yaml(config, nodepool_config)
|
42
|
+
|
43
|
+
compute_cluster = ComputeCluster(
|
44
|
+
compute_cluster_id=compute_cluster_id,
|
45
|
+
user_id=ctx.obj['user_id'],
|
46
|
+
pat=ctx.obj['pat'],
|
47
|
+
base_url=ctx.obj['base_url'])
|
48
|
+
if nodepool_id:
|
49
|
+
compute_cluster.create_nodepool(config, nodepool_id=nodepool_id)
|
50
|
+
else:
|
51
|
+
compute_cluster.create_nodepool(config)
|
52
|
+
|
53
|
+
|
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.')
|
60
|
+
@click.option('--page_no', required=False, help='Page number to list.', default=1)
|
61
|
+
@click.option('--per_page', required=False, help='Number of items per page.', default=16)
|
62
|
+
@click.pass_context
|
63
|
+
def list(ctx, compute_cluster_id, page_no, per_page):
|
64
|
+
"""List all nodepools for the user."""
|
65
|
+
|
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")
|
73
|
+
|
74
|
+
|
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.')
|
82
|
+
@click.pass_context
|
83
|
+
def delete(ctx, compute_cluster_id, nodepool_id):
|
84
|
+
"""Deletes a nodepool for the user."""
|
85
|
+
|
86
|
+
compute_cluster = ComputeCluster(
|
87
|
+
compute_cluster_id=compute_cluster_id,
|
88
|
+
user_id=ctx.obj['user_id'],
|
89
|
+
pat=ctx.obj['pat'],
|
90
|
+
base_url=ctx.obj['base_url'])
|
91
|
+
compute_cluster.delete_nodepools([nodepool_id])
|
clarifai/client/auth/helper.py
CHANGED
@@ -321,6 +321,7 @@ Additionally, these optional params are supported:
|
|
321
321
|
|
322
322
|
def set_base(self, base: str):
|
323
323
|
""" Set the base domain for the API. """
|
324
|
+
base = DEFAULT_BASE if base is None else base
|
324
325
|
self._base = https_cache(base_https_cache, base)
|
325
326
|
|
326
327
|
def set_ui(self, ui: str):
|
@@ -102,12 +102,12 @@ class ComputeCluster(Lister, BaseClient):
|
|
102
102
|
nodepool["visibility"] = resources_pb2.Visibility(**nodepool["visibility"])
|
103
103
|
return nodepool
|
104
104
|
|
105
|
-
def create_nodepool(self,
|
105
|
+
def create_nodepool(self, config_filepath: str, nodepool_id: str = None) -> Nodepool:
|
106
106
|
"""Creates a nodepool for the compute cluster.
|
107
107
|
|
108
108
|
Args:
|
109
|
-
nodepool_id (str): The nodepool ID for the nodepool to create.
|
110
109
|
config_filepath (str): The path to the nodepool config file.
|
110
|
+
nodepool_id (str): New nodepool ID for the nodepool to create.
|
111
111
|
|
112
112
|
Returns:
|
113
113
|
Nodepool: A Nodepool object for the specified nodepool ID.
|
@@ -115,7 +115,7 @@ class ComputeCluster(Lister, BaseClient):
|
|
115
115
|
Example:
|
116
116
|
>>> from clarifai.client.compute_cluster import ComputeCluster
|
117
117
|
>>> compute_cluster = ComputeCluster(compute_cluster_id="compute_cluster_id", user_id="user_id")
|
118
|
-
>>> nodepool = compute_cluster.create_nodepool(
|
118
|
+
>>> nodepool = compute_cluster.create_nodepool(config_filepath="config.yml")
|
119
119
|
"""
|
120
120
|
if not os.path.exists(config_filepath):
|
121
121
|
raise UserError(f"Nodepool config file not found at {config_filepath}")
|
@@ -123,7 +123,8 @@ class ComputeCluster(Lister, BaseClient):
|
|
123
123
|
nodepool_config = self._process_nodepool_config(config_filepath)
|
124
124
|
|
125
125
|
if 'id' in nodepool_config:
|
126
|
-
nodepool_id
|
126
|
+
if nodepool_id is None:
|
127
|
+
nodepool_id = nodepool_config['id']
|
127
128
|
nodepool_config.pop('id')
|
128
129
|
|
129
130
|
request = service_pb2.PostNodepoolsRequest(
|
clarifai/client/nodepool.py
CHANGED
@@ -136,12 +136,12 @@ class Nodepool(Lister, BaseClient):
|
|
136
136
|
nodepool = resources_pb2.Nodepool(id=nodepool_id, compute_cluster=compute_cluster)
|
137
137
|
return resources_pb2.RunnerSelector(nodepool=nodepool)
|
138
138
|
|
139
|
-
def create_deployment(self,
|
139
|
+
def create_deployment(self, config_filepath: str, deployment_id: str = None) -> Deployment:
|
140
140
|
"""Creates a deployment for the nodepool.
|
141
141
|
|
142
142
|
Args:
|
143
|
-
deployment_id (str): The deployment ID for the deployment to create.
|
144
143
|
config_filepath (str): The path to the deployment config file.
|
144
|
+
deployment_id (str): New deployment ID for the deployment to create.
|
145
145
|
|
146
146
|
Returns:
|
147
147
|
Deployment: A Deployment object for the specified deployment ID.
|
@@ -149,7 +149,7 @@ class Nodepool(Lister, BaseClient):
|
|
149
149
|
Example:
|
150
150
|
>>> from clarifai.client.nodepool import Nodepool
|
151
151
|
>>> nodepool = Nodepool(nodepool_id="nodepool_id", user_id="user_id")
|
152
|
-
>>> deployment = nodepool.create_deployment(
|
152
|
+
>>> deployment = nodepool.create_deployment(config_filepath="config.yml")
|
153
153
|
"""
|
154
154
|
if not os.path.exists(config_filepath):
|
155
155
|
raise UserError(f"Deployment config file not found at {config_filepath}")
|
@@ -157,7 +157,8 @@ class Nodepool(Lister, BaseClient):
|
|
157
157
|
deployment_config = self._process_deployment_config(config_filepath)
|
158
158
|
|
159
159
|
if 'id' in deployment_config:
|
160
|
-
deployment_id
|
160
|
+
if deployment_id is None:
|
161
|
+
deployment_id = deployment_config['id']
|
161
162
|
deployment_config.pop('id')
|
162
163
|
|
163
164
|
request = service_pb2.PostDeploymentsRequest(
|
clarifai/client/user.py
CHANGED
@@ -222,13 +222,13 @@ class User(Lister, BaseClient):
|
|
222
222
|
compute_cluster["visibility"] = resources_pb2.Visibility(**compute_cluster["visibility"])
|
223
223
|
return compute_cluster
|
224
224
|
|
225
|
-
def create_compute_cluster(self,
|
226
|
-
|
225
|
+
def create_compute_cluster(self, config_filepath: str,
|
226
|
+
compute_cluster_id: str = None) -> ComputeCluster:
|
227
227
|
"""Creates a compute cluster for the user.
|
228
228
|
|
229
229
|
Args:
|
230
|
-
compute_cluster_id (str): The compute cluster ID for the compute cluster to create.
|
231
230
|
config_filepath (str): The path to the compute cluster config file.
|
231
|
+
compute_cluster_id (str): New compute cluster ID for the compute cluster to create.
|
232
232
|
|
233
233
|
Returns:
|
234
234
|
ComputeCluster: A Compute Cluster object for the specified compute cluster ID.
|
@@ -236,7 +236,7 @@ class User(Lister, BaseClient):
|
|
236
236
|
Example:
|
237
237
|
>>> from clarifai.client.user import User
|
238
238
|
>>> client = User(user_id="user_id")
|
239
|
-
>>> compute_cluster = client.create_compute_cluster(
|
239
|
+
>>> compute_cluster = client.create_compute_cluster(config_filepath="config.yml")
|
240
240
|
"""
|
241
241
|
if not os.path.exists(config_filepath):
|
242
242
|
raise UserError(f"Compute Cluster config file not found at {config_filepath}")
|
@@ -244,7 +244,8 @@ class User(Lister, BaseClient):
|
|
244
244
|
compute_cluster_config = self._process_compute_cluster_config(config_filepath)
|
245
245
|
|
246
246
|
if 'id' in compute_cluster_config:
|
247
|
-
compute_cluster_id
|
247
|
+
if compute_cluster_id is None:
|
248
|
+
compute_cluster_id = compute_cluster_config['id']
|
248
249
|
compute_cluster_config.pop('id')
|
249
250
|
|
250
251
|
request = service_pb2.PostComputeClustersRequest(
|
clarifai/utils/cli.py
CHANGED
@@ -5,6 +5,11 @@ import pkgutil
|
|
5
5
|
import click
|
6
6
|
import yaml
|
7
7
|
|
8
|
+
from rich.console import Console
|
9
|
+
from rich.panel import Panel
|
10
|
+
from rich.style import Style
|
11
|
+
from rich.text import Text
|
12
|
+
|
8
13
|
|
9
14
|
def from_yaml(filename: str):
|
10
15
|
try:
|
@@ -43,3 +48,23 @@ def load_command_modules():
|
|
43
48
|
for _, module_name, _ in pkgutil.iter_modules([package_dir]):
|
44
49
|
if module_name != 'base': # Skip the base.py file itself
|
45
50
|
importlib.import_module(f'clarifai.cli.{module_name}')
|
51
|
+
|
52
|
+
|
53
|
+
def display_co_resources(response, resource_type):
|
54
|
+
"""Display compute orchestration resources listing results using rich."""
|
55
|
+
|
56
|
+
console = Console()
|
57
|
+
panel = Panel(
|
58
|
+
Text(f"List of {resource_type}s", justify="center"),
|
59
|
+
title="",
|
60
|
+
style=Style(color="blue", bold=True),
|
61
|
+
border_style="green",
|
62
|
+
width=60)
|
63
|
+
console.print(panel)
|
64
|
+
for indx, item in enumerate(list(response)):
|
65
|
+
panel = Panel(
|
66
|
+
"\n".join([f"{'ID'}: {item.id}", f"{'Description'}: {item.description}"]),
|
67
|
+
title=f"{resource_type} {(indx + 1)}",
|
68
|
+
border_style="green",
|
69
|
+
width=60)
|
70
|
+
console.print(panel)
|
@@ -1,26 +1,30 @@
|
|
1
|
-
clarifai/__init__.py,sha256=
|
1
|
+
clarifai/__init__.py,sha256=iP2iq6azkvKNWyZGbbMP-neuljcKozm4vbYLd6OYWHg,24
|
2
2
|
clarifai/cli.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
clarifai/errors.py,sha256=RwzTajwds51wLD0MVlMC5kcpBnzRpreDLlazPSBZxrg,2605
|
4
4
|
clarifai/versions.py,sha256=jctnczzfGk_S3EnVqb2FjRKfSREkNmvNEwAAa_VoKiQ,222
|
5
|
+
clarifai/cli/README.md,sha256=YGApHfeUyu5P0Pdth-mqQCQftWHDxz6bugDlvDXDhOE,1942
|
5
6
|
clarifai/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
clarifai/cli/base.py,sha256=
|
7
|
-
clarifai/cli/
|
7
|
+
clarifai/cli/base.py,sha256=okuBNlMmLEQw9-0f4yzemCtneNNRTVXUugCwD58-ZtQ,3417
|
8
|
+
clarifai/cli/compute_cluster.py,sha256=N2dNQNJEPg9nxsb8x2igEzYuGRzjn7l4kNttjFIxmhI,1827
|
9
|
+
clarifai/cli/deployment.py,sha256=sUEuz5-rtozMx8deVcJXLi6lHsP2jc8x3y2MpUAVfqY,2506
|
10
|
+
clarifai/cli/model.py,sha256=lp_5FGO-lWb07c7nNHEsJ6NA0mxVyvL3wqU5N-_sbEU,1934
|
11
|
+
clarifai/cli/nodepool.py,sha256=yihxS_rIFoBBKzRlqBX8Ab42iPpBMJrJFsk8saph6ms,3049
|
8
12
|
clarifai/client/__init__.py,sha256=xI1U0l5AZdRThvQAXCLsd9axxyFzXXJ22m8LHqVjQRU,662
|
9
13
|
clarifai/client/app.py,sha256=6pckYme1urV2YJjLIYfeZ-vH0Z5YSQa51jzIMcEfwug,38342
|
10
14
|
clarifai/client/base.py,sha256=hSHOqkXbSKyaRDeylMMnkhUHCAHhEqno4KI0CXGziBA,7536
|
11
|
-
clarifai/client/compute_cluster.py,sha256=
|
15
|
+
clarifai/client/compute_cluster.py,sha256=EvW9TJjPvInUlggfg1A98sxoWH8_PY5rCVXZhsj6ac0,8705
|
12
16
|
clarifai/client/dataset.py,sha256=Xt8M9sP7RLeAqqTu17-8cpupThhkU9n_bl6jXtG_25A,31148
|
13
17
|
clarifai/client/deployment.py,sha256=4gfvUvQY9adFS98B0vP9C5fR9OnDRV2JbUIdAkMymT8,2551
|
14
18
|
clarifai/client/input.py,sha256=smAZqvBEVJlM59PQ3KhqbA6HaKHRNlSyQCcw917SbJ0,44322
|
15
19
|
clarifai/client/lister.py,sha256=03KGMvs5RVyYqxLsSrWhNc34I8kiF1Ph0NeyEwu7nMU,2082
|
16
20
|
clarifai/client/model.py,sha256=WmLBPm_rDzbPR_Cxo8gnntBnPiWFt3gYKiiKuJ9lH04,84652
|
17
21
|
clarifai/client/module.py,sha256=FTkm8s9m-EaTKN7g9MnLhGJ9eETUfKG7aWZ3o1RshYs,4204
|
18
|
-
clarifai/client/nodepool.py,sha256=
|
22
|
+
clarifai/client/nodepool.py,sha256=la3vTFrO4LX8zm2eQ5jqf2L0-kQ63Dano8FibadoZbk,10152
|
19
23
|
clarifai/client/search.py,sha256=GaPWN6JmTQGZaCHr6U1yv0zqR6wKFl7i9IVLg2ul1CI,14254
|
20
|
-
clarifai/client/user.py,sha256=
|
24
|
+
clarifai/client/user.py,sha256=WOv66ww2wx9isIge3V-xTHCkqC6akl2jEGAxzT_Ugfs,17642
|
21
25
|
clarifai/client/workflow.py,sha256=BOmA1ilHxsw-yl_ZE1NOEshzV7owavnXTIG2UOD6PuA,12163
|
22
26
|
clarifai/client/auth/__init__.py,sha256=7EwR0NrozkAUwpUnCsqXvE_p0wqx_SelXlSpKShKJK0,136
|
23
|
-
clarifai/client/auth/helper.py,sha256=
|
27
|
+
clarifai/client/auth/helper.py,sha256=Ngw5IDkOWvnOz5YwViVk55z3mC52MyezLc0G3WxLqok,14643
|
24
28
|
clarifai/client/auth/register.py,sha256=2CMdBsoVLoTfjyksE6j7BM2tiEc73WKYvxnwDDgNn1k,536
|
25
29
|
clarifai/client/auth/stub.py,sha256=xy4-fV0W8keCgXld4eOVzFQEIKxOktNwtL5bLztReug,4940
|
26
30
|
clarifai/constants/base.py,sha256=ogmFSZYoF0YhGjHg5aiOc3MLqPr_poKAls6xaD0_C3U,89
|
@@ -75,7 +79,7 @@ clarifai/runners/utils/url_fetcher.py,sha256=-Hwjb1SURszn7zUVwi4Of0-nrksfZy-uqT4
|
|
75
79
|
clarifai/schema/search.py,sha256=JjTi8ammJgZZ2OGl4K6tIA4zEJ1Fr2ASZARXavI1j5c,2448
|
76
80
|
clarifai/urls/helper.py,sha256=tjoMGGHuWX68DUB0pk4MEjrmFsClUAQj2jmVEM_Sy78,4751
|
77
81
|
clarifai/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
78
|
-
clarifai/utils/cli.py,sha256=
|
82
|
+
clarifai/utils/cli.py,sha256=O6ukcQb05pFIgdQKWn0tL0AALAjT3U3DFRjd_GgPCvk,1918
|
79
83
|
clarifai/utils/constants.py,sha256=MG_iHnSwNEyUZOpvsrTicNwaT4CIjmlK_Ixk_qqEX8g,142
|
80
84
|
clarifai/utils/logging.py,sha256=rhutBRQJLtkNRz8IErNCgbIpvtl2fQ3D2otYcGqd3-Q,11565
|
81
85
|
clarifai/utils/misc.py,sha256=ptjt1NtteDT0EhrPoyQ7mgWtvoAQ-XNncQaZvNHb0KI,2253
|
@@ -88,9 +92,9 @@ clarifai/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
88
92
|
clarifai/workflows/export.py,sha256=vICRhIreqDSShxLKjHNM2JwzKsf1B4fdXB0ciMcA70k,1945
|
89
93
|
clarifai/workflows/utils.py,sha256=nGeB_yjVgUO9kOeKTg4OBBaBz-AwXI3m-huSVj-9W18,1924
|
90
94
|
clarifai/workflows/validate.py,sha256=yJq03MaJqi5AK3alKGJJBR89xmmjAQ31sVufJUiOqY8,2556
|
91
|
-
clarifai-10.
|
92
|
-
clarifai-10.
|
93
|
-
clarifai-10.
|
94
|
-
clarifai-10.
|
95
|
-
clarifai-10.
|
96
|
-
clarifai-10.
|
95
|
+
clarifai-10.10.0.dist-info/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
|
96
|
+
clarifai-10.10.0.dist-info/METADATA,sha256=PajE2Uj7fFkxXzercHRxBVxoYmOaqauF6yoWwLS2jU4,19566
|
97
|
+
clarifai-10.10.0.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
98
|
+
clarifai-10.10.0.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
|
99
|
+
clarifai-10.10.0.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
|
100
|
+
clarifai-10.10.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|