clarifai 9.8.2__py3-none-any.whl → 9.9.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.
Files changed (62) hide show
  1. clarifai/client/app.py +17 -0
  2. clarifai/client/search.py +173 -0
  3. clarifai/client/workflow.py +1 -1
  4. clarifai/constants/search.py +2 -0
  5. clarifai/models/model_serving/README.md +3 -3
  6. clarifai/models/model_serving/docs/dependencies.md +5 -10
  7. clarifai/models/model_serving/examples/image_classification/age_vit/requirements.txt +1 -0
  8. clarifai/models/model_serving/examples/text_classification/xlm-roberta/requirements.txt +1 -0
  9. clarifai/models/model_serving/examples/text_to_image/sd-v1.5/requirements.txt +1 -0
  10. clarifai/models/model_serving/examples/text_to_text/bart-summarize/requirements.txt +1 -0
  11. clarifai/models/model_serving/examples/visual_detection/yolov5x/requirements.txt +1 -1
  12. clarifai/models/model_serving/examples/visual_embedding/vit-base/requirements.txt +1 -0
  13. clarifai/models/model_serving/examples/visual_segmentation/segformer-b2/requirements.txt +1 -0
  14. clarifai/models/model_serving/pb_model_repository.py +1 -3
  15. clarifai/schema/search.py +60 -0
  16. clarifai/versions.py +1 -1
  17. clarifai/workflows/export.py +9 -8
  18. clarifai/workflows/utils.py +1 -1
  19. clarifai/workflows/validate.py +1 -1
  20. {clarifai-9.8.2.dist-info → clarifai-9.9.0.dist-info}/METADATA +1 -1
  21. {clarifai-9.8.2.dist-info → clarifai-9.9.0.dist-info}/RECORD +44 -56
  22. clarifai_utils/client/app.py +17 -0
  23. clarifai_utils/client/search.py +173 -0
  24. clarifai_utils/client/workflow.py +1 -1
  25. clarifai_utils/constants/search.py +2 -0
  26. clarifai_utils/models/model_serving/README.md +3 -3
  27. clarifai_utils/models/model_serving/docs/dependencies.md +5 -10
  28. clarifai_utils/models/model_serving/examples/image_classification/age_vit/requirements.txt +1 -0
  29. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/requirements.txt +1 -0
  30. clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/requirements.txt +1 -0
  31. clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/requirements.txt +1 -0
  32. clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/requirements.txt +1 -1
  33. clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/requirements.txt +1 -0
  34. clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/requirements.txt +1 -0
  35. clarifai_utils/models/model_serving/pb_model_repository.py +1 -3
  36. clarifai_utils/schema/search.py +60 -0
  37. clarifai_utils/versions.py +1 -1
  38. clarifai_utils/workflows/export.py +9 -8
  39. clarifai_utils/workflows/utils.py +1 -1
  40. clarifai_utils/workflows/validate.py +1 -1
  41. clarifai/models/model_serving/envs/triton_conda-cp3.8-torch1.13.1-19f97078.yaml +0 -35
  42. clarifai/models/model_serving/envs/triton_conda-cp3.8-torch2.0.0-ce980f28.yaml +0 -51
  43. clarifai/models/model_serving/examples/image_classification/age_vit/triton_conda.yaml +0 -1
  44. clarifai/models/model_serving/examples/text_classification/xlm-roberta/triton_conda.yaml +0 -1
  45. clarifai/models/model_serving/examples/text_to_image/sd-v1.5/triton_conda.yaml +0 -1
  46. clarifai/models/model_serving/examples/text_to_text/bart-summarize/triton_conda.yaml +0 -1
  47. clarifai/models/model_serving/examples/visual_detection/yolov5x/triton_conda.yaml +0 -1
  48. clarifai/models/model_serving/examples/visual_embedding/vit-base/triton_conda.yaml +0 -1
  49. clarifai/models/model_serving/examples/visual_segmentation/segformer-b2/triton_conda.yaml +0 -1
  50. clarifai_utils/models/model_serving/envs/triton_conda-cp3.8-torch1.13.1-19f97078.yaml +0 -35
  51. clarifai_utils/models/model_serving/envs/triton_conda-cp3.8-torch2.0.0-ce980f28.yaml +0 -51
  52. clarifai_utils/models/model_serving/examples/image_classification/age_vit/triton_conda.yaml +0 -1
  53. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/triton_conda.yaml +0 -1
  54. clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/triton_conda.yaml +0 -1
  55. clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/triton_conda.yaml +0 -1
  56. clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/triton_conda.yaml +0 -1
  57. clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/triton_conda.yaml +0 -1
  58. clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/triton_conda.yaml +0 -1
  59. {clarifai-9.8.2.dist-info → clarifai-9.9.0.dist-info}/LICENSE +0 -0
  60. {clarifai-9.8.2.dist-info → clarifai-9.9.0.dist-info}/WHEEL +0 -0
  61. {clarifai-9.8.2.dist-info → clarifai-9.9.0.dist-info}/entry_points.txt +0 -0
  62. {clarifai-9.8.2.dist-info → clarifai-9.9.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,60 @@
1
+ from schema import And, Optional, Regex, Schema
2
+
3
+
4
+ def get_schema() -> Schema:
5
+ """Initialize the schema for rank and filter.
6
+
7
+ This schema validates:
8
+
9
+ - Rank and filter must be a list
10
+ - Each item in the list must be a dict
11
+ - The dict can contain these optional keys:
12
+ - 'image_url': Valid URL string
13
+ - 'text_raw': Non-empty string
14
+ - 'metadata': Dict
15
+ - 'image_bytes': Bytes
16
+ - 'geo_point': Dict with 'longitude', 'latitude' and 'geo_limit' as float, float and int respectively
17
+ - 'concepts': List where each item is a concept dict
18
+ - Concept dict requires at least one of:
19
+ - 'name': Non-empty string with dashes/underscores
20
+ - 'id': Non-empty string
21
+ - 'language': Non-empty string
22
+ - 'value': 0 or 1 integer
23
+
24
+ Returns:
25
+ Schema: The schema for rank and filter.
26
+ """
27
+ # Schema for a single concept
28
+ concept_schema = Schema({
29
+ Optional('value'):
30
+ And(int, lambda x: x in [0, 1]),
31
+ Optional('id'):
32
+ And(str, len),
33
+ Optional('language'):
34
+ And(str, len),
35
+ # Non-empty strings with internal dashes and underscores.
36
+ Optional('name'):
37
+ And(str, len, Regex(r'^[0-9A-Za-z]+([-_][0-9A-Za-z]+)*$'))
38
+ })
39
+
40
+ # Schema for a rank or filter item
41
+ rank_filter_item_schema = Schema({
42
+ Optional('image_url'):
43
+ And(str, Regex(r'^https?://')),
44
+ Optional('text_raw'):
45
+ And(str, len),
46
+ Optional('metadata'):
47
+ dict,
48
+ Optional('image_bytes'):
49
+ bytes,
50
+ Optional('geo_point'): {
51
+ 'longitude': float,
52
+ 'latitude': float,
53
+ 'geo_limit': int
54
+ },
55
+ Optional("concepts"):
56
+ And(list, lambda x: all(concept_schema.is_valid(item) and len(item) > 0 for item in x)),
57
+ })
58
+
59
+ # Schema for rank and filter args
60
+ return Schema([rank_filter_item_schema])
@@ -1,6 +1,6 @@
1
1
  import os
2
2
 
3
- CLIENT_VERSION = '9.8.2'
3
+ CLIENT_VERSION = '9.9.0'
4
4
  OS_VER = os.sys.platform
5
5
  PYTHON_VERSION = '.'.join(
6
6
  map(str, [os.sys.version_info.major, os.sys.version_info.minor, os.sys.version_info.micro]))
@@ -1,14 +1,13 @@
1
- import yaml
1
+ from typing import Any, Dict
2
2
 
3
+ import yaml
3
4
  from google.protobuf.json_format import MessageToDict
4
5
 
5
6
  VALID_YAML_KEYS = ["workflow", "id", "nodes", "node_inputs", "node_id", "model"]
6
7
 
7
8
 
8
9
  def clean_up_unused_keys(wf: dict):
9
- """Removes unused keys from dict before exporting to yaml.
10
- Supports nested dicts.
11
- """
10
+ """Removes unused keys from dict before exporting to yaml. Supports nested dicts."""
12
11
  new_wf = dict()
13
12
  for key, val in wf.items():
14
13
  if key not in VALID_YAML_KEYS:
@@ -44,10 +43,12 @@ class Exporter:
44
43
  def __enter__(self):
45
44
  return self
46
45
 
47
- def parse(self):
46
+ def parse(self) -> Dict[str, Any]:
48
47
  """Reads a resources_pb2.Workflow object (e.g. from a GetWorkflow response)
49
- Returns a cleaned workflow dict.
50
- """
48
+
49
+ Returns:
50
+ dict: A dict representation of the workflow.
51
+ """
51
52
  if isinstance(self.wf, list):
52
53
  self.wf = self.wf[0]
53
54
  wf = {"workflow": MessageToDict(self.wf, preserving_proto_field_name=True)}
@@ -57,7 +58,7 @@ class Exporter:
57
58
 
58
59
  def export(self, out_path):
59
60
  with open(out_path, 'w') as out_file:
60
- yaml.dump(self.wf_dict["workflow"], out_file, default_flow_style=True)
61
+ yaml.dump(self.wf_dict["workflow"], out_file, default_flow_style=False)
61
62
 
62
63
  def __exit__(self, *args):
63
64
  self.close()
@@ -31,7 +31,7 @@ def is_same_yaml_model(api_model: resources_pb2.Model, yaml_model: Dict) -> bool
31
31
 
32
32
  yaml_model_from_api = dict()
33
33
  for k, _ in yaml_model.items():
34
- if k == "output_info":
34
+ if k == "output_info" and api_model["model_version"].get("output_info", "") != "":
35
35
  yaml_model_from_api[k] = dict(params=api_model["model_version"]["output_info"].get("params"))
36
36
  else:
37
37
  yaml_model_from_api[k] = api_model.get(k)
@@ -1,7 +1,7 @@
1
1
  from schema import And, Optional, Regex, Schema, SchemaError, Use
2
2
 
3
3
  # Non-empty, up to 32-character ASCII strings with internal dashes and underscores.
4
- _id_validator = And(str, lambda s: 0 < len(s) <= 32, Regex(r'^[0-9A-Za-z]+([-_][0-9A-Za-z]+)*$'))
4
+ _id_validator = And(str, lambda s: 0 < len(s) <= 48, Regex(r'^[0-9A-Za-z]+([-_][0-9A-Za-z]+)*$'))
5
5
 
6
6
  # 32-character hex string, converted to lower-case.
7
7
  _hex_id_validator = And(str, Use(str.lower), Regex(r'^[0-9a-f]{32}'))
@@ -1,35 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
2
- channels:
3
- - conda-forge
4
- dependencies:
5
- - _libgcc_mutex=0.1=conda_forge
6
- - _openmp_mutex=4.5=2_gnu
7
- - bzip2=1.0.8=h7f98852_4
8
- - ca-certificates=2022.12.7=ha878542_0
9
- - ld_impl_linux-64=2.40=h41732ed_0
10
- - libffi=3.4.2=h7f98852_5
11
- - libgcc-ng=12.2.0=h65d4601_19
12
- - libgomp=12.2.0=h65d4601_19
13
- - libnsl=2.0.0=h7f98852_0
14
- - libsqlite=3.40.0=h753d276_0
15
- - libuuid=2.32.1=h7f98852_1000
16
- - libzlib=1.2.13=h166bdaf_4
17
- - ncurses=6.3=h27087fc_1
18
- - openssl=3.0.8=h0b41bf4_0
19
- - pip=23.0.1=pyhd8ed1ab_0
20
- - python=3.8.16=he550d4f_1_cpython
21
- - readline=8.1.2=h0f457ee_0
22
- - setuptools=67.4.0=pyhd8ed1ab_0
23
- - tk=8.6.12=h27826a3_0
24
- - wheel=0.38.4=pyhd8ed1ab_0
25
- - xz=5.2.6=h166bdaf_0
26
- - pip:
27
- - numpy==1.24.2
28
- - nvidia-cublas-cu11==11.10.3.66
29
- - nvidia-cuda-nvrtc-cu11==11.7.99
30
- - nvidia-cuda-runtime-cu11==11.7.99
31
- - nvidia-cudnn-cu11==8.5.0.96
32
- - opencv-python==4.7.0.72
33
- - pillow==9.4.0
34
- - torch==1.13.1
35
- - typing-extensions==4.5.0
@@ -1,51 +0,0 @@
1
- name: triton_conda-cp3.8-torch2.0.0-ce980f28
2
- channels:
3
- - conda-forge
4
- dependencies:
5
- - _libgcc_mutex=0.1=conda_forge
6
- - _openmp_mutex=4.5=2_gnu
7
- - bzip2=1.0.8=h7f98852_4
8
- - ca-certificates=2023.5.7=hbcca054_0
9
- - ld_impl_linux-64=2.40=h41732ed_0
10
- - libffi=3.4.2=h7f98852_5
11
- - libgcc-ng=13.1.0=he5830b7_0
12
- - libgomp=13.1.0=he5830b7_0
13
- - libnsl=2.0.0=h7f98852_0
14
- - libsqlite=3.42.0=h2797004_0
15
- - libuuid=2.38.1=h0b41bf4_0
16
- - libzlib=1.2.13=hd590300_5
17
- - ncurses=6.4=hcb278e6_0
18
- - openssl=3.1.1=hd590300_1
19
- - pip=23.1.2=pyhd8ed1ab_0
20
- - python=3.8.17=he550d4f_0_cpython
21
- - readline=8.2=h8228510_1
22
- - setuptools=68.0.0=pyhd8ed1ab_0
23
- - tk=8.6.12=h27826a3_0
24
- - wheel=0.40.0=pyhd8ed1ab_0
25
- - xz=5.2.6=h166bdaf_0
26
- - pip:
27
- - cmake==3.26.4
28
- - filelock==3.12.2
29
- - jinja2==3.1.2
30
- - lit==16.0.6
31
- - markupsafe==2.1.3
32
- - mpmath==1.3.0
33
- - networkx==3.1
34
- - numpy==1.24.2
35
- - nvidia-cublas-cu11==11.10.3.66
36
- - nvidia-cuda-cupti-cu11==11.7.101
37
- - nvidia-cuda-nvrtc-cu11==11.7.99
38
- - nvidia-cuda-runtime-cu11==11.7.99
39
- - nvidia-cudnn-cu11==8.5.0.96
40
- - nvidia-cufft-cu11==10.9.0.58
41
- - nvidia-curand-cu11==10.2.10.91
42
- - nvidia-cusolver-cu11==11.4.0.1
43
- - nvidia-cusparse-cu11==11.7.4.91
44
- - nvidia-nccl-cu11==2.14.3
45
- - nvidia-nvtx-cu11==11.7.91
46
- - opencv-python==4.7.0.72
47
- - pillow==9.4.0
48
- - sympy==1.12
49
- - torch==2.0.0
50
- - triton==2.0.0
51
- - typing-extensions==4.5.0
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1,35 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
2
- channels:
3
- - conda-forge
4
- dependencies:
5
- - _libgcc_mutex=0.1=conda_forge
6
- - _openmp_mutex=4.5=2_gnu
7
- - bzip2=1.0.8=h7f98852_4
8
- - ca-certificates=2022.12.7=ha878542_0
9
- - ld_impl_linux-64=2.40=h41732ed_0
10
- - libffi=3.4.2=h7f98852_5
11
- - libgcc-ng=12.2.0=h65d4601_19
12
- - libgomp=12.2.0=h65d4601_19
13
- - libnsl=2.0.0=h7f98852_0
14
- - libsqlite=3.40.0=h753d276_0
15
- - libuuid=2.32.1=h7f98852_1000
16
- - libzlib=1.2.13=h166bdaf_4
17
- - ncurses=6.3=h27087fc_1
18
- - openssl=3.0.8=h0b41bf4_0
19
- - pip=23.0.1=pyhd8ed1ab_0
20
- - python=3.8.16=he550d4f_1_cpython
21
- - readline=8.1.2=h0f457ee_0
22
- - setuptools=67.4.0=pyhd8ed1ab_0
23
- - tk=8.6.12=h27826a3_0
24
- - wheel=0.38.4=pyhd8ed1ab_0
25
- - xz=5.2.6=h166bdaf_0
26
- - pip:
27
- - numpy==1.24.2
28
- - nvidia-cublas-cu11==11.10.3.66
29
- - nvidia-cuda-nvrtc-cu11==11.7.99
30
- - nvidia-cuda-runtime-cu11==11.7.99
31
- - nvidia-cudnn-cu11==8.5.0.96
32
- - opencv-python==4.7.0.72
33
- - pillow==9.4.0
34
- - torch==1.13.1
35
- - typing-extensions==4.5.0
@@ -1,51 +0,0 @@
1
- name: triton_conda-cp3.8-torch2.0.0-ce980f28
2
- channels:
3
- - conda-forge
4
- dependencies:
5
- - _libgcc_mutex=0.1=conda_forge
6
- - _openmp_mutex=4.5=2_gnu
7
- - bzip2=1.0.8=h7f98852_4
8
- - ca-certificates=2023.5.7=hbcca054_0
9
- - ld_impl_linux-64=2.40=h41732ed_0
10
- - libffi=3.4.2=h7f98852_5
11
- - libgcc-ng=13.1.0=he5830b7_0
12
- - libgomp=13.1.0=he5830b7_0
13
- - libnsl=2.0.0=h7f98852_0
14
- - libsqlite=3.42.0=h2797004_0
15
- - libuuid=2.38.1=h0b41bf4_0
16
- - libzlib=1.2.13=hd590300_5
17
- - ncurses=6.4=hcb278e6_0
18
- - openssl=3.1.1=hd590300_1
19
- - pip=23.1.2=pyhd8ed1ab_0
20
- - python=3.8.17=he550d4f_0_cpython
21
- - readline=8.2=h8228510_1
22
- - setuptools=68.0.0=pyhd8ed1ab_0
23
- - tk=8.6.12=h27826a3_0
24
- - wheel=0.40.0=pyhd8ed1ab_0
25
- - xz=5.2.6=h166bdaf_0
26
- - pip:
27
- - cmake==3.26.4
28
- - filelock==3.12.2
29
- - jinja2==3.1.2
30
- - lit==16.0.6
31
- - markupsafe==2.1.3
32
- - mpmath==1.3.0
33
- - networkx==3.1
34
- - numpy==1.24.2
35
- - nvidia-cublas-cu11==11.10.3.66
36
- - nvidia-cuda-cupti-cu11==11.7.101
37
- - nvidia-cuda-nvrtc-cu11==11.7.99
38
- - nvidia-cuda-runtime-cu11==11.7.99
39
- - nvidia-cudnn-cu11==8.5.0.96
40
- - nvidia-cufft-cu11==10.9.0.58
41
- - nvidia-curand-cu11==10.2.10.91
42
- - nvidia-cusolver-cu11==11.4.0.1
43
- - nvidia-cusparse-cu11==11.7.4.91
44
- - nvidia-nccl-cu11==2.14.3
45
- - nvidia-nvtx-cu11==11.7.91
46
- - opencv-python==4.7.0.72
47
- - pillow==9.4.0
48
- - sympy==1.12
49
- - torch==2.0.0
50
- - triton==2.0.0
51
- - typing-extensions==4.5.0
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078
@@ -1 +0,0 @@
1
- name: triton_conda-cp3.8-torch1.13.1-19f97078