wandb 0.17.0rc1__py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (841) hide show
  1. package_readme.md +95 -0
  2. wandb/__init__.py +253 -0
  3. wandb/__main__.py +3 -0
  4. wandb/_globals.py +19 -0
  5. wandb/agents/__init__.py +0 -0
  6. wandb/agents/pyagent.py +364 -0
  7. wandb/analytics/__init__.py +3 -0
  8. wandb/analytics/sentry.py +266 -0
  9. wandb/apis/__init__.py +48 -0
  10. wandb/apis/attrs.py +40 -0
  11. wandb/apis/importers/__init__.py +1 -0
  12. wandb/apis/importers/internals/internal.py +386 -0
  13. wandb/apis/importers/internals/protocols.py +99 -0
  14. wandb/apis/importers/internals/util.py +78 -0
  15. wandb/apis/importers/mlflow.py +254 -0
  16. wandb/apis/importers/validation.py +108 -0
  17. wandb/apis/importers/wandb.py +1598 -0
  18. wandb/apis/internal.py +228 -0
  19. wandb/apis/normalize.py +89 -0
  20. wandb/apis/paginator.py +81 -0
  21. wandb/apis/public/__init__.py +34 -0
  22. wandb/apis/public/api.py +1045 -0
  23. wandb/apis/public/artifacts.py +851 -0
  24. wandb/apis/public/const.py +4 -0
  25. wandb/apis/public/files.py +195 -0
  26. wandb/apis/public/history.py +149 -0
  27. wandb/apis/public/jobs.py +634 -0
  28. wandb/apis/public/projects.py +162 -0
  29. wandb/apis/public/query_generator.py +166 -0
  30. wandb/apis/public/reports.py +469 -0
  31. wandb/apis/public/runs.py +803 -0
  32. wandb/apis/public/sweeps.py +240 -0
  33. wandb/apis/public/teams.py +198 -0
  34. wandb/apis/public/users.py +136 -0
  35. wandb/apis/reports/__init__.py +7 -0
  36. wandb/apis/reports/v1/__init__.py +30 -0
  37. wandb/apis/reports/v1/_blocks.py +1406 -0
  38. wandb/apis/reports/v1/_helpers.py +70 -0
  39. wandb/apis/reports/v1/_panels.py +1282 -0
  40. wandb/apis/reports/v1/_templates.py +478 -0
  41. wandb/apis/reports/v1/blocks.py +27 -0
  42. wandb/apis/reports/v1/helpers.py +2 -0
  43. wandb/apis/reports/v1/mutations.py +66 -0
  44. wandb/apis/reports/v1/panels.py +17 -0
  45. wandb/apis/reports/v1/report.py +268 -0
  46. wandb/apis/reports/v1/runset.py +144 -0
  47. wandb/apis/reports/v1/templates.py +7 -0
  48. wandb/apis/reports/v1/util.py +406 -0
  49. wandb/apis/reports/v1/validators.py +131 -0
  50. wandb/apis/reports/v2/__init__.py +20 -0
  51. wandb/apis/reports/v2/blocks.py +25 -0
  52. wandb/apis/reports/v2/expr_parsing.py +257 -0
  53. wandb/apis/reports/v2/gql.py +68 -0
  54. wandb/apis/reports/v2/interface.py +1911 -0
  55. wandb/apis/reports/v2/internal.py +867 -0
  56. wandb/apis/reports/v2/metrics.py +6 -0
  57. wandb/apis/reports/v2/panels.py +15 -0
  58. wandb/beta/workflows.py +283 -0
  59. wandb/bin/wandb-core +0 -0
  60. wandb/catboost/__init__.py +9 -0
  61. wandb/cli/__init__.py +0 -0
  62. wandb/cli/cli.py +2890 -0
  63. wandb/data_types.py +2068 -0
  64. wandb/docker/__init__.py +342 -0
  65. wandb/docker/auth.py +436 -0
  66. wandb/docker/wandb-entrypoint.sh +33 -0
  67. wandb/docker/www_authenticate.py +94 -0
  68. wandb/env.py +496 -0
  69. wandb/errors/__init__.py +46 -0
  70. wandb/errors/term.py +95 -0
  71. wandb/errors/util.py +57 -0
  72. wandb/fastai/__init__.py +9 -0
  73. wandb/filesync/__init__.py +0 -0
  74. wandb/filesync/dir_watcher.py +403 -0
  75. wandb/filesync/stats.py +100 -0
  76. wandb/filesync/step_checksum.py +145 -0
  77. wandb/filesync/step_prepare.py +199 -0
  78. wandb/filesync/step_upload.py +392 -0
  79. wandb/filesync/upload_job.py +218 -0
  80. wandb/integration/__init__.py +0 -0
  81. wandb/integration/catboost/__init__.py +5 -0
  82. wandb/integration/catboost/catboost.py +178 -0
  83. wandb/integration/cohere/__init__.py +3 -0
  84. wandb/integration/cohere/cohere.py +21 -0
  85. wandb/integration/cohere/resolver.py +347 -0
  86. wandb/integration/diffusers/__init__.py +3 -0
  87. wandb/integration/diffusers/autologger.py +76 -0
  88. wandb/integration/diffusers/pipeline_resolver.py +50 -0
  89. wandb/integration/diffusers/resolvers/__init__.py +9 -0
  90. wandb/integration/diffusers/resolvers/multimodal.py +882 -0
  91. wandb/integration/diffusers/resolvers/utils.py +102 -0
  92. wandb/integration/fastai/__init__.py +249 -0
  93. wandb/integration/gym/__init__.py +85 -0
  94. wandb/integration/huggingface/__init__.py +3 -0
  95. wandb/integration/huggingface/huggingface.py +18 -0
  96. wandb/integration/huggingface/resolver.py +213 -0
  97. wandb/integration/keras/__init__.py +14 -0
  98. wandb/integration/keras/callbacks/__init__.py +5 -0
  99. wandb/integration/keras/callbacks/metrics_logger.py +130 -0
  100. wandb/integration/keras/callbacks/model_checkpoint.py +200 -0
  101. wandb/integration/keras/callbacks/tables_builder.py +226 -0
  102. wandb/integration/keras/keras.py +1080 -0
  103. wandb/integration/kfp/__init__.py +6 -0
  104. wandb/integration/kfp/helpers.py +28 -0
  105. wandb/integration/kfp/kfp_patch.py +324 -0
  106. wandb/integration/kfp/wandb_logging.py +182 -0
  107. wandb/integration/langchain/__init__.py +3 -0
  108. wandb/integration/langchain/wandb_tracer.py +48 -0
  109. wandb/integration/lightgbm/__init__.py +239 -0
  110. wandb/integration/lightning/__init__.py +0 -0
  111. wandb/integration/lightning/fabric/__init__.py +3 -0
  112. wandb/integration/lightning/fabric/logger.py +762 -0
  113. wandb/integration/magic.py +556 -0
  114. wandb/integration/metaflow/__init__.py +3 -0
  115. wandb/integration/metaflow/metaflow.py +383 -0
  116. wandb/integration/openai/__init__.py +3 -0
  117. wandb/integration/openai/fine_tuning.py +454 -0
  118. wandb/integration/openai/openai.py +22 -0
  119. wandb/integration/openai/resolver.py +240 -0
  120. wandb/integration/prodigy/__init__.py +3 -0
  121. wandb/integration/prodigy/prodigy.py +299 -0
  122. wandb/integration/sacred/__init__.py +117 -0
  123. wandb/integration/sagemaker/__init__.py +12 -0
  124. wandb/integration/sagemaker/auth.py +28 -0
  125. wandb/integration/sagemaker/config.py +49 -0
  126. wandb/integration/sagemaker/files.py +3 -0
  127. wandb/integration/sagemaker/resources.py +34 -0
  128. wandb/integration/sb3/__init__.py +3 -0
  129. wandb/integration/sb3/sb3.py +153 -0
  130. wandb/integration/tensorboard/__init__.py +10 -0
  131. wandb/integration/tensorboard/log.py +358 -0
  132. wandb/integration/tensorboard/monkeypatch.py +185 -0
  133. wandb/integration/tensorflow/__init__.py +5 -0
  134. wandb/integration/tensorflow/estimator_hook.py +54 -0
  135. wandb/integration/torch/__init__.py +0 -0
  136. wandb/integration/ultralytics/__init__.py +11 -0
  137. wandb/integration/ultralytics/bbox_utils.py +208 -0
  138. wandb/integration/ultralytics/callback.py +524 -0
  139. wandb/integration/ultralytics/classification_utils.py +83 -0
  140. wandb/integration/ultralytics/mask_utils.py +202 -0
  141. wandb/integration/ultralytics/pose_utils.py +104 -0
  142. wandb/integration/xgboost/__init__.py +11 -0
  143. wandb/integration/xgboost/xgboost.py +189 -0
  144. wandb/integration/yolov8/__init__.py +0 -0
  145. wandb/integration/yolov8/yolov8.py +284 -0
  146. wandb/jupyter.py +501 -0
  147. wandb/keras/__init__.py +19 -0
  148. wandb/lightgbm/__init__.py +9 -0
  149. wandb/magic.py +3 -0
  150. wandb/mpmain/__init__.py +0 -0
  151. wandb/mpmain/__main__.py +1 -0
  152. wandb/old/__init__.py +0 -0
  153. wandb/old/core.py +131 -0
  154. wandb/old/settings.py +173 -0
  155. wandb/old/summary.py +435 -0
  156. wandb/plot/__init__.py +19 -0
  157. wandb/plot/bar.py +42 -0
  158. wandb/plot/confusion_matrix.py +99 -0
  159. wandb/plot/histogram.py +36 -0
  160. wandb/plot/line.py +40 -0
  161. wandb/plot/line_series.py +88 -0
  162. wandb/plot/pr_curve.py +135 -0
  163. wandb/plot/roc_curve.py +117 -0
  164. wandb/plot/scatter.py +32 -0
  165. wandb/plots/__init__.py +6 -0
  166. wandb/plots/explain_text.py +36 -0
  167. wandb/plots/heatmap.py +81 -0
  168. wandb/plots/named_entity.py +43 -0
  169. wandb/plots/part_of_speech.py +50 -0
  170. wandb/plots/plot_definitions.py +768 -0
  171. wandb/plots/precision_recall.py +121 -0
  172. wandb/plots/roc.py +103 -0
  173. wandb/plots/utils.py +195 -0
  174. wandb/proto/__init__.py +0 -0
  175. wandb/proto/v3/__init__.py +0 -0
  176. wandb/proto/v3/wandb_base_pb2.py +54 -0
  177. wandb/proto/v3/wandb_internal_pb2.py +1586 -0
  178. wandb/proto/v3/wandb_server_pb2.py +207 -0
  179. wandb/proto/v3/wandb_settings_pb2.py +111 -0
  180. wandb/proto/v3/wandb_telemetry_pb2.py +105 -0
  181. wandb/proto/v4/__init__.py +0 -0
  182. wandb/proto/v4/wandb_base_pb2.py +29 -0
  183. wandb/proto/v4/wandb_internal_pb2.py +354 -0
  184. wandb/proto/v4/wandb_server_pb2.py +62 -0
  185. wandb/proto/v4/wandb_settings_pb2.py +44 -0
  186. wandb/proto/v4/wandb_telemetry_pb2.py +40 -0
  187. wandb/proto/wandb_base_pb2.py +8 -0
  188. wandb/proto/wandb_deprecated.py +37 -0
  189. wandb/proto/wandb_internal_codegen.py +83 -0
  190. wandb/proto/wandb_internal_pb2.py +8 -0
  191. wandb/proto/wandb_server_pb2.py +8 -0
  192. wandb/proto/wandb_settings_pb2.py +8 -0
  193. wandb/proto/wandb_telemetry_pb2.py +8 -0
  194. wandb/py.typed +0 -0
  195. wandb/sacred/__init__.py +3 -0
  196. wandb/sdk/__init__.py +37 -0
  197. wandb/sdk/artifacts/__init__.py +0 -0
  198. wandb/sdk/artifacts/artifact.py +2317 -0
  199. wandb/sdk/artifacts/artifact_download_logger.py +43 -0
  200. wandb/sdk/artifacts/artifact_file_cache.py +229 -0
  201. wandb/sdk/artifacts/artifact_instance_cache.py +15 -0
  202. wandb/sdk/artifacts/artifact_manifest.py +72 -0
  203. wandb/sdk/artifacts/artifact_manifest_entry.py +205 -0
  204. wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
  205. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +90 -0
  206. wandb/sdk/artifacts/artifact_saver.py +270 -0
  207. wandb/sdk/artifacts/artifact_state.py +11 -0
  208. wandb/sdk/artifacts/artifact_ttl.py +7 -0
  209. wandb/sdk/artifacts/exceptions.py +56 -0
  210. wandb/sdk/artifacts/staging.py +25 -0
  211. wandb/sdk/artifacts/storage_handler.py +60 -0
  212. wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
  213. wandb/sdk/artifacts/storage_handlers/azure_handler.py +194 -0
  214. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +195 -0
  215. wandb/sdk/artifacts/storage_handlers/http_handler.py +113 -0
  216. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +135 -0
  217. wandb/sdk/artifacts/storage_handlers/multi_handler.py +54 -0
  218. wandb/sdk/artifacts/storage_handlers/s3_handler.py +300 -0
  219. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +68 -0
  220. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +133 -0
  221. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +72 -0
  222. wandb/sdk/artifacts/storage_layout.py +6 -0
  223. wandb/sdk/artifacts/storage_policies/__init__.py +4 -0
  224. wandb/sdk/artifacts/storage_policies/register.py +1 -0
  225. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +411 -0
  226. wandb/sdk/artifacts/storage_policy.py +83 -0
  227. wandb/sdk/backend/__init__.py +0 -0
  228. wandb/sdk/backend/backend.py +240 -0
  229. wandb/sdk/data_types/__init__.py +0 -0
  230. wandb/sdk/data_types/_dtypes.py +911 -0
  231. wandb/sdk/data_types/_private.py +10 -0
  232. wandb/sdk/data_types/base_types/__init__.py +0 -0
  233. wandb/sdk/data_types/base_types/json_metadata.py +55 -0
  234. wandb/sdk/data_types/base_types/media.py +313 -0
  235. wandb/sdk/data_types/base_types/wb_value.py +274 -0
  236. wandb/sdk/data_types/helper_types/__init__.py +0 -0
  237. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +293 -0
  238. wandb/sdk/data_types/helper_types/classes.py +159 -0
  239. wandb/sdk/data_types/helper_types/image_mask.py +233 -0
  240. wandb/sdk/data_types/histogram.py +96 -0
  241. wandb/sdk/data_types/html.py +115 -0
  242. wandb/sdk/data_types/image.py +687 -0
  243. wandb/sdk/data_types/molecule.py +241 -0
  244. wandb/sdk/data_types/object_3d.py +363 -0
  245. wandb/sdk/data_types/plotly.py +82 -0
  246. wandb/sdk/data_types/saved_model.py +444 -0
  247. wandb/sdk/data_types/trace_tree.py +438 -0
  248. wandb/sdk/data_types/utils.py +180 -0
  249. wandb/sdk/data_types/video.py +245 -0
  250. wandb/sdk/integration_utils/__init__.py +0 -0
  251. wandb/sdk/integration_utils/auto_logging.py +239 -0
  252. wandb/sdk/integration_utils/data_logging.py +475 -0
  253. wandb/sdk/interface/__init__.py +0 -0
  254. wandb/sdk/interface/constants.py +4 -0
  255. wandb/sdk/interface/interface.py +949 -0
  256. wandb/sdk/interface/interface_queue.py +59 -0
  257. wandb/sdk/interface/interface_relay.py +53 -0
  258. wandb/sdk/interface/interface_shared.py +550 -0
  259. wandb/sdk/interface/interface_sock.py +61 -0
  260. wandb/sdk/interface/message_future.py +27 -0
  261. wandb/sdk/interface/message_future_poll.py +50 -0
  262. wandb/sdk/interface/router.py +118 -0
  263. wandb/sdk/interface/router_queue.py +44 -0
  264. wandb/sdk/interface/router_relay.py +39 -0
  265. wandb/sdk/interface/router_sock.py +36 -0
  266. wandb/sdk/interface/summary_record.py +67 -0
  267. wandb/sdk/internal/__init__.py +0 -0
  268. wandb/sdk/internal/context.py +89 -0
  269. wandb/sdk/internal/datastore.py +297 -0
  270. wandb/sdk/internal/file_pusher.py +184 -0
  271. wandb/sdk/internal/file_stream.py +708 -0
  272. wandb/sdk/internal/flow_control.py +263 -0
  273. wandb/sdk/internal/handler.py +909 -0
  274. wandb/sdk/internal/internal.py +417 -0
  275. wandb/sdk/internal/internal_api.py +4202 -0
  276. wandb/sdk/internal/internal_util.py +100 -0
  277. wandb/sdk/internal/job_builder.py +554 -0
  278. wandb/sdk/internal/profiler.py +78 -0
  279. wandb/sdk/internal/progress.py +111 -0
  280. wandb/sdk/internal/run.py +25 -0
  281. wandb/sdk/internal/sample.py +70 -0
  282. wandb/sdk/internal/sender.py +1642 -0
  283. wandb/sdk/internal/sender_config.py +197 -0
  284. wandb/sdk/internal/settings_static.py +83 -0
  285. wandb/sdk/internal/system/__init__.py +0 -0
  286. wandb/sdk/internal/system/assets/__init__.py +27 -0
  287. wandb/sdk/internal/system/assets/aggregators.py +37 -0
  288. wandb/sdk/internal/system/assets/asset_registry.py +20 -0
  289. wandb/sdk/internal/system/assets/cpu.py +163 -0
  290. wandb/sdk/internal/system/assets/disk.py +210 -0
  291. wandb/sdk/internal/system/assets/gpu.py +414 -0
  292. wandb/sdk/internal/system/assets/gpu_amd.py +230 -0
  293. wandb/sdk/internal/system/assets/gpu_apple.py +177 -0
  294. wandb/sdk/internal/system/assets/interfaces.py +207 -0
  295. wandb/sdk/internal/system/assets/ipu.py +177 -0
  296. wandb/sdk/internal/system/assets/memory.py +166 -0
  297. wandb/sdk/internal/system/assets/network.py +125 -0
  298. wandb/sdk/internal/system/assets/open_metrics.py +299 -0
  299. wandb/sdk/internal/system/assets/tpu.py +154 -0
  300. wandb/sdk/internal/system/assets/trainium.py +398 -0
  301. wandb/sdk/internal/system/env_probe_helpers.py +13 -0
  302. wandb/sdk/internal/system/system_info.py +247 -0
  303. wandb/sdk/internal/system/system_monitor.py +229 -0
  304. wandb/sdk/internal/tb_watcher.py +518 -0
  305. wandb/sdk/internal/thread_local_settings.py +18 -0
  306. wandb/sdk/internal/update.py +113 -0
  307. wandb/sdk/internal/writer.py +206 -0
  308. wandb/sdk/launch/__init__.py +6 -0
  309. wandb/sdk/launch/_launch.py +348 -0
  310. wandb/sdk/launch/_launch_add.py +257 -0
  311. wandb/sdk/launch/_project_spec.py +578 -0
  312. wandb/sdk/launch/agent/__init__.py +5 -0
  313. wandb/sdk/launch/agent/agent.py +878 -0
  314. wandb/sdk/launch/agent/config.py +299 -0
  315. wandb/sdk/launch/agent/job_status_tracker.py +53 -0
  316. wandb/sdk/launch/agent/run_queue_item_file_saver.py +47 -0
  317. wandb/sdk/launch/builder/__init__.py +0 -0
  318. wandb/sdk/launch/builder/abstract.py +89 -0
  319. wandb/sdk/launch/builder/build.py +706 -0
  320. wandb/sdk/launch/builder/docker_builder.py +193 -0
  321. wandb/sdk/launch/builder/kaniko_builder.py +579 -0
  322. wandb/sdk/launch/builder/noop.py +58 -0
  323. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +187 -0
  324. wandb/sdk/launch/create_job.py +520 -0
  325. wandb/sdk/launch/environment/abstract.py +29 -0
  326. wandb/sdk/launch/environment/aws_environment.py +297 -0
  327. wandb/sdk/launch/environment/azure_environment.py +105 -0
  328. wandb/sdk/launch/environment/gcp_environment.py +335 -0
  329. wandb/sdk/launch/environment/local_environment.py +66 -0
  330. wandb/sdk/launch/errors.py +19 -0
  331. wandb/sdk/launch/git_reference.py +109 -0
  332. wandb/sdk/launch/loader.py +249 -0
  333. wandb/sdk/launch/registry/abstract.py +48 -0
  334. wandb/sdk/launch/registry/anon.py +29 -0
  335. wandb/sdk/launch/registry/azure_container_registry.py +124 -0
  336. wandb/sdk/launch/registry/elastic_container_registry.py +192 -0
  337. wandb/sdk/launch/registry/google_artifact_registry.py +219 -0
  338. wandb/sdk/launch/registry/local_registry.py +67 -0
  339. wandb/sdk/launch/runner/__init__.py +0 -0
  340. wandb/sdk/launch/runner/abstract.py +195 -0
  341. wandb/sdk/launch/runner/kubernetes_monitor.py +441 -0
  342. wandb/sdk/launch/runner/kubernetes_runner.py +893 -0
  343. wandb/sdk/launch/runner/local_container.py +299 -0
  344. wandb/sdk/launch/runner/local_process.py +99 -0
  345. wandb/sdk/launch/runner/sagemaker_runner.py +422 -0
  346. wandb/sdk/launch/runner/vertex_runner.py +229 -0
  347. wandb/sdk/launch/sweeps/__init__.py +39 -0
  348. wandb/sdk/launch/sweeps/scheduler.py +738 -0
  349. wandb/sdk/launch/sweeps/scheduler_sweep.py +91 -0
  350. wandb/sdk/launch/sweeps/utils.py +316 -0
  351. wandb/sdk/launch/utils.py +866 -0
  352. wandb/sdk/launch/wandb_reference.py +138 -0
  353. wandb/sdk/lib/__init__.py +5 -0
  354. wandb/sdk/lib/_settings_toposort_generate.py +159 -0
  355. wandb/sdk/lib/_settings_toposort_generated.py +244 -0
  356. wandb/sdk/lib/_wburls_generate.py +25 -0
  357. wandb/sdk/lib/_wburls_generated.py +22 -0
  358. wandb/sdk/lib/apikey.py +258 -0
  359. wandb/sdk/lib/capped_dict.py +26 -0
  360. wandb/sdk/lib/config_util.py +101 -0
  361. wandb/sdk/lib/console.py +39 -0
  362. wandb/sdk/lib/deprecate.py +42 -0
  363. wandb/sdk/lib/disabled.py +190 -0
  364. wandb/sdk/lib/exit_hooks.py +54 -0
  365. wandb/sdk/lib/file_stream_utils.py +118 -0
  366. wandb/sdk/lib/filenames.py +64 -0
  367. wandb/sdk/lib/filesystem.py +372 -0
  368. wandb/sdk/lib/fsm.py +174 -0
  369. wandb/sdk/lib/gitlib.py +239 -0
  370. wandb/sdk/lib/gql_request.py +65 -0
  371. wandb/sdk/lib/handler_util.py +21 -0
  372. wandb/sdk/lib/hashutil.py +62 -0
  373. wandb/sdk/lib/import_hooks.py +275 -0
  374. wandb/sdk/lib/ipython.py +146 -0
  375. wandb/sdk/lib/json_util.py +80 -0
  376. wandb/sdk/lib/lazyloader.py +63 -0
  377. wandb/sdk/lib/mailbox.py +460 -0
  378. wandb/sdk/lib/module.py +69 -0
  379. wandb/sdk/lib/paths.py +106 -0
  380. wandb/sdk/lib/preinit.py +42 -0
  381. wandb/sdk/lib/printer.py +313 -0
  382. wandb/sdk/lib/proto_util.py +69 -0
  383. wandb/sdk/lib/redirect.py +840 -0
  384. wandb/sdk/lib/reporting.py +99 -0
  385. wandb/sdk/lib/retry.py +289 -0
  386. wandb/sdk/lib/run_moment.py +78 -0
  387. wandb/sdk/lib/runid.py +12 -0
  388. wandb/sdk/lib/server.py +52 -0
  389. wandb/sdk/lib/sock_client.py +291 -0
  390. wandb/sdk/lib/sparkline.py +45 -0
  391. wandb/sdk/lib/telemetry.py +100 -0
  392. wandb/sdk/lib/timed_input.py +133 -0
  393. wandb/sdk/lib/timer.py +19 -0
  394. wandb/sdk/lib/tracelog.py +255 -0
  395. wandb/sdk/lib/wburls.py +46 -0
  396. wandb/sdk/service/__init__.py +0 -0
  397. wandb/sdk/service/_startup_debug.py +22 -0
  398. wandb/sdk/service/port_file.py +53 -0
  399. wandb/sdk/service/server.py +119 -0
  400. wandb/sdk/service/server_sock.py +276 -0
  401. wandb/sdk/service/service.py +266 -0
  402. wandb/sdk/service/service_base.py +50 -0
  403. wandb/sdk/service/service_sock.py +70 -0
  404. wandb/sdk/service/streams.py +426 -0
  405. wandb/sdk/verify/__init__.py +0 -0
  406. wandb/sdk/verify/verify.py +501 -0
  407. wandb/sdk/wandb_alerts.py +12 -0
  408. wandb/sdk/wandb_config.py +319 -0
  409. wandb/sdk/wandb_helper.py +54 -0
  410. wandb/sdk/wandb_init.py +1220 -0
  411. wandb/sdk/wandb_login.py +339 -0
  412. wandb/sdk/wandb_manager.py +222 -0
  413. wandb/sdk/wandb_metric.py +110 -0
  414. wandb/sdk/wandb_require.py +92 -0
  415. wandb/sdk/wandb_require_helpers.py +44 -0
  416. wandb/sdk/wandb_run.py +4191 -0
  417. wandb/sdk/wandb_settings.py +1973 -0
  418. wandb/sdk/wandb_setup.py +335 -0
  419. wandb/sdk/wandb_summary.py +150 -0
  420. wandb/sdk/wandb_sweep.py +114 -0
  421. wandb/sdk/wandb_sync.py +75 -0
  422. wandb/sdk/wandb_watch.py +128 -0
  423. wandb/sklearn/__init__.py +37 -0
  424. wandb/sklearn/calculate/__init__.py +32 -0
  425. wandb/sklearn/calculate/calibration_curves.py +125 -0
  426. wandb/sklearn/calculate/class_proportions.py +68 -0
  427. wandb/sklearn/calculate/confusion_matrix.py +92 -0
  428. wandb/sklearn/calculate/decision_boundaries.py +40 -0
  429. wandb/sklearn/calculate/elbow_curve.py +55 -0
  430. wandb/sklearn/calculate/feature_importances.py +67 -0
  431. wandb/sklearn/calculate/learning_curve.py +64 -0
  432. wandb/sklearn/calculate/outlier_candidates.py +69 -0
  433. wandb/sklearn/calculate/residuals.py +86 -0
  434. wandb/sklearn/calculate/silhouette.py +118 -0
  435. wandb/sklearn/calculate/summary_metrics.py +62 -0
  436. wandb/sklearn/plot/__init__.py +35 -0
  437. wandb/sklearn/plot/classifier.py +331 -0
  438. wandb/sklearn/plot/clusterer.py +142 -0
  439. wandb/sklearn/plot/regressor.py +121 -0
  440. wandb/sklearn/plot/shared.py +91 -0
  441. wandb/sklearn/utils.py +183 -0
  442. wandb/sync/__init__.py +3 -0
  443. wandb/sync/sync.py +443 -0
  444. wandb/testing/relay.py +859 -0
  445. wandb/trigger.py +29 -0
  446. wandb/util.py +1925 -0
  447. wandb/vendor/__init__.py +0 -0
  448. wandb/vendor/gql-0.2.0/setup.py +40 -0
  449. wandb/vendor/gql-0.2.0/tests/__init__.py +0 -0
  450. wandb/vendor/gql-0.2.0/tests/starwars/__init__.py +0 -0
  451. wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py +96 -0
  452. wandb/vendor/gql-0.2.0/tests/starwars/schema.py +146 -0
  453. wandb/vendor/gql-0.2.0/tests/starwars/test_dsl.py +293 -0
  454. wandb/vendor/gql-0.2.0/tests/starwars/test_query.py +355 -0
  455. wandb/vendor/gql-0.2.0/tests/starwars/test_validation.py +171 -0
  456. wandb/vendor/gql-0.2.0/tests/test_client.py +31 -0
  457. wandb/vendor/gql-0.2.0/tests/test_transport.py +89 -0
  458. wandb/vendor/gql-0.2.0/wandb_gql/__init__.py +4 -0
  459. wandb/vendor/gql-0.2.0/wandb_gql/client.py +75 -0
  460. wandb/vendor/gql-0.2.0/wandb_gql/dsl.py +152 -0
  461. wandb/vendor/gql-0.2.0/wandb_gql/gql.py +10 -0
  462. wandb/vendor/gql-0.2.0/wandb_gql/transport/__init__.py +0 -0
  463. wandb/vendor/gql-0.2.0/wandb_gql/transport/http.py +6 -0
  464. wandb/vendor/gql-0.2.0/wandb_gql/transport/local_schema.py +15 -0
  465. wandb/vendor/gql-0.2.0/wandb_gql/transport/requests.py +46 -0
  466. wandb/vendor/gql-0.2.0/wandb_gql/utils.py +21 -0
  467. wandb/vendor/graphql-core-1.1/setup.py +86 -0
  468. wandb/vendor/graphql-core-1.1/wandb_graphql/__init__.py +287 -0
  469. wandb/vendor/graphql-core-1.1/wandb_graphql/error/__init__.py +6 -0
  470. wandb/vendor/graphql-core-1.1/wandb_graphql/error/base.py +42 -0
  471. wandb/vendor/graphql-core-1.1/wandb_graphql/error/format_error.py +11 -0
  472. wandb/vendor/graphql-core-1.1/wandb_graphql/error/located_error.py +29 -0
  473. wandb/vendor/graphql-core-1.1/wandb_graphql/error/syntax_error.py +36 -0
  474. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/__init__.py +26 -0
  475. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/base.py +311 -0
  476. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executor.py +398 -0
  477. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/__init__.py +0 -0
  478. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/asyncio.py +53 -0
  479. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/gevent.py +22 -0
  480. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/process.py +32 -0
  481. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/sync.py +7 -0
  482. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/thread.py +35 -0
  483. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/utils.py +6 -0
  484. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/__init__.py +0 -0
  485. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/executor.py +66 -0
  486. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/fragment.py +252 -0
  487. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/resolver.py +151 -0
  488. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/utils.py +7 -0
  489. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/middleware.py +57 -0
  490. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/values.py +145 -0
  491. wandb/vendor/graphql-core-1.1/wandb_graphql/graphql.py +60 -0
  492. wandb/vendor/graphql-core-1.1/wandb_graphql/language/__init__.py +0 -0
  493. wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py +1349 -0
  494. wandb/vendor/graphql-core-1.1/wandb_graphql/language/base.py +19 -0
  495. wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py +435 -0
  496. wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py +30 -0
  497. wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py +779 -0
  498. wandb/vendor/graphql-core-1.1/wandb_graphql/language/printer.py +193 -0
  499. wandb/vendor/graphql-core-1.1/wandb_graphql/language/source.py +18 -0
  500. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py +222 -0
  501. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor_meta.py +82 -0
  502. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/__init__.py +0 -0
  503. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/cached_property.py +17 -0
  504. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/contain_subset.py +28 -0
  505. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/default_ordered_dict.py +40 -0
  506. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/ordereddict.py +8 -0
  507. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/pair_set.py +43 -0
  508. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/version.py +78 -0
  509. wandb/vendor/graphql-core-1.1/wandb_graphql/type/__init__.py +67 -0
  510. wandb/vendor/graphql-core-1.1/wandb_graphql/type/definition.py +619 -0
  511. wandb/vendor/graphql-core-1.1/wandb_graphql/type/directives.py +132 -0
  512. wandb/vendor/graphql-core-1.1/wandb_graphql/type/introspection.py +440 -0
  513. wandb/vendor/graphql-core-1.1/wandb_graphql/type/scalars.py +131 -0
  514. wandb/vendor/graphql-core-1.1/wandb_graphql/type/schema.py +100 -0
  515. wandb/vendor/graphql-core-1.1/wandb_graphql/type/typemap.py +145 -0
  516. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/__init__.py +0 -0
  517. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/assert_valid_name.py +9 -0
  518. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_from_value.py +65 -0
  519. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_code.py +49 -0
  520. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_dict.py +24 -0
  521. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/base.py +75 -0
  522. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_ast_schema.py +291 -0
  523. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_client_schema.py +250 -0
  524. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/concat_ast.py +9 -0
  525. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/extend_schema.py +357 -0
  526. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_field_def.py +27 -0
  527. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_operation_ast.py +21 -0
  528. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/introspection_query.py +90 -0
  529. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_literal_value.py +67 -0
  530. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_value.py +66 -0
  531. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/quoted_or_list.py +21 -0
  532. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/schema_printer.py +168 -0
  533. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/suggestion_list.py +56 -0
  534. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_comparators.py +69 -0
  535. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_from_ast.py +21 -0
  536. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_info.py +149 -0
  537. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/value_from_ast.py +69 -0
  538. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/__init__.py +4 -0
  539. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/__init__.py +79 -0
  540. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/arguments_of_correct_type.py +24 -0
  541. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/base.py +8 -0
  542. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/default_values_of_correct_type.py +44 -0
  543. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fields_on_correct_type.py +113 -0
  544. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fragments_on_composite_types.py +33 -0
  545. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_argument_names.py +70 -0
  546. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_directives.py +97 -0
  547. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_fragment_names.py +19 -0
  548. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_type_names.py +43 -0
  549. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/lone_anonymous_operation.py +23 -0
  550. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_fragment_cycles.py +59 -0
  551. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_undefined_variables.py +36 -0
  552. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_fragments.py +38 -0
  553. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_variables.py +37 -0
  554. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/overlapping_fields_can_be_merged.py +529 -0
  555. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/possible_fragment_spreads.py +44 -0
  556. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/provided_non_null_arguments.py +46 -0
  557. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/scalar_leafs.py +33 -0
  558. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_argument_names.py +32 -0
  559. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_fragment_names.py +28 -0
  560. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_input_field_names.py +33 -0
  561. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_operation_names.py +31 -0
  562. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_variable_names.py +27 -0
  563. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_are_input_types.py +21 -0
  564. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_in_allowed_position.py +53 -0
  565. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/validation.py +158 -0
  566. wandb/vendor/promise-2.3.0/conftest.py +30 -0
  567. wandb/vendor/promise-2.3.0/setup.py +64 -0
  568. wandb/vendor/promise-2.3.0/tests/__init__.py +0 -0
  569. wandb/vendor/promise-2.3.0/tests/conftest.py +8 -0
  570. wandb/vendor/promise-2.3.0/tests/test_awaitable.py +32 -0
  571. wandb/vendor/promise-2.3.0/tests/test_awaitable_35.py +47 -0
  572. wandb/vendor/promise-2.3.0/tests/test_benchmark.py +116 -0
  573. wandb/vendor/promise-2.3.0/tests/test_complex_threads.py +23 -0
  574. wandb/vendor/promise-2.3.0/tests/test_dataloader.py +452 -0
  575. wandb/vendor/promise-2.3.0/tests/test_dataloader_awaitable_35.py +99 -0
  576. wandb/vendor/promise-2.3.0/tests/test_dataloader_extra.py +65 -0
  577. wandb/vendor/promise-2.3.0/tests/test_extra.py +670 -0
  578. wandb/vendor/promise-2.3.0/tests/test_issues.py +132 -0
  579. wandb/vendor/promise-2.3.0/tests/test_promise_list.py +70 -0
  580. wandb/vendor/promise-2.3.0/tests/test_spec.py +584 -0
  581. wandb/vendor/promise-2.3.0/tests/test_thread_safety.py +115 -0
  582. wandb/vendor/promise-2.3.0/tests/utils.py +3 -0
  583. wandb/vendor/promise-2.3.0/wandb_promise/__init__.py +38 -0
  584. wandb/vendor/promise-2.3.0/wandb_promise/async_.py +135 -0
  585. wandb/vendor/promise-2.3.0/wandb_promise/compat.py +32 -0
  586. wandb/vendor/promise-2.3.0/wandb_promise/dataloader.py +326 -0
  587. wandb/vendor/promise-2.3.0/wandb_promise/iterate_promise.py +12 -0
  588. wandb/vendor/promise-2.3.0/wandb_promise/promise.py +848 -0
  589. wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py +151 -0
  590. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/__init__.py +0 -0
  591. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/version.py +83 -0
  592. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/__init__.py +0 -0
  593. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/asyncio.py +22 -0
  594. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/gevent.py +21 -0
  595. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/immediate.py +27 -0
  596. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/thread.py +18 -0
  597. wandb/vendor/promise-2.3.0/wandb_promise/utils.py +56 -0
  598. wandb/vendor/pygments/__init__.py +90 -0
  599. wandb/vendor/pygments/cmdline.py +568 -0
  600. wandb/vendor/pygments/console.py +74 -0
  601. wandb/vendor/pygments/filter.py +74 -0
  602. wandb/vendor/pygments/filters/__init__.py +350 -0
  603. wandb/vendor/pygments/formatter.py +95 -0
  604. wandb/vendor/pygments/formatters/__init__.py +153 -0
  605. wandb/vendor/pygments/formatters/_mapping.py +85 -0
  606. wandb/vendor/pygments/formatters/bbcode.py +109 -0
  607. wandb/vendor/pygments/formatters/html.py +851 -0
  608. wandb/vendor/pygments/formatters/img.py +600 -0
  609. wandb/vendor/pygments/formatters/irc.py +182 -0
  610. wandb/vendor/pygments/formatters/latex.py +482 -0
  611. wandb/vendor/pygments/formatters/other.py +160 -0
  612. wandb/vendor/pygments/formatters/rtf.py +147 -0
  613. wandb/vendor/pygments/formatters/svg.py +153 -0
  614. wandb/vendor/pygments/formatters/terminal.py +136 -0
  615. wandb/vendor/pygments/formatters/terminal256.py +309 -0
  616. wandb/vendor/pygments/lexer.py +871 -0
  617. wandb/vendor/pygments/lexers/__init__.py +329 -0
  618. wandb/vendor/pygments/lexers/_asy_builtins.py +1645 -0
  619. wandb/vendor/pygments/lexers/_cl_builtins.py +232 -0
  620. wandb/vendor/pygments/lexers/_cocoa_builtins.py +72 -0
  621. wandb/vendor/pygments/lexers/_csound_builtins.py +1346 -0
  622. wandb/vendor/pygments/lexers/_lasso_builtins.py +5327 -0
  623. wandb/vendor/pygments/lexers/_lua_builtins.py +295 -0
  624. wandb/vendor/pygments/lexers/_mapping.py +500 -0
  625. wandb/vendor/pygments/lexers/_mql_builtins.py +1172 -0
  626. wandb/vendor/pygments/lexers/_openedge_builtins.py +2547 -0
  627. wandb/vendor/pygments/lexers/_php_builtins.py +4756 -0
  628. wandb/vendor/pygments/lexers/_postgres_builtins.py +621 -0
  629. wandb/vendor/pygments/lexers/_scilab_builtins.py +3094 -0
  630. wandb/vendor/pygments/lexers/_sourcemod_builtins.py +1163 -0
  631. wandb/vendor/pygments/lexers/_stan_builtins.py +532 -0
  632. wandb/vendor/pygments/lexers/_stata_builtins.py +419 -0
  633. wandb/vendor/pygments/lexers/_tsql_builtins.py +1004 -0
  634. wandb/vendor/pygments/lexers/_vim_builtins.py +1939 -0
  635. wandb/vendor/pygments/lexers/actionscript.py +240 -0
  636. wandb/vendor/pygments/lexers/agile.py +24 -0
  637. wandb/vendor/pygments/lexers/algebra.py +221 -0
  638. wandb/vendor/pygments/lexers/ambient.py +76 -0
  639. wandb/vendor/pygments/lexers/ampl.py +87 -0
  640. wandb/vendor/pygments/lexers/apl.py +101 -0
  641. wandb/vendor/pygments/lexers/archetype.py +318 -0
  642. wandb/vendor/pygments/lexers/asm.py +641 -0
  643. wandb/vendor/pygments/lexers/automation.py +374 -0
  644. wandb/vendor/pygments/lexers/basic.py +500 -0
  645. wandb/vendor/pygments/lexers/bibtex.py +160 -0
  646. wandb/vendor/pygments/lexers/business.py +612 -0
  647. wandb/vendor/pygments/lexers/c_cpp.py +252 -0
  648. wandb/vendor/pygments/lexers/c_like.py +541 -0
  649. wandb/vendor/pygments/lexers/capnproto.py +78 -0
  650. wandb/vendor/pygments/lexers/chapel.py +102 -0
  651. wandb/vendor/pygments/lexers/clean.py +288 -0
  652. wandb/vendor/pygments/lexers/compiled.py +34 -0
  653. wandb/vendor/pygments/lexers/configs.py +833 -0
  654. wandb/vendor/pygments/lexers/console.py +114 -0
  655. wandb/vendor/pygments/lexers/crystal.py +393 -0
  656. wandb/vendor/pygments/lexers/csound.py +366 -0
  657. wandb/vendor/pygments/lexers/css.py +689 -0
  658. wandb/vendor/pygments/lexers/d.py +251 -0
  659. wandb/vendor/pygments/lexers/dalvik.py +125 -0
  660. wandb/vendor/pygments/lexers/data.py +555 -0
  661. wandb/vendor/pygments/lexers/diff.py +165 -0
  662. wandb/vendor/pygments/lexers/dotnet.py +691 -0
  663. wandb/vendor/pygments/lexers/dsls.py +878 -0
  664. wandb/vendor/pygments/lexers/dylan.py +289 -0
  665. wandb/vendor/pygments/lexers/ecl.py +125 -0
  666. wandb/vendor/pygments/lexers/eiffel.py +65 -0
  667. wandb/vendor/pygments/lexers/elm.py +121 -0
  668. wandb/vendor/pygments/lexers/erlang.py +533 -0
  669. wandb/vendor/pygments/lexers/esoteric.py +277 -0
  670. wandb/vendor/pygments/lexers/ezhil.py +69 -0
  671. wandb/vendor/pygments/lexers/factor.py +344 -0
  672. wandb/vendor/pygments/lexers/fantom.py +250 -0
  673. wandb/vendor/pygments/lexers/felix.py +273 -0
  674. wandb/vendor/pygments/lexers/forth.py +177 -0
  675. wandb/vendor/pygments/lexers/fortran.py +205 -0
  676. wandb/vendor/pygments/lexers/foxpro.py +428 -0
  677. wandb/vendor/pygments/lexers/functional.py +21 -0
  678. wandb/vendor/pygments/lexers/go.py +101 -0
  679. wandb/vendor/pygments/lexers/grammar_notation.py +213 -0
  680. wandb/vendor/pygments/lexers/graph.py +80 -0
  681. wandb/vendor/pygments/lexers/graphics.py +553 -0
  682. wandb/vendor/pygments/lexers/haskell.py +843 -0
  683. wandb/vendor/pygments/lexers/haxe.py +936 -0
  684. wandb/vendor/pygments/lexers/hdl.py +382 -0
  685. wandb/vendor/pygments/lexers/hexdump.py +103 -0
  686. wandb/vendor/pygments/lexers/html.py +602 -0
  687. wandb/vendor/pygments/lexers/idl.py +270 -0
  688. wandb/vendor/pygments/lexers/igor.py +288 -0
  689. wandb/vendor/pygments/lexers/inferno.py +96 -0
  690. wandb/vendor/pygments/lexers/installers.py +322 -0
  691. wandb/vendor/pygments/lexers/int_fiction.py +1343 -0
  692. wandb/vendor/pygments/lexers/iolang.py +63 -0
  693. wandb/vendor/pygments/lexers/j.py +146 -0
  694. wandb/vendor/pygments/lexers/javascript.py +1525 -0
  695. wandb/vendor/pygments/lexers/julia.py +333 -0
  696. wandb/vendor/pygments/lexers/jvm.py +1573 -0
  697. wandb/vendor/pygments/lexers/lisp.py +2621 -0
  698. wandb/vendor/pygments/lexers/make.py +202 -0
  699. wandb/vendor/pygments/lexers/markup.py +595 -0
  700. wandb/vendor/pygments/lexers/math.py +21 -0
  701. wandb/vendor/pygments/lexers/matlab.py +663 -0
  702. wandb/vendor/pygments/lexers/ml.py +769 -0
  703. wandb/vendor/pygments/lexers/modeling.py +358 -0
  704. wandb/vendor/pygments/lexers/modula2.py +1561 -0
  705. wandb/vendor/pygments/lexers/monte.py +204 -0
  706. wandb/vendor/pygments/lexers/ncl.py +894 -0
  707. wandb/vendor/pygments/lexers/nimrod.py +159 -0
  708. wandb/vendor/pygments/lexers/nit.py +64 -0
  709. wandb/vendor/pygments/lexers/nix.py +136 -0
  710. wandb/vendor/pygments/lexers/oberon.py +105 -0
  711. wandb/vendor/pygments/lexers/objective.py +504 -0
  712. wandb/vendor/pygments/lexers/ooc.py +85 -0
  713. wandb/vendor/pygments/lexers/other.py +41 -0
  714. wandb/vendor/pygments/lexers/parasail.py +79 -0
  715. wandb/vendor/pygments/lexers/parsers.py +835 -0
  716. wandb/vendor/pygments/lexers/pascal.py +644 -0
  717. wandb/vendor/pygments/lexers/pawn.py +199 -0
  718. wandb/vendor/pygments/lexers/perl.py +620 -0
  719. wandb/vendor/pygments/lexers/php.py +267 -0
  720. wandb/vendor/pygments/lexers/praat.py +294 -0
  721. wandb/vendor/pygments/lexers/prolog.py +306 -0
  722. wandb/vendor/pygments/lexers/python.py +939 -0
  723. wandb/vendor/pygments/lexers/qvt.py +152 -0
  724. wandb/vendor/pygments/lexers/r.py +453 -0
  725. wandb/vendor/pygments/lexers/rdf.py +270 -0
  726. wandb/vendor/pygments/lexers/rebol.py +431 -0
  727. wandb/vendor/pygments/lexers/resource.py +85 -0
  728. wandb/vendor/pygments/lexers/rnc.py +67 -0
  729. wandb/vendor/pygments/lexers/roboconf.py +82 -0
  730. wandb/vendor/pygments/lexers/robotframework.py +560 -0
  731. wandb/vendor/pygments/lexers/ruby.py +519 -0
  732. wandb/vendor/pygments/lexers/rust.py +220 -0
  733. wandb/vendor/pygments/lexers/sas.py +228 -0
  734. wandb/vendor/pygments/lexers/scripting.py +1222 -0
  735. wandb/vendor/pygments/lexers/shell.py +794 -0
  736. wandb/vendor/pygments/lexers/smalltalk.py +195 -0
  737. wandb/vendor/pygments/lexers/smv.py +79 -0
  738. wandb/vendor/pygments/lexers/snobol.py +83 -0
  739. wandb/vendor/pygments/lexers/special.py +103 -0
  740. wandb/vendor/pygments/lexers/sql.py +681 -0
  741. wandb/vendor/pygments/lexers/stata.py +108 -0
  742. wandb/vendor/pygments/lexers/supercollider.py +90 -0
  743. wandb/vendor/pygments/lexers/tcl.py +145 -0
  744. wandb/vendor/pygments/lexers/templates.py +2283 -0
  745. wandb/vendor/pygments/lexers/testing.py +207 -0
  746. wandb/vendor/pygments/lexers/text.py +25 -0
  747. wandb/vendor/pygments/lexers/textedit.py +169 -0
  748. wandb/vendor/pygments/lexers/textfmts.py +297 -0
  749. wandb/vendor/pygments/lexers/theorem.py +458 -0
  750. wandb/vendor/pygments/lexers/trafficscript.py +54 -0
  751. wandb/vendor/pygments/lexers/typoscript.py +226 -0
  752. wandb/vendor/pygments/lexers/urbi.py +133 -0
  753. wandb/vendor/pygments/lexers/varnish.py +190 -0
  754. wandb/vendor/pygments/lexers/verification.py +111 -0
  755. wandb/vendor/pygments/lexers/web.py +24 -0
  756. wandb/vendor/pygments/lexers/webmisc.py +988 -0
  757. wandb/vendor/pygments/lexers/whiley.py +116 -0
  758. wandb/vendor/pygments/lexers/x10.py +69 -0
  759. wandb/vendor/pygments/modeline.py +44 -0
  760. wandb/vendor/pygments/plugin.py +68 -0
  761. wandb/vendor/pygments/regexopt.py +92 -0
  762. wandb/vendor/pygments/scanner.py +105 -0
  763. wandb/vendor/pygments/sphinxext.py +158 -0
  764. wandb/vendor/pygments/style.py +155 -0
  765. wandb/vendor/pygments/styles/__init__.py +80 -0
  766. wandb/vendor/pygments/styles/abap.py +29 -0
  767. wandb/vendor/pygments/styles/algol.py +63 -0
  768. wandb/vendor/pygments/styles/algol_nu.py +63 -0
  769. wandb/vendor/pygments/styles/arduino.py +98 -0
  770. wandb/vendor/pygments/styles/autumn.py +65 -0
  771. wandb/vendor/pygments/styles/borland.py +51 -0
  772. wandb/vendor/pygments/styles/bw.py +49 -0
  773. wandb/vendor/pygments/styles/colorful.py +81 -0
  774. wandb/vendor/pygments/styles/default.py +73 -0
  775. wandb/vendor/pygments/styles/emacs.py +72 -0
  776. wandb/vendor/pygments/styles/friendly.py +72 -0
  777. wandb/vendor/pygments/styles/fruity.py +42 -0
  778. wandb/vendor/pygments/styles/igor.py +29 -0
  779. wandb/vendor/pygments/styles/lovelace.py +97 -0
  780. wandb/vendor/pygments/styles/manni.py +75 -0
  781. wandb/vendor/pygments/styles/monokai.py +106 -0
  782. wandb/vendor/pygments/styles/murphy.py +80 -0
  783. wandb/vendor/pygments/styles/native.py +65 -0
  784. wandb/vendor/pygments/styles/paraiso_dark.py +125 -0
  785. wandb/vendor/pygments/styles/paraiso_light.py +125 -0
  786. wandb/vendor/pygments/styles/pastie.py +75 -0
  787. wandb/vendor/pygments/styles/perldoc.py +69 -0
  788. wandb/vendor/pygments/styles/rainbow_dash.py +89 -0
  789. wandb/vendor/pygments/styles/rrt.py +33 -0
  790. wandb/vendor/pygments/styles/sas.py +44 -0
  791. wandb/vendor/pygments/styles/stata.py +40 -0
  792. wandb/vendor/pygments/styles/tango.py +141 -0
  793. wandb/vendor/pygments/styles/trac.py +63 -0
  794. wandb/vendor/pygments/styles/vim.py +63 -0
  795. wandb/vendor/pygments/styles/vs.py +38 -0
  796. wandb/vendor/pygments/styles/xcode.py +51 -0
  797. wandb/vendor/pygments/token.py +213 -0
  798. wandb/vendor/pygments/unistring.py +217 -0
  799. wandb/vendor/pygments/util.py +388 -0
  800. wandb/vendor/pynvml/__init__.py +0 -0
  801. wandb/vendor/pynvml/pynvml.py +4779 -0
  802. wandb/vendor/watchdog_0_9_0/wandb_watchdog/__init__.py +17 -0
  803. wandb/vendor/watchdog_0_9_0/wandb_watchdog/events.py +615 -0
  804. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/__init__.py +98 -0
  805. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/api.py +369 -0
  806. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents.py +172 -0
  807. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents2.py +239 -0
  808. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify.py +218 -0
  809. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_buffer.py +81 -0
  810. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_c.py +575 -0
  811. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/kqueue.py +730 -0
  812. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/polling.py +145 -0
  813. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/read_directory_changes.py +133 -0
  814. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/winapi.py +348 -0
  815. wandb/vendor/watchdog_0_9_0/wandb_watchdog/patterns.py +265 -0
  816. wandb/vendor/watchdog_0_9_0/wandb_watchdog/tricks/__init__.py +174 -0
  817. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/__init__.py +151 -0
  818. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/bricks.py +249 -0
  819. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/compat.py +29 -0
  820. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/decorators.py +198 -0
  821. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/delayed_queue.py +88 -0
  822. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/dirsnapshot.py +293 -0
  823. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/echo.py +157 -0
  824. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/event_backport.py +41 -0
  825. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/importlib2.py +40 -0
  826. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/platform.py +57 -0
  827. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/unicode_paths.py +64 -0
  828. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/win32stat.py +123 -0
  829. wandb/vendor/watchdog_0_9_0/wandb_watchdog/version.py +28 -0
  830. wandb/vendor/watchdog_0_9_0/wandb_watchdog/watchmedo.py +577 -0
  831. wandb/viz.py +123 -0
  832. wandb/wandb_agent.py +586 -0
  833. wandb/wandb_controller.py +720 -0
  834. wandb/wandb_run.py +9 -0
  835. wandb/wandb_torch.py +550 -0
  836. wandb/xgboost/__init__.py +9 -0
  837. wandb-0.17.0rc1.dist-info/METADATA +219 -0
  838. wandb-0.17.0rc1.dist-info/RECORD +841 -0
  839. wandb-0.17.0rc1.dist-info/WHEEL +6 -0
  840. wandb-0.17.0rc1.dist-info/entry_points.txt +3 -0
  841. wandb-0.17.0rc1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,1911 @@
1
+ """Public interfaces for the Report API."""
2
+
3
+ import os
4
+ from datetime import datetime
5
+ from typing import Dict, Iterable, Optional, Tuple, Union
6
+ from typing import List as LList
7
+
8
+ from annotated_types import Annotated, Ge, Le
9
+
10
+ try:
11
+ from typing import Literal
12
+ except ImportError:
13
+ from typing_extensions import Literal
14
+
15
+ from urllib.parse import urlparse, urlunparse
16
+
17
+ from pydantic import ConfigDict, Field, validator
18
+ from pydantic.dataclasses import dataclass
19
+
20
+ import wandb
21
+
22
+ from . import expr_parsing, gql, internal
23
+ from .internal import (
24
+ CodeCompareDiff,
25
+ FontSize,
26
+ GroupAgg,
27
+ GroupArea,
28
+ Language,
29
+ LegendPosition,
30
+ LinePlotStyle,
31
+ Range,
32
+ ReportWidth,
33
+ SmoothingType,
34
+ )
35
+
36
+ TextLike = Union[str, "TextWithInlineComments", "Link", "InlineLatex", "InlineCode"]
37
+ TextLikeField = Union[TextLike, LList[TextLike]]
38
+ SpecialMetricType = Union["Config", "SummaryMetric", "Metric"]
39
+ MetricType = Union[str, SpecialMetricType]
40
+ ParallelCoordinatesMetric = Union[str, "Config", "SummaryMetric"]
41
+ RunId = str
42
+
43
+
44
+ dataclass_config = ConfigDict(validate_assignment=True, extra="forbid", slots=True)
45
+
46
+
47
+ @dataclass(config=dataclass_config)
48
+ class Base:
49
+ ...
50
+ # TODO: Add __repr__ that hides Nones
51
+
52
+ @property
53
+ def _model(self):
54
+ return self.to_model()
55
+
56
+ @property
57
+ def _spec(self):
58
+ return self._model.model_dump(by_alias=True, exclude_none=True)
59
+
60
+
61
+ @dataclass(config=dataclass_config, frozen=True)
62
+ class RunsetGroupKey:
63
+ key: MetricType
64
+ value: str
65
+
66
+
67
+ @dataclass(config=dataclass_config, frozen=True)
68
+ class RunsetGroup:
69
+ runset_name: str
70
+ keys: Tuple[RunsetGroupKey, ...]
71
+
72
+
73
+ @dataclass(config=dataclass_config, frozen=True)
74
+ class Metric:
75
+ name: str
76
+
77
+
78
+ @dataclass(config=dataclass_config, frozen=True)
79
+ class Config:
80
+ name: str
81
+
82
+
83
+ @dataclass(config=dataclass_config, frozen=True)
84
+ class SummaryMetric:
85
+ name: str
86
+
87
+
88
+ @dataclass(config=dataclass_config)
89
+ class Layout(Base):
90
+ x: int = 0
91
+ y: int = 0
92
+ w: int = 8
93
+ h: int = 6
94
+
95
+ def to_model(self):
96
+ return internal.Layout(x=self.x, y=self.y, w=self.w, h=self.h)
97
+
98
+ @classmethod
99
+ def from_model(cls, model: internal.Layout):
100
+ return cls(x=model.x, y=model.y, w=model.w, h=model.h)
101
+
102
+
103
+ @dataclass(config=dataclass_config)
104
+ class Block(Base): ...
105
+
106
+
107
+ @dataclass(config=ConfigDict(validate_assignment=True, extra="allow", slots=True))
108
+ class UnknownBlock(Block):
109
+ def __repr__(self) -> str:
110
+ class_name = self.__class__.__name__
111
+ attributes = ", ".join(
112
+ f"{key}={value!r}" for key, value in self.__dict__.items()
113
+ )
114
+ return f"{class_name}({attributes})"
115
+
116
+ def to_model(self):
117
+ d = self.__dict__
118
+ return internal.UnknownBlock.model_validate(d)
119
+
120
+ @classmethod
121
+ def from_model(cls, model: internal.UnknownBlock):
122
+ d = model.model_dump()
123
+ return cls(**d)
124
+
125
+
126
+ @dataclass(config=dataclass_config)
127
+ class TextWithInlineComments(Base):
128
+ text: str
129
+
130
+ _inline_comments: Optional[LList[internal.InlineComment]] = Field(
131
+ default_factory=lambda: None, repr=False
132
+ )
133
+
134
+
135
+ @dataclass(config=dataclass_config)
136
+ class Heading(Block):
137
+ @classmethod
138
+ def from_model(cls, model: internal.Heading):
139
+ text = _internal_children_to_text(model.children)
140
+
141
+ blocks = None
142
+ if model.collapsed_children:
143
+ blocks = [_lookup(b) for b in model.collapsed_children]
144
+
145
+ if model.level == 1:
146
+ return H1(text=text, collapsed_blocks=blocks)
147
+ if model.level == 2:
148
+ return H2(text=text, collapsed_blocks=blocks)
149
+ if model.level == 3:
150
+ return H3(text=text, collapsed_blocks=blocks)
151
+
152
+
153
+ @dataclass(config=dataclass_config)
154
+ class H1(Heading):
155
+ text: TextLikeField = ""
156
+ collapsed_blocks: Optional[LList["BlockTypes"]] = None
157
+
158
+ def to_model(self):
159
+ collapsed_children = self.collapsed_blocks
160
+ if collapsed_children is not None:
161
+ collapsed_children = [b.to_model() for b in collapsed_children]
162
+
163
+ return internal.Heading(
164
+ level=1,
165
+ children=_text_to_internal_children(self.text),
166
+ collapsed_children=collapsed_children,
167
+ )
168
+
169
+
170
+ @dataclass(config=dataclass_config)
171
+ class H2(Heading):
172
+ text: TextLikeField = ""
173
+ collapsed_blocks: Optional[LList["BlockTypes"]] = None
174
+
175
+ def to_model(self):
176
+ collapsed_children = self.collapsed_blocks
177
+ if collapsed_children is not None:
178
+ collapsed_children = [b.to_model() for b in collapsed_children]
179
+
180
+ return internal.Heading(
181
+ level=2,
182
+ children=_text_to_internal_children(self.text),
183
+ collapsed_children=collapsed_children,
184
+ )
185
+
186
+
187
+ @dataclass(config=dataclass_config)
188
+ class H3(Heading):
189
+ text: TextLikeField = ""
190
+ collapsed_blocks: Optional[LList["BlockTypes"]] = None
191
+
192
+ def to_model(self):
193
+ collapsed_children = self.collapsed_blocks
194
+ if collapsed_children is not None:
195
+ collapsed_children = [b.to_model() for b in collapsed_children]
196
+
197
+ return internal.Heading(
198
+ level=3,
199
+ children=_text_to_internal_children(self.text),
200
+ collapsed_children=collapsed_children,
201
+ )
202
+
203
+
204
+ @dataclass(config=dataclass_config)
205
+ class Link(Base):
206
+ text: Union[str, TextWithInlineComments]
207
+ url: str
208
+
209
+ _inline_comments: Optional[LList[internal.InlineComment]] = Field(
210
+ default_factory=lambda: None, init=False, repr=False
211
+ )
212
+
213
+
214
+ @dataclass(config=dataclass_config)
215
+ class InlineLatex(Base):
216
+ text: str
217
+
218
+
219
+ @dataclass(config=dataclass_config)
220
+ class InlineCode(Base):
221
+ text: str
222
+
223
+
224
+ @dataclass(config=dataclass_config)
225
+ class P(Block):
226
+ text: TextLikeField = ""
227
+
228
+ def to_model(self):
229
+ children = _text_to_internal_children(self.text)
230
+ return internal.Paragraph(children=children)
231
+
232
+ @classmethod
233
+ def from_model(cls, model: internal.Paragraph):
234
+ pieces = _internal_children_to_text(model.children)
235
+ return cls(text=pieces)
236
+
237
+
238
+ @dataclass(config=dataclass_config)
239
+ class ListItem(Base):
240
+ @classmethod
241
+ def from_model(cls, model: internal.ListItem):
242
+ text = _internal_children_to_text(model.children)
243
+ if model.checked is not None:
244
+ return CheckedListItem(text=text, checked=model.checked)
245
+ return text
246
+ # if model.ordered is not None:
247
+ # return OrderedListItem(text=text)
248
+ # return UnorderedListItem(text=text)
249
+
250
+
251
+ @dataclass(config=dataclass_config)
252
+ class CheckedListItem(Base):
253
+ text: TextLikeField = ""
254
+ checked: bool = False
255
+
256
+ def to_model(self):
257
+ return internal.ListItem(
258
+ children=[
259
+ internal.Paragraph(children=_text_to_internal_children(self.text))
260
+ ],
261
+ checked=self.checked,
262
+ )
263
+
264
+
265
+ @dataclass(config=dataclass_config)
266
+ class OrderedListItem(Base):
267
+ text: TextLikeField = ""
268
+
269
+ def to_model(self):
270
+ return internal.ListItem(
271
+ children=[
272
+ internal.Paragraph(children=_text_to_internal_children(self.text))
273
+ ],
274
+ ordered=True,
275
+ )
276
+
277
+
278
+ @dataclass(config=dataclass_config)
279
+ class UnorderedListItem(Base):
280
+ text: TextLikeField = ""
281
+
282
+ def to_model(self):
283
+ return internal.ListItem(
284
+ children=[
285
+ internal.Paragraph(children=_text_to_internal_children(self.text))
286
+ ],
287
+ )
288
+
289
+
290
+ @dataclass(config=dataclass_config)
291
+ class List(Block):
292
+ @classmethod
293
+ def from_model(cls, model: internal.List):
294
+ if not model.children:
295
+ return UnorderedList()
296
+
297
+ item = model.children[0]
298
+ items = [ListItem.from_model(x) for x in model.children]
299
+ if item.checked is not None:
300
+ return CheckedList(items=items)
301
+
302
+ if item.ordered is not None:
303
+ return OrderedList(items=items)
304
+
305
+ # else unordered
306
+ return UnorderedList(items=items)
307
+
308
+
309
+ @dataclass(config=dataclass_config)
310
+ class CheckedList(List):
311
+ items: LList[CheckedListItem] = Field(default_factory=lambda: [CheckedListItem()])
312
+
313
+ def to_model(self):
314
+ items = [x.to_model() for x in self.items]
315
+ return internal.List(children=items)
316
+
317
+
318
+ @dataclass(config=dataclass_config)
319
+ class OrderedList(List):
320
+ items: LList[str] = Field(default_factory=lambda: [""])
321
+
322
+ def to_model(self):
323
+ children = [OrderedListItem(li).to_model() for li in self.items]
324
+ return internal.List(children=children, ordered=True)
325
+
326
+
327
+ @dataclass(config=dataclass_config)
328
+ class UnorderedList(List):
329
+ items: LList[str] = Field(default_factory=lambda: [""])
330
+
331
+ def to_model(self):
332
+ children = [UnorderedListItem(li).to_model() for li in self.items]
333
+ return internal.List(children=children)
334
+
335
+
336
+ @dataclass(config=dataclass_config)
337
+ class BlockQuote(Block):
338
+ text: TextLikeField = ""
339
+
340
+ def to_model(self):
341
+ return internal.BlockQuote(children=_text_to_internal_children(self.text))
342
+
343
+ @classmethod
344
+ def from_model(cls, model: internal.BlockQuote):
345
+ return cls(text=_internal_children_to_text(model.children))
346
+
347
+
348
+ @dataclass(config=dataclass_config)
349
+ class CodeBlock(Block):
350
+ code: TextLikeField = ""
351
+ language: Optional[Language] = "python"
352
+
353
+ def to_model(self):
354
+ return internal.CodeBlock(
355
+ children=[
356
+ internal.CodeLine(
357
+ children=_text_to_internal_children(self.code),
358
+ language=self.language,
359
+ )
360
+ ],
361
+ language=self.language,
362
+ )
363
+
364
+ @classmethod
365
+ def from_model(cls, model: internal.CodeBlock):
366
+ code = _internal_children_to_text(model.children[0].children)
367
+ return cls(code=code, language=model.language)
368
+
369
+
370
+ @dataclass(config=dataclass_config)
371
+ class MarkdownBlock(Block):
372
+ text: str = ""
373
+
374
+ def to_model(self):
375
+ return internal.MarkdownBlock(content=self.text)
376
+
377
+ @classmethod
378
+ def from_model(cls, model: internal.MarkdownBlock):
379
+ return cls(text=model.content)
380
+
381
+
382
+ @dataclass(config=dataclass_config)
383
+ class LatexBlock(Block):
384
+ text: str = ""
385
+
386
+ def to_model(self):
387
+ return internal.LatexBlock(content=self.text)
388
+
389
+ @classmethod
390
+ def from_model(cls, model: internal.LatexBlock):
391
+ return cls(text=model.content)
392
+
393
+
394
+ @dataclass(config=dataclass_config)
395
+ class Image(Block):
396
+ url: str = "https://raw.githubusercontent.com/wandb/assets/main/wandb-logo-yellow-dots-black-wb.svg"
397
+ caption: TextLikeField = ""
398
+
399
+ def to_model(self):
400
+ has_caption = False
401
+ children = _text_to_internal_children(self.caption)
402
+ if children:
403
+ has_caption = True
404
+
405
+ return internal.Image(children=children, url=self.url, has_caption=has_caption)
406
+
407
+ @classmethod
408
+ def from_model(cls, model: internal.Image):
409
+ caption = _internal_children_to_text(model.children)
410
+ return cls(url=model.url, caption=caption)
411
+
412
+
413
+ @dataclass(config=dataclass_config)
414
+ class CalloutBlock(Block):
415
+ text: TextLikeField = ""
416
+
417
+ def to_model(self):
418
+ return internal.CalloutBlock(
419
+ children=[
420
+ internal.CalloutLine(children=_text_to_internal_children(self.text))
421
+ ]
422
+ )
423
+
424
+ @classmethod
425
+ def from_model(cls, model: internal.CalloutBlock):
426
+ text = _internal_children_to_text(model.children[0].children)
427
+ return cls(text=text)
428
+
429
+
430
+ @dataclass(config=dataclass_config)
431
+ class HorizontalRule(Block):
432
+ def to_model(self):
433
+ return internal.HorizontalRule()
434
+
435
+ @classmethod
436
+ def from_model(cls, model: internal.HorizontalRule):
437
+ return cls()
438
+
439
+
440
+ @dataclass(config=dataclass_config)
441
+ class Video(Block):
442
+ url: str = "https://www.youtube.com/watch?v=krWjJcW80_A"
443
+
444
+ def to_model(self):
445
+ return internal.Video(url=self.url)
446
+
447
+ @classmethod
448
+ def from_model(cls, model: internal.Video):
449
+ return cls(url=model.url)
450
+
451
+
452
+ @dataclass(config=dataclass_config)
453
+ class Spotify(Block):
454
+ spotify_id: str
455
+
456
+ def to_model(self):
457
+ return internal.Spotify(spotify_id=self.spotify_id)
458
+
459
+ @classmethod
460
+ def from_model(cls, model: internal.Spotify):
461
+ return cls(spotify_id=model.spotify_id)
462
+
463
+
464
+ @dataclass(config=dataclass_config)
465
+ class SoundCloud(Block):
466
+ html: str
467
+
468
+ def to_model(self):
469
+ return internal.SoundCloud(html=self.html)
470
+
471
+ @classmethod
472
+ def from_model(cls, model: internal.SoundCloud):
473
+ return cls(html=model.html)
474
+
475
+
476
+ @dataclass(config=dataclass_config)
477
+ class GalleryReport(Base):
478
+ report_id: str
479
+
480
+
481
+ @dataclass(config=dataclass_config)
482
+ class GalleryURL(Base):
483
+ url: str # app accepts non-standard URL unfortunately
484
+ title: Optional[str] = None
485
+ description: Optional[str] = None
486
+ image_url: Optional[str] = None
487
+
488
+
489
+ @dataclass(config=dataclass_config)
490
+ class Gallery(Block):
491
+ items: LList[Union[GalleryReport, GalleryURL]] = Field(default_factory=list)
492
+
493
+ def to_model(self):
494
+ links = []
495
+ for x in self.items:
496
+ if isinstance(x, GalleryReport):
497
+ link = internal.GalleryLinkReport(id=x.report_id)
498
+ elif isinstance(x, GalleryURL):
499
+ link = internal.GalleryLinkURL(
500
+ url=x.url,
501
+ title=x.title,
502
+ description=x.description,
503
+ image_url=x.image_url,
504
+ )
505
+ links.append(link)
506
+
507
+ return internal.Gallery(links=links)
508
+
509
+ @classmethod
510
+ def from_model(cls, model: internal.Gallery):
511
+ items = []
512
+ if model.ids:
513
+ items = [GalleryReport(x) for x in model.ids]
514
+ elif model.links:
515
+ for x in model.links:
516
+ if isinstance(x, internal.GalleryLinkReport):
517
+ item = GalleryReport(report_id=x.id)
518
+ elif isinstance(x, internal.GalleryLinkURL):
519
+ item = GalleryURL(
520
+ url=x.url,
521
+ title=x.title,
522
+ description=x.description,
523
+ image_url=x.image_url,
524
+ )
525
+ items.append(item)
526
+
527
+ return cls(items=items)
528
+
529
+
530
+ @dataclass(config=dataclass_config)
531
+ class OrderBy(Base):
532
+ name: MetricType
533
+ ascending: bool = False
534
+
535
+ def to_model(self):
536
+ return internal.SortKey(
537
+ key=internal.SortKeyKey(name=_metric_to_backend(self.name)),
538
+ ascending=self.ascending,
539
+ )
540
+
541
+ @classmethod
542
+ def from_model(cls, model: internal.SortKey):
543
+ return cls(
544
+ name=_metric_to_frontend(model.key.name),
545
+ ascending=model.ascending,
546
+ )
547
+
548
+
549
+ @dataclass(config=dataclass_config)
550
+ class Runset(Base):
551
+ entity: str = ""
552
+ project: str = ""
553
+ name: str = "Run set"
554
+ query: str = ""
555
+ filters: Optional[str] = ""
556
+ groupby: LList[str] = Field(default_factory=list)
557
+ order: LList[OrderBy] = Field(
558
+ default_factory=lambda: [OrderBy("CreatedTimestamp", ascending=False)]
559
+ )
560
+
561
+ # this field does not get exported to model, but is used in PanelGrid
562
+ custom_run_colors: Dict[Union[str, Tuple[MetricType, ...]], str] = Field(
563
+ default_factory=dict
564
+ )
565
+
566
+ _id: str = Field(default_factory=internal._generate_name, init=False, repr=False)
567
+
568
+ def to_model(self):
569
+ project = None
570
+ if self.entity or self.project:
571
+ project = internal.Project(entity_name=self.entity, name=self.project)
572
+
573
+ obj = internal.Runset(
574
+ project=project,
575
+ name=self.name,
576
+ filters=expr_parsing.expr_to_filters(self.filters),
577
+ grouping=[
578
+ internal.Key(name=expr_parsing.to_backend_name(g)) for g in self.groupby
579
+ ],
580
+ sort=internal.Sort(keys=[o.to_model() for o in self.order]),
581
+ )
582
+ obj.id = self._id
583
+ return obj
584
+
585
+ @classmethod
586
+ def from_model(cls, model: internal.Runset):
587
+ entity = ""
588
+ project = ""
589
+
590
+ p = model.project
591
+ if p is not None:
592
+ if p.entity_name:
593
+ entity = p.entity_name
594
+ if p.name:
595
+ project = p.name
596
+
597
+ obj = cls(
598
+ entity=entity,
599
+ project=project,
600
+ name=model.name,
601
+ filters=expr_parsing.filters_to_expr(model.filters),
602
+ groupby=[expr_parsing.to_frontend_name(k.name) for k in model.grouping],
603
+ order=[OrderBy.from_model(s) for s in model.sort.keys],
604
+ )
605
+ obj._id = model.id
606
+ return obj
607
+
608
+
609
+ @dataclass(config=dataclass_config)
610
+ class Panel(Base):
611
+ id: str = Field(default_factory=internal._generate_name, kw_only=True)
612
+ layout: Layout = Field(default_factory=Layout, kw_only=True)
613
+
614
+ _ref: Optional[internal.Ref] = Field(
615
+ default_factory=lambda: None, init=False, repr=False
616
+ )
617
+
618
+
619
+ @dataclass(config=dataclass_config)
620
+ class PanelGrid(Block):
621
+ runsets: LList["Runset"] = Field(default_factory=lambda: [Runset()])
622
+ panels: LList["PanelTypes"] = Field(default_factory=list)
623
+ active_runset: int = 0
624
+ custom_run_colors: Dict[Union[RunId, RunsetGroup], str] = Field(
625
+ default_factory=dict
626
+ )
627
+
628
+ _ref: Optional[internal.Ref] = Field(
629
+ default_factory=lambda: None, init=False, repr=False
630
+ )
631
+ _open_viz: bool = Field(default_factory=lambda: True, init=False, repr=False)
632
+ _panel_bank_sections: LList[dict] = Field(
633
+ default_factory=list, init=False, repr=False
634
+ )
635
+ _panel_grid_metadata_ref: Optional[internal.Ref] = Field(
636
+ default_factory=lambda: None, init=False, repr=False
637
+ )
638
+
639
+ def to_model(self):
640
+ return internal.PanelGrid(
641
+ metadata=internal.PanelGridMetadata(
642
+ run_sets=[rs.to_model() for rs in self.runsets],
643
+ panel_bank_section_config=internal.PanelBankSectionConfig(
644
+ panels=[p.to_model() for p in self.panels],
645
+ ),
646
+ panels=internal.PanelGridMetadataPanels(
647
+ ref=self._panel_grid_metadata_ref,
648
+ panel_bank_config=internal.PanelBankConfig(),
649
+ open_viz=self._open_viz,
650
+ ),
651
+ custom_run_colors=_to_color_dict(self.custom_run_colors, self.runsets),
652
+ )
653
+ )
654
+
655
+ @classmethod
656
+ def from_model(cls, model: internal.PanelGrid):
657
+ runsets = [Runset.from_model(rs) for rs in model.metadata.run_sets]
658
+ obj = cls(
659
+ runsets=runsets,
660
+ panels=[
661
+ _lookup_panel(p)
662
+ for p in model.metadata.panel_bank_section_config.panels
663
+ ],
664
+ active_runset=model.metadata.open_run_set,
665
+ custom_run_colors=_from_color_dict(
666
+ model.metadata.custom_run_colors, runsets
667
+ ),
668
+ # _panel_bank_sections=model.metadata.panel_bank_config.sections,
669
+ )
670
+ obj._open_viz = model.metadata.open_viz
671
+ obj._ref = model.metadata.panels.ref
672
+ return obj
673
+
674
+ @validator("panels")
675
+ def _resolve_collisions(cls, v): # noqa: N805
676
+ v2 = _resolve_collisions(v)
677
+ return v2
678
+
679
+ @validator("runsets")
680
+ def _validate_list_not_empty(cls, v): # noqa: N805
681
+ if len(v) < 1:
682
+ raise ValueError("must have at least one runset")
683
+ return v
684
+
685
+
686
+ @dataclass(config=dataclass_config)
687
+ class TableOfContents(Block):
688
+ def to_model(self):
689
+ return internal.TableOfContents()
690
+
691
+ @classmethod
692
+ def from_model(cls, model: internal.TableOfContents):
693
+ return cls()
694
+
695
+
696
+ @dataclass(config=dataclass_config)
697
+ class Twitter(Block):
698
+ html: str
699
+
700
+ def to_model(self):
701
+ return internal.Twitter(html=self.html)
702
+
703
+ @classmethod
704
+ def from_model(cls, model: internal.Twitter):
705
+ return cls(html=model.html)
706
+
707
+
708
+ @dataclass(config=dataclass_config)
709
+ class WeaveBlock(Block): ...
710
+
711
+
712
+ BlockTypes = Union[
713
+ H1,
714
+ H2,
715
+ H3,
716
+ P,
717
+ CodeBlock,
718
+ MarkdownBlock,
719
+ LatexBlock,
720
+ Image,
721
+ UnorderedList,
722
+ OrderedList,
723
+ CheckedList,
724
+ CalloutBlock,
725
+ Video,
726
+ HorizontalRule,
727
+ Spotify,
728
+ SoundCloud,
729
+ Gallery,
730
+ PanelGrid,
731
+ TableOfContents,
732
+ BlockQuote,
733
+ Twitter,
734
+ UnknownBlock,
735
+ ]
736
+
737
+
738
+ block_mapping = {
739
+ internal.Paragraph: P,
740
+ internal.CalloutBlock: CalloutBlock,
741
+ internal.CodeBlock: CodeBlock,
742
+ internal.Gallery: Gallery,
743
+ internal.Heading: Heading,
744
+ internal.HorizontalRule: HorizontalRule,
745
+ internal.Image: Image,
746
+ internal.LatexBlock: LatexBlock,
747
+ internal.List: List,
748
+ internal.MarkdownBlock: MarkdownBlock,
749
+ internal.PanelGrid: PanelGrid,
750
+ internal.TableOfContents: TableOfContents,
751
+ internal.Video: Video,
752
+ internal.BlockQuote: BlockQuote,
753
+ internal.Spotify: Spotify,
754
+ internal.Twitter: Twitter,
755
+ internal.SoundCloud: SoundCloud,
756
+ internal.UnknownBlock: UnknownBlock,
757
+ }
758
+
759
+
760
+ @dataclass(config=dataclass_config)
761
+ class GradientPoint(Base):
762
+ color: Annotated[str, internal.ColorStrConstraints]
763
+ offset: Annotated[float, Ge(0), Le(100)] = 0
764
+
765
+ def to_model(self):
766
+ return internal.GradientPoint(color=self.color, offset=self.offset)
767
+
768
+ @classmethod
769
+ def from_model(cls, model: internal.GradientPoint):
770
+ return cls(color=model.color, offset=model.offset)
771
+
772
+
773
+ @dataclass(config=dataclass_config)
774
+ class LinePlot(Panel):
775
+ title: Optional[str] = None
776
+ x: Optional[MetricType] = "Step"
777
+ y: LList[MetricType] = Field(default_factory=list)
778
+ range_x: Range = Field(default_factory=lambda: (None, None))
779
+ range_y: Range = Field(default_factory=lambda: (None, None))
780
+ log_x: Optional[bool] = None
781
+ log_y: Optional[bool] = None
782
+ title_x: Optional[str] = None
783
+ title_y: Optional[str] = None
784
+ ignore_outliers: Optional[bool] = None
785
+ groupby: Optional[str] = None
786
+ groupby_aggfunc: Optional[GroupAgg] = None
787
+ groupby_rangefunc: Optional[GroupArea] = None
788
+ smoothing_factor: Optional[float] = None
789
+ smoothing_type: Optional[SmoothingType] = None
790
+ smoothing_show_original: Optional[bool] = None
791
+ max_runs_to_show: Optional[int] = None
792
+ custom_expressions: Optional[LList[str]] = None
793
+ plot_type: Optional[LinePlotStyle] = None
794
+ font_size: Optional[FontSize] = None
795
+ legend_position: Optional[LegendPosition] = None
796
+ legend_template: Optional[str] = None
797
+ aggregate: Optional[bool] = None
798
+ xaxis_expression: Optional[str] = None
799
+
800
+ def to_model(self):
801
+ obj = internal.LinePlot(
802
+ config=internal.LinePlotConfig(
803
+ chart_title=self.title,
804
+ x_axis=_metric_to_backend(self.x),
805
+ metrics=[_metric_to_backend(name) for name in _listify(self.y)],
806
+ x_axis_min=self.range_x[0],
807
+ x_axis_max=self.range_x[1],
808
+ y_axis_min=self.range_x[0],
809
+ y_axis_max=self.range_x[1],
810
+ x_log_scale=self.log_x,
811
+ y_log_scale=self.log_y,
812
+ x_axis_title=self.title_x,
813
+ y_axis_title=self.title_y,
814
+ ignore_outliers=self.ignore_outliers,
815
+ group_by=self.groupby,
816
+ group_agg=self.groupby_aggfunc,
817
+ group_area=self.groupby_rangefunc,
818
+ smoothing_weight=self.smoothing_factor,
819
+ smoothing_type=self.smoothing_type,
820
+ show_original_after_smoothing=self.smoothing_show_original,
821
+ limit=self.max_runs_to_show,
822
+ expressions=self.custom_expressions,
823
+ plot_type=self.plot_type,
824
+ font_size=self.font_size,
825
+ legend_position=self.legend_position,
826
+ legend_template=self.legend_template,
827
+ aggregate=self.aggregate,
828
+ x_expression=self.xaxis_expression,
829
+ ),
830
+ id=self.id,
831
+ layout=self.layout.to_model(),
832
+ )
833
+ obj.ref = self._ref
834
+ return obj
835
+
836
+ @classmethod
837
+ def from_model(cls, model: internal.LinePlot):
838
+ obj = cls(
839
+ title=model.config.chart_title,
840
+ x=_metric_to_frontend(model.config.x_axis),
841
+ y=[_metric_to_frontend(name) for name in model.config.metrics],
842
+ range_x=(model.config.x_axis_min, model.config.x_axis_max),
843
+ range_y=(model.config.y_axis_min, model.config.y_axis_max),
844
+ log_x=model.config.x_log_scale,
845
+ log_y=model.config.y_log_scale,
846
+ title_x=model.config.x_axis_title,
847
+ title_y=model.config.y_axis_title,
848
+ ignore_outliers=model.config.ignore_outliers,
849
+ groupby=model.config.group_by,
850
+ groupby_aggfunc=model.config.group_agg,
851
+ groupby_rangefunc=model.config.group_area,
852
+ smoothing_factor=model.config.smoothing_weight,
853
+ smoothing_type=model.config.smoothing_type,
854
+ smoothing_show_original=model.config.show_original_after_smoothing,
855
+ max_runs_to_show=model.config.limit,
856
+ custom_expressions=model.config.expressions,
857
+ plot_type=model.config.plot_type,
858
+ font_size=model.config.font_size,
859
+ legend_position=model.config.legend_position,
860
+ legend_template=model.config.legend_template,
861
+ aggregate=model.config.aggregate,
862
+ xaxis_expression=model.config.x_expression,
863
+ layout=Layout.from_model(model.layout),
864
+ id=model.id,
865
+ )
866
+ obj._ref = model.ref
867
+ return obj
868
+
869
+
870
+ @dataclass(config=dataclass_config)
871
+ class ScatterPlot(Panel):
872
+ title: Optional[str] = None
873
+ x: Optional[MetricType] = None
874
+ y: Optional[MetricType] = None
875
+ z: Optional[MetricType] = None
876
+ range_x: Range = Field(default_factory=lambda: (None, None))
877
+ range_y: Range = Field(default_factory=lambda: (None, None))
878
+ range_z: Range = Field(default_factory=lambda: (None, None))
879
+ log_x: Optional[bool] = None
880
+ log_y: Optional[bool] = None
881
+ log_z: Optional[bool] = None
882
+ running_ymin: Optional[bool] = None
883
+ running_ymax: Optional[bool] = None
884
+ running_ymean: Optional[bool] = None
885
+ legend_template: Optional[str] = None
886
+ gradient: Optional[LList[GradientPoint]] = None
887
+ font_size: Optional[FontSize] = None
888
+ regression: Optional[bool] = None
889
+
890
+ def to_model(self):
891
+ custom_gradient = self.gradient
892
+ if custom_gradient is not None:
893
+ custom_gradient = [cgp.to_model() for cgp in self.gradient]
894
+
895
+ obj = internal.ScatterPlot(
896
+ config=internal.ScatterPlotConfig(
897
+ chart_title=self.title,
898
+ x_axis=_metric_to_backend(self.x),
899
+ y_axis=_metric_to_backend(self.y),
900
+ z_axis=_metric_to_backend(self.z),
901
+ x_axis_min=self.range_x[0],
902
+ x_axis_max=self.range_x[1],
903
+ y_axis_min=self.range_y[0],
904
+ y_axis_max=self.range_y[1],
905
+ z_axis_min=self.range_z[0],
906
+ z_axis_max=self.range_z[1],
907
+ x_axis_log_scale=self.log_x,
908
+ y_axis_log_scale=self.log_y,
909
+ z_axis_log_scale=self.log_z,
910
+ show_min_y_axis_line=self.running_ymin,
911
+ show_max_y_axis_line=self.running_ymax,
912
+ show_avg_y_axis_line=self.running_ymean,
913
+ legend_template=self.legend_template,
914
+ custom_gradient=custom_gradient,
915
+ font_size=self.font_size,
916
+ show_linear_regression=self.regression,
917
+ ),
918
+ layout=self.layout.to_model(),
919
+ id=self.id,
920
+ )
921
+ obj.ref = self._ref
922
+ return obj
923
+
924
+ @classmethod
925
+ def from_model(cls, model: internal.ScatterPlot):
926
+ gradient = model.config.custom_gradient
927
+ if gradient is not None:
928
+ gradient = [GradientPoint.from_model(cgp) for cgp in gradient]
929
+
930
+ obj = cls(
931
+ title=model.config.chart_title,
932
+ x=_metric_to_frontend(model.config.x_axis),
933
+ y=_metric_to_frontend(model.config.y_axis),
934
+ z=_metric_to_frontend(model.config.z_axis),
935
+ range_x=(model.config.x_axis_min, model.config.x_axis_max),
936
+ range_y=(model.config.y_axis_min, model.config.y_axis_max),
937
+ range_z=(model.config.z_axis_min, model.config.z_axis_max),
938
+ log_x=model.config.x_axis_log_scale,
939
+ log_y=model.config.y_axis_log_scale,
940
+ log_z=model.config.z_axis_log_scale,
941
+ running_ymin=model.config.show_min_y_axis_line,
942
+ running_ymax=model.config.show_max_y_axis_line,
943
+ running_ymean=model.config.show_avg_y_axis_line,
944
+ legend_template=model.config.legend_template,
945
+ gradient=gradient,
946
+ font_size=model.config.font_size,
947
+ regression=model.config.show_linear_regression,
948
+ layout=Layout.from_model(model.layout),
949
+ id=model.id,
950
+ )
951
+ obj._ref = model.ref
952
+ return obj
953
+
954
+
955
+ @dataclass(config=dataclass_config)
956
+ class BarPlot(Panel):
957
+ title: Optional[str] = None
958
+ metrics: LList[MetricType] = Field(default_factory=list)
959
+ orientation: Literal["v", "h"] = "h"
960
+ range_x: Range = Field(default_factory=lambda: (None, None))
961
+ title_x: Optional[str] = None
962
+ title_y: Optional[str] = None
963
+ groupby: Optional[str] = None
964
+ groupby_aggfunc: Optional[GroupAgg] = None
965
+ groupby_rangefunc: Optional[GroupArea] = None
966
+ max_runs_to_show: Optional[int] = None
967
+ max_bars_to_show: Optional[int] = None
968
+ custom_expressions: Optional[LList[str]] = None
969
+ legend_template: Optional[str] = None
970
+ font_size: Optional[FontSize] = None
971
+ line_titles: Optional[dict] = None
972
+ line_colors: Optional[dict] = None
973
+
974
+ def to_model(self):
975
+ obj = internal.BarPlot(
976
+ config=internal.BarPlotConfig(
977
+ chart_title=self.title,
978
+ metrics=[_metric_to_backend(name) for name in _listify(self.metrics)],
979
+ vertical=self.orientation == "v",
980
+ x_axis_min=self.range_x[0],
981
+ x_axis_max=self.range_x[1],
982
+ x_axis_title=self.title_x,
983
+ y_axis_title=self.title_y,
984
+ group_by=self.groupby,
985
+ group_agg=self.groupby_aggfunc,
986
+ group_area=self.groupby_rangefunc,
987
+ limit=self.max_runs_to_show,
988
+ bar_limit=self.max_bars_to_show,
989
+ expressions=self.custom_expressions,
990
+ legend_template=self.legend_template,
991
+ font_size=self.font_size,
992
+ override_series_titles=self.line_titles,
993
+ override_colors=self.line_colors,
994
+ ),
995
+ layout=self.layout.to_model(),
996
+ id=self.id,
997
+ )
998
+ obj.ref = self._ref
999
+ return obj
1000
+
1001
+ @classmethod
1002
+ def from_model(cls, model: internal.ScatterPlot):
1003
+ obj = cls(
1004
+ title=model.config.chart_title,
1005
+ metrics=[_metric_to_frontend(name) for name in model.config.metrics],
1006
+ orientation="v" if model.config.vertical else "h",
1007
+ range_x=(model.config.x_axis_min, model.config.x_axis_max),
1008
+ title_x=model.config.x_axis_title,
1009
+ title_y=model.config.y_axis_title,
1010
+ groupby=model.config.group_by,
1011
+ groupby_aggfunc=model.config.group_agg,
1012
+ groupby_rangefunc=model.config.group_area,
1013
+ max_runs_to_show=model.config.limit,
1014
+ max_bars_to_show=model.config.bar_limit,
1015
+ custom_expressions=model.config.expressions,
1016
+ legend_template=model.config.legend_template,
1017
+ font_size=model.config.font_size,
1018
+ line_titles=model.config.override_series_titles,
1019
+ line_colors=model.config.override_colors,
1020
+ layout=Layout.from_model(model.layout),
1021
+ id=model.id,
1022
+ )
1023
+ obj._ref = model.ref
1024
+ return obj
1025
+
1026
+
1027
+ @dataclass(config=dataclass_config)
1028
+ class ScalarChart(Panel):
1029
+ title: Optional[str] = None
1030
+ metric: MetricType = ""
1031
+ groupby_aggfunc: Optional[GroupAgg] = None
1032
+ groupby_rangefunc: Optional[GroupArea] = None
1033
+ custom_expressions: Optional[LList[str]] = None
1034
+ legend_template: Optional[str] = None
1035
+ font_size: Optional[FontSize] = None
1036
+
1037
+ def to_model(self):
1038
+ obj = internal.ScalarChart(
1039
+ config=internal.ScalarChartConfig(
1040
+ chart_title=self.title,
1041
+ metrics=[_metric_to_backend(self.metric)],
1042
+ group_agg=self.groupby_aggfunc,
1043
+ group_area=self.groupby_rangefunc,
1044
+ expressions=self.custom_expressions,
1045
+ legend_template=self.legend_template,
1046
+ font_size=self.font_size,
1047
+ ),
1048
+ layout=self.layout.to_model(),
1049
+ id=self.id,
1050
+ )
1051
+ obj.ref = self._ref
1052
+ return obj
1053
+
1054
+ @classmethod
1055
+ def from_model(cls, model: internal.ScatterPlot):
1056
+ obj = cls(
1057
+ title=model.config.chart_title,
1058
+ metric=_metric_to_frontend(model.config.metrics[0]),
1059
+ groupby_aggfunc=model.config.group_agg,
1060
+ groupby_rangefunc=model.config.group_area,
1061
+ custom_expressions=model.config.expressions,
1062
+ legend_template=model.config.legend_template,
1063
+ font_size=model.config.font_size,
1064
+ layout=Layout.from_model(model.layout),
1065
+ id=model.id,
1066
+ )
1067
+ obj._ref = model.ref
1068
+ return obj
1069
+
1070
+
1071
+ @dataclass(config=dataclass_config)
1072
+ class CodeComparer(Panel):
1073
+ diff: CodeCompareDiff = "split"
1074
+
1075
+ def to_model(self):
1076
+ obj = internal.CodeComparer(
1077
+ config=internal.CodeComparerConfig(diff=self.diff),
1078
+ layout=self.layout.to_model(),
1079
+ id=self.id,
1080
+ )
1081
+ obj.ref = self._ref
1082
+ return obj
1083
+
1084
+ @classmethod
1085
+ def from_model(cls, model: internal.ScatterPlot):
1086
+ obj = cls(
1087
+ diff=model.config.diff,
1088
+ layout=Layout.from_model(model.layout),
1089
+ id=model.id,
1090
+ )
1091
+ obj._ref = model.ref
1092
+ return obj
1093
+
1094
+
1095
+ @dataclass(config=dataclass_config)
1096
+ class ParallelCoordinatesPlotColumn(Base):
1097
+ metric: ParallelCoordinatesMetric
1098
+ display_name: Optional[str] = None
1099
+ inverted: Optional[bool] = None
1100
+ log: Optional[bool] = None
1101
+
1102
+ _ref: Optional[internal.Ref] = Field(
1103
+ default_factory=lambda: None, init=False, repr=False
1104
+ )
1105
+
1106
+ def to_model(self):
1107
+ obj = internal.Column(
1108
+ accessor=_metric_to_backend_pc(self.metric),
1109
+ display_name=self.display_name,
1110
+ inverted=self.inverted,
1111
+ log=self.log,
1112
+ )
1113
+ obj.ref = self._ref
1114
+ return obj
1115
+
1116
+ @classmethod
1117
+ def from_model(cls, model: internal.Column):
1118
+ obj = cls(
1119
+ metric=_metric_to_frontend_pc(model.accessor),
1120
+ display_name=model.display_name,
1121
+ inverted=model.inverted,
1122
+ log=model.log,
1123
+ )
1124
+ obj._ref = model.ref
1125
+ return obj
1126
+
1127
+
1128
+ @dataclass(config=dataclass_config)
1129
+ class ParallelCoordinatesPlot(Panel):
1130
+ columns: LList[ParallelCoordinatesPlotColumn] = Field(default_factory=list)
1131
+ title: Optional[str] = None
1132
+ gradient: Optional[LList[GradientPoint]] = None
1133
+ font_size: Optional[FontSize] = None
1134
+
1135
+ def to_model(self):
1136
+ gradient = self.gradient
1137
+ if gradient is not None:
1138
+ gradient = [x.to_model() for x in self.gradient]
1139
+
1140
+ obj = internal.ParallelCoordinatesPlot(
1141
+ config=internal.ParallelCoordinatesPlotConfig(
1142
+ chart_title=self.title,
1143
+ columns=[c.to_model() for c in self.columns],
1144
+ custom_gradient=gradient,
1145
+ font_size=self.font_size,
1146
+ ),
1147
+ layout=self.layout.to_model(),
1148
+ id=self.id,
1149
+ )
1150
+ obj.ref = self._ref
1151
+ return obj
1152
+
1153
+ @classmethod
1154
+ def from_model(cls, model: internal.ScatterPlot):
1155
+ gradient = model.config.custom_gradient
1156
+ if gradient is not None:
1157
+ gradient = [GradientPoint.from_model(x) for x in gradient]
1158
+
1159
+ obj = cls(
1160
+ columns=[
1161
+ ParallelCoordinatesPlotColumn.from_model(c)
1162
+ for c in model.config.columns
1163
+ ],
1164
+ title=model.config.chart_title,
1165
+ gradient=gradient,
1166
+ font_size=model.config.font_size,
1167
+ layout=Layout.from_model(model.layout),
1168
+ id=model.id,
1169
+ )
1170
+ obj._ref = model.ref
1171
+ return obj
1172
+
1173
+
1174
+ @dataclass(config=dataclass_config)
1175
+ class ParameterImportancePlot(Panel):
1176
+ with_respect_to: str = ""
1177
+
1178
+ def to_model(self):
1179
+ obj = internal.ParameterImportancePlot(
1180
+ config=internal.ParameterImportancePlotConfig(
1181
+ target_key=self.with_respect_to
1182
+ ),
1183
+ layout=self.layout.to_model(),
1184
+ id=self.id,
1185
+ )
1186
+ obj.ref = self._ref
1187
+ return obj
1188
+
1189
+ @classmethod
1190
+ def from_model(cls, model: internal.ScatterPlot):
1191
+ obj = cls(
1192
+ with_respect_to=model.config.target_key,
1193
+ layout=Layout.from_model(model.layout),
1194
+ id=model.id,
1195
+ )
1196
+ obj._ref = model.ref
1197
+ return obj
1198
+
1199
+
1200
+ @dataclass(config=dataclass_config)
1201
+ class RunComparer(Panel):
1202
+ diff_only: Optional[Literal["split", True]] = None
1203
+
1204
+ def to_model(self):
1205
+ obj = internal.RunComparer(
1206
+ config=internal.RunComparerConfig(diff_only=self.diff_only),
1207
+ layout=self.layout.to_model(),
1208
+ id=self.id,
1209
+ )
1210
+ obj.ref = self._ref
1211
+ return obj
1212
+
1213
+ @classmethod
1214
+ def from_model(cls, model: internal.ScatterPlot):
1215
+ obj = cls(
1216
+ diff_only=model.config.diff_only,
1217
+ layout=Layout.from_model(model.layout),
1218
+ id=model.id,
1219
+ )
1220
+ obj._ref = model.ref
1221
+ return obj
1222
+
1223
+
1224
+ @dataclass(config=dataclass_config)
1225
+ class MediaBrowser(Panel):
1226
+ num_columns: Optional[int] = None
1227
+ media_keys: LList[str] = Field(default_factory=list)
1228
+
1229
+ def to_model(self):
1230
+ obj = internal.MediaBrowser(
1231
+ config=internal.MediaBrowserConfig(
1232
+ column_count=self.num_columns,
1233
+ media_keys=self.media_keys,
1234
+ ),
1235
+ layout=self.layout.to_model(),
1236
+ id=self.id,
1237
+ )
1238
+ obj.ref = self._ref
1239
+ return obj
1240
+
1241
+ @classmethod
1242
+ def from_model(cls, model: internal.MediaBrowser):
1243
+ obj = cls(
1244
+ num_columns=model.config.column_count,
1245
+ media_keys=model.config.media_keys,
1246
+ layout=Layout.from_model(model.layout),
1247
+ id=model.id,
1248
+ )
1249
+ obj._ref = model.ref
1250
+ return obj
1251
+
1252
+
1253
+ @dataclass(config=dataclass_config)
1254
+ class MarkdownPanel(Panel):
1255
+ markdown: str = ""
1256
+
1257
+ def to_model(self):
1258
+ obj = internal.MarkdownPanel(
1259
+ config=internal.MarkdownPanelConfig(value=self.markdown),
1260
+ layout=self.layout.to_model(),
1261
+ id=self.id,
1262
+ )
1263
+ obj.ref = self._ref
1264
+ return obj
1265
+
1266
+ @classmethod
1267
+ def from_model(cls, model: internal.ScatterPlot):
1268
+ obj = cls(
1269
+ markdown=model.config.value,
1270
+ layout=Layout.from_model(model.layout),
1271
+ id=model.id,
1272
+ )
1273
+ obj._ref = model.ref
1274
+ return obj
1275
+
1276
+
1277
+ # @dataclass(config=dataclass_config)
1278
+ # class ConfusionMatrix(Panel):
1279
+ # def to_model(self):
1280
+ # ...
1281
+
1282
+ # @classmethod
1283
+ # def from_model(cls, model: internal.ConfusionMatrix):
1284
+ # ...
1285
+
1286
+
1287
+ # @dataclass(config=dataclass_config)
1288
+ # class DataFrames(Panel):
1289
+ # def to_model(self):
1290
+ # ...
1291
+
1292
+ # @classmethod
1293
+ # def from_model(cls, model: internal.ScatterPlot):
1294
+ # ...
1295
+
1296
+
1297
+ # @dataclass(config=dataclass_config)
1298
+ # class MultiRunTable(Panel):
1299
+ # def to_model(self):
1300
+ # ...
1301
+
1302
+ # @classmethod
1303
+ # def from_model(cls, model: internal.ScatterPlot):
1304
+ # ...
1305
+
1306
+
1307
+ # @dataclass(config=dataclass_config)
1308
+ # class Vega(Panel):
1309
+ # def to_model(self):
1310
+ # ...
1311
+
1312
+ # @classmethod
1313
+ # def from_model(cls, model: internal.ScatterPlot):
1314
+ # ...
1315
+
1316
+
1317
+ # @dataclass(config=dataclass_config)
1318
+ # class Vega3(Panel):
1319
+ # def to_model(self):
1320
+ # ...
1321
+
1322
+ # @classmethod
1323
+ # def from_model(cls, model: internal.ScatterPlot):
1324
+ # ...
1325
+
1326
+
1327
+ @dataclass(config=dataclass_config)
1328
+ class CustomChart(Panel):
1329
+ query: dict = Field(default_factory=dict)
1330
+ chart_name: str = Field(default_factory=dict)
1331
+ chart_fields: dict = Field(default_factory=dict)
1332
+ chart_strings: dict = Field(default_factory=dict)
1333
+
1334
+ @classmethod
1335
+ def from_table(
1336
+ cls, table_name: str, chart_fields: dict = None, chart_strings: dict = None
1337
+ ):
1338
+ return cls(
1339
+ query={"summaryTable": {"tableKey": table_name}},
1340
+ chart_fields=chart_fields,
1341
+ chart_strings=chart_strings,
1342
+ )
1343
+
1344
+ def to_model(self):
1345
+ obj = internal.Vega2(
1346
+ config=internal.Vega2Config(
1347
+ # user_query=internal.UserQuery(
1348
+ # query_fields=[
1349
+ # internal.QueryField(
1350
+ # args=...,
1351
+ # fields=...,
1352
+ # name=...,
1353
+ # )
1354
+ # ]
1355
+ # )
1356
+ ),
1357
+ layout=self.layout.to_model(),
1358
+ )
1359
+ obj.ref = self._ref
1360
+ # obj.id=self.id,
1361
+ return obj
1362
+
1363
+ @classmethod
1364
+ def from_model(cls, model: internal.ScatterPlot):
1365
+ obj = cls(
1366
+ # query=model.config.user_query.query_fields,
1367
+ # chart_name=model.config.panel_def_id,
1368
+ # chart_fields=model.config.field_settings,
1369
+ # chart_strings=model.config.string_settings,
1370
+ layout=Layout.from_model(model.layout),
1371
+ )
1372
+ obj._ref = model.ref
1373
+ return obj
1374
+
1375
+
1376
+ @dataclass(config=ConfigDict(validate_assignment=True, extra="forbid", slots=True))
1377
+ class UnknownPanel(Base):
1378
+ def __repr__(self) -> str:
1379
+ class_name = self.__class__.__name__
1380
+ attributes = ", ".join(
1381
+ f"{key}={value!r}" for key, value in self.__dict__.items()
1382
+ )
1383
+ return f"{class_name}({attributes})"
1384
+
1385
+ def to_model(self):
1386
+ d = self.__dict__
1387
+ print(d)
1388
+ return internal.UnknownPanel.model_validate(d)
1389
+
1390
+ @classmethod
1391
+ def from_model(cls, model: internal.UnknownPanel):
1392
+ d = model.model_dump()
1393
+ return cls(**d)
1394
+
1395
+
1396
+ @dataclass(config=ConfigDict(validate_assignment=True, extra="forbid", slots=True))
1397
+ class WeavePanel(Panel):
1398
+ config: dict = Field(default_factory=dict)
1399
+
1400
+ def to_model(self):
1401
+ return internal.WeavePanel(config=self.config)
1402
+
1403
+ @classmethod
1404
+ def from_model(cls, model: internal.WeavePanel):
1405
+ return cls(config=model.config)
1406
+
1407
+
1408
+ @dataclass(config=dataclass_config)
1409
+ class Report(Base):
1410
+ project: str
1411
+ entity: str = Field(default_factory=lambda: _get_api().default_entity)
1412
+ title: str = Field("Untitled Report", max_length=128)
1413
+ width: ReportWidth = "readable"
1414
+ description: str = ""
1415
+ blocks: LList[BlockTypes] = Field(default_factory=list)
1416
+
1417
+ id: str = Field(default_factory=lambda: "", init=False, repr=False, kw_only=True)
1418
+ _discussion_threads: list = Field(default_factory=list, init=False, repr=False)
1419
+ _ref: dict = Field(default_factory=dict, init=False, repr=False)
1420
+ _panel_settings: dict = Field(default_factory=dict, init=False, repr=False)
1421
+ _authors: LList[dict] = Field(default_factory=list, init=False, repr=False)
1422
+ _created_at: Optional[datetime] = Field(
1423
+ default_factory=lambda: None, init=False, repr=False
1424
+ )
1425
+ _updated_at: Optional[datetime] = Field(
1426
+ default_factory=lambda: None, init=False, repr=False
1427
+ )
1428
+
1429
+ def to_model(self):
1430
+ blocks = self.blocks
1431
+ if len(blocks) > 0 and blocks[0] != P():
1432
+ blocks = [P()] + blocks
1433
+
1434
+ if len(blocks) > 0 and blocks[-1] != P():
1435
+ blocks = blocks + [P()]
1436
+
1437
+ if not blocks:
1438
+ blocks = [P(), P()]
1439
+
1440
+ return internal.ReportViewspec(
1441
+ display_name=self.title,
1442
+ description=self.description,
1443
+ project=internal.Project(name=self.project, entity_name=self.entity),
1444
+ id=self.id,
1445
+ created_at=self._created_at,
1446
+ updated_at=self._updated_at,
1447
+ spec=internal.Spec(
1448
+ panel_settings=self._panel_settings,
1449
+ blocks=[b.to_model() for b in blocks],
1450
+ width=self.width,
1451
+ authors=self._authors,
1452
+ discussion_threads=self._discussion_threads,
1453
+ ref=self._ref,
1454
+ ),
1455
+ )
1456
+
1457
+ @classmethod
1458
+ def from_model(cls, model: internal.ReportViewspec):
1459
+ blocks = model.spec.blocks
1460
+
1461
+ if blocks[0] == internal.Paragraph():
1462
+ blocks = blocks[1:]
1463
+
1464
+ if blocks[-1] == internal.Paragraph():
1465
+ blocks = blocks[:-1]
1466
+
1467
+ obj = cls(
1468
+ title=model.display_name,
1469
+ description=model.description,
1470
+ entity=model.project.entity_name,
1471
+ project=model.project.name,
1472
+ blocks=[_lookup(b) for b in blocks],
1473
+ )
1474
+ obj.id = model.id
1475
+ obj._discussion_threads = model.spec.discussion_threads
1476
+ obj._panel_settings = model.spec.panel_settings
1477
+ obj._ref = model.spec.ref
1478
+ obj._authors = model.spec.authors
1479
+ obj._created_at = model.created_at
1480
+ obj._updated_at = model.updated_at
1481
+
1482
+ return obj
1483
+
1484
+ @property
1485
+ def url(self):
1486
+ if self.id == "":
1487
+ raise AttributeError("save report or explicitly pass `id` to get a url")
1488
+
1489
+ base = urlparse(_get_api().client.app_url)
1490
+
1491
+ title = self.title.replace(" ", "-")
1492
+
1493
+ scheme = base.scheme
1494
+ netloc = base.netloc
1495
+ path = os.path.join(self.entity, self.project, "reports", f"{title}--{self.id}")
1496
+ params = ""
1497
+ query = ""
1498
+ fragment = ""
1499
+
1500
+ return urlunparse((scheme, netloc, path, params, query, fragment))
1501
+
1502
+ def save(self, draft: bool = False, clone: bool = False):
1503
+ model = self.to_model()
1504
+
1505
+ # create project if not exists
1506
+ projects = _get_api().projects(self.entity)
1507
+ is_new_project = True
1508
+ for p in projects:
1509
+ if p.name == self.project:
1510
+ is_new_project = False
1511
+ break
1512
+
1513
+ if is_new_project:
1514
+ _get_api().create_project(self.project, self.entity)
1515
+
1516
+ r = _get_api().client.execute(
1517
+ gql.upsert_view,
1518
+ variable_values={
1519
+ "id": None if clone or not model.id else model.id,
1520
+ "name": internal._generate_name()
1521
+ if clone or not model.name
1522
+ else model.name,
1523
+ "entityName": model.project.entity_name,
1524
+ "projectName": model.project.name,
1525
+ "description": model.description,
1526
+ "displayName": model.display_name,
1527
+ "type": "runs/draft" if draft else "runs",
1528
+ "spec": model.spec.model_dump_json(by_alias=True, exclude_none=True),
1529
+ },
1530
+ )
1531
+
1532
+ viewspec = r["upsertView"]["view"]
1533
+ new_model = internal.ReportViewspec.model_validate(viewspec)
1534
+ self.id = new_model.id
1535
+
1536
+ wandb.termlog(f"Saved report to: {self.url}")
1537
+ return self
1538
+
1539
+ @classmethod
1540
+ def from_url(cls, url, *, as_model: bool = False):
1541
+ vs = _url_to_viewspec(url)
1542
+ model = internal.ReportViewspec.model_validate(vs)
1543
+ if as_model:
1544
+ return model
1545
+ return cls.from_model(model)
1546
+
1547
+ def to_html(self, height: int = 1024, hidden: bool = False) -> str:
1548
+ """Generate HTML containing an iframe displaying this report."""
1549
+ try:
1550
+ url = self.url + "?jupyter=true"
1551
+ style = f"border:none;width:100%;height:{height}px;"
1552
+ prefix = ""
1553
+ if hidden:
1554
+ style += "display:none;"
1555
+ prefix = wandb.sdk.lib.ipython.toggle_button("report")
1556
+ return prefix + f"<iframe src={url!r} style={style!r}></iframe>"
1557
+ except AttributeError:
1558
+ wandb.termlog("HTML repr will be available after you save the report!")
1559
+
1560
+ def _repr_html_(self) -> str:
1561
+ return self.to_html()
1562
+
1563
+
1564
+ def _get_api():
1565
+ try:
1566
+ return wandb.Api()
1567
+ except wandb.errors.UsageError as e:
1568
+ raise Exception("not logged in to W&B, try `wandb login --relogin`") from e
1569
+
1570
+
1571
+ def _url_to_viewspec(url):
1572
+ report_id = _url_to_report_id(url)
1573
+ r = _get_api().client.execute(
1574
+ gql.view_report, variable_values={"reportId": report_id}
1575
+ )
1576
+ viewspec = r["view"]
1577
+ return viewspec
1578
+
1579
+
1580
+ def _url_to_report_id(url):
1581
+ parse_result = urlparse(url)
1582
+ path = parse_result.path
1583
+
1584
+ _, entity, project, _, name = path.split("/")
1585
+ title, report_id = name.split("--")
1586
+
1587
+ return report_id
1588
+
1589
+
1590
+ def _lookup(block):
1591
+ cls = block_mapping.get(block.__class__, UnknownBlock)
1592
+ return cls.from_model(block)
1593
+
1594
+
1595
+ def _should_show_attr(k, v):
1596
+ if k.startswith("_"):
1597
+ return False
1598
+ if k == "id":
1599
+ return False
1600
+ if v is None:
1601
+ return False
1602
+ if isinstance(v, Iterable) and not isinstance(v, (str, bytes, bytearray)):
1603
+ return not all(x is None for x in v)
1604
+ # ignore the default layout
1605
+ if isinstance(v, Layout) and v.x == 0 and v.y == 0 and v.w == 8 and v.h == 6:
1606
+ return False
1607
+ return True
1608
+
1609
+
1610
+ def _listify(x):
1611
+ if isinstance(x, Iterable):
1612
+ return list(x)
1613
+ return [x]
1614
+
1615
+
1616
+ def _lookup_panel(panel):
1617
+ cls = panel_mapping.get(panel.__class__, UnknownPanel)
1618
+ return cls.from_model(panel)
1619
+
1620
+
1621
+ def _load_spec_from_url(url, as_model=False):
1622
+ import json
1623
+
1624
+ vs = _url_to_viewspec(url)
1625
+ spec = vs["spec"]
1626
+ if as_model:
1627
+ return internal.Spec.model_validate_json(spec)
1628
+ return json.loads(spec)
1629
+
1630
+
1631
+ panel_mapping = {
1632
+ internal.LinePlot: LinePlot,
1633
+ internal.ScatterPlot: ScatterPlot,
1634
+ internal.BarPlot: BarPlot,
1635
+ internal.ScalarChart: ScalarChart,
1636
+ internal.CodeComparer: CodeComparer,
1637
+ internal.ParallelCoordinatesPlot: ParallelCoordinatesPlot,
1638
+ internal.ParameterImportancePlot: ParameterImportancePlot,
1639
+ internal.RunComparer: RunComparer,
1640
+ internal.Vega2: CustomChart,
1641
+ internal.WeavePanel: WeavePanel,
1642
+ internal.MediaBrowser: MediaBrowser,
1643
+ internal.MarkdownPanel: MarkdownPanel,
1644
+ }
1645
+
1646
+ PanelTypes = Union[
1647
+ LinePlot,
1648
+ ScatterPlot,
1649
+ ScalarChart,
1650
+ BarPlot,
1651
+ CodeComparer,
1652
+ ParallelCoordinatesPlot,
1653
+ ParameterImportancePlot,
1654
+ RunComparer,
1655
+ MediaBrowser,
1656
+ MarkdownPanel,
1657
+ CustomChart,
1658
+ WeavePanel,
1659
+ UnknownPanel,
1660
+ ]
1661
+
1662
+
1663
+ def _text_to_internal_children(text_field):
1664
+ text = text_field
1665
+ if text == []:
1666
+ text = ""
1667
+ # if isinstance(text, str):
1668
+ if not isinstance(text, list):
1669
+ text = [text]
1670
+
1671
+ texts = []
1672
+ for x in text:
1673
+ t = None
1674
+ if isinstance(x, str):
1675
+ t = internal.Text(text=x)
1676
+ elif isinstance(x, TextWithInlineComments):
1677
+ t = internal.Text(text=x.text, inline_comments=x._inline_comments)
1678
+ elif isinstance(x, Link):
1679
+ txt = x.text
1680
+ if isinstance(txt, str):
1681
+ children = [internal.Text(text=txt)]
1682
+ elif isinstance(txt, TextWithInlineComments):
1683
+ children = [
1684
+ internal.Text(text=txt.text, inline_comments=txt._inline_comments)
1685
+ ]
1686
+ t = internal.InlineLink(url=x.url, children=children)
1687
+ elif isinstance(x, InlineLatex):
1688
+ t = internal.InlineLatex(content=x.text)
1689
+ elif isinstance(x, InlineCode):
1690
+ t = internal.Text(text=x.text, inline_code=True)
1691
+ texts.append(t)
1692
+ if not all(isinstance(x, str) for x in texts):
1693
+ pass
1694
+ return texts
1695
+
1696
+
1697
+ def _generate_thing(x):
1698
+ if isinstance(x, internal.Paragraph):
1699
+ return _internal_children_to_text(x.children)
1700
+ elif isinstance(x, internal.Text):
1701
+ if x.inline_code:
1702
+ return InlineCode(x.text)
1703
+ elif x.inline_comments:
1704
+ return TextWithInlineComments(
1705
+ text=x.text, _inline_comments=x.inline_comments
1706
+ )
1707
+ return x.text
1708
+ elif isinstance(x, internal.InlineLink):
1709
+ text_obj = x.children[0]
1710
+ if text_obj.inline_comments:
1711
+ text = TextWithInlineComments(
1712
+ text=text_obj.text, _inline_comments=text_obj.inline_comments
1713
+ )
1714
+ else:
1715
+ text = text_obj.text
1716
+ return Link(url=x.url, text=text)
1717
+ elif isinstance(x, internal.InlineLatex):
1718
+ return InlineLatex(text=x.content)
1719
+
1720
+
1721
+ def _internal_children_to_text(children):
1722
+ pieces = []
1723
+ for x in children:
1724
+ t = _generate_thing(x)
1725
+ if isinstance(t, list):
1726
+ for x in t:
1727
+ pieces.append(x)
1728
+ else:
1729
+ pieces.append(t)
1730
+
1731
+ if not pieces:
1732
+ return ""
1733
+
1734
+ if len(pieces) == 1 and isinstance(pieces[0], str):
1735
+ return pieces[0]
1736
+
1737
+ if len(pieces) == 3 and pieces[0] == "" and pieces[-1] == "":
1738
+ return pieces[1]
1739
+
1740
+ if len(pieces) >= 3 and pieces[0] == "" and pieces[-1] == "":
1741
+ return pieces[1:-1]
1742
+
1743
+ if all(x == "" for x in pieces):
1744
+ return ""
1745
+
1746
+ return pieces
1747
+
1748
+
1749
+ def _resolve_collisions(panels: LList[Panel], x_max: int = 24):
1750
+ for i, p1 in enumerate(panels):
1751
+ for p2 in panels[i + 1 :]:
1752
+ l1, l2 = p1.layout, p2.layout
1753
+
1754
+ if _collides(p1, p2):
1755
+ x = l1.x + l1.w - l2.x
1756
+ y = l1.y + l1.h - l2.y
1757
+
1758
+ if l2.x + l2.w + x <= x_max:
1759
+ l2.x += x
1760
+
1761
+ else:
1762
+ l2.y += y
1763
+ l2.x = 0
1764
+ return panels
1765
+
1766
+
1767
+ def _collides(p1: Panel, p2: Panel) -> bool:
1768
+ l1, l2 = p1.layout, p2.layout
1769
+
1770
+ if (
1771
+ (p1.id == p2.id)
1772
+ or (l1.x + l1.w <= l2.x)
1773
+ or (l1.x >= l2.w + l2.x)
1774
+ or (l1.y + l1.h <= l2.y)
1775
+ or (l1.y >= l2.y + l2.h)
1776
+ ):
1777
+ return False
1778
+
1779
+ return True
1780
+
1781
+
1782
+ def _metric_to_backend(x: Optional[MetricType]):
1783
+ if x is None:
1784
+ return x
1785
+ if isinstance(x, str): # Same as Metric
1786
+ return expr_parsing.to_backend_name(x)
1787
+ if isinstance(x, Metric):
1788
+ name = x.name
1789
+ return expr_parsing.to_backend_name(name)
1790
+ if isinstance(x, Config):
1791
+ name, *rest = x.name.split(".")
1792
+ rest = "." + ".".join(rest) if rest else ""
1793
+ return f"config.{name}.value{rest}"
1794
+ if isinstance(x, SummaryMetric):
1795
+ name = x.name
1796
+ return f"summary_metrics.{name}"
1797
+ raise Exception("Unexpected metric type")
1798
+
1799
+
1800
+ def _metric_to_frontend(x: str):
1801
+ if x is None:
1802
+ return x
1803
+ if x.startswith("config.") and ".value" in x:
1804
+ name = x.replace("config.", "").replace(".value", "")
1805
+ return Config(name)
1806
+ if x.startswith("summary_metrics."):
1807
+ name = x.replace("summary_metrics.", "")
1808
+ return SummaryMetric(name)
1809
+
1810
+ name = expr_parsing.to_frontend_name(x)
1811
+ return Metric(name)
1812
+
1813
+
1814
+ def _metric_to_backend_pc(x: Optional[ParallelCoordinatesMetric]):
1815
+ if x is None:
1816
+ return x
1817
+ if isinstance(x, str): # Same as SummaryMetric
1818
+ name = x
1819
+ return f"summary:{name}"
1820
+ if isinstance(x, Config):
1821
+ name = x.name
1822
+ return f"c::{name}"
1823
+ if isinstance(x, SummaryMetric):
1824
+ name = x.name
1825
+ return f"summary:{name}"
1826
+ raise Exception("Unexpected metric type")
1827
+
1828
+
1829
+ def _metric_to_frontend_pc(x: str):
1830
+ if x is None:
1831
+ return x
1832
+ if x.startswith("c::"):
1833
+ name = x.replace("c::", "")
1834
+ return Config(name)
1835
+ if x.startswith("summary:"):
1836
+ name = x.replace("summary:", "")
1837
+ return SummaryMetric(name)
1838
+
1839
+ name = expr_parsing.to_frontend_name(x)
1840
+ return Metric(name)
1841
+
1842
+
1843
+ def _metric_to_backend_panel_grid(x: Optional[MetricType]):
1844
+ if isinstance(x, str):
1845
+ name, *rest = x.split(".")
1846
+ rest = "." + ".".join(rest) if rest else ""
1847
+ return f"config:{name}.value{rest}"
1848
+ return _metric_to_backend(x)
1849
+
1850
+
1851
+ def _metric_to_frontend_panel_grid(x: str):
1852
+ if x.startswith("config:") and ".value" in x:
1853
+ name = x.replace("config:", "").replace(".value", "")
1854
+ return Config(name)
1855
+ return _metric_to_frontend(x)
1856
+
1857
+
1858
+ def _get_rs_by_name(runsets, name):
1859
+ for rs in runsets:
1860
+ if rs.name == name:
1861
+ return rs
1862
+
1863
+
1864
+ def _get_rs_by_id(runsets, id):
1865
+ for rs in runsets:
1866
+ if rs._id == id:
1867
+ return rs
1868
+
1869
+
1870
+ def _to_color_dict(custom_run_colors, runsets):
1871
+ d = {}
1872
+ for k, v in custom_run_colors.items():
1873
+ if isinstance(k, RunsetGroup):
1874
+ rs = _get_rs_by_name(runsets, k.runset_name)
1875
+ if not rs:
1876
+ continue
1877
+ id = rs._id
1878
+ kvs = []
1879
+ for keys in k.keys:
1880
+ kk = _metric_to_backend_panel_grid(keys.key)
1881
+ vv = keys.value
1882
+ kv = f"{kk}:{vv}"
1883
+ kvs.append(kv)
1884
+ linked = "-".join(kvs)
1885
+ key = f"{id}-{linked}"
1886
+ else:
1887
+ key = k
1888
+ d[key] = v
1889
+
1890
+ return d
1891
+
1892
+
1893
+ def _from_color_dict(d, runsets):
1894
+ d2 = {}
1895
+ for k, v in d.items():
1896
+ id, *backend_parts = k.split("-")
1897
+
1898
+ if backend_parts:
1899
+ groups = []
1900
+ for part in backend_parts:
1901
+ key, value = part.rsplit(":", 1)
1902
+ kkey = _metric_to_frontend_panel_grid(key)
1903
+ group = RunsetGroupKey(kkey, value)
1904
+ groups.append(group)
1905
+ rs = _get_rs_by_id(runsets, id)
1906
+ rg = RunsetGroup(runset_name=rs.name, keys=groups)
1907
+ new_key = rg
1908
+ else:
1909
+ new_key = k
1910
+ d2[new_key] = v
1911
+ return d2