clarifai 10.8.7__py3-none-any.whl → 10.8.8__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "10.8.7"
1
+ __version__ = "10.8.8"
@@ -13,6 +13,11 @@ class ModelServicer(service_pb2_grpc.V2Servicer):
13
13
  """
14
14
 
15
15
  def __init__(self, model_class):
16
+ """
17
+ Args:
18
+ model_class: The class that will handle the model logic. Must implement predict(),
19
+ generate(), stream().
20
+ """
16
21
  self.model_class = model_class
17
22
 
18
23
  def PostModelOutputs(self, request: service_pb2.PostModelOutputsRequest,
@@ -255,7 +255,7 @@ class ModelUploader:
255
255
  flush=True)
256
256
  print()
257
257
  if response.status.code != status_code_pb2.MODEL_BUILDING:
258
- logger.error(f"Failed to upload model version: {response.status.description}")
258
+ logger.error(f"Failed to upload model version: {response}")
259
259
  return
260
260
  model_version_id = response.model_version_id
261
261
  logger.info(f"Created Model Version ID: {model_version_id}")
@@ -269,9 +269,9 @@ class ModelUploader:
269
269
  chunk_size = int(127 * 1024 * 1024) # 127MB chunk size
270
270
  num_chunks = (file_size // chunk_size) + 1
271
271
  logger.info("Uploading file...")
272
- logger.info("File size: ", file_size)
273
- logger.info("Chunk size: ", chunk_size)
274
- logger.info("Number of chunks: ", num_chunks)
272
+ logger.info(f"File size: {file_size}")
273
+ logger.info(f"Chunk size: {chunk_size}")
274
+ logger.info(f"Number of chunks: {num_chunks}")
275
275
  read_so_far = 0
276
276
  for part_id in range(num_chunks):
277
277
  try:
@@ -317,8 +317,7 @@ class ModelUploader:
317
317
  ))
318
318
  status_code = resp.model_version.status.code
319
319
  if status_code == status_code_pb2.MODEL_BUILDING:
320
- logger.info(
321
- f"Model is building... (elapsed {time.time() - st:.1f}s)", end='\r', flush=True)
320
+ print(f"Model is building... (elapsed {time.time() - st:.1f}s)", end='\r', flush=True)
322
321
  time.sleep(1)
323
322
  elif status_code == status_code_pb2.MODEL_TRAINED:
324
323
  logger.info("\nModel build complete!")
@@ -15,6 +15,7 @@ from clarifai_protocol import BaseRunner
15
15
  from clarifai_protocol.utils.grpc_server import GRPCServer
16
16
 
17
17
  from clarifai.runners.models.model_servicer import ModelServicer
18
+ from clarifai.runners.models.model_upload import ModelUploader
18
19
  from clarifai.utils.logging import logger
19
20
 
20
21
 
@@ -93,21 +94,26 @@ def main():
93
94
 
94
95
  MyRunner = classes[0]
95
96
 
96
- # initialize the Runner class. This is what the user implements.
97
- # (Note) do we want to set runner_id, nodepool_id, compute_cluster_id, base_url, num_parallel_polls as env vars? or as args?
98
- runner = MyRunner(
99
- runner_id=os.environ["CLARIFAI_RUNNER_ID"],
100
- nodepool_id=os.environ["CLARIFAI_NODEPOOL_ID"],
101
- compute_cluster_id=os.environ["CLARIFAI_COMPUTE_CLUSTER_ID"],
102
- base_url=os.environ["CLARIFAI_API_BASE"],
103
- num_parallel_polls=int(os.environ.get("CLARIFAI_NUM_THREADS", 1)),
104
- )
105
-
106
- # initialize the servicer
107
- servicer = ModelServicer(runner)
108
-
109
97
  # Setup the grpc server for local development.
110
98
  if parsed_args.start_dev_server:
99
+
100
+ # We validate that we have checkpoints downloaded before constructing MyRunner which
101
+ # will call load_model()
102
+ uploader = ModelUploader(parsed_args.model_path)
103
+ uploader.download_checkpoints()
104
+
105
+ # initialize the Runner class. This is what the user implements.
106
+ # we aren't going to call runner.start() to engage with the API so IDs are not necessary.
107
+ runner = MyRunner(
108
+ runner_id="n/a",
109
+ nodepool_id="n/a",
110
+ compute_cluster_id="n/a",
111
+ health_check_port=None, # not needed when running local server
112
+ )
113
+
114
+ # initialize the servicer with the runner so that it gets the predict(), generate(), stream() classes.
115
+ servicer = ModelServicer(runner)
116
+
111
117
  server = GRPCServer(
112
118
  futures.ThreadPoolExecutor(
113
119
  max_workers=parsed_args.pool_size,
@@ -121,9 +127,18 @@ def main():
121
127
  service_pb2_grpc.add_V2Servicer_to_server(servicer, server)
122
128
  server.start()
123
129
  logger.info("Started server on port %s", parsed_args.port)
124
- # server.wait_for_termination() # won't get here currently.
125
-
126
- runner.start() # start the runner loop to fetch work from the API.
130
+ server.wait_for_termination()
131
+ else: # start the runner with the proper env variables and as a runner protocol.
132
+
133
+ # initialize the Runner class. This is what the user implements.
134
+ runner = MyRunner(
135
+ runner_id=os.environ["CLARIFAI_RUNNER_ID"],
136
+ nodepool_id=os.environ["CLARIFAI_NODEPOOL_ID"],
137
+ compute_cluster_id=os.environ["CLARIFAI_COMPUTE_CLUSTER_ID"],
138
+ base_url=os.environ["CLARIFAI_API_BASE"],
139
+ num_parallel_polls=int(os.environ.get("CLARIFAI_NUM_THREADS", 1)),
140
+ )
141
+ runner.start() # start the runner to fetch work from the API.
127
142
 
128
143
 
129
144
  if __name__ == '__main__':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clarifai
3
- Version: 10.8.7
3
+ Version: 10.8.8
4
4
  Summary: Clarifai Python SDK
5
5
  Home-page: https://github.com/Clarifai/clarifai-python
6
6
  Author: Clarifai
@@ -21,7 +21,7 @@ Requires-Python: >=3.8
21
21
  Description-Content-Type: text/markdown
22
22
  License-File: LICENSE
23
23
  Requires-Dist: clarifai-grpc >=10.8.7
24
- Requires-Dist: clarifai-protocol >=0.0.4
24
+ Requires-Dist: clarifai-protocol >=0.0.6
25
25
  Requires-Dist: numpy >=1.22.0
26
26
  Requires-Dist: tqdm >=4.65.0
27
27
  Requires-Dist: tritonclient >=2.34.0
@@ -1,4 +1,4 @@
1
- clarifai/__init__.py,sha256=rJghd8fTbSCfCAow2Dmd1bS2hdZ2VQdNcu2IHtIH5vU,23
1
+ clarifai/__init__.py,sha256=R5TlZkVSY_3KONgwTjYGkLjWDowTwpSZI-Sd8aiRjAU,23
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
@@ -54,15 +54,15 @@ clarifai/rag/__init__.py,sha256=wu3PzAzo7uqgrEzuaC9lY_3gj1HFiR3GU3elZIKTT5g,40
54
54
  clarifai/rag/rag.py,sha256=L10TcV9E0PF1aJ2Nn1z1x6WVoUoGxbKt20lQXg8ksqo,12594
55
55
  clarifai/rag/utils.py,sha256=yr1jAcbpws4vFGBqlAwPPE7v1DRba48g8gixLFw8OhQ,4070
56
56
  clarifai/runners/__init__.py,sha256=3vr4RVvN1IRy2SxJpyycAAvrUBbH-mXR7pqUmu4w36A,412
57
- clarifai/runners/server.py,sha256=M6TaNy5gWgAJG29ZkUgzGThVNnWpWJerIiFINk2X-j4,4259
57
+ clarifai/runners/server.py,sha256=CVLrv2DjzCvKVXcJ4SWvcFWUZq0bdlBmyEpfVlfgT2A,4902
58
58
  clarifai/runners/dockerfile_template/Dockerfile.cpu.template,sha256=lJw28GwMHEGO1uaDmEk2xb-Xx4y5pr_YY2Ipg25SLqo,1213
59
59
  clarifai/runners/dockerfile_template/Dockerfile.cuda.template,sha256=lwDwfeb9vtW3zVLBtlJYo44j02Am7FH2FABthwY47kY,4971
60
60
  clarifai/runners/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
61
61
  clarifai/runners/models/base_typed_model.py,sha256=OnAk08Lo2Y1fGiBc6JJ6UvJ8P435cTsikTNYDkStDpI,7790
62
62
  clarifai/runners/models/model_class.py,sha256=9JSPAr4U4K7xI0kSl-q0mHB06zknm2OR-8XIgBCto94,1611
63
63
  clarifai/runners/models/model_runner.py,sha256=3vzoastQxkGRDK8T9aojDsLNBb9A3IiKm6YmbFrE9S0,6241
64
- clarifai/runners/models/model_servicer.py,sha256=i10oxz4pb1NsTQwkyhccJ3URg88Qn63XiuoBRCnJn9w,2737
65
- clarifai/runners/models/model_upload.py,sha256=4MD85lYtUwEolZF9nxmiH0zRM69Altv-z3luDlvxEvM,14276
64
+ clarifai/runners/models/model_servicer.py,sha256=L5AuqKDZrsKOnv_Fz1Ld4-nzqehltLTsYAS7NIclm1g,2880
65
+ clarifai/runners/models/model_upload.py,sha256=vd9S_Oq33DO2RyWBcnjIaoll965VkkIYWwceKHaPAxk,14241
66
66
  clarifai/runners/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
67
  clarifai/runners/utils/data_handler.py,sha256=sxy9zlAgI6ETuxCQhUgEXAn2GCsaW1GxpK6GTaMne0g,6966
68
68
  clarifai/runners/utils/data_utils.py,sha256=R1iQ82TuQ9JwxCJk8yEB1Lyb0BYVhVbWJI9YDi1zGOs,318
@@ -83,9 +83,9 @@ clarifai/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
83
83
  clarifai/workflows/export.py,sha256=vICRhIreqDSShxLKjHNM2JwzKsf1B4fdXB0ciMcA70k,1945
84
84
  clarifai/workflows/utils.py,sha256=nGeB_yjVgUO9kOeKTg4OBBaBz-AwXI3m-huSVj-9W18,1924
85
85
  clarifai/workflows/validate.py,sha256=yJq03MaJqi5AK3alKGJJBR89xmmjAQ31sVufJUiOqY8,2556
86
- clarifai-10.8.7.dist-info/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
87
- clarifai-10.8.7.dist-info/METADATA,sha256=VwT5l9f_03dv65G4fsQgcHyEWZcsTOCBmpmodcj3OhE,19479
88
- clarifai-10.8.7.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
89
- clarifai-10.8.7.dist-info/entry_points.txt,sha256=qZOr_MIPG0dBBE1zringDJS_wXNGTAA_SQ-zcbmDHOw,82
90
- clarifai-10.8.7.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
91
- clarifai-10.8.7.dist-info/RECORD,,
86
+ clarifai-10.8.8.dist-info/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
87
+ clarifai-10.8.8.dist-info/METADATA,sha256=CjYP3nvJUa7UVUi8r5LAvzeMqaypddsVn6eGZ0nFSFA,19479
88
+ clarifai-10.8.8.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
89
+ clarifai-10.8.8.dist-info/entry_points.txt,sha256=qZOr_MIPG0dBBE1zringDJS_wXNGTAA_SQ-zcbmDHOw,82
90
+ clarifai-10.8.8.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
91
+ clarifai-10.8.8.dist-info/RECORD,,