clarifai 11.3.0rc2__py3-none-any.whl → 11.4.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. clarifai/__init__.py +1 -1
  2. clarifai/cli/__main__.py +1 -1
  3. clarifai/cli/base.py +144 -136
  4. clarifai/cli/compute_cluster.py +45 -31
  5. clarifai/cli/deployment.py +93 -76
  6. clarifai/cli/model.py +578 -180
  7. clarifai/cli/nodepool.py +100 -82
  8. clarifai/client/__init__.py +12 -2
  9. clarifai/client/app.py +973 -911
  10. clarifai/client/auth/helper.py +345 -342
  11. clarifai/client/auth/register.py +7 -7
  12. clarifai/client/auth/stub.py +107 -106
  13. clarifai/client/base.py +185 -178
  14. clarifai/client/compute_cluster.py +214 -180
  15. clarifai/client/dataset.py +793 -698
  16. clarifai/client/deployment.py +55 -50
  17. clarifai/client/input.py +1223 -1088
  18. clarifai/client/lister.py +47 -45
  19. clarifai/client/model.py +1939 -1717
  20. clarifai/client/model_client.py +525 -502
  21. clarifai/client/module.py +82 -73
  22. clarifai/client/nodepool.py +358 -213
  23. clarifai/client/runner.py +58 -0
  24. clarifai/client/search.py +342 -309
  25. clarifai/client/user.py +419 -414
  26. clarifai/client/workflow.py +294 -274
  27. clarifai/constants/dataset.py +11 -17
  28. clarifai/constants/model.py +8 -2
  29. clarifai/datasets/export/inputs_annotations.py +233 -217
  30. clarifai/datasets/upload/base.py +63 -51
  31. clarifai/datasets/upload/features.py +43 -38
  32. clarifai/datasets/upload/image.py +237 -207
  33. clarifai/datasets/upload/loaders/coco_captions.py +34 -32
  34. clarifai/datasets/upload/loaders/coco_detection.py +72 -65
  35. clarifai/datasets/upload/loaders/imagenet_classification.py +57 -53
  36. clarifai/datasets/upload/loaders/xview_detection.py +274 -132
  37. clarifai/datasets/upload/multimodal.py +55 -46
  38. clarifai/datasets/upload/text.py +55 -47
  39. clarifai/datasets/upload/utils.py +250 -234
  40. clarifai/errors.py +51 -50
  41. clarifai/models/api.py +260 -238
  42. clarifai/modules/css.py +50 -50
  43. clarifai/modules/pages.py +33 -33
  44. clarifai/rag/rag.py +312 -288
  45. clarifai/rag/utils.py +91 -84
  46. clarifai/runners/models/model_builder.py +906 -802
  47. clarifai/runners/models/model_class.py +370 -331
  48. clarifai/runners/models/model_run_locally.py +459 -419
  49. clarifai/runners/models/model_runner.py +170 -162
  50. clarifai/runners/models/model_servicer.py +78 -70
  51. clarifai/runners/server.py +111 -101
  52. clarifai/runners/utils/code_script.py +225 -187
  53. clarifai/runners/utils/const.py +4 -1
  54. clarifai/runners/utils/data_types/__init__.py +12 -0
  55. clarifai/runners/utils/data_types/data_types.py +598 -0
  56. clarifai/runners/utils/data_utils.py +387 -440
  57. clarifai/runners/utils/loader.py +247 -227
  58. clarifai/runners/utils/method_signatures.py +411 -386
  59. clarifai/runners/utils/openai_convertor.py +108 -109
  60. clarifai/runners/utils/serializers.py +175 -179
  61. clarifai/runners/utils/url_fetcher.py +35 -35
  62. clarifai/schema/search.py +56 -63
  63. clarifai/urls/helper.py +125 -102
  64. clarifai/utils/cli.py +129 -123
  65. clarifai/utils/config.py +127 -87
  66. clarifai/utils/constants.py +49 -0
  67. clarifai/utils/evaluation/helpers.py +503 -466
  68. clarifai/utils/evaluation/main.py +431 -393
  69. clarifai/utils/evaluation/testset_annotation_parser.py +154 -144
  70. clarifai/utils/logging.py +324 -306
  71. clarifai/utils/misc.py +60 -56
  72. clarifai/utils/model_train.py +165 -146
  73. clarifai/utils/protobuf.py +126 -103
  74. clarifai/versions.py +3 -1
  75. clarifai/workflows/export.py +48 -50
  76. clarifai/workflows/utils.py +39 -36
  77. clarifai/workflows/validate.py +55 -43
  78. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/METADATA +16 -6
  79. clarifai-11.4.0.dist-info/RECORD +109 -0
  80. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/WHEEL +1 -1
  81. clarifai/__pycache__/__init__.cpython-310.pyc +0 -0
  82. clarifai/__pycache__/__init__.cpython-311.pyc +0 -0
  83. clarifai/__pycache__/__init__.cpython-39.pyc +0 -0
  84. clarifai/__pycache__/errors.cpython-310.pyc +0 -0
  85. clarifai/__pycache__/errors.cpython-311.pyc +0 -0
  86. clarifai/__pycache__/versions.cpython-310.pyc +0 -0
  87. clarifai/__pycache__/versions.cpython-311.pyc +0 -0
  88. clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  89. clarifai/cli/__pycache__/__init__.cpython-311.pyc +0 -0
  90. clarifai/cli/__pycache__/base.cpython-310.pyc +0 -0
  91. clarifai/cli/__pycache__/base.cpython-311.pyc +0 -0
  92. clarifai/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
  93. clarifai/cli/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  94. clarifai/cli/__pycache__/compute_cluster.cpython-311.pyc +0 -0
  95. clarifai/cli/__pycache__/deployment.cpython-310.pyc +0 -0
  96. clarifai/cli/__pycache__/deployment.cpython-311.pyc +0 -0
  97. clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
  98. clarifai/cli/__pycache__/model.cpython-311.pyc +0 -0
  99. clarifai/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
  100. clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
  101. clarifai/cli/__pycache__/nodepool.cpython-311.pyc +0 -0
  102. clarifai/client/__pycache__/__init__.cpython-310.pyc +0 -0
  103. clarifai/client/__pycache__/__init__.cpython-311.pyc +0 -0
  104. clarifai/client/__pycache__/__init__.cpython-39.pyc +0 -0
  105. clarifai/client/__pycache__/app.cpython-310.pyc +0 -0
  106. clarifai/client/__pycache__/app.cpython-311.pyc +0 -0
  107. clarifai/client/__pycache__/app.cpython-39.pyc +0 -0
  108. clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
  109. clarifai/client/__pycache__/base.cpython-311.pyc +0 -0
  110. clarifai/client/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  111. clarifai/client/__pycache__/compute_cluster.cpython-311.pyc +0 -0
  112. clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
  113. clarifai/client/__pycache__/dataset.cpython-311.pyc +0 -0
  114. clarifai/client/__pycache__/deployment.cpython-310.pyc +0 -0
  115. clarifai/client/__pycache__/deployment.cpython-311.pyc +0 -0
  116. clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
  117. clarifai/client/__pycache__/input.cpython-311.pyc +0 -0
  118. clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
  119. clarifai/client/__pycache__/lister.cpython-311.pyc +0 -0
  120. clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
  121. clarifai/client/__pycache__/model.cpython-311.pyc +0 -0
  122. clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
  123. clarifai/client/__pycache__/module.cpython-311.pyc +0 -0
  124. clarifai/client/__pycache__/nodepool.cpython-310.pyc +0 -0
  125. clarifai/client/__pycache__/nodepool.cpython-311.pyc +0 -0
  126. clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
  127. clarifai/client/__pycache__/search.cpython-311.pyc +0 -0
  128. clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
  129. clarifai/client/__pycache__/user.cpython-311.pyc +0 -0
  130. clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
  131. clarifai/client/__pycache__/workflow.cpython-311.pyc +0 -0
  132. clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
  133. clarifai/client/auth/__pycache__/__init__.cpython-311.pyc +0 -0
  134. clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
  135. clarifai/client/auth/__pycache__/helper.cpython-311.pyc +0 -0
  136. clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
  137. clarifai/client/auth/__pycache__/register.cpython-311.pyc +0 -0
  138. clarifai/client/auth/__pycache__/stub.cpython-310.pyc +0 -0
  139. clarifai/client/auth/__pycache__/stub.cpython-311.pyc +0 -0
  140. clarifai/client/cli/__init__.py +0 -0
  141. clarifai/client/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  142. clarifai/client/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
  143. clarifai/client/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
  144. clarifai/client/cli/base_cli.py +0 -88
  145. clarifai/client/cli/model_cli.py +0 -29
  146. clarifai/constants/__pycache__/base.cpython-310.pyc +0 -0
  147. clarifai/constants/__pycache__/base.cpython-311.pyc +0 -0
  148. clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
  149. clarifai/constants/__pycache__/dataset.cpython-311.pyc +0 -0
  150. clarifai/constants/__pycache__/input.cpython-310.pyc +0 -0
  151. clarifai/constants/__pycache__/input.cpython-311.pyc +0 -0
  152. clarifai/constants/__pycache__/model.cpython-310.pyc +0 -0
  153. clarifai/constants/__pycache__/model.cpython-311.pyc +0 -0
  154. clarifai/constants/__pycache__/rag.cpython-310.pyc +0 -0
  155. clarifai/constants/__pycache__/rag.cpython-311.pyc +0 -0
  156. clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
  157. clarifai/constants/__pycache__/search.cpython-311.pyc +0 -0
  158. clarifai/constants/__pycache__/workflow.cpython-310.pyc +0 -0
  159. clarifai/constants/__pycache__/workflow.cpython-311.pyc +0 -0
  160. clarifai/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
  161. clarifai/datasets/__pycache__/__init__.cpython-311.pyc +0 -0
  162. clarifai/datasets/__pycache__/__init__.cpython-39.pyc +0 -0
  163. clarifai/datasets/export/__pycache__/__init__.cpython-310.pyc +0 -0
  164. clarifai/datasets/export/__pycache__/__init__.cpython-311.pyc +0 -0
  165. clarifai/datasets/export/__pycache__/__init__.cpython-39.pyc +0 -0
  166. clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
  167. clarifai/datasets/export/__pycache__/inputs_annotations.cpython-311.pyc +0 -0
  168. clarifai/datasets/upload/__pycache__/__init__.cpython-310.pyc +0 -0
  169. clarifai/datasets/upload/__pycache__/__init__.cpython-311.pyc +0 -0
  170. clarifai/datasets/upload/__pycache__/__init__.cpython-39.pyc +0 -0
  171. clarifai/datasets/upload/__pycache__/base.cpython-310.pyc +0 -0
  172. clarifai/datasets/upload/__pycache__/base.cpython-311.pyc +0 -0
  173. clarifai/datasets/upload/__pycache__/features.cpython-310.pyc +0 -0
  174. clarifai/datasets/upload/__pycache__/features.cpython-311.pyc +0 -0
  175. clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
  176. clarifai/datasets/upload/__pycache__/image.cpython-311.pyc +0 -0
  177. clarifai/datasets/upload/__pycache__/multimodal.cpython-310.pyc +0 -0
  178. clarifai/datasets/upload/__pycache__/multimodal.cpython-311.pyc +0 -0
  179. clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
  180. clarifai/datasets/upload/__pycache__/text.cpython-311.pyc +0 -0
  181. clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
  182. clarifai/datasets/upload/__pycache__/utils.cpython-311.pyc +0 -0
  183. clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-311.pyc +0 -0
  184. clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-39.pyc +0 -0
  185. clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-311.pyc +0 -0
  186. clarifai/datasets/upload/loaders/__pycache__/imagenet_classification.cpython-311.pyc +0 -0
  187. clarifai/models/__pycache__/__init__.cpython-39.pyc +0 -0
  188. clarifai/modules/__pycache__/__init__.cpython-39.pyc +0 -0
  189. clarifai/rag/__pycache__/__init__.cpython-310.pyc +0 -0
  190. clarifai/rag/__pycache__/__init__.cpython-311.pyc +0 -0
  191. clarifai/rag/__pycache__/__init__.cpython-39.pyc +0 -0
  192. clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
  193. clarifai/rag/__pycache__/rag.cpython-311.pyc +0 -0
  194. clarifai/rag/__pycache__/rag.cpython-39.pyc +0 -0
  195. clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
  196. clarifai/rag/__pycache__/utils.cpython-311.pyc +0 -0
  197. clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
  198. clarifai/runners/__pycache__/__init__.cpython-311.pyc +0 -0
  199. clarifai/runners/__pycache__/__init__.cpython-39.pyc +0 -0
  200. clarifai/runners/dockerfile_template/Dockerfile.cpu.template +0 -31
  201. clarifai/runners/dockerfile_template/Dockerfile.cuda.template +0 -42
  202. clarifai/runners/dockerfile_template/Dockerfile.nim +0 -71
  203. clarifai/runners/models/__pycache__/__init__.cpython-310.pyc +0 -0
  204. clarifai/runners/models/__pycache__/__init__.cpython-311.pyc +0 -0
  205. clarifai/runners/models/__pycache__/__init__.cpython-39.pyc +0 -0
  206. clarifai/runners/models/__pycache__/base_typed_model.cpython-310.pyc +0 -0
  207. clarifai/runners/models/__pycache__/base_typed_model.cpython-311.pyc +0 -0
  208. clarifai/runners/models/__pycache__/base_typed_model.cpython-39.pyc +0 -0
  209. clarifai/runners/models/__pycache__/model_builder.cpython-311.pyc +0 -0
  210. clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
  211. clarifai/runners/models/__pycache__/model_class.cpython-311.pyc +0 -0
  212. clarifai/runners/models/__pycache__/model_run_locally.cpython-310-pytest-7.1.2.pyc +0 -0
  213. clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc +0 -0
  214. clarifai/runners/models/__pycache__/model_run_locally.cpython-311.pyc +0 -0
  215. clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc +0 -0
  216. clarifai/runners/models/__pycache__/model_runner.cpython-311.pyc +0 -0
  217. clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
  218. clarifai/runners/models/base_typed_model.py +0 -238
  219. clarifai/runners/models/model_class_refract.py +0 -80
  220. clarifai/runners/models/model_upload.py +0 -607
  221. clarifai/runners/models/temp.py +0 -25
  222. clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  223. clarifai/runners/utils/__pycache__/__init__.cpython-311.pyc +0 -0
  224. clarifai/runners/utils/__pycache__/__init__.cpython-38.pyc +0 -0
  225. clarifai/runners/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  226. clarifai/runners/utils/__pycache__/buffered_stream.cpython-310.pyc +0 -0
  227. clarifai/runners/utils/__pycache__/buffered_stream.cpython-38.pyc +0 -0
  228. clarifai/runners/utils/__pycache__/buffered_stream.cpython-39.pyc +0 -0
  229. clarifai/runners/utils/__pycache__/const.cpython-310.pyc +0 -0
  230. clarifai/runners/utils/__pycache__/const.cpython-311.pyc +0 -0
  231. clarifai/runners/utils/__pycache__/constants.cpython-310.pyc +0 -0
  232. clarifai/runners/utils/__pycache__/constants.cpython-38.pyc +0 -0
  233. clarifai/runners/utils/__pycache__/constants.cpython-39.pyc +0 -0
  234. clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc +0 -0
  235. clarifai/runners/utils/__pycache__/data_handler.cpython-311.pyc +0 -0
  236. clarifai/runners/utils/__pycache__/data_handler.cpython-38.pyc +0 -0
  237. clarifai/runners/utils/__pycache__/data_handler.cpython-39.pyc +0 -0
  238. clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc +0 -0
  239. clarifai/runners/utils/__pycache__/data_utils.cpython-311.pyc +0 -0
  240. clarifai/runners/utils/__pycache__/data_utils.cpython-38.pyc +0 -0
  241. clarifai/runners/utils/__pycache__/data_utils.cpython-39.pyc +0 -0
  242. clarifai/runners/utils/__pycache__/grpc_server.cpython-310.pyc +0 -0
  243. clarifai/runners/utils/__pycache__/grpc_server.cpython-38.pyc +0 -0
  244. clarifai/runners/utils/__pycache__/grpc_server.cpython-39.pyc +0 -0
  245. clarifai/runners/utils/__pycache__/health.cpython-310.pyc +0 -0
  246. clarifai/runners/utils/__pycache__/health.cpython-38.pyc +0 -0
  247. clarifai/runners/utils/__pycache__/health.cpython-39.pyc +0 -0
  248. clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
  249. clarifai/runners/utils/__pycache__/loader.cpython-311.pyc +0 -0
  250. clarifai/runners/utils/__pycache__/logging.cpython-310.pyc +0 -0
  251. clarifai/runners/utils/__pycache__/logging.cpython-38.pyc +0 -0
  252. clarifai/runners/utils/__pycache__/logging.cpython-39.pyc +0 -0
  253. clarifai/runners/utils/__pycache__/stream_source.cpython-310.pyc +0 -0
  254. clarifai/runners/utils/__pycache__/stream_source.cpython-39.pyc +0 -0
  255. clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc +0 -0
  256. clarifai/runners/utils/__pycache__/url_fetcher.cpython-311.pyc +0 -0
  257. clarifai/runners/utils/__pycache__/url_fetcher.cpython-38.pyc +0 -0
  258. clarifai/runners/utils/__pycache__/url_fetcher.cpython-39.pyc +0 -0
  259. clarifai/runners/utils/data_handler.py +0 -231
  260. clarifai/runners/utils/data_handler_refract.py +0 -213
  261. clarifai/runners/utils/data_types.py +0 -469
  262. clarifai/runners/utils/logger.py +0 -0
  263. clarifai/runners/utils/openai_format.py +0 -87
  264. clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
  265. clarifai/schema/__pycache__/search.cpython-311.pyc +0 -0
  266. clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
  267. clarifai/urls/__pycache__/helper.cpython-311.pyc +0 -0
  268. clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  269. clarifai/utils/__pycache__/__init__.cpython-311.pyc +0 -0
  270. clarifai/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  271. clarifai/utils/__pycache__/cli.cpython-310.pyc +0 -0
  272. clarifai/utils/__pycache__/cli.cpython-311.pyc +0 -0
  273. clarifai/utils/__pycache__/config.cpython-311.pyc +0 -0
  274. clarifai/utils/__pycache__/constants.cpython-310.pyc +0 -0
  275. clarifai/utils/__pycache__/constants.cpython-311.pyc +0 -0
  276. clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
  277. clarifai/utils/__pycache__/logging.cpython-311.pyc +0 -0
  278. clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
  279. clarifai/utils/__pycache__/misc.cpython-311.pyc +0 -0
  280. clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
  281. clarifai/utils/__pycache__/model_train.cpython-311.pyc +0 -0
  282. clarifai/utils/__pycache__/protobuf.cpython-311.pyc +0 -0
  283. clarifai/utils/evaluation/__pycache__/__init__.cpython-311.pyc +0 -0
  284. clarifai/utils/evaluation/__pycache__/__init__.cpython-39.pyc +0 -0
  285. clarifai/utils/evaluation/__pycache__/helpers.cpython-311.pyc +0 -0
  286. clarifai/utils/evaluation/__pycache__/main.cpython-311.pyc +0 -0
  287. clarifai/utils/evaluation/__pycache__/main.cpython-39.pyc +0 -0
  288. clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
  289. clarifai/workflows/__pycache__/__init__.cpython-311.pyc +0 -0
  290. clarifai/workflows/__pycache__/__init__.cpython-39.pyc +0 -0
  291. clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
  292. clarifai/workflows/__pycache__/export.cpython-311.pyc +0 -0
  293. clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
  294. clarifai/workflows/__pycache__/utils.cpython-311.pyc +0 -0
  295. clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
  296. clarifai/workflows/__pycache__/validate.cpython-311.pyc +0 -0
  297. clarifai-11.3.0rc2.dist-info/RECORD +0 -322
  298. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/entry_points.txt +0 -0
  299. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info/licenses}/LICENSE +0 -0
  300. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/top_level.txt +0 -0
clarifai/models/api.py CHANGED
@@ -23,261 +23,283 @@ from clarifai.client.auth.helper import ClarifaiAuthHelper
23
23
 
24
24
 
25
25
  def _make_default_value_proto(dtype, value):
26
- if dtype == 1:
27
- return Value(bool_value=value)
28
- elif dtype == 2 or dtype == 21:
29
- return Value(string_value=value)
30
- elif dtype == 3:
31
- return Value(number_value=value)
26
+ if dtype == 1:
27
+ return Value(bool_value=value)
28
+ elif dtype == 2 or dtype == 21:
29
+ return Value(string_value=value)
30
+ elif dtype == 3:
31
+ return Value(number_value=value)
32
32
 
33
33
 
34
34
  class Models:
35
- """
36
- Interface to Clarifai models api
37
- """
38
-
39
- def __init__(self, auth: Type[ClarifaiAuthHelper]) -> None:
40
- self.auth = auth
41
- self.stub = create_stub(self.auth)
42
-
43
- def list_model_types(self) -> Dict:
44
35
  """
45
- List all API Model Types that support input and output.
36
+ Interface to Clarifai models api
37
+ """
46
38
 
47
- Returns:
48
- - A dict of;
49
- model_type, [{expected_input_name: value}, {expected_output_name: value}, model_descripton]
50
- key, value pairs respectively.i.e.
51
- {model_type: [{inp_field_name: value}, {output_field_name: value,...}, model_description]}
39
+ def __init__(self, auth: Type[ClarifaiAuthHelper]) -> None:
40
+ self.auth = auth
41
+ self.stub = create_stub(self.auth)
42
+
43
+ def list_model_types(self) -> Dict:
44
+ """
45
+ List all API Model Types that support input and output.
46
+
47
+ Returns:
48
+ - A dict of;
49
+ model_type, [{expected_input_name: value}, {expected_output_name: value}, model_descripton]
50
+ key, value pairs respectively.i.e.
51
+ {model_type: [{inp_field_name: value}, {output_field_name: value,...}, model_description]}
52
+
53
+ - model_type: supported input shapes and data types dict. Structure;
54
+ {model_type: [(supported_input_N_dims, dtypes_N),...]}
55
+
56
+ - model_type: supported output shapes and data types dict. Structure;
57
+ {model_type: [(supported_output_N_dims, dtypes_N),...]}
58
+ """
59
+ ## List model types from API
60
+ model_types_response = self.stub.ListModelTypes(
61
+ service_pb2.ListModelTypesRequest(), # (user_app_id=auth.user_app_id),
62
+ metadata=self.auth.metadata,
63
+ )
64
+ # model types dict structure:
65
+ # {model_type: [{inp_field_name: value,}, {output_field_name: value,...}, desc]}
66
+ model_types = {}
67
+ in_dims_dtype = {} # {model_type: [(supported_input_N_dims, dtypes_N),...]}
68
+ out_dims_dtype = {} # {model_type: [(supported_output_N_dims, dtypes_N),...]}
69
+ types_dict = MessageToDict(model_types_response, preserving_proto_field_name=True)[
70
+ 'model_types'
71
+ ]
72
+ for i in range(len(types_dict)):
73
+ model_id = types_dict[i]['id']
74
+ model_desc = types_dict[i]['description']
75
+ if 'expected_output_layers' in types_dict[i].keys():
76
+ # expected_input_layers exist for all expected_output_layers
77
+ # hence one conditional check
78
+ model_types[model_id] = []
79
+ in_dims_dtype[model_id] = []
80
+ out_dims_dtype[model_id] = []
81
+ expected_input = types_dict[i]['expected_input_layers']
82
+ expected_output = types_dict[i]['expected_output_layers']
83
+ for inp in expected_input:
84
+ if 'data_field_name' in inp.keys():
85
+ model_types[model_id].append({inp['data_field_name']: None})
86
+ if 'shapes' in inp.keys():
87
+ for dim in inp['shapes']:
88
+ if 'dims' in dim.keys():
89
+ if 'max_dims' in dim.keys():
90
+ in_dims_dtype[model_id].append(
91
+ (dim['dims'], dim['max_dims'], dim['data_type'])
92
+ )
93
+ else:
94
+ in_dims_dtype[model_id].append((dim['dims'], dim['data_type']))
95
+ continue
96
+ temp_out = {}
97
+ for each in expected_output:
98
+ if 'data_field_name' in each.keys():
99
+ temp_out[each['data_field_name']] = None
100
+ if 'shapes' in each.keys():
101
+ for dim in each['shapes']:
102
+ if 'dims' in dim.keys():
103
+ out_dims_dtype[model_id].append((dim['dims'], dim['data_type']))
104
+ else:
105
+ continue
106
+ model_types[model_id].append(temp_out)
107
+ model_types[model_id].append(model_desc)
108
+
109
+ return {
110
+ "Model Types": model_types,
111
+ "Input Metadata": in_dims_dtype,
112
+ "Output Metadata": out_dims_dtype,
113
+ }
114
+
115
+ def init_model(
116
+ self,
117
+ model_id: str,
118
+ model_type: str,
119
+ description: str = "",
120
+ ):
121
+ """Init a new model on Clarifai platform.
122
+
123
+ Args:
124
+ model_id (str): Clarifai model id
125
+ model_type (str): Clarifai model type
126
+ description (str, optional): a description of the model. Defaults to "".
127
+
128
+ Returns:
129
+ dict: Clarifai api response
130
+ """
131
+ user_data_object = self.auth.get_user_app_id_proto()
132
+ post_models_response = self.stub.PostModels(
133
+ service_pb2.PostModelsRequest(
134
+ user_app_id=user_data_object,
135
+ models=[
136
+ resources_pb2.Model(id=model_id, notes=description, model_type_id=model_type)
137
+ ],
138
+ ),
139
+ metadata=self.auth.metadata,
140
+ )
52
141
 
53
- - model_type: supported input shapes and data types dict. Structure;
54
- {model_type: [(supported_input_N_dims, dtypes_N),...]}
142
+ return MessageToDict(post_models_response, preserving_proto_field_name=True)
143
+
144
+ def post_model_version(
145
+ self,
146
+ model_id: str,
147
+ model_zip_url: str,
148
+ input: dict,
149
+ outputs: dict,
150
+ param_specs: List[dict] = None,
151
+ ):
152
+ """Post a new version of an existing model in the Clarifai platform.
153
+
154
+ Args:
155
+ model_id (str): Clarifai model id
156
+ model_zip_url (str]): url of zip of model
157
+ model_zip_url (str): url of zip of model
158
+ input (dict): a dict where the key is clarifai input field and the value is triton model input,
159
+ {clarifai_input_field: triton_input_filed}.
160
+ outputs (dict): a dict where the keys are clarifai output fields and the values are triton model outputs,
161
+ {clarifai_output_field1: triton_output_filed1, clarifai_output_field2: triton_output_filed2,...}.
162
+ param_specs (List[dict]): list of dicts - keys are path, field_type, default_value, description. Default is None
163
+ Returns:
164
+ dict: clarifai api response
165
+ """
166
+ user_data_object = self.auth.get_user_app_id_proto()
167
+
168
+ def _parse_fields_map(x):
169
+ """parse input, outputs to Struct"""
170
+ _fields_map = Struct()
171
+ _fields_map.update(x)
172
+ return _fields_map
173
+
174
+ input_fields_map = _parse_fields_map(input)
175
+ output_fields_map = _parse_fields_map(outputs)
176
+ # resources_pb2.ModelTypeField(path="abc", default_value=1, description="test")
177
+ if param_specs:
178
+ iterative_proto_params = []
179
+ for param in param_specs:
180
+ dtype = param.get("field_type")
181
+ proto_param = resources_pb2.ModelTypeField(
182
+ path=param.get("path"),
183
+ field_type=dtype,
184
+ default_value=_make_default_value_proto(
185
+ dtype=dtype, value=param.get("default_value")
186
+ ),
187
+ description=param.get("description"),
188
+ )
189
+ iterative_proto_params.append(proto_param)
190
+ param_specs = iterative_proto_params
191
+
192
+ post_model_versions = self.stub.PostModelVersions(
193
+ service_pb2.PostModelVersionsRequest(
194
+ user_app_id=user_data_object,
195
+ model_id=model_id,
196
+ model_versions=[
197
+ resources_pb2.ModelVersion(
198
+ pretrained_model_config=resources_pb2.PretrainedModelConfig(
199
+ model_zip_url=model_zip_url,
200
+ input_fields_map=input_fields_map,
201
+ output_fields_map=output_fields_map,
202
+ ),
203
+ output_info=resources_pb2.OutputInfo(params_specs=param_specs),
204
+ )
205
+ ],
206
+ ),
207
+ metadata=self.auth.metadata,
208
+ )
55
209
 
56
- - model_type: supported output shapes and data types dict. Structure;
57
- {model_type: [(supported_output_N_dims, dtypes_N),...]}
58
- """
59
- ## List model types from API
60
- model_types_response = self.stub.ListModelTypes(
61
- service_pb2.ListModelTypesRequest(), #(user_app_id=auth.user_app_id),
62
- metadata=self.auth.metadata)
63
- # model types dict structure:
64
- # {model_type: [{inp_field_name: value,}, {output_field_name: value,...}, desc]}
65
- model_types = {}
66
- in_dims_dtype = {} # {model_type: [(supported_input_N_dims, dtypes_N),...]}
67
- out_dims_dtype = {} # {model_type: [(supported_output_N_dims, dtypes_N),...]}
68
- types_dict = MessageToDict(
69
- model_types_response, preserving_proto_field_name=True)['model_types']
70
- for i in range(len(types_dict)):
71
- model_id = types_dict[i]['id']
72
- model_desc = types_dict[i]['description']
73
- if 'expected_output_layers' in types_dict[i].keys():
74
- # expected_input_layers exist for all expected_output_layers
75
- # hence one conditional check
76
- model_types[model_id] = []
77
- in_dims_dtype[model_id] = []
78
- out_dims_dtype[model_id] = []
79
- expected_input = types_dict[i]['expected_input_layers']
80
- expected_output = types_dict[i]['expected_output_layers']
81
- for inp in expected_input:
82
- if 'data_field_name' in inp.keys():
83
- model_types[model_id].append({inp['data_field_name']: None})
84
- if 'shapes' in inp.keys():
85
- for dim in inp['shapes']:
86
- if 'dims' in dim.keys():
87
- if 'max_dims' in dim.keys():
88
- in_dims_dtype[model_id].append((dim['dims'], dim['max_dims'], dim['data_type']))
89
- else:
90
- in_dims_dtype[model_id].append((dim['dims'], dim['data_type']))
91
- continue
92
- temp_out = {}
93
- for each in expected_output:
94
- if 'data_field_name' in each.keys():
95
- temp_out[each['data_field_name']] = None
96
- if 'shapes' in each.keys():
97
- for dim in each['shapes']:
98
-
99
- if 'dims' in dim.keys():
100
- out_dims_dtype[model_id].append((dim['dims'], dim['data_type']))
101
- else:
102
- continue
103
- model_types[model_id].append(temp_out)
104
- model_types[model_id].append(model_desc)
105
-
106
- return {
107
- "Model Types": model_types,
108
- "Input Metadata": in_dims_dtype,
109
- "Output Metadata": out_dims_dtype
110
- }
111
-
112
- def init_model(
113
- self,
114
- model_id: str,
115
- model_type: str,
116
- description: str = "",
117
- ):
118
- """Init a new model on Clarifai platform.
119
-
120
- Args:
121
- model_id (str): Clarifai model id
122
- model_type (str): Clarifai model type
123
- description (str, optional): a description of the model. Defaults to "".
124
-
125
- Returns:
126
- dict: Clarifai api response
127
- """
128
- user_data_object = self.auth.get_user_app_id_proto()
129
- post_models_response = self.stub.PostModels(
130
- service_pb2.PostModelsRequest(
131
- user_app_id=user_data_object,
132
- models=[resources_pb2.Model(id=model_id, notes=description,
133
- model_type_id=model_type)]),
134
- metadata=self.auth.metadata)
135
-
136
- return MessageToDict(post_models_response, preserving_proto_field_name=True)
137
-
138
- def post_model_version(self,
139
- model_id: str,
140
- model_zip_url: str,
141
- input: dict,
142
- outputs: dict,
143
- param_specs: List[dict] = None):
144
- """Post a new version of an existing model in the Clarifai platform.
145
-
146
- Args:
147
- model_id (str): Clarifai model id
148
- model_zip_url (str]): url of zip of model
149
- model_zip_url (str): url of zip of model
150
- input (dict): a dict where the key is clarifai input field and the value is triton model input,
151
- {clarifai_input_field: triton_input_filed}.
152
- outputs (dict): a dict where the keys are clarifai output fields and the values are triton model outputs,
153
- {clarifai_output_field1: triton_output_filed1, clarifai_output_field2: triton_output_filed2,...}.
154
- param_specs (List[dict]): list of dicts - keys are path, field_type, default_value, description. Default is None
155
- Returns:
156
- dict: clarifai api response
157
- """
158
- user_data_object = self.auth.get_user_app_id_proto()
159
-
160
- def _parse_fields_map(x):
161
- """parse input, outputs to Struct"""
162
- _fields_map = Struct()
163
- _fields_map.update(x)
164
- return _fields_map
165
-
166
- input_fields_map = _parse_fields_map(input)
167
- output_fields_map = _parse_fields_map(outputs)
168
- #resources_pb2.ModelTypeField(path="abc", default_value=1, description="test")
169
- if param_specs:
170
- iterative_proto_params = []
171
- for param in param_specs:
172
- dtype = param.get("field_type")
173
- proto_param = resources_pb2.ModelTypeField(
174
- path=param.get("path"),
175
- field_type=dtype,
176
- default_value=_make_default_value_proto(dtype=dtype, value=param.get("default_value")),
177
- description=param.get("description"),
210
+ return MessageToDict(post_model_versions, preserving_proto_field_name=True)
211
+
212
+ def upload_model(
213
+ self,
214
+ model_id: str,
215
+ model_zip_url: str,
216
+ input: dict,
217
+ outputs: dict,
218
+ model_type: str,
219
+ description: str = "",
220
+ param_specs: List[dict] = None,
221
+ ):
222
+ """Doing 2 requests for initializing and creating version for a new trained model to the Clarifai platform.
223
+
224
+ Args:
225
+ model_id (str): Clarifai model id
226
+ model_zip_url (str): url of zip of model
227
+ input (dict): a dict where the key is clarifai input field and the value is triton model input,
228
+ {clarifai_input_field: triton_input_filed}
229
+ outputs (dict): a dict where the keys are clarifai output fields and the values are triton model outputs,
230
+ {clarifai_output_field1: triton_output_filed1, clarifai_output_field2: triton_output_filed2,...}
231
+ model_type (str): Clarifai model type.
232
+ description (str, optional): a description of the model. Defaults to "".
233
+ param_specs (List[dict]): list of dicts - keys are path, field_type, default_value, description. Default is None
234
+
235
+ Returns:
236
+ dict: Clarifai api response
237
+ """
238
+ init_resp = self.init_model(model_id, model_type, description)
239
+ if init_resp["status"]["code"] != "SUCCESS":
240
+ return init_resp
241
+ version_resp = self.post_model_version(
242
+ model_id, model_zip_url, input, outputs, param_specs
178
243
  )
179
- iterative_proto_params.append(proto_param)
180
- param_specs = iterative_proto_params
181
-
182
- post_model_versions = self.stub.PostModelVersions(
183
- service_pb2.PostModelVersionsRequest(
184
- user_app_id=user_data_object,
185
- model_id=model_id,
186
- model_versions=[
187
- resources_pb2.ModelVersion(
188
- pretrained_model_config=resources_pb2.PretrainedModelConfig(
189
- model_zip_url=model_zip_url,
190
- input_fields_map=input_fields_map,
191
- output_fields_map=output_fields_map),
192
- output_info=resources_pb2.OutputInfo(params_specs=param_specs))
193
- ]),
194
- metadata=self.auth.metadata)
195
-
196
- return MessageToDict(post_model_versions, preserving_proto_field_name=True)
197
-
198
- def upload_model(self,
199
- model_id: str,
200
- model_zip_url: str,
201
- input: dict,
202
- outputs: dict,
203
- model_type: str,
204
- description: str = "",
205
- param_specs: List[dict] = None):
206
- """Doing 2 requests for initializing and creating version for a new trained model to the Clarifai platform.
207
-
208
- Args:
209
- model_id (str): Clarifai model id
210
- model_zip_url (str): url of zip of model
211
- input (dict): a dict where the key is clarifai input field and the value is triton model input,
212
- {clarifai_input_field: triton_input_filed}
213
- outputs (dict): a dict where the keys are clarifai output fields and the values are triton model outputs,
214
- {clarifai_output_field1: triton_output_filed1, clarifai_output_field2: triton_output_filed2,...}
215
- model_type (str): Clarifai model type.
216
- description (str, optional): a description of the model. Defaults to "".
217
- param_specs (List[dict]): list of dicts - keys are path, field_type, default_value, description. Default is None
218
-
219
- Returns:
220
- dict: Clarifai api response
221
- """
222
- init_resp = self.init_model(model_id, model_type, description)
223
- if init_resp["status"]["code"] != "SUCCESS":
224
- return init_resp
225
- version_resp = self.post_model_version(model_id, model_zip_url, input, outputs, param_specs)
226
244
 
227
- return version_resp
245
+ return version_resp
228
246
 
229
- def delete_model(self, model_id: str):
230
- """Delete model api by model id
247
+ def delete_model(self, model_id: str):
248
+ """Delete model api by model id
231
249
 
232
- Args:
233
- model_id (str): Clarifai model id
250
+ Args:
251
+ model_id (str): Clarifai model id
234
252
 
235
- Returns:
236
- dict: clarifai api response
237
- """
238
- user_data_object = self.auth.get_user_app_id_proto()
239
- delete_model_response = self.stub.DeleteModel(
240
- service_pb2.DeleteModelRequest(
241
- user_app_id=user_data_object,
242
- model_id=model_id,
243
- ),
244
- metadata=self.auth.metadata)
253
+ Returns:
254
+ dict: clarifai api response
255
+ """
256
+ user_data_object = self.auth.get_user_app_id_proto()
257
+ delete_model_response = self.stub.DeleteModel(
258
+ service_pb2.DeleteModelRequest(
259
+ user_app_id=user_data_object,
260
+ model_id=model_id,
261
+ ),
262
+ metadata=self.auth.metadata,
263
+ )
245
264
 
246
- return MessageToDict(delete_model_response, preserving_proto_field_name=True)
265
+ return MessageToDict(delete_model_response, preserving_proto_field_name=True)
247
266
 
248
- def delete_model_version(self, model_id: str, version_id: str):
249
- """Delete specific version of model
267
+ def delete_model_version(self, model_id: str, version_id: str):
268
+ """Delete specific version of model
250
269
 
251
- Args:
252
- model_id (str): Clarifai model id
253
- version_id (str): version id of model that will be removed
270
+ Args:
271
+ model_id (str): Clarifai model id
272
+ version_id (str): version id of model that will be removed
254
273
 
255
- Returns:
256
- dict: Clarifai API response
257
- """
258
- user_data_object = self.auth.get_user_app_id_proto()
259
- delete_model_response = self.stub.DeleteModelVersion(
260
- service_pb2.DeleteModelVersionRequest(
261
- user_app_id=user_data_object, model_id=model_id, version_id=version_id),
262
- metadata=self.auth.metadata)
274
+ Returns:
275
+ dict: Clarifai API response
276
+ """
277
+ user_data_object = self.auth.get_user_app_id_proto()
278
+ delete_model_response = self.stub.DeleteModelVersion(
279
+ service_pb2.DeleteModelVersionRequest(
280
+ user_app_id=user_data_object, model_id=model_id, version_id=version_id
281
+ ),
282
+ metadata=self.auth.metadata,
283
+ )
263
284
 
264
- return MessageToDict(delete_model_response, preserving_proto_field_name=True)
285
+ return MessageToDict(delete_model_response, preserving_proto_field_name=True)
265
286
 
266
- def get_model(self, model_id: str):
267
- """Get model by id
287
+ def get_model(self, model_id: str):
288
+ """Get model by id
268
289
 
269
- Args:
270
- model_id (str): Clarifai model id
290
+ Args:
291
+ model_id (str): Clarifai model id
271
292
 
272
- Returns:
273
- dict: Clarifai API response
274
- """
275
- user_data_object = self.auth.get_user_app_id_proto()
276
- response = self.stub.GetModel(
277
- service_pb2.GetModelRequest(
278
- user_app_id=user_data_object,
279
- model_id=model_id,
280
- ),
281
- metadata=self.auth.metadata)
282
-
283
- return MessageToDict(response, preserving_proto_field_name=True)
293
+ Returns:
294
+ dict: Clarifai API response
295
+ """
296
+ user_data_object = self.auth.get_user_app_id_proto()
297
+ response = self.stub.GetModel(
298
+ service_pb2.GetModelRequest(
299
+ user_app_id=user_data_object,
300
+ model_id=model_id,
301
+ ),
302
+ metadata=self.auth.metadata,
303
+ )
304
+
305
+ return MessageToDict(response, preserving_proto_field_name=True)
clarifai/modules/css.py CHANGED
@@ -2,59 +2,59 @@ import os
2
2
 
3
3
 
4
4
  class ClarifaiStreamlitCSS(object):
5
- """ ClarifaiStreamlitCSS helps get a consistent style by default for Clarifai provided
6
- streamlit apps.
7
- """
8
-
9
- @classmethod
10
- def insert_default_css(cls, st):
11
- """ Inserts the default style provided in style.css in this folder into the streamlit page
12
-
13
- Example:
14
- ClarifaiStreamlitCSS.insert_default_css()
15
-
16
- Note:
17
- This must be placed in both the app.py AND all the pages/*.py files to get the custom styles.
18
- """
19
- file_name = os.path.join(os.path.dirname(__file__), "style.css")
20
- cls.insert_css_file(file_name, st)
21
-
22
- @classmethod
23
- def insert_css_file(cls, css_file, st):
24
- """ Open the full filename to the css file and insert it's contents the style of the page.
25
- """
26
- with open(css_file) as f:
27
- st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
28
-
29
- @classmethod
30
- def buttonlink(cls, st, label, link, target="_parent", style=""):
31
- """
32
- This is a streamlit button that will link to another page (or _self if target is _self).
33
- It is styled to look like the other stButton>button buttons that are created with st.button().
34
-
35
- You must insert_default_css(st) before using on a page.
36
-
37
- Example:
38
- ClarifaiStreamlitCSS.insert_default_css(st)
39
- cols = st.columns(4)
40
- ClarifaiStreamlitCSS.buttonlink(cols[3], "Button", "https://clarifai.com", "_blank")
41
-
42
- Args:
43
- st: the streamlit package.
44
- label: the text string to display in the button.
45
- link: the url to link the button to.
46
- target: to open the link in same page (_parent) or new tab (_blank).
47
- style: additional style to apply to the button link.
48
- Ex: "background-color: rgb(45, 164, 78); color:white;" makes the button green background with white text.
5
+ """ClarifaiStreamlitCSS helps get a consistent style by default for Clarifai provided
6
+ streamlit apps.
49
7
  """
50
- astyle = ""
51
- if style:
52
- astyle = f'style="{style}"'
53
8
 
54
- st.markdown(
55
- f'''
9
+ @classmethod
10
+ def insert_default_css(cls, st):
11
+ """Inserts the default style provided in style.css in this folder into the streamlit page
12
+
13
+ Example:
14
+ ClarifaiStreamlitCSS.insert_default_css()
15
+
16
+ Note:
17
+ This must be placed in both the app.py AND all the pages/*.py files to get the custom styles.
18
+ """
19
+ file_name = os.path.join(os.path.dirname(__file__), "style.css")
20
+ cls.insert_css_file(file_name, st)
21
+
22
+ @classmethod
23
+ def insert_css_file(cls, css_file, st):
24
+ """Open the full filename to the css file and insert it's contents the style of the page."""
25
+ with open(css_file) as f:
26
+ st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
27
+
28
+ @classmethod
29
+ def buttonlink(cls, st, label, link, target="_parent", style=""):
30
+ """
31
+ This is a streamlit button that will link to another page (or _self if target is _self).
32
+ It is styled to look like the other stButton>button buttons that are created with st.button().
33
+
34
+ You must insert_default_css(st) before using on a page.
35
+
36
+ Example:
37
+ ClarifaiStreamlitCSS.insert_default_css(st)
38
+ cols = st.columns(4)
39
+ ClarifaiStreamlitCSS.buttonlink(cols[3], "Button", "https://clarifai.com", "_blank")
40
+
41
+ Args:
42
+ st: the streamlit package.
43
+ label: the text string to display in the button.
44
+ link: the url to link the button to.
45
+ target: to open the link in same page (_parent) or new tab (_blank).
46
+ style: additional style to apply to the button link.
47
+ Ex: "background-color: rgb(45, 164, 78); color:white;" makes the button green background with white text.
48
+ """
49
+ astyle = ""
50
+ if style:
51
+ astyle = f'style="{style}"'
52
+
53
+ st.markdown(
54
+ f'''
56
55
  <div class="stButton">
57
56
  <a href="{link}" target="{target}" {astyle}>{label}</a>
58
57
  </div>
59
58
  ''',
60
- unsafe_allow_html=True)
59
+ unsafe_allow_html=True,
60
+ )