clarifai 11.2.3rc1__py3-none-any.whl → 11.2.3rc3__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 (248) hide show
  1. clarifai/__init__.py +1 -1
  2. clarifai/__pycache__/__init__.cpython-310.pyc +0 -0
  3. clarifai/__pycache__/__init__.cpython-39.pyc +0 -0
  4. clarifai/__pycache__/errors.cpython-310.pyc +0 -0
  5. clarifai/__pycache__/versions.cpython-310.pyc +0 -0
  6. clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  7. clarifai/cli/__pycache__/base.cpython-310.pyc +0 -0
  8. clarifai/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
  9. clarifai/cli/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  10. clarifai/cli/__pycache__/deployment.cpython-310.pyc +0 -0
  11. clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
  12. clarifai/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
  13. clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
  14. clarifai/cli/base.py +81 -228
  15. clarifai/cli/compute_cluster.py +17 -25
  16. clarifai/cli/deployment.py +41 -67
  17. clarifai/cli/model.py +39 -26
  18. clarifai/cli/nodepool.py +40 -59
  19. clarifai/client/__pycache__/__init__.cpython-310.pyc +0 -0
  20. clarifai/client/__pycache__/__init__.cpython-39.pyc +0 -0
  21. clarifai/client/__pycache__/app.cpython-310.pyc +0 -0
  22. clarifai/client/__pycache__/app.cpython-39.pyc +0 -0
  23. clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
  24. clarifai/client/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  25. clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
  26. clarifai/client/__pycache__/deployment.cpython-310.pyc +0 -0
  27. clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
  28. clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
  29. clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
  30. clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
  31. clarifai/client/__pycache__/nodepool.cpython-310.pyc +0 -0
  32. clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
  33. clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
  34. clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
  35. clarifai/client/app.py +1 -1
  36. clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
  37. clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
  38. clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
  39. clarifai/client/auth/__pycache__/stub.cpython-310.pyc +0 -0
  40. clarifai/client/cli/__init__.py +0 -0
  41. clarifai/client/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  42. clarifai/client/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
  43. clarifai/client/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
  44. clarifai/client/cli/base_cli.py +88 -0
  45. clarifai/client/cli/model_cli.py +29 -0
  46. clarifai/client/model.py +159 -393
  47. clarifai/client/model_client.py +502 -0
  48. clarifai/constants/__pycache__/base.cpython-310.pyc +0 -0
  49. clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
  50. clarifai/constants/__pycache__/input.cpython-310.pyc +0 -0
  51. clarifai/constants/__pycache__/{model.cpython-312.pyc → model.cpython-310.pyc} +0 -0
  52. clarifai/constants/__pycache__/rag.cpython-310.pyc +0 -0
  53. clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
  54. clarifai/constants/__pycache__/workflow.cpython-310.pyc +0 -0
  55. clarifai/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
  56. clarifai/datasets/__pycache__/__init__.cpython-39.pyc +0 -0
  57. clarifai/datasets/export/__pycache__/__init__.cpython-310.pyc +0 -0
  58. clarifai/datasets/export/__pycache__/__init__.cpython-39.pyc +0 -0
  59. clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
  60. clarifai/datasets/upload/__pycache__/__init__.cpython-310.pyc +0 -0
  61. clarifai/datasets/upload/__pycache__/__init__.cpython-39.pyc +0 -0
  62. clarifai/datasets/upload/__pycache__/base.cpython-310.pyc +0 -0
  63. clarifai/datasets/upload/__pycache__/features.cpython-310.pyc +0 -0
  64. clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
  65. clarifai/datasets/upload/__pycache__/multimodal.cpython-310.pyc +0 -0
  66. clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
  67. clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
  68. clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-39.pyc +0 -0
  69. clarifai/models/__pycache__/__init__.cpython-39.pyc +0 -0
  70. clarifai/modules/__pycache__/__init__.cpython-39.pyc +0 -0
  71. clarifai/rag/__pycache__/__init__.cpython-310.pyc +0 -0
  72. clarifai/rag/__pycache__/__init__.cpython-39.pyc +0 -0
  73. clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
  74. clarifai/rag/__pycache__/rag.cpython-39.pyc +0 -0
  75. clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
  76. clarifai/runners/__init__.py +2 -7
  77. clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
  78. clarifai/runners/__pycache__/__init__.cpython-39.pyc +0 -0
  79. clarifai/runners/dockerfile_template/Dockerfile.cpu.template +31 -0
  80. clarifai/runners/dockerfile_template/Dockerfile.cuda.template +42 -0
  81. clarifai/runners/dockerfile_template/Dockerfile.nim +71 -0
  82. clarifai/runners/models/__pycache__/__init__.cpython-310.pyc +0 -0
  83. clarifai/runners/models/__pycache__/__init__.cpython-39.pyc +0 -0
  84. clarifai/runners/models/__pycache__/base_typed_model.cpython-310.pyc +0 -0
  85. clarifai/runners/models/__pycache__/base_typed_model.cpython-39.pyc +0 -0
  86. clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
  87. clarifai/runners/models/__pycache__/model_run_locally.cpython-310-pytest-7.1.2.pyc +0 -0
  88. clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc +0 -0
  89. clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc +0 -0
  90. clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
  91. clarifai/runners/models/model_builder.py +138 -51
  92. clarifai/runners/models/model_class.py +441 -28
  93. clarifai/runners/models/model_class_refract.py +80 -0
  94. clarifai/runners/models/model_run_locally.py +25 -89
  95. clarifai/runners/models/model_runner.py +8 -0
  96. clarifai/runners/models/model_servicer.py +11 -2
  97. clarifai/runners/models/model_upload.py +607 -0
  98. clarifai/runners/models/temp.py +25 -0
  99. clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  100. clarifai/runners/utils/__pycache__/__init__.cpython-38.pyc +0 -0
  101. clarifai/runners/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  102. clarifai/runners/utils/__pycache__/buffered_stream.cpython-310.pyc +0 -0
  103. clarifai/runners/utils/__pycache__/buffered_stream.cpython-38.pyc +0 -0
  104. clarifai/runners/utils/__pycache__/buffered_stream.cpython-39.pyc +0 -0
  105. clarifai/runners/utils/__pycache__/const.cpython-310.pyc +0 -0
  106. clarifai/runners/utils/__pycache__/constants.cpython-310.pyc +0 -0
  107. clarifai/runners/utils/__pycache__/constants.cpython-38.pyc +0 -0
  108. clarifai/runners/utils/__pycache__/constants.cpython-39.pyc +0 -0
  109. clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc +0 -0
  110. clarifai/runners/utils/__pycache__/data_handler.cpython-38.pyc +0 -0
  111. clarifai/runners/utils/__pycache__/data_handler.cpython-39.pyc +0 -0
  112. clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc +0 -0
  113. clarifai/runners/utils/__pycache__/data_utils.cpython-38.pyc +0 -0
  114. clarifai/runners/utils/__pycache__/data_utils.cpython-39.pyc +0 -0
  115. clarifai/runners/utils/__pycache__/grpc_server.cpython-310.pyc +0 -0
  116. clarifai/runners/utils/__pycache__/grpc_server.cpython-38.pyc +0 -0
  117. clarifai/runners/utils/__pycache__/grpc_server.cpython-39.pyc +0 -0
  118. clarifai/runners/utils/__pycache__/health.cpython-310.pyc +0 -0
  119. clarifai/runners/utils/__pycache__/health.cpython-38.pyc +0 -0
  120. clarifai/runners/utils/__pycache__/health.cpython-39.pyc +0 -0
  121. clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
  122. clarifai/runners/utils/__pycache__/logging.cpython-310.pyc +0 -0
  123. clarifai/runners/utils/__pycache__/logging.cpython-38.pyc +0 -0
  124. clarifai/runners/utils/__pycache__/logging.cpython-39.pyc +0 -0
  125. clarifai/runners/utils/__pycache__/stream_source.cpython-310.pyc +0 -0
  126. clarifai/runners/utils/__pycache__/stream_source.cpython-39.pyc +0 -0
  127. clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc +0 -0
  128. clarifai/runners/utils/__pycache__/url_fetcher.cpython-38.pyc +0 -0
  129. clarifai/runners/utils/__pycache__/url_fetcher.cpython-39.pyc +0 -0
  130. clarifai/runners/utils/code_script.py +217 -0
  131. clarifai/runners/utils/const.py +8 -9
  132. clarifai/runners/utils/data_handler.py +271 -210
  133. clarifai/runners/utils/data_handler_refract.py +213 -0
  134. clarifai/runners/utils/data_types.py +473 -0
  135. clarifai/runners/utils/data_utils.py +165 -0
  136. clarifai/runners/utils/loader.py +6 -36
  137. clarifai/runners/utils/logger.py +0 -0
  138. clarifai/runners/utils/method_signatures.py +518 -0
  139. clarifai/runners/utils/serializers.py +222 -0
  140. clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
  141. clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
  142. clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  143. clarifai/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  144. clarifai/utils/__pycache__/cli.cpython-310.pyc +0 -0
  145. clarifai/utils/__pycache__/constants.cpython-310.pyc +0 -0
  146. clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
  147. clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
  148. clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
  149. clarifai/utils/cli.py +33 -132
  150. clarifai/utils/constants.py +0 -4
  151. clarifai/utils/evaluation/__pycache__/__init__.cpython-39.pyc +0 -0
  152. clarifai/utils/evaluation/__pycache__/main.cpython-39.pyc +0 -0
  153. clarifai/utils/misc.py +0 -2
  154. clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
  155. clarifai/workflows/__pycache__/__init__.cpython-39.pyc +0 -0
  156. clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
  157. clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
  158. clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
  159. {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/METADATA +14 -3
  160. clarifai-11.2.3rc3.dist-info/RECORD +238 -0
  161. {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/WHEEL +1 -1
  162. clarifai/__pycache__/__init__.cpython-312.pyc +0 -0
  163. clarifai/__pycache__/errors.cpython-312.pyc +0 -0
  164. clarifai/__pycache__/versions.cpython-312.pyc +0 -0
  165. clarifai/cli/__pycache__/__init__.cpython-312.pyc +0 -0
  166. clarifai/cli/__pycache__/base.cpython-312.pyc +0 -0
  167. clarifai/cli/__pycache__/compute_cluster.cpython-312.pyc +0 -0
  168. clarifai/cli/__pycache__/deployment.cpython-312.pyc +0 -0
  169. clarifai/cli/__pycache__/model.cpython-312.pyc +0 -0
  170. clarifai/cli/__pycache__/nodepool.cpython-312.pyc +0 -0
  171. clarifai/client/__pycache__/__init__.cpython-312.pyc +0 -0
  172. clarifai/client/__pycache__/app.cpython-312.pyc +0 -0
  173. clarifai/client/__pycache__/base.cpython-312.pyc +0 -0
  174. clarifai/client/__pycache__/compute_cluster.cpython-312.pyc +0 -0
  175. clarifai/client/__pycache__/dataset.cpython-312.pyc +0 -0
  176. clarifai/client/__pycache__/deployment.cpython-312.pyc +0 -0
  177. clarifai/client/__pycache__/input.cpython-312.pyc +0 -0
  178. clarifai/client/__pycache__/lister.cpython-312.pyc +0 -0
  179. clarifai/client/__pycache__/model.cpython-312.pyc +0 -0
  180. clarifai/client/__pycache__/model_client.cpython-312.pyc +0 -0
  181. clarifai/client/__pycache__/module.cpython-312.pyc +0 -0
  182. clarifai/client/__pycache__/nodepool.cpython-312.pyc +0 -0
  183. clarifai/client/__pycache__/search.cpython-312.pyc +0 -0
  184. clarifai/client/__pycache__/user.cpython-312.pyc +0 -0
  185. clarifai/client/__pycache__/workflow.cpython-312.pyc +0 -0
  186. clarifai/client/auth/__pycache__/__init__.cpython-312.pyc +0 -0
  187. clarifai/client/auth/__pycache__/helper.cpython-312.pyc +0 -0
  188. clarifai/client/auth/__pycache__/register.cpython-312.pyc +0 -0
  189. clarifai/client/auth/__pycache__/stub.cpython-312.pyc +0 -0
  190. clarifai/constants/__pycache__/base.cpython-312.pyc +0 -0
  191. clarifai/constants/__pycache__/dataset.cpython-312.pyc +0 -0
  192. clarifai/constants/__pycache__/input.cpython-312.pyc +0 -0
  193. clarifai/constants/__pycache__/search.cpython-312.pyc +0 -0
  194. clarifai/constants/__pycache__/workflow.cpython-312.pyc +0 -0
  195. clarifai/datasets/__pycache__/__init__.cpython-312.pyc +0 -0
  196. clarifai/datasets/export/__pycache__/__init__.cpython-312.pyc +0 -0
  197. clarifai/datasets/export/__pycache__/inputs_annotations.cpython-312.pyc +0 -0
  198. clarifai/datasets/upload/__pycache__/__init__.cpython-312.pyc +0 -0
  199. clarifai/datasets/upload/__pycache__/base.cpython-312.pyc +0 -0
  200. clarifai/datasets/upload/__pycache__/features.cpython-312.pyc +0 -0
  201. clarifai/datasets/upload/__pycache__/image.cpython-312.pyc +0 -0
  202. clarifai/datasets/upload/__pycache__/multimodal.cpython-312.pyc +0 -0
  203. clarifai/datasets/upload/__pycache__/text.cpython-312.pyc +0 -0
  204. clarifai/datasets/upload/__pycache__/utils.cpython-312.pyc +0 -0
  205. clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-312.pyc +0 -0
  206. clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-312.pyc +0 -0
  207. clarifai/modules/__pycache__/__init__.cpython-312.pyc +0 -0
  208. clarifai/modules/__pycache__/css.cpython-312.pyc +0 -0
  209. clarifai/runners/__pycache__/__init__.cpython-312.pyc +0 -0
  210. clarifai/runners/__pycache__/server.cpython-312.pyc +0 -0
  211. clarifai/runners/models/__pycache__/__init__.cpython-312.pyc +0 -0
  212. clarifai/runners/models/__pycache__/base_typed_model.cpython-312.pyc +0 -0
  213. clarifai/runners/models/__pycache__/model_builder.cpython-312.pyc +0 -0
  214. clarifai/runners/models/__pycache__/model_class.cpython-312.pyc +0 -0
  215. clarifai/runners/models/__pycache__/model_run_locally.cpython-312.pyc +0 -0
  216. clarifai/runners/models/__pycache__/model_runner.cpython-312.pyc +0 -0
  217. clarifai/runners/models/__pycache__/model_servicer.cpython-312.pyc +0 -0
  218. clarifai/runners/utils/__pycache__/__init__.cpython-312.pyc +0 -0
  219. clarifai/runners/utils/__pycache__/const.cpython-312.pyc +0 -0
  220. clarifai/runners/utils/__pycache__/data_handler.cpython-312.pyc +0 -0
  221. clarifai/runners/utils/__pycache__/data_types.cpython-312.pyc +0 -0
  222. clarifai/runners/utils/__pycache__/data_utils.cpython-312.pyc +0 -0
  223. clarifai/runners/utils/__pycache__/loader.cpython-312.pyc +0 -0
  224. clarifai/runners/utils/__pycache__/method_signatures.cpython-312.pyc +0 -0
  225. clarifai/runners/utils/__pycache__/serializers.cpython-312.pyc +0 -0
  226. clarifai/runners/utils/__pycache__/url_fetcher.cpython-312.pyc +0 -0
  227. clarifai/schema/__pycache__/search.cpython-312.pyc +0 -0
  228. clarifai/urls/__pycache__/helper.cpython-312.pyc +0 -0
  229. clarifai/utils/__pycache__/__init__.cpython-312.pyc +0 -0
  230. clarifai/utils/__pycache__/cli.cpython-312.pyc +0 -0
  231. clarifai/utils/__pycache__/config.cpython-312.pyc +0 -0
  232. clarifai/utils/__pycache__/constants.cpython-312.pyc +0 -0
  233. clarifai/utils/__pycache__/logging.cpython-312.pyc +0 -0
  234. clarifai/utils/__pycache__/misc.cpython-312.pyc +0 -0
  235. clarifai/utils/__pycache__/model_train.cpython-312.pyc +0 -0
  236. clarifai/utils/config.py +0 -105
  237. clarifai/utils/config.py~ +0 -145
  238. clarifai/utils/evaluation/__pycache__/__init__.cpython-312.pyc +0 -0
  239. clarifai/utils/evaluation/__pycache__/helpers.cpython-312.pyc +0 -0
  240. clarifai/utils/evaluation/__pycache__/main.cpython-312.pyc +0 -0
  241. clarifai/workflows/__pycache__/__init__.cpython-312.pyc +0 -0
  242. clarifai/workflows/__pycache__/export.cpython-312.pyc +0 -0
  243. clarifai/workflows/__pycache__/utils.cpython-312.pyc +0 -0
  244. clarifai/workflows/__pycache__/validate.cpython-312.pyc +0 -0
  245. clarifai-11.2.3rc1.dist-info/RECORD +0 -185
  246. {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/LICENSE +0 -0
  247. {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/entry_points.txt +0 -0
  248. {clarifai-11.2.3rc1.dist-info → clarifai-11.2.3rc3.dist-info}/top_level.txt +0 -0
@@ -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"]
@@ -1,3 +1,4 @@
1
+ import builtins
1
2
  import importlib
2
3
  import inspect
3
4
  import os
@@ -6,6 +7,7 @@ import sys
6
7
  import tarfile
7
8
  import time
8
9
  from string import Template
10
+ from unittest.mock import MagicMock
9
11
 
10
12
  import yaml
11
13
  from clarifai_grpc.grpc.api import resources_pb2, service_pb2
@@ -14,13 +16,14 @@ from google.protobuf import json_format
14
16
  from rich import print
15
17
  from rich.markup import escape
16
18
 
17
- from clarifai.client import BaseClient
19
+ from clarifai.client.base import BaseClient
18
20
  from clarifai.runners.models.model_class import ModelClass
19
21
  from clarifai.runners.utils.const import (
20
22
  AVAILABLE_PYTHON_IMAGES, AVAILABLE_TORCH_IMAGES, CONCEPTS_REQUIRED_MODEL_TYPE,
21
23
  DEFAULT_DOWNLOAD_CHECKPOINT_WHEN, DEFAULT_PYTHON_VERSION, DEFAULT_RUNTIME_DOWNLOAD_PATH,
22
24
  PYTHON_BASE_IMAGE, TORCH_BASE_IMAGE)
23
25
  from clarifai.runners.utils.loader import HuggingFaceLoader
26
+ from clarifai.runners.utils.method_signatures import signatures_to_yaml
24
27
  from clarifai.urls.helper import ClarifaiUrlHelper
25
28
  from clarifai.utils.logging import logger
26
29
  from clarifai.versions import CLIENT_VERSION
@@ -65,10 +68,22 @@ class ModelBuilder:
65
68
  self.inference_compute_info = self._get_inference_compute_info()
66
69
  self.is_v3 = True # Do model build for v3
67
70
 
68
- def create_model_instance(self, load_model=True):
71
+ def create_model_instance(self, load_model=True, mocking=False):
69
72
  """
70
73
  Create an instance of the model class, as specified in the config file.
71
74
  """
75
+ model_class = self.load_model_class(mocking=mocking)
76
+
77
+ # initialize the model
78
+ model = model_class()
79
+ if load_model:
80
+ model.load_model()
81
+ return model
82
+
83
+ def load_model_class(self, mocking=False):
84
+ """
85
+ Import the model class from the model.py file, dynamically handling missing dependencies
86
+ """
72
87
  # look for default model.py file location
73
88
  for loc in ["model.py", "1/model.py"]:
74
89
  model_file = os.path.join(self.folder, loc)
@@ -82,7 +97,30 @@ class ModelBuilder:
82
97
  spec = importlib.util.spec_from_file_location(module_name, model_file)
83
98
  module = importlib.util.module_from_spec(spec)
84
99
  sys.modules[module_name] = module
85
- spec.loader.exec_module(module)
100
+
101
+ original_import = builtins.__import__
102
+
103
+ def custom_import(name, globals=None, locals=None, fromlist=(), level=0):
104
+
105
+ # Allow standard libraries and clarifai
106
+ if self._is_standard_or_clarifai(name):
107
+ return original_import(name, globals, locals, fromlist, level)
108
+
109
+ # Mock all third-party imports to avoid ImportErrors or other issues
110
+ return MagicMock()
111
+
112
+ if mocking:
113
+ # Replace the built-in __import__ function with our custom one
114
+ builtins.__import__ = custom_import
115
+
116
+ try:
117
+ spec.loader.exec_module(module)
118
+ except Exception as e:
119
+ logger.error(f"Error loading model.py: {e}")
120
+ raise
121
+ finally:
122
+ # Restore the original __import__ function
123
+ builtins.__import__ = original_import
86
124
 
87
125
  # Find all classes in the model.py file that are subclasses of ModelClass
88
126
  classes = [
@@ -107,12 +145,24 @@ class ModelBuilder:
107
145
  "Could not determine model class. There should be exactly one model inheriting from ModelClass defined in the model.py"
108
146
  )
109
147
  model_class = classes[0]
148
+ return model_class
110
149
 
111
- # initialize the model
112
- model = model_class()
113
- if load_model:
114
- model.load_model()
115
- return model
150
+ def _is_standard_or_clarifai(self, name):
151
+ """Check if import is from standard library or clarifai"""
152
+ if name.startswith("clarifai"):
153
+ return True
154
+
155
+ # Handle Python <3.10 compatibility
156
+ stdlib_names = getattr(sys, "stdlib_module_names", sys.builtin_module_names)
157
+ if name in stdlib_names:
158
+ return True
159
+
160
+ # Handle submodules (e.g., os.path)
161
+ parts = name.split(".")
162
+ for i in range(1, len(parts)):
163
+ if ".".join(parts[:i]) in stdlib_names:
164
+ return True
165
+ return False
116
166
 
117
167
  def _validate_folder(self, folder):
118
168
  if folder == ".":
@@ -142,21 +192,17 @@ class ModelBuilder:
142
192
  def _validate_config_checkpoints(self):
143
193
  """
144
194
  Validates the checkpoints section in the config file.
145
- return loader_type, repo_id, hf_token, when, allowed_file_patterns, ignore_file_patterns
146
195
  :return: loader_type the type of loader or None if no checkpoints.
147
196
  :return: repo_id location of checkpoint.
148
197
  :return: hf_token token to access checkpoint.
149
- :return: when one of ['upload', 'build', 'runtime'] to download checkpoint
150
- :return: allowed_file_patterns patterns to allow in downloaded checkpoint
151
- :return: ignore_file_patterns patterns to ignore in downloaded checkpoint
152
198
  """
153
199
  if "checkpoints" not in self.config:
154
- return None, None, None, DEFAULT_DOWNLOAD_CHECKPOINT_WHEN, None, None
200
+ return None, None, None, DEFAULT_DOWNLOAD_CHECKPOINT_WHEN
155
201
  assert "type" in self.config.get("checkpoints"), "No loader type specified in the config file"
156
202
  loader_type = self.config.get("checkpoints").get("type")
157
203
  if not loader_type:
158
204
  logger.info("No loader type specified in the config file for checkpoints")
159
- return None, None, None, DEFAULT_DOWNLOAD_CHECKPOINT_WHEN, None, None
205
+ return None, None, None
160
206
  checkpoints = self.config.get("checkpoints")
161
207
  if 'when' not in checkpoints:
162
208
  logger.warn(
@@ -175,30 +221,15 @@ class ModelBuilder:
175
221
 
176
222
  # get from config.yaml otherwise fall back to HF_TOKEN env var.
177
223
  hf_token = self.config.get("checkpoints").get("hf_token", os.environ.get("HF_TOKEN", None))
178
-
179
- allowed_file_patterns = self.config.get("checkpoints").get('allowed_file_patterns', None)
180
- if isinstance(allowed_file_patterns, str):
181
- allowed_file_patterns = [allowed_file_patterns]
182
- ignore_file_patterns = self.config.get("checkpoints").get('ignore_file_patterns', None)
183
- if isinstance(ignore_file_patterns, str):
184
- ignore_file_patterns = [ignore_file_patterns]
185
- return loader_type, repo_id, hf_token, when, allowed_file_patterns, ignore_file_patterns
224
+ return loader_type, repo_id, hf_token, when
186
225
 
187
226
  def _check_app_exists(self):
188
227
  resp = self.client.STUB.GetApp(service_pb2.GetAppRequest(user_app_id=self.client.user_app_id))
189
228
  if resp.status.code == status_code_pb2.SUCCESS:
190
229
  return True
191
- if resp.status.code == status_code_pb2.CONN_KEY_INVALID:
192
- logger.error(
193
- f"Invalid PAT provided for user {self.client.user_app_id.user_id}. Please check your PAT and try again."
194
- )
195
- return False
196
230
  logger.error(
197
231
  f"Error checking API {self._base_api} for user app {self.client.user_app_id.user_id}/{self.client.user_app_id.app_id}. Error code: {resp.status.code}"
198
232
  )
199
- logger.error(
200
- f"App {self.client.user_app_id.app_id} not found for user {self.client.user_app_id.user_id}. Please create the app first and try again."
201
- )
202
233
  return False
203
234
 
204
235
  def _validate_config_model(self):
@@ -219,6 +250,9 @@ class ModelBuilder:
219
250
  assert model.get('id') != "", "model_id cannot be empty in the config file"
220
251
 
221
252
  if not self._check_app_exists():
253
+ logger.error(
254
+ f"App {self.client.user_app_id.app_id} not found for user {self.client.user_app_id.user_id}"
255
+ )
222
256
  sys.exit(1)
223
257
 
224
258
  def _validate_config(self):
@@ -232,7 +266,7 @@ class ModelBuilder:
232
266
  assert model_type_id in CONCEPTS_REQUIRED_MODEL_TYPE, f"Model type {model_type_id} not supported for concepts"
233
267
 
234
268
  if self.config.get("checkpoints"):
235
- loader_type, _, hf_token, _, _, _ = self._validate_config_checkpoints()
269
+ loader_type, _, hf_token, _ = self._validate_config_checkpoints()
236
270
 
237
271
  if loader_type == "huggingface" and hf_token:
238
272
  is_valid_token = HuggingFaceLoader.validate_hftoken(hf_token)
@@ -248,7 +282,7 @@ class ModelBuilder:
248
282
  f"`num_threads` must be an integer greater than or equal to 1. Received type {type(num_threads)} with value {num_threads}."
249
283
  )
250
284
  else:
251
- num_threads = int(os.environ.get("CLARIFAI_NUM_THREADS", 16))
285
+ num_threads = int(os.environ.get("CLARIFAI_NUM_THREADS", 1))
252
286
  self.config["num_threads"] = num_threads
253
287
 
254
288
  @staticmethod
@@ -269,6 +303,24 @@ class ModelBuilder:
269
303
  total_size += member.size
270
304
  return total_size
271
305
 
306
+ def method_signatures_yaml(self):
307
+ """
308
+ Returns the method signatures for the model class in YAML format.
309
+ """
310
+ model_class = self.load_model_class(mocking=True)
311
+ method_info = model_class._get_method_info()
312
+ signatures = {method.name: method.signature for method in method_info.values()}
313
+ return signatures_to_yaml(signatures)
314
+
315
+ def get_method_signatures(self):
316
+ """
317
+ Returns the method signatures for the model class.
318
+ """
319
+ model_class = self.load_model_class(mocking=True)
320
+ method_info = model_class._get_method_info()
321
+ signatures = [method.signature for method in method_info.values()]
322
+ return signatures
323
+
272
324
  @property
273
325
  def client(self):
274
326
  if self._client is None:
@@ -302,9 +354,8 @@ class ModelBuilder:
302
354
 
303
355
  assert "model_type_id" in model, "model_type_id not found in the config file"
304
356
  assert "id" in model, "model_id not found in the config file"
305
- if not self.download_validation_only:
306
- assert "user_id" in model, "user_id not found in the config file"
307
- assert "app_id" in model, "app_id not found in the config file"
357
+ assert "user_id" in model, "user_id not found in the config file"
358
+ assert "app_id" in model, "app_id not found in the config file"
308
359
 
309
360
  model_proto = json_format.ParseDict(model, resources_pb2.Model())
310
361
 
@@ -415,12 +466,11 @@ class ModelBuilder:
415
466
  # Sort in reverse so that newer cuda versions come first and are preferred.
416
467
  for image in sorted(AVAILABLE_TORCH_IMAGES, reverse=True):
417
468
  if torch_version in image and f'py{python_version}' in image:
418
- # like cu124, rocm6.3, etc.
419
- gpu_version = image.split('-')[-1]
469
+ cuda_version = image.split('-')[-1].replace('cuda', '')
420
470
  final_image = TORCH_BASE_IMAGE.format(
421
471
  torch_version=torch_version,
422
472
  python_version=python_version,
423
- gpu_version=gpu_version,
473
+ cuda_version=cuda_version,
424
474
  )
425
475
  logger.info(f"Using Torch version {torch_version} base image to build the Docker image")
426
476
  break
@@ -497,10 +547,8 @@ class ModelBuilder:
497
547
  if not self.config.get("checkpoints"):
498
548
  logger.info("No checkpoints specified in the config file")
499
549
  return path
500
- clarifai_model_type_id = self.config.get('model').get('model_type_id')
501
550
 
502
- loader_type, repo_id, hf_token, when, allowed_file_patterns, ignore_file_patterns = self._validate_config_checkpoints(
503
- )
551
+ loader_type, repo_id, hf_token, when = self._validate_config_checkpoints()
504
552
  if stage not in ["build", "upload", "runtime"]:
505
553
  raise Exception("Invalid stage provided, must be one of ['build', 'upload', 'runtime']")
506
554
  if when != stage:
@@ -509,18 +557,14 @@ class ModelBuilder:
509
557
  )
510
558
  return path
511
559
 
512
- success = False
560
+ success = True
513
561
  if loader_type == "huggingface":
514
- loader = HuggingFaceLoader(
515
- repo_id=repo_id, token=hf_token, model_type_id=clarifai_model_type_id)
562
+ loader = HuggingFaceLoader(repo_id=repo_id, token=hf_token)
516
563
  # for runtime default to /tmp path
517
564
  if stage == "runtime" and checkpoint_path_override is None:
518
565
  checkpoint_path_override = self.default_runtime_checkpoint_path()
519
566
  path = checkpoint_path_override if checkpoint_path_override else self.checkpoint_path
520
- success = loader.download_checkpoints(
521
- path,
522
- allowed_file_patterns=allowed_file_patterns,
523
- ignore_file_patterns=ignore_file_patterns)
567
+ success = loader.download_checkpoints(path)
524
568
 
525
569
  if loader_type:
526
570
  if not success:
@@ -554,11 +598,53 @@ class ModelBuilder:
554
598
  concepts = config.get('concepts')
555
599
  logger.info(f"Updated config.yaml with {len(concepts)} concepts.")
556
600
 
557
- def get_model_version_proto(self):
601
+ def filled_params_specs_with_inference_params(self, method_signatures: list[resources_pb2.MethodSignature]) -> list[resources_pb2.ModelTypeField]:
602
+ """
603
+ Fills the params_specs with the inference params.
604
+ """
605
+ inference_params = set()
606
+ for i, signature in enumerate(method_signatures):
607
+ for field in signature.input_fields:
608
+ if field.is_param:
609
+ if i==0:
610
+ inference_params.add(field.name)
611
+ else:
612
+ # if field.name not in inference_params then remove from inference_params
613
+ if field.name not in inference_params:
614
+ inference_params.remove(field.name)
615
+ output=[]
616
+ for signature in method_signatures:
617
+ for field in signature.input_fields:
618
+ if field.is_param and field.name in inference_params:
619
+ field.path = field.name
620
+ if field.type == resources_pb2.ModelTypeField.DataType.STR:
621
+ field.default_value= str(field.default)
622
+ field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.STRING
623
+ elif field.type == resources_pb2.ModelTypeField.DataType.INT:
624
+ field.default_value= int(field.default)
625
+ field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.NUMBER
626
+ elif field.type == resources_pb2.ModelTypeField.DataType.FLOAT:
627
+ field.default_value= float(field.default)
628
+ field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.NUMBER
629
+ elif field.type == resources_pb2.ModelTypeField.DataType.BOOL:
630
+ field.default_value= bool(field.default)
631
+ field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.BOOLEAN
632
+ else:
633
+ field.default_value= field.default
634
+ field.field_type = resources_pb2.ModelTypeField.ModelTypeFieldType.STRING
635
+ output.append(field)
636
+ return output
558
637
 
638
+
639
+ def get_model_version_proto(self):
640
+ signatures = self.get_method_signatures()
559
641
  model_version_proto = resources_pb2.ModelVersion(
560
642
  pretrained_model_config=resources_pb2.PretrainedModelConfig(),
561
643
  inference_compute_info=self.inference_compute_info,
644
+ method_signatures=signatures,
645
+ # output_info= resources_pb2.OutputInfo(
646
+ # params_specs=self.filled_params_specs_with_inference_params(signatures),
647
+ # )
562
648
  )
563
649
 
564
650
  model_type_id = self.config.get('model').get('model_type_id')
@@ -592,7 +678,7 @@ class ModelBuilder:
592
678
  logger.debug(f"Will tar it into file: {file_path}")
593
679
 
594
680
  model_type_id = self.config.get('model').get('model_type_id')
595
- loader_type, repo_id, hf_token, when, _, _ = self._validate_config_checkpoints()
681
+ loader_type, repo_id, hf_token, when = self._validate_config_checkpoints()
596
682
 
597
683
  if (model_type_id in CONCEPTS_REQUIRED_MODEL_TYPE) and 'concepts' not in self.config:
598
684
  logger.info(
@@ -640,7 +726,7 @@ class ModelBuilder:
640
726
  # First check for the env variable, then try querying huggingface. If all else fails, use the default.
641
727
  checkpoint_size = os.environ.get('CHECKPOINT_SIZE_BYTES', 0)
642
728
  if not checkpoint_size:
643
- _, repo_id, _, _, _, _ = self._validate_config_checkpoints()
729
+ _, repo_id, _, _ = self._validate_config_checkpoints()
644
730
  checkpoint_size = HuggingFaceLoader.get_huggingface_checkpoint_total_size(repo_id)
645
731
  if not checkpoint_size:
646
732
  checkpoint_size = self.DEFAULT_CHECKPOINT_SIZE
@@ -746,6 +832,7 @@ class ModelBuilder:
746
832
  model_id=self.model_proto.id,
747
833
  version_id=self.model_version_id,
748
834
  ))
835
+
749
836
  status_code = resp.model_version.status.code
750
837
  logs = self.get_model_build_logs()
751
838
  for log_entry in logs.log_entries: