clarifai 11.1.5rc1__tar.gz → 11.1.5rc2__tar.gz

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 (227) hide show
  1. {clarifai-11.1.5rc1/clarifai.egg-info → clarifai-11.1.5rc2}/PKG-INFO +1 -1
  2. clarifai-11.1.5rc2/clarifai/__init__.py +1 -0
  3. clarifai-11.1.5rc2/clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
  4. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/model.py +1 -2
  5. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/model_client.py +47 -25
  6. clarifai-11.1.5rc2/clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
  7. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/__pycache__/base_typed_model.cpython-310.pyc +0 -0
  8. clarifai-11.1.5rc2/clarifai/runners/models/__pycache__/model_builder.cpython-310.pyc +0 -0
  9. clarifai-11.1.5rc2/clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
  10. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc +0 -0
  11. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/model_class.py +59 -42
  12. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/model_run_locally.py +3 -78
  13. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc +0 -0
  14. clarifai-11.1.5rc2/clarifai/runners/utils/__pycache__/data_types.cpython-310.pyc +0 -0
  15. clarifai-11.1.5rc2/clarifai/runners/utils/__pycache__/method_signatures.cpython-310.pyc +0 -0
  16. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__pycache__/serializers.cpython-310.pyc +0 -0
  17. clarifai-11.1.5rc1/clarifai/runners/utils/data_handler.py → clarifai-11.1.5rc2/clarifai/runners/utils/data_types.py +1 -1
  18. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/method_signatures.py +44 -29
  19. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/serializers.py +1 -1
  20. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2/clarifai.egg-info}/PKG-INFO +1 -1
  21. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai.egg-info/SOURCES.txt +2 -1
  22. clarifai-11.1.5rc1/clarifai/__init__.py +0 -1
  23. clarifai-11.1.5rc1/clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
  24. clarifai-11.1.5rc1/clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
  25. clarifai-11.1.5rc1/clarifai/runners/models/__pycache__/model_builder.cpython-310.pyc +0 -0
  26. clarifai-11.1.5rc1/clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
  27. clarifai-11.1.5rc1/clarifai/runners/utils/__pycache__/method_signatures.cpython-310.pyc +0 -0
  28. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/LICENSE +0 -0
  29. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/MANIFEST.in +0 -0
  30. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/README.md +0 -0
  31. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/__pycache__/__init__.cpython-310.pyc +0 -0
  32. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/__pycache__/errors.cpython-310.pyc +0 -0
  33. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/__pycache__/versions.cpython-310.pyc +0 -0
  34. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/README.md +0 -0
  35. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__init__.py +0 -0
  36. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__main__.py +0 -0
  37. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__main__.py~ +0 -0
  38. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  39. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__pycache__/__main__.cpython-310.pyc +0 -0
  40. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__pycache__/base.cpython-310.pyc +0 -0
  41. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  42. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__pycache__/deployment.cpython-310.pyc +0 -0
  43. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
  44. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/base.py +0 -0
  45. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/compute_cluster.py +0 -0
  46. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/deployment.py +0 -0
  47. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/model.py +0 -0
  48. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli/nodepool.py +0 -0
  49. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/cli.py +0 -0
  50. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__init__.py +0 -0
  51. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/__init__.cpython-310.pyc +0 -0
  52. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/app.cpython-310.pyc +0 -0
  53. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
  54. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
  55. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
  56. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
  57. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
  58. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
  59. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/runner.cpython-310.pyc +0 -0
  60. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
  61. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
  62. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
  63. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/app.py +0 -0
  64. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/auth/__init__.py +0 -0
  65. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
  66. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
  67. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
  68. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/auth/__pycache__/stub.cpython-310.pyc +0 -0
  69. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/auth/helper.py +0 -0
  70. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/auth/register.py +0 -0
  71. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/auth/stub.py +0 -0
  72. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/base.py +0 -0
  73. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/compute_cluster.py +0 -0
  74. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/dataset.py +0 -0
  75. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/deployment.py +0 -0
  76. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/input.py +0 -0
  77. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/lister.py +0 -0
  78. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/module.py +0 -0
  79. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/nodepool.py +0 -0
  80. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/search.py +0 -0
  81. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/user.py +0 -0
  82. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/client/workflow.py +0 -0
  83. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
  84. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/__pycache__/model.cpython-310.pyc +0 -0
  85. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
  86. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/base.py +0 -0
  87. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/dataset.py +0 -0
  88. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/input.py +0 -0
  89. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/model.py +0 -0
  90. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/rag.py +0 -0
  91. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/search.py +0 -0
  92. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/constants/workflow.py +0 -0
  93. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/__init__.py +0 -0
  94. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
  95. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/export/__init__.py +0 -0
  96. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/export/__pycache__/__init__.cpython-310.pyc +0 -0
  97. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
  98. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/export/inputs_annotations.py +0 -0
  99. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/__init__.py +0 -0
  100. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/__pycache__/__init__.cpython-310.pyc +0 -0
  101. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/__pycache__/base.cpython-310.pyc +0 -0
  102. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/__pycache__/features.cpython-310.pyc +0 -0
  103. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
  104. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
  105. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
  106. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/base.py +0 -0
  107. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/features.py +0 -0
  108. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/image.py +0 -0
  109. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/loaders/README.md +0 -0
  110. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/loaders/__init__.py +0 -0
  111. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-310.pyc +0 -0
  112. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-310.pyc +0 -0
  113. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
  114. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
  115. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
  116. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
  117. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/multimodal.py +0 -0
  118. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/text.py +0 -0
  119. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/datasets/upload/utils.py +0 -0
  120. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/errors.py +0 -0
  121. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/__init__.py +0 -0
  122. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/__pycache__/__init__.cpython-310.pyc +0 -0
  123. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/api.py +0 -0
  124. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/__pycache__/__init__.cpython-310.pyc +0 -0
  125. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/__pycache__/constants.cpython-310.pyc +0 -0
  126. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  127. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/cli/__pycache__/_utils.cpython-310.pyc +0 -0
  128. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/cli/__pycache__/base.cpython-310.pyc +0 -0
  129. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/cli/__pycache__/build.cpython-310.pyc +0 -0
  130. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/cli/__pycache__/create.cpython-310.pyc +0 -0
  131. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/__pycache__/__init__.cpython-310.pyc +0 -0
  132. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/__pycache__/base.cpython-310.pyc +0 -0
  133. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/__pycache__/config.cpython-310.pyc +0 -0
  134. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/__pycache__/inference_parameter.cpython-310.pyc +0 -0
  135. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/__pycache__/output.cpython-310.pyc +0 -0
  136. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/triton/__pycache__/__init__.cpython-310.pyc +0 -0
  137. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/triton/__pycache__/serializer.cpython-310.pyc +0 -0
  138. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/triton/__pycache__/triton_config.cpython-310.pyc +0 -0
  139. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/model_config/triton/__pycache__/wrappers.cpython-310.pyc +0 -0
  140. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/repo_build/__pycache__/__init__.cpython-310.pyc +0 -0
  141. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/repo_build/__pycache__/build.cpython-310.pyc +0 -0
  142. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/models/model_serving/repo_build/static_files/__pycache__/base_test.cpython-310-pytest-7.2.0.pyc +0 -0
  143. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/modules/README.md +0 -0
  144. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/modules/__init__.py +0 -0
  145. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/modules/css.py +0 -0
  146. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/modules/pages.py +0 -0
  147. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/modules/style.css +0 -0
  148. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/rag/__init__.py +0 -0
  149. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/rag/__pycache__/__init__.cpython-310.pyc +0 -0
  150. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
  151. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
  152. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/rag/rag.py +0 -0
  153. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/rag/utils.py +0 -0
  154. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/__init__.py +0 -0
  155. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/__pycache__/server.cpython-310.pyc +0 -0
  156. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/dockerfile_template/Dockerfile.debug +0 -0
  157. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/dockerfile_template/Dockerfile.debug~ +0 -0
  158. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/dockerfile_template/Dockerfile.template +0 -0
  159. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/__init__.py +0 -0
  160. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/__pycache__/__init__.cpython-310.pyc +0 -0
  161. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc +0 -0
  162. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/__pycache__/model_servicer.cpython-310.pyc +0 -0
  163. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
  164. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/model_builder.py +0 -0
  165. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/model_runner.py +0 -0
  166. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/models/model_servicer.py +0 -0
  167. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/server.py +0 -0
  168. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__init__.py +0 -0
  169. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  170. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__pycache__/const.cpython-310.pyc +0 -0
  171. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc +0 -0
  172. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
  173. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__pycache__/logging.cpython-310.pyc +0 -0
  174. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc +0 -0
  175. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/const.py +0 -0
  176. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/data_utils.py +0 -0
  177. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/loader.py +0 -0
  178. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/runners/utils/url_fetcher.py +0 -0
  179. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
  180. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/schema/search.py +0 -0
  181. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
  182. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/urls/helper.py +0 -0
  183. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/__init__.py +0 -0
  184. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  185. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
  186. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
  187. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
  188. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/cli.py +0 -0
  189. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/constants.py +0 -0
  190. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/evaluation/__init__.py +0 -0
  191. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/evaluation/__pycache__/__init__.cpython-310.pyc +0 -0
  192. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/evaluation/__pycache__/helpers.cpython-310.pyc +0 -0
  193. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/evaluation/__pycache__/main.cpython-310.pyc +0 -0
  194. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/evaluation/helpers.py +0 -0
  195. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/evaluation/main.py +0 -0
  196. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
  197. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/logging.py +0 -0
  198. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/misc.py +0 -0
  199. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/utils/model_train.py +0 -0
  200. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/versions.py +0 -0
  201. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/workflows/__init__.py +0 -0
  202. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
  203. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
  204. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
  205. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
  206. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/workflows/export.py +0 -0
  207. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/workflows/utils.py +0 -0
  208. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai/workflows/validate.py +0 -0
  209. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai.egg-info/dependency_links.txt +0 -0
  210. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai.egg-info/entry_points.txt +0 -0
  211. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai.egg-info/requires.txt +0 -0
  212. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/clarifai.egg-info/top_level.txt +0 -0
  213. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/pyproject.toml +0 -0
  214. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/requirements.txt +0 -0
  215. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/setup.cfg +0 -0
  216. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/setup.py +0 -0
  217. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_app.py +0 -0
  218. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_auth.py +0 -0
  219. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_data_upload.py +0 -0
  220. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_eval.py +0 -0
  221. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_misc.py +0 -0
  222. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_model_predict.py +0 -0
  223. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_model_train.py +0 -0
  224. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_modules.py +0 -0
  225. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_rag.py +0 -0
  226. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_search.py +0 -0
  227. {clarifai-11.1.5rc1 → clarifai-11.1.5rc2}/tests/test_stub.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clarifai
3
- Version: 11.1.5rc1
3
+ Version: 11.1.5rc2
4
4
  Summary: Clarifai Python SDK
5
5
  Home-page: https://github.com/Clarifai/clarifai-python
6
6
  Author: Clarifai
@@ -0,0 +1 @@
1
+ __version__ = "11.1.5rc2"
@@ -494,8 +494,7 @@ class Model(Lister, BaseClient):
494
494
  nodepool_id: str = None,
495
495
  deployment_id: str = None,
496
496
  user_id: str = None):
497
- runner_selector = resources_pb2.RunnerSelector()
498
-
497
+ runner_selector = None
499
498
  if deployment_id and (compute_cluster_id or nodepool_id):
500
499
  raise UserError(
501
500
  "You can only specify one of deployment_id or compute_cluster_id and nodepool_id.")
@@ -1,3 +1,4 @@
1
+ import inspect
1
2
  import time
2
3
  from typing import Any, Dict, Iterator, List
3
4
 
@@ -6,7 +7,9 @@ from clarifai_grpc.grpc.api.status import status_code_pb2
6
7
 
7
8
  from clarifai.constants.model import MAX_MODEL_PREDICT_INPUTS
8
9
  from clarifai.errors import UserError
9
- from clarifai.runners.utils.method_signatures import deserialize, serialize, signatures_from_json
10
+ from clarifai.runners.utils.method_signatures import (deserialize, get_stream_from_signature,
11
+ serialize, signatures_from_json,
12
+ unflatten_nested_keys)
10
13
  from clarifai.utils.misc import BackoffIterator, status_is_retryable
11
14
 
12
15
 
@@ -56,12 +59,13 @@ class ModelClient:
56
59
  self.logger.info(f"Retrying model info fetch with response {response.status!r}")
57
60
  time.sleep(next(backoff_iterator))
58
61
  continue
59
-
60
- if response.status.code != status_code_pb2.SUCCESS:
61
- raise Exception(f"Model failed with response {response.status!r}")
62
62
  break
63
+ if response.status.code == status_code_pb2.INPUT_UNSUPPORTED_FORMAT:
64
+ # return code from older models that don't support _GET_SIGNATURES
65
+ self._method_signatures = {}
66
+ return
63
67
  if response.status.code != status_code_pb2.SUCCESS:
64
- raise Exception(response.status)
68
+ raise Exception(f"Model failed with response {response.status!r}")
65
69
  self._method_signatures = signatures_from_json(response.outputs[0].data.string_value)
66
70
 
67
71
  def _define_functions(self):
@@ -105,26 +109,47 @@ class ModelClient:
105
109
  # need to bind method_name to the value, not the mutating loop variable
106
110
  f = bind_f(method_name, method_argnames, call_func)
107
111
 
108
- # set names and docstrings
109
- # note we could also have used exec with strings from the signature to define the
110
- # function, but this is safer (no xss), and docstrings with the signature is ok enough
112
+ # set names, annotations and docstrings
111
113
  f.__name__ = method_name
112
114
  f.__qualname__ = f'{self.__class__.__name__}.{method_name}'
113
- input_spec = ', '.join(
114
- f'{var.name}: {var.data_type}{" = " + str(var.default) if not var.required else ""}'
115
- for var in method_signature.inputs)
116
- output_vars = method_signature.outputs
117
- if len(output_vars) == 1 and output_vars[0].name == 'return':
115
+ input_annos = {var.name: var.data_type for var in method_signature.inputs}
116
+ output_annos = {var.name: var.data_type for var in method_signature.outputs}
117
+ # unflatten nested keys to match the user function args for docs
118
+ input_annos = unflatten_nested_keys(input_annos, method_signature.inputs, is_output=False)
119
+ output_annos = unflatten_nested_keys(output_annos, method_signature.outputs, is_output=True)
120
+
121
+ # add Stream[] to the stream input annotations for docs
122
+ input_stream_argname, _ = get_stream_from_signature(method_signature.inputs)
123
+ if input_stream_argname:
124
+ input_annos[input_stream_argname] = 'Stream[' + str(
125
+ input_annos[input_stream_argname]) + ']'
126
+
127
+ # handle multiple outputs in the return annotation
128
+ return_annotation = output_annos
129
+ name = next(iter(output_annos.keys()))
130
+ if len(output_annos) == 1 and name == 'return':
118
131
  # single output
119
- output_spec = output_vars[0].data_type
120
- elif output_vars[0].name == 'return.0':
132
+ return_annotation = output_annos[name]
133
+ elif name.startswith('return.') and name.split('.', 1)[1].isnumeric():
121
134
  # tuple output
122
- output_spec = '(' + ', '.join(var.data_type for var in output_vars) + ')'
135
+ return_annotation = '(' + ", ".join(output_annos[f'return.{i}']
136
+ for i in range(len(output_annos))) + ')'
123
137
  else:
124
138
  # named output
125
- output_spec = f'Output({", ".join(f"{var.name}={var.data_type}" for var in output_vars)})'
126
- f.__doc__ = f'''{method_name}(self, {input_spec}) -> {output_spec}\n'''
127
- #f.__doc__ += method_signature.description # TODO
139
+ return_annotation = f'Output({", ".join(f"{k}={t}" for k, t in output_annos.items())})'
140
+ if method_signature.method_type in ['generate', 'stream']:
141
+ return_annotation = f'Stream[{return_annotation}]'
142
+
143
+ # set annotations and docstrings
144
+ sig = inspect.signature(f).replace(
145
+ parameters=[
146
+ inspect.Parameter(k, inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=v)
147
+ for k, v in input_annos.items()
148
+ ],
149
+ return_annotation=return_annotation,
150
+ )
151
+ f.__signature__ = sig
152
+ f.__doc__ = method_signature.docstring
128
153
  setattr(self, method_name, f)
129
154
 
130
155
  def _predict(
@@ -190,7 +215,8 @@ class ModelClient:
190
215
  if inference_params:
191
216
  request.model.model_version.output_info.params.update(inference_params)
192
217
  if output_config:
193
- request.model.model_version.output_info.output_config.MergeFromDict(output_config)
218
+ request.model.model_version.output_info.output_config.MergeFrom(
219
+ resources_pb2.OutputConfig(**output_config))
194
220
 
195
221
  start_time = time.time()
196
222
  backoff_iterator = BackoffIterator(10)
@@ -312,11 +338,7 @@ class ModelClient:
312
338
  kwargs = inputs
313
339
 
314
340
  # find the streaming vars in the input signature, and the streaming input python param
315
- streaming_var_signatures = [var for var in input_signature if var.streaming]
316
- stream_argname = set([var.name.split('.', 1)[0] for var in streaming_var_signatures])
317
- assert len(
318
- stream_argname) == 1, 'streaming methods must have exactly one streaming function arg'
319
- stream_argname = stream_argname.pop()
341
+ stream_argname, streaming_var_signatures = get_stream_from_signature(input_signature)
320
342
 
321
343
  # get the streaming input generator from the user-provided function arg values
322
344
  user_inputs_generator = kwargs.pop(stream_argname)
@@ -3,39 +3,74 @@ import itertools
3
3
  import logging
4
4
  import os
5
5
  import traceback
6
- import types
7
6
  from abc import ABC
8
7
  from typing import Any, Dict, Iterator, List
9
8
 
10
9
  from clarifai_grpc.grpc.api import resources_pb2, service_pb2
11
10
  from clarifai_grpc.grpc.api.status import status_code_pb2, status_pb2
12
11
 
13
- from clarifai.runners.utils import data_handler
12
+ from clarifai.runners.utils import data_types
14
13
  from clarifai.runners.utils.method_signatures import (build_function_signature, deserialize,
15
- serialize, signatures_to_json)
14
+ get_stream_from_signature, serialize,
15
+ signatures_to_json)
16
16
 
17
17
  _METHOD_INFO_ATTR = '_cf_method_info'
18
18
 
19
19
  _RAISE_EXCEPTIONS = os.getenv("RAISE_EXCEPTIONS", "false").lower() == "true"
20
20
 
21
21
 
22
+ class methods:
23
+ '''
24
+ Decorators to mark methods as predict, generate, or stream methods.
25
+ '''
26
+
27
+ @staticmethod
28
+ def predict(method):
29
+ setattr(method, _METHOD_INFO_ATTR, _MethodInfo(method, 'predict'))
30
+ return method
31
+
32
+ @staticmethod
33
+ def generate(method):
34
+ setattr(method, _METHOD_INFO_ATTR, _MethodInfo(method, 'generate'))
35
+ return method
36
+
37
+ @staticmethod
38
+ def stream(method):
39
+ setattr(method, _METHOD_INFO_ATTR, _MethodInfo(method, 'stream'))
40
+ return method
41
+
42
+
22
43
  class ModelClass(ABC):
44
+ '''
45
+ Base class for model classes that can be run as a service.
23
46
 
24
- def load_model(self):
25
- """Load the model."""
26
- pass
47
+ Define methods as predict, generate, or stream methods using the @methods decorators.
48
+
49
+ Example:
27
50
 
28
- def predict(self, **kwargs):
29
- """Predict method for single or batched inputs."""
30
- raise NotImplementedError("predict() not implemented")
51
+ from clarifai.runners.model_class import ModelClass, methods
52
+ from clarifai.runners.utils.data_types import Input, Stream
31
53
 
32
- def generate(self, **kwargs) -> Iterator:
33
- """Generate method for streaming outputs."""
34
- raise NotImplementedError("generate() not implemented")
54
+ class MyModel(ModelClass):
35
55
 
36
- def stream(self, **kwargs) -> Iterator:
37
- """Stream method for streaming inputs and outputs."""
38
- raise NotImplementedError("stream() not implemented")
56
+ @methods.predict
57
+ def predict(self, x: str, y: int) -> List[str]:
58
+ return [x] * y
59
+
60
+ @methods.generate
61
+ def generate(self, x: str, y: int) -> Stream[str]:
62
+ for i in range(y):
63
+ yield x + str(i)
64
+
65
+ @methods.stream
66
+ def stream(self, input_stream: Stream[Input(x=str, y=int)]) -> Stream[str]:
67
+ for item in input_stream:
68
+ yield item.x + ' ' + str(item.y)
69
+ '''
70
+
71
+ def load_model(self):
72
+ """Load the model."""
73
+ pass
39
74
 
40
75
  def _handle_get_signatures_request(self) -> service_pb2.MultiOutputResponse:
41
76
  methods = self._get_method_info()
@@ -63,7 +98,8 @@ class ModelClass(ABC):
63
98
  outputs = []
64
99
  try:
65
100
  # TODO add method name field to proto
66
- method_name = request.model.model_version.output_info.params['_method_name']
101
+ call_params = dict(request.model.model_version.output_info.params)
102
+ method_name = call_params.get('_method_name', 'predict')
67
103
  if method_name == '_GET_SIGNATURES': # special case to fetch signatures, TODO add endpoint for this
68
104
  return self._handle_get_signatures_request()
69
105
  if method_name not in self._get_method_info():
@@ -96,7 +132,8 @@ class ModelClass(ABC):
96
132
  def generate_wrapper(self, request: service_pb2.PostModelOutputsRequest
97
133
  ) -> Iterator[service_pb2.MultiOutputResponse]:
98
134
  try:
99
- method_name = request.model.model_version.output_info.params['_method_name']
135
+ call_params = dict(request.model.model_version.output_info.params)
136
+ method_name = call_params.get('_method_name', 'generate')
100
137
  method = getattr(self, method_name)
101
138
  method_info = method._cf_method_info
102
139
  signature = method_info.signature
@@ -133,18 +170,15 @@ class ModelClass(ABC):
133
170
  request = next(request_iterator) # get first request to determine method
134
171
  assert len(request.inputs) == 1, "Streaming requires exactly one input"
135
172
 
136
- method_name = request.model.model_version.output_info.params['_method_name']
173
+ call_params = dict(request.model.model_version.output_info.params)
174
+ method_name = call_params.get('_method_name', 'stream')
137
175
  method = getattr(self, method_name)
138
176
  method_info = method._cf_method_info
139
177
  signature = method_info.signature
140
178
  python_param_types = method_info.python_param_types
141
179
 
142
180
  # find the streaming vars in the signature
143
- streaming_var_signatures = [var for var in signature.inputs if var.streaming]
144
- stream_argname = set([var.name.split('.', 1)[0] for var in streaming_var_signatures])
145
- assert len(
146
- stream_argname) == 1, 'streaming methods must have exactly one streaming function arg'
147
- stream_argname = stream_argname.pop()
181
+ stream_argname, streaming_var_signatures = get_stream_from_signature(signature.inputs)
148
182
 
149
183
  # convert all inputs for the first request, including the first stream value
150
184
  inputs = self._convert_input_protos_to_python(request.inputs, signature.inputs,
@@ -190,7 +224,7 @@ class ModelClass(ABC):
190
224
  for k, v in kwargs.items():
191
225
  if k not in python_param_types:
192
226
  continue
193
- kwargs[k] = data_handler.cast(v, python_param_types[k])
227
+ kwargs[k] = data_types.cast(v, python_param_types[k])
194
228
  result.append(kwargs)
195
229
  return result
196
230
 
@@ -203,6 +237,7 @@ class ModelClass(ABC):
203
237
  if not isinstance(output, dict): # TODO Output type, not just dict
204
238
  output = {'return': output}
205
239
  serialize(output, variables_signature, proto.data, is_output=True)
240
+ proto.status.code = status_code_pb2.SUCCESS
206
241
  return proto
207
242
 
208
243
  @classmethod
@@ -245,21 +280,3 @@ class _MethodInfo:
245
280
  if p.annotation != inspect.Parameter.empty
246
281
  }
247
282
  self.python_param_types.pop('self', None)
248
-
249
-
250
- def predict(method):
251
- setattr(method, _METHOD_INFO_ATTR, _MethodInfo(method, 'predict'))
252
- return method
253
-
254
-
255
- def generate(method):
256
- setattr(method, _METHOD_INFO_ATTR, _MethodInfo(method, 'generate'))
257
- return method
258
-
259
-
260
- def stream(method):
261
- setattr(method, _METHOD_INFO_ATTR, _MethodInfo(method, 'stream'))
262
- return method
263
-
264
-
265
- methods = types.SimpleNamespace(predict=predict, generate=generate, stream=stream)
@@ -7,14 +7,11 @@ import subprocess
7
7
  import sys
8
8
  import tempfile
9
9
  import time
10
- import traceback
11
10
  import venv
12
11
 
13
12
  from clarifai_grpc.grpc.api import resources_pb2, service_pb2
14
- from clarifai_grpc.grpc.api.status import status_code_pb2, status_pb2
15
13
 
16
14
  from clarifai.runners.models.model_builder import ModelBuilder
17
- from clarifai.runners.utils.url_fetcher import ensure_urls_downloaded
18
15
  from clarifai.utils.logging import logger
19
16
 
20
17
 
@@ -111,85 +108,13 @@ class ModelRunLocally:
111
108
  for i in range(1):
112
109
  yield request
113
110
 
114
- def _run_model_inference(self, model):
115
- """Perform inference using the model."""
116
- request = self._build_request()
117
- stream_request = self._build_stream_request()
118
-
119
- ensure_urls_downloaded(request)
120
- predict_response = None
121
- generate_response = None
122
- stream_response = None
123
- try:
124
- predict_response = model.predict(request)
125
- except NotImplementedError:
126
- logger.info("Model does not implement predict() method.")
127
- except Exception as e:
128
- logger.error(f"Model Prediction failed: {e}")
129
- traceback.print_exc()
130
- predict_response = service_pb2.MultiOutputResponse(status=status_pb2.Status(
131
- code=status_code_pb2.MODEL_PREDICTION_FAILED,
132
- description="Prediction failed",
133
- details="",
134
- internal_details=str(e),
135
- ))
136
-
137
- if predict_response:
138
- if predict_response.outputs[0].status.code != status_code_pb2.SUCCESS:
139
- logger.error(f"Moddel Prediction failed: {predict_response}")
140
- else:
141
- logger.info(f"Model Prediction succeeded: {predict_response}")
142
-
143
- try:
144
- generate_response = model.generate(request)
145
- except NotImplementedError:
146
- logger.info("Model does not implement generate() method.")
147
- except Exception as e:
148
- logger.error(f"Model Generation failed: {e}")
149
- traceback.print_exc()
150
- generate_response = service_pb2.MultiOutputResponse(status=status_pb2.Status(
151
- code=status_code_pb2.MODEL_GENERATION_FAILED,
152
- description="Generation failed",
153
- details="",
154
- internal_details=str(e),
155
- ))
156
-
157
- if generate_response:
158
- generate_first_res = next(generate_response)
159
- if generate_first_res.outputs[0].status.code != status_code_pb2.SUCCESS:
160
- logger.error(f"Moddel Prediction failed: {generate_first_res}")
161
- else:
162
- logger.info(
163
- f"Model Prediction succeeded for generate and first response: {generate_first_res}")
164
-
165
- try:
166
- stream_response = model.stream(stream_request)
167
- except NotImplementedError:
168
- logger.info("Model does not implement stream() method.")
169
- except Exception as e:
170
- logger.error(f"Model Stream failed: {e}")
171
- traceback.print_exc()
172
- stream_response = service_pb2.MultiOutputResponse(status=status_pb2.Status(
173
- code=status_code_pb2.MODEL_STREAM_FAILED,
174
- description="Stream failed",
175
- details="",
176
- internal_details=str(e),
177
- ))
178
-
179
- if stream_response:
180
- stream_first_res = next(stream_response)
181
- if stream_first_res.outputs[0].status.code != status_code_pb2.SUCCESS:
182
- logger.error(f"Moddel Prediction failed: {stream_first_res}")
183
- else:
184
- logger.info(
185
- f"Model Prediction succeeded for stream and first response: {stream_first_res}")
186
-
187
111
  def _run_test(self):
188
112
  """Test the model locally by making a prediction."""
189
113
  # Create the model
190
114
  model = self.builder.create_model_instance()
191
- # send an inference.
192
- self._run_model_inference(model)
115
+ # call its test method, if it has one
116
+ if hasattr(model, "test"):
117
+ model.test()
193
118
 
194
119
  def test_model(self):
195
120
  """Test the model by running it locally in the virtual environment."""
@@ -60,7 +60,7 @@ class Text(MessageData):
60
60
  self.url = url
61
61
 
62
62
  def to_proto(self) -> TextProto:
63
- return TextProto(raw=self.text or '', self_url=self.url or '')
63
+ return TextProto(raw=self.text or '', url=self.url or '')
64
64
 
65
65
  @classmethod
66
66
  def from_proto(cls, proto: TextProto) -> "Text":
@@ -2,7 +2,7 @@ import inspect
2
2
  import json
3
3
  import re
4
4
  import types
5
- from collections import namedtuple
5
+ from collections import OrderedDict, namedtuple
6
6
  from typing import List, get_args, get_origin
7
7
 
8
8
  import numpy as np
@@ -11,7 +11,7 @@ import yaml
11
11
  from clarifai_grpc.grpc.api import resources_pb2
12
12
  from google.protobuf.message import Message as MessageProto
13
13
 
14
- from clarifai.runners.utils import data_handler
14
+ from clarifai.runners.utils import data_types
15
15
  from clarifai.runners.utils.serializers import (AtomicFieldSerializer, ImageSerializer,
16
16
  ListSerializer, MessageSerializer,
17
17
  NDArraySerializer, NullValueSerializer, Serializer)
@@ -33,7 +33,7 @@ def build_function_signature(func, method_type: str):
33
33
  raise ValueError('Function must have a return annotation')
34
34
  # check for multiple return values and convert to dict for named values
35
35
  return_streaming = False
36
- if get_origin(return_annotation) == data_handler.Stream:
36
+ if get_origin(return_annotation) == data_types.Stream:
37
37
  return_annotation = get_args(return_annotation)[0]
38
38
  return_streaming = True
39
39
  if get_origin(return_annotation) == tuple:
@@ -73,7 +73,7 @@ def build_function_signature(func, method_type: str):
73
73
  input_stream_vars = [var for var in input_vars if var.streaming]
74
74
  if len(input_stream_vars) == 0:
75
75
  raise TypeError('Stream methods must include a Stream input')
76
- if len(output_vars) != 1 or not output_vars[0].streaming:
76
+ if not all(var.streaming for var in output_vars):
77
77
  raise TypeError('Stream methods must return a single Stream')
78
78
  else:
79
79
  raise TypeError('Invalid method type: %s' % method_type)
@@ -85,6 +85,7 @@ def build_function_signature(func, method_type: str):
85
85
  #method_signature.method_type = getattr(resources_pb2.RunnerMethodType, method_type)
86
86
  assert method_type in ('predict', 'generate', 'stream')
87
87
  method_signature.method_type = method_type
88
+ method_signature.docstring = func.__doc__
88
89
 
89
90
  #method_signature.inputs.extend(input_vars)
90
91
  #method_signature.outputs.extend(output_vars)
@@ -163,7 +164,7 @@ def serialize(kwargs, signatures, proto=None, is_output=False):
163
164
  if proto is None:
164
165
  proto = resources_pb2.Data()
165
166
  if not is_output: # TODO: use this consistently for return keys also
166
- flatten_nested_keys(kwargs, signatures, is_output)
167
+ kwargs = flatten_nested_keys(kwargs, signatures, is_output)
167
168
  unknown = set(kwargs.keys()) - set(sig.name for sig in signatures)
168
169
  if unknown:
169
170
  if unknown == {'return'} and len(signatures) > 1:
@@ -204,8 +205,8 @@ def deserialize(proto, signatures, is_output=False):
204
205
  return kwargs['return']
205
206
  if kwargs and 'return.0' in kwargs: # case for tuple return values
206
207
  return tuple(kwargs[f'return.{i}'] for i in range(len(kwargs)))
207
- return data_handler.Output(kwargs)
208
- unflatten_nested_keys(kwargs, signatures, is_output)
208
+ return data_types.Output(kwargs)
209
+ kwargs = unflatten_nested_keys(kwargs, signatures, is_output)
209
210
  return kwargs
210
211
 
211
212
 
@@ -238,18 +239,32 @@ def unflatten_nested_keys(kwargs, signatures, is_output):
238
239
  Unflatten nested keys in kwargs into a dict, e.g. {'a.b': 1} -> {'a': {'b': 1}}
239
240
  Uses the signatures to determine which keys are nested.
240
241
  The dict subclass is Input or Output, depending on the is_output flag.
242
+ Preserves the order of args from the signatures.
241
243
  '''
244
+ unflattened = OrderedDict()
242
245
  for sig in signatures:
243
246
  if '.' not in sig.name:
247
+ if sig.name in kwargs:
248
+ unflattened[sig.name] = kwargs[sig.name]
244
249
  continue
245
250
  if sig.name not in kwargs:
246
251
  continue
247
252
  parts = sig.name.split('.')
248
253
  assert len(parts) == 2, 'Only one level of nested keys is supported'
249
- if parts[0] not in kwargs:
250
- kwargs[parts[0]] = data_handler.Output() if is_output else data_handler.Input()
251
- kwargs[parts[0]][parts[1]] = kwargs.pop(sig.name)
252
- return kwargs
254
+ if parts[0] not in unflattened:
255
+ unflattened[parts[0]] = data_types.Output() if is_output else data_types.Input()
256
+ unflattened[parts[0]][parts[1]] = kwargs[sig.name]
257
+ return unflattened
258
+
259
+
260
+ def get_stream_from_signature(signatures):
261
+ streaming_signatures = [var for var in signatures if var.streaming]
262
+ if not streaming_signatures:
263
+ return None, []
264
+ stream_argname = set([var.name.split('.', 1)[0] for var in streaming_signatures])
265
+ assert len(stream_argname) == 1, 'streaming methods must have exactly one streaming function arg'
266
+ stream_argname = stream_argname.pop()
267
+ return stream_argname, streaming_signatures
253
268
 
254
269
 
255
270
  def _is_empty_proto_data(data):
@@ -314,20 +329,20 @@ def _normalize_types(param, is_output=False):
314
329
  tp = param.annotation
315
330
 
316
331
  # stream type indicates streaming, not part of the data itself
317
- streaming = (get_origin(tp) == data_handler.Stream)
332
+ streaming = (get_origin(tp) == data_types.Stream)
318
333
  if streaming:
319
334
  tp = get_args(tp)[0]
320
335
 
321
336
  if is_output or streaming: # named types can be used for outputs or streaming inputs
322
337
  # output type used for named return values, each with their own data type
323
- if isinstance(tp, (dict, data_handler.Output, data_handler.Input)):
338
+ if isinstance(tp, (dict, data_types.Output, data_types.Input)):
324
339
  return {param.name + '.' + name: _normalize_data_type(val)
325
340
  for name, val in tp.items()}, streaming
326
- if tp == data_handler.Output: # check for Output type without values
341
+ if tp == data_types.Output: # check for Output type without values
327
342
  if not is_output:
328
343
  raise TypeError('Output types can only be used for output values')
329
344
  raise TypeError('Output types must be instantiated with inner type values for each key')
330
- if tp == data_handler.Input: # check for Output type without values
345
+ if tp == data_types.Input: # check for Output type without values
331
346
  if is_output:
332
347
  raise TypeError('Input types can only be used for input values')
333
348
  raise TypeError(
@@ -349,7 +364,7 @@ def _normalize_data_type(tp):
349
364
  # check for PIL images (sometimes types use the module, sometimes the class)
350
365
  # set these to use the Image data handler
351
366
  if tp in (PIL.Image, PIL.Image.Image):
352
- tp = data_handler.Image
367
+ tp = data_types.Image
353
368
 
354
369
  # put back list
355
370
  if is_list:
@@ -388,20 +403,20 @@ _DATA_TYPES = {
388
403
  _DataType('None', '', NullValueSerializer()),
389
404
  np.ndarray:
390
405
  _DataType('ndarray', 'ndarray', NDArraySerializer()),
391
- data_handler.Text:
392
- _DataType('Text', 'text', MessageSerializer(data_handler.Text)),
393
- data_handler.Image:
406
+ data_types.Text:
407
+ _DataType('Text', 'text', MessageSerializer(data_types.Text)),
408
+ data_types.Image:
394
409
  _DataType('Image', 'image', ImageSerializer()),
395
- data_handler.Concept:
396
- _DataType('Concept', 'concepts', MessageSerializer(data_handler.Concept)),
397
- data_handler.Region:
398
- _DataType('Region', 'regions', MessageSerializer(data_handler.Region)),
399
- data_handler.Frame:
400
- _DataType('Frame', 'frames', MessageSerializer(data_handler.Frame)),
401
- data_handler.Audio:
402
- _DataType('Audio', 'audio', MessageSerializer(data_handler.Audio)),
403
- data_handler.Video:
404
- _DataType('Video', 'video', MessageSerializer(data_handler.Video)),
410
+ data_types.Concept:
411
+ _DataType('Concept', 'concepts', MessageSerializer(data_types.Concept)),
412
+ data_types.Region:
413
+ _DataType('Region', 'regions', MessageSerializer(data_types.Region)),
414
+ data_types.Frame:
415
+ _DataType('Frame', 'frames', MessageSerializer(data_types.Frame)),
416
+ data_types.Audio:
417
+ _DataType('Audio', 'audio', MessageSerializer(data_types.Audio)),
418
+ data_types.Video:
419
+ _DataType('Video', 'video', MessageSerializer(data_types.Video)),
405
420
 
406
421
  # lists handled specially, not as generic lists using parts
407
422
  List[int]:
@@ -4,7 +4,7 @@ import numpy as np
4
4
  from clarifai_grpc.grpc.api import resources_pb2
5
5
  from PIL import Image as PILImage
6
6
 
7
- from clarifai.runners.utils.data_handler import Image, MessageData
7
+ from clarifai.runners.utils.data_types import Image, MessageData
8
8
 
9
9
 
10
10
  class Serializer:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clarifai
3
- Version: 11.1.5rc1
3
+ Version: 11.1.5rc2
4
4
  Summary: Clarifai Python SDK
5
5
  Home-page: https://github.com/Clarifai/clarifai-python
6
6
  Author: Clarifai
@@ -161,7 +161,7 @@ clarifai/runners/models/__pycache__/model_servicer.cpython-310.pyc
161
161
  clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc
162
162
  clarifai/runners/utils/__init__.py
163
163
  clarifai/runners/utils/const.py
164
- clarifai/runners/utils/data_handler.py
164
+ clarifai/runners/utils/data_types.py
165
165
  clarifai/runners/utils/data_utils.py
166
166
  clarifai/runners/utils/loader.py
167
167
  clarifai/runners/utils/method_signatures.py
@@ -170,6 +170,7 @@ clarifai/runners/utils/url_fetcher.py
170
170
  clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc
171
171
  clarifai/runners/utils/__pycache__/const.cpython-310.pyc
172
172
  clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc
173
+ clarifai/runners/utils/__pycache__/data_types.cpython-310.pyc
173
174
  clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc
174
175
  clarifai/runners/utils/__pycache__/loader.cpython-310.pyc
175
176
  clarifai/runners/utils/__pycache__/logging.cpython-310.pyc
@@ -1 +0,0 @@
1
- __version__ = "11.1.5rc1"