wandb 0.22.1__py3-none-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (919) hide show
  1. package_readme.md +97 -0
  2. wandb/__init__.py +248 -0
  3. wandb/__init__.pyi +1230 -0
  4. wandb/__main__.py +3 -0
  5. wandb/_analytics.py +65 -0
  6. wandb/_iterutils.py +73 -0
  7. wandb/_pydantic/__init__.py +30 -0
  8. wandb/_pydantic/base.py +108 -0
  9. wandb/_pydantic/field_types.py +29 -0
  10. wandb/_pydantic/utils.py +80 -0
  11. wandb/_pydantic/v1_compat.py +301 -0
  12. wandb/_strutils.py +40 -0
  13. wandb/agents/__init__.py +0 -0
  14. wandb/agents/pyagent.py +386 -0
  15. wandb/analytics/__init__.py +3 -0
  16. wandb/analytics/sentry.py +267 -0
  17. wandb/apis/__init__.py +50 -0
  18. wandb/apis/attrs.py +52 -0
  19. wandb/apis/importers/__init__.py +1 -0
  20. wandb/apis/importers/internals/internal.py +375 -0
  21. wandb/apis/importers/internals/protocols.py +103 -0
  22. wandb/apis/importers/internals/util.py +78 -0
  23. wandb/apis/importers/mlflow.py +254 -0
  24. wandb/apis/importers/validation.py +108 -0
  25. wandb/apis/importers/wandb.py +1608 -0
  26. wandb/apis/internal.py +241 -0
  27. wandb/apis/normalize.py +83 -0
  28. wandb/apis/paginator.py +138 -0
  29. wandb/apis/public/__init__.py +78 -0
  30. wandb/apis/public/api.py +2513 -0
  31. wandb/apis/public/artifacts.py +1050 -0
  32. wandb/apis/public/automations.py +86 -0
  33. wandb/apis/public/const.py +6 -0
  34. wandb/apis/public/files.py +411 -0
  35. wandb/apis/public/history.py +203 -0
  36. wandb/apis/public/integrations.py +203 -0
  37. wandb/apis/public/jobs.py +744 -0
  38. wandb/apis/public/projects.py +278 -0
  39. wandb/apis/public/query_generator.py +179 -0
  40. wandb/apis/public/registries/__init__.py +7 -0
  41. wandb/apis/public/registries/_freezable_list.py +176 -0
  42. wandb/apis/public/registries/_utils.py +139 -0
  43. wandb/apis/public/registries/registries_search.py +353 -0
  44. wandb/apis/public/registries/registry.py +370 -0
  45. wandb/apis/public/reports.py +597 -0
  46. wandb/apis/public/runs.py +1438 -0
  47. wandb/apis/public/sweeps.py +441 -0
  48. wandb/apis/public/teams.py +237 -0
  49. wandb/apis/public/users.py +179 -0
  50. wandb/apis/public/utils.py +211 -0
  51. wandb/apis/reports/__init__.py +1 -0
  52. wandb/apis/reports/v1/__init__.py +8 -0
  53. wandb/apis/reports/v2/__init__.py +8 -0
  54. wandb/apis/workspaces/__init__.py +8 -0
  55. wandb/automations/__init__.py +73 -0
  56. wandb/automations/_filters/__init__.py +40 -0
  57. wandb/automations/_filters/expressions.py +182 -0
  58. wandb/automations/_filters/operators.py +259 -0
  59. wandb/automations/_filters/run_metrics.py +330 -0
  60. wandb/automations/_generated/__init__.py +104 -0
  61. wandb/automations/_generated/create_automation.py +17 -0
  62. wandb/automations/_generated/create_generic_webhook_integration.py +37 -0
  63. wandb/automations/_generated/delete_automation.py +15 -0
  64. wandb/automations/_generated/enums.py +35 -0
  65. wandb/automations/_generated/fragments.py +293 -0
  66. wandb/automations/_generated/generic_webhook_integrations_by_entity.py +22 -0
  67. wandb/automations/_generated/get_automations.py +24 -0
  68. wandb/automations/_generated/get_automations_by_entity.py +26 -0
  69. wandb/automations/_generated/input_types.py +104 -0
  70. wandb/automations/_generated/integrations_by_entity.py +22 -0
  71. wandb/automations/_generated/operations.py +647 -0
  72. wandb/automations/_generated/slack_integrations_by_entity.py +22 -0
  73. wandb/automations/_generated/update_automation.py +17 -0
  74. wandb/automations/_utils.py +235 -0
  75. wandb/automations/_validators.py +185 -0
  76. wandb/automations/actions.py +220 -0
  77. wandb/automations/automations.py +85 -0
  78. wandb/automations/events.py +284 -0
  79. wandb/automations/integrations.py +45 -0
  80. wandb/automations/scopes.py +78 -0
  81. wandb/beta/workflows.py +324 -0
  82. wandb/bin/gpu_stats.exe +0 -0
  83. wandb/bin/wandb-core +0 -0
  84. wandb/cli/__init__.py +0 -0
  85. wandb/cli/beta.py +93 -0
  86. wandb/cli/beta_sync.py +224 -0
  87. wandb/cli/cli.py +2883 -0
  88. wandb/data_types.py +66 -0
  89. wandb/docker/__init__.py +290 -0
  90. wandb/docker/names.py +40 -0
  91. wandb/docker/wandb-entrypoint.sh +33 -0
  92. wandb/env.py +535 -0
  93. wandb/errors/__init__.py +17 -0
  94. wandb/errors/errors.py +40 -0
  95. wandb/errors/links.py +73 -0
  96. wandb/errors/term.py +415 -0
  97. wandb/errors/util.py +57 -0
  98. wandb/errors/warnings.py +2 -0
  99. wandb/filesync/__init__.py +0 -0
  100. wandb/filesync/dir_watcher.py +404 -0
  101. wandb/filesync/stats.py +100 -0
  102. wandb/filesync/step_checksum.py +142 -0
  103. wandb/filesync/step_prepare.py +179 -0
  104. wandb/filesync/step_upload.py +287 -0
  105. wandb/filesync/upload_job.py +142 -0
  106. wandb/integration/__init__.py +0 -0
  107. wandb/integration/catboost/__init__.py +5 -0
  108. wandb/integration/catboost/catboost.py +182 -0
  109. wandb/integration/cohere/__init__.py +3 -0
  110. wandb/integration/cohere/cohere.py +21 -0
  111. wandb/integration/cohere/resolver.py +347 -0
  112. wandb/integration/diffusers/__init__.py +3 -0
  113. wandb/integration/diffusers/autologger.py +76 -0
  114. wandb/integration/diffusers/pipeline_resolver.py +50 -0
  115. wandb/integration/diffusers/resolvers/__init__.py +9 -0
  116. wandb/integration/diffusers/resolvers/multimodal.py +881 -0
  117. wandb/integration/diffusers/resolvers/utils.py +102 -0
  118. wandb/integration/dspy/__init__.py +5 -0
  119. wandb/integration/dspy/dspy.py +422 -0
  120. wandb/integration/fastai/__init__.py +243 -0
  121. wandb/integration/gym/__init__.py +98 -0
  122. wandb/integration/huggingface/__init__.py +3 -0
  123. wandb/integration/huggingface/huggingface.py +18 -0
  124. wandb/integration/huggingface/resolver.py +213 -0
  125. wandb/integration/keras/__init__.py +11 -0
  126. wandb/integration/keras/callbacks/__init__.py +5 -0
  127. wandb/integration/keras/callbacks/metrics_logger.py +129 -0
  128. wandb/integration/keras/callbacks/model_checkpoint.py +188 -0
  129. wandb/integration/keras/callbacks/tables_builder.py +228 -0
  130. wandb/integration/keras/keras.py +1086 -0
  131. wandb/integration/kfp/__init__.py +6 -0
  132. wandb/integration/kfp/helpers.py +28 -0
  133. wandb/integration/kfp/kfp_patch.py +335 -0
  134. wandb/integration/kfp/wandb_logging.py +182 -0
  135. wandb/integration/langchain/__init__.py +3 -0
  136. wandb/integration/langchain/wandb_tracer.py +49 -0
  137. wandb/integration/lightgbm/__init__.py +239 -0
  138. wandb/integration/lightning/__init__.py +0 -0
  139. wandb/integration/lightning/fabric/__init__.py +3 -0
  140. wandb/integration/lightning/fabric/logger.py +763 -0
  141. wandb/integration/metaflow/__init__.py +9 -0
  142. wandb/integration/metaflow/data_pandas.py +74 -0
  143. wandb/integration/metaflow/data_pytorch.py +75 -0
  144. wandb/integration/metaflow/data_sklearn.py +76 -0
  145. wandb/integration/metaflow/errors.py +13 -0
  146. wandb/integration/metaflow/metaflow.py +327 -0
  147. wandb/integration/openai/__init__.py +3 -0
  148. wandb/integration/openai/fine_tuning.py +480 -0
  149. wandb/integration/openai/openai.py +22 -0
  150. wandb/integration/openai/resolver.py +240 -0
  151. wandb/integration/prodigy/__init__.py +3 -0
  152. wandb/integration/prodigy/prodigy.py +291 -0
  153. wandb/integration/sacred/__init__.py +117 -0
  154. wandb/integration/sagemaker/__init__.py +14 -0
  155. wandb/integration/sagemaker/auth.py +29 -0
  156. wandb/integration/sagemaker/config.py +58 -0
  157. wandb/integration/sagemaker/files.py +2 -0
  158. wandb/integration/sagemaker/resources.py +63 -0
  159. wandb/integration/sb3/__init__.py +3 -0
  160. wandb/integration/sb3/sb3.py +147 -0
  161. wandb/integration/sklearn/__init__.py +37 -0
  162. wandb/integration/sklearn/calculate/__init__.py +32 -0
  163. wandb/integration/sklearn/calculate/calibration_curves.py +125 -0
  164. wandb/integration/sklearn/calculate/class_proportions.py +68 -0
  165. wandb/integration/sklearn/calculate/confusion_matrix.py +93 -0
  166. wandb/integration/sklearn/calculate/decision_boundaries.py +40 -0
  167. wandb/integration/sklearn/calculate/elbow_curve.py +55 -0
  168. wandb/integration/sklearn/calculate/feature_importances.py +67 -0
  169. wandb/integration/sklearn/calculate/learning_curve.py +64 -0
  170. wandb/integration/sklearn/calculate/outlier_candidates.py +69 -0
  171. wandb/integration/sklearn/calculate/residuals.py +86 -0
  172. wandb/integration/sklearn/calculate/silhouette.py +118 -0
  173. wandb/integration/sklearn/calculate/summary_metrics.py +62 -0
  174. wandb/integration/sklearn/plot/__init__.py +35 -0
  175. wandb/integration/sklearn/plot/classifier.py +329 -0
  176. wandb/integration/sklearn/plot/clusterer.py +146 -0
  177. wandb/integration/sklearn/plot/regressor.py +121 -0
  178. wandb/integration/sklearn/plot/shared.py +91 -0
  179. wandb/integration/sklearn/utils.py +184 -0
  180. wandb/integration/tensorboard/__init__.py +10 -0
  181. wandb/integration/tensorboard/log.py +351 -0
  182. wandb/integration/tensorboard/monkeypatch.py +186 -0
  183. wandb/integration/tensorflow/__init__.py +5 -0
  184. wandb/integration/tensorflow/estimator_hook.py +54 -0
  185. wandb/integration/torch/__init__.py +0 -0
  186. wandb/integration/torch/wandb_torch.py +554 -0
  187. wandb/integration/ultralytics/__init__.py +11 -0
  188. wandb/integration/ultralytics/bbox_utils.py +215 -0
  189. wandb/integration/ultralytics/callback.py +528 -0
  190. wandb/integration/ultralytics/classification_utils.py +83 -0
  191. wandb/integration/ultralytics/mask_utils.py +202 -0
  192. wandb/integration/ultralytics/pose_utils.py +103 -0
  193. wandb/integration/weave/__init__.py +6 -0
  194. wandb/integration/weave/interface.py +49 -0
  195. wandb/integration/weave/weave.py +118 -0
  196. wandb/integration/xgboost/__init__.py +11 -0
  197. wandb/integration/xgboost/xgboost.py +189 -0
  198. wandb/integration/yolov8/__init__.py +0 -0
  199. wandb/integration/yolov8/yolov8.py +284 -0
  200. wandb/jupyter.py +538 -0
  201. wandb/mpmain/__init__.py +0 -0
  202. wandb/mpmain/__main__.py +1 -0
  203. wandb/old/__init__.py +0 -0
  204. wandb/old/core.py +53 -0
  205. wandb/old/settings.py +176 -0
  206. wandb/old/summary.py +438 -0
  207. wandb/plot/__init__.py +30 -0
  208. wandb/plot/bar.py +71 -0
  209. wandb/plot/confusion_matrix.py +185 -0
  210. wandb/plot/custom_chart.py +147 -0
  211. wandb/plot/histogram.py +66 -0
  212. wandb/plot/line.py +75 -0
  213. wandb/plot/line_series.py +173 -0
  214. wandb/plot/pr_curve.py +186 -0
  215. wandb/plot/roc_curve.py +163 -0
  216. wandb/plot/scatter.py +66 -0
  217. wandb/plot/utils.py +184 -0
  218. wandb/plot/viz.py +41 -0
  219. wandb/proto/__init__.py +0 -0
  220. wandb/proto/v3/__init__.py +0 -0
  221. wandb/proto/v3/wandb_base_pb2.py +55 -0
  222. wandb/proto/v3/wandb_internal_pb2.py +1738 -0
  223. wandb/proto/v3/wandb_server_pb2.py +209 -0
  224. wandb/proto/v3/wandb_settings_pb2.py +122 -0
  225. wandb/proto/v3/wandb_sync_pb2.py +100 -0
  226. wandb/proto/v3/wandb_telemetry_pb2.py +106 -0
  227. wandb/proto/v4/__init__.py +0 -0
  228. wandb/proto/v4/wandb_base_pb2.py +30 -0
  229. wandb/proto/v4/wandb_internal_pb2.py +384 -0
  230. wandb/proto/v4/wandb_server_pb2.py +64 -0
  231. wandb/proto/v4/wandb_settings_pb2.py +47 -0
  232. wandb/proto/v4/wandb_sync_pb2.py +42 -0
  233. wandb/proto/v4/wandb_telemetry_pb2.py +41 -0
  234. wandb/proto/v5/wandb_base_pb2.py +31 -0
  235. wandb/proto/v5/wandb_internal_pb2.py +385 -0
  236. wandb/proto/v5/wandb_server_pb2.py +65 -0
  237. wandb/proto/v5/wandb_settings_pb2.py +48 -0
  238. wandb/proto/v5/wandb_sync_pb2.py +43 -0
  239. wandb/proto/v5/wandb_telemetry_pb2.py +42 -0
  240. wandb/proto/v6/wandb_base_pb2.py +41 -0
  241. wandb/proto/v6/wandb_internal_pb2.py +395 -0
  242. wandb/proto/v6/wandb_server_pb2.py +75 -0
  243. wandb/proto/v6/wandb_settings_pb2.py +58 -0
  244. wandb/proto/v6/wandb_sync_pb2.py +53 -0
  245. wandb/proto/v6/wandb_telemetry_pb2.py +52 -0
  246. wandb/proto/wandb_base_pb2.py +12 -0
  247. wandb/proto/wandb_deprecated.py +59 -0
  248. wandb/proto/wandb_generate_deprecated.py +30 -0
  249. wandb/proto/wandb_generate_proto.py +50 -0
  250. wandb/proto/wandb_internal_pb2.py +18 -0
  251. wandb/proto/wandb_server_pb2.py +12 -0
  252. wandb/proto/wandb_settings_pb2.py +12 -0
  253. wandb/proto/wandb_sync_pb2.py +12 -0
  254. wandb/proto/wandb_telemetry_pb2.py +12 -0
  255. wandb/py.typed +0 -0
  256. wandb/sdk/__init__.py +37 -0
  257. wandb/sdk/artifacts/__init__.py +0 -0
  258. wandb/sdk/artifacts/_factories.py +22 -0
  259. wandb/sdk/artifacts/_generated/__init__.py +208 -0
  260. wandb/sdk/artifacts/_generated/add_aliases.py +21 -0
  261. wandb/sdk/artifacts/_generated/artifact_by_id.py +17 -0
  262. wandb/sdk/artifacts/_generated/artifact_by_name.py +22 -0
  263. wandb/sdk/artifacts/_generated/artifact_collection_membership_file_urls.py +43 -0
  264. wandb/sdk/artifacts/_generated/artifact_collection_membership_files.py +43 -0
  265. wandb/sdk/artifacts/_generated/artifact_created_by.py +47 -0
  266. wandb/sdk/artifacts/_generated/artifact_file_urls.py +22 -0
  267. wandb/sdk/artifacts/_generated/artifact_type.py +31 -0
  268. wandb/sdk/artifacts/_generated/artifact_used_by.py +43 -0
  269. wandb/sdk/artifacts/_generated/artifact_version_files.py +36 -0
  270. wandb/sdk/artifacts/_generated/artifact_via_membership_by_name.py +26 -0
  271. wandb/sdk/artifacts/_generated/create_artifact_collection_tag_assignments.py +36 -0
  272. wandb/sdk/artifacts/_generated/delete_aliases.py +21 -0
  273. wandb/sdk/artifacts/_generated/delete_artifact.py +28 -0
  274. wandb/sdk/artifacts/_generated/delete_artifact_collection_tag_assignments.py +25 -0
  275. wandb/sdk/artifacts/_generated/delete_artifact_portfolio.py +35 -0
  276. wandb/sdk/artifacts/_generated/delete_artifact_sequence.py +35 -0
  277. wandb/sdk/artifacts/_generated/enums.py +22 -0
  278. wandb/sdk/artifacts/_generated/fetch_artifact_manifest.py +38 -0
  279. wandb/sdk/artifacts/_generated/fetch_linked_artifacts.py +67 -0
  280. wandb/sdk/artifacts/_generated/fetch_registries.py +32 -0
  281. wandb/sdk/artifacts/_generated/fragments.py +524 -0
  282. wandb/sdk/artifacts/_generated/input_types.py +46 -0
  283. wandb/sdk/artifacts/_generated/link_artifact.py +27 -0
  284. wandb/sdk/artifacts/_generated/move_artifact_collection.py +35 -0
  285. wandb/sdk/artifacts/_generated/operations.py +1253 -0
  286. wandb/sdk/artifacts/_generated/project_artifact_collection.py +101 -0
  287. wandb/sdk/artifacts/_generated/project_artifact_collections.py +33 -0
  288. wandb/sdk/artifacts/_generated/project_artifact_type.py +24 -0
  289. wandb/sdk/artifacts/_generated/project_artifact_types.py +24 -0
  290. wandb/sdk/artifacts/_generated/project_artifacts.py +42 -0
  291. wandb/sdk/artifacts/_generated/registry_collections.py +34 -0
  292. wandb/sdk/artifacts/_generated/registry_versions.py +34 -0
  293. wandb/sdk/artifacts/_generated/run_input_artifacts.py +31 -0
  294. wandb/sdk/artifacts/_generated/run_output_artifacts.py +31 -0
  295. wandb/sdk/artifacts/_generated/type_info.py +19 -0
  296. wandb/sdk/artifacts/_generated/unlink_artifact.py +25 -0
  297. wandb/sdk/artifacts/_generated/update_artifact.py +26 -0
  298. wandb/sdk/artifacts/_generated/update_artifact_portfolio.py +35 -0
  299. wandb/sdk/artifacts/_generated/update_artifact_sequence.py +35 -0
  300. wandb/sdk/artifacts/_gqlutils.py +47 -0
  301. wandb/sdk/artifacts/_internal_artifact.py +54 -0
  302. wandb/sdk/artifacts/_models/__init__.py +4 -0
  303. wandb/sdk/artifacts/_models/base_model.py +20 -0
  304. wandb/sdk/artifacts/_validators.py +338 -0
  305. wandb/sdk/artifacts/artifact.py +2683 -0
  306. wandb/sdk/artifacts/artifact_download_logger.py +45 -0
  307. wandb/sdk/artifacts/artifact_file_cache.py +256 -0
  308. wandb/sdk/artifacts/artifact_instance_cache.py +17 -0
  309. wandb/sdk/artifacts/artifact_manifest.py +76 -0
  310. wandb/sdk/artifacts/artifact_manifest_entry.py +315 -0
  311. wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
  312. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +94 -0
  313. wandb/sdk/artifacts/artifact_saver.py +277 -0
  314. wandb/sdk/artifacts/artifact_state.py +13 -0
  315. wandb/sdk/artifacts/artifact_ttl.py +9 -0
  316. wandb/sdk/artifacts/exceptions.py +72 -0
  317. wandb/sdk/artifacts/staging.py +27 -0
  318. wandb/sdk/artifacts/storage_handler.py +62 -0
  319. wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
  320. wandb/sdk/artifacts/storage_handlers/azure_handler.py +214 -0
  321. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +224 -0
  322. wandb/sdk/artifacts/storage_handlers/http_handler.py +112 -0
  323. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +142 -0
  324. wandb/sdk/artifacts/storage_handlers/multi_handler.py +56 -0
  325. wandb/sdk/artifacts/storage_handlers/s3_handler.py +340 -0
  326. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +68 -0
  327. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +131 -0
  328. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +74 -0
  329. wandb/sdk/artifacts/storage_layout.py +8 -0
  330. wandb/sdk/artifacts/storage_policies/__init__.py +4 -0
  331. wandb/sdk/artifacts/storage_policies/_factories.py +63 -0
  332. wandb/sdk/artifacts/storage_policies/register.py +1 -0
  333. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +525 -0
  334. wandb/sdk/artifacts/storage_policy.py +75 -0
  335. wandb/sdk/backend/__init__.py +0 -0
  336. wandb/sdk/backend/backend.py +57 -0
  337. wandb/sdk/data_types/__init__.py +0 -0
  338. wandb/sdk/data_types/_dtypes.py +914 -0
  339. wandb/sdk/data_types/_private.py +10 -0
  340. wandb/sdk/data_types/audio.py +208 -0
  341. wandb/sdk/data_types/base_types/__init__.py +0 -0
  342. wandb/sdk/data_types/base_types/json_metadata.py +55 -0
  343. wandb/sdk/data_types/base_types/media.py +339 -0
  344. wandb/sdk/data_types/base_types/wb_value.py +295 -0
  345. wandb/sdk/data_types/bokeh.py +91 -0
  346. wandb/sdk/data_types/graph.py +439 -0
  347. wandb/sdk/data_types/helper_types/__init__.py +0 -0
  348. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +327 -0
  349. wandb/sdk/data_types/helper_types/classes.py +159 -0
  350. wandb/sdk/data_types/helper_types/image_mask.py +251 -0
  351. wandb/sdk/data_types/histogram.py +107 -0
  352. wandb/sdk/data_types/html.py +165 -0
  353. wandb/sdk/data_types/image.py +985 -0
  354. wandb/sdk/data_types/molecule.py +250 -0
  355. wandb/sdk/data_types/object_3d.py +495 -0
  356. wandb/sdk/data_types/plotly.py +95 -0
  357. wandb/sdk/data_types/saved_model.py +435 -0
  358. wandb/sdk/data_types/table.py +1468 -0
  359. wandb/sdk/data_types/table_decorators.py +108 -0
  360. wandb/sdk/data_types/trace_tree.py +440 -0
  361. wandb/sdk/data_types/utils.py +260 -0
  362. wandb/sdk/data_types/video.py +303 -0
  363. wandb/sdk/integration_utils/__init__.py +0 -0
  364. wandb/sdk/integration_utils/auto_logging.py +232 -0
  365. wandb/sdk/integration_utils/data_logging.py +475 -0
  366. wandb/sdk/interface/__init__.py +0 -0
  367. wandb/sdk/interface/constants.py +4 -0
  368. wandb/sdk/interface/interface.py +1093 -0
  369. wandb/sdk/interface/interface_queue.py +50 -0
  370. wandb/sdk/interface/interface_shared.py +473 -0
  371. wandb/sdk/interface/interface_sock.py +55 -0
  372. wandb/sdk/interface/summary_record.py +67 -0
  373. wandb/sdk/internal/__init__.py +0 -0
  374. wandb/sdk/internal/_generated/__init__.py +5 -0
  375. wandb/sdk/internal/_generated/enums.py +4 -0
  376. wandb/sdk/internal/_generated/input_types.py +4 -0
  377. wandb/sdk/internal/_generated/operations.py +15 -0
  378. wandb/sdk/internal/_generated/server_features_query.py +27 -0
  379. wandb/sdk/internal/context.py +89 -0
  380. wandb/sdk/internal/datastore.py +293 -0
  381. wandb/sdk/internal/file_pusher.py +177 -0
  382. wandb/sdk/internal/file_stream.py +686 -0
  383. wandb/sdk/internal/handler.py +854 -0
  384. wandb/sdk/internal/incremental_table_util.py +53 -0
  385. wandb/sdk/internal/internal_api.py +4723 -0
  386. wandb/sdk/internal/job_builder.py +639 -0
  387. wandb/sdk/internal/profiler.py +79 -0
  388. wandb/sdk/internal/progress.py +77 -0
  389. wandb/sdk/internal/run.py +27 -0
  390. wandb/sdk/internal/sample.py +70 -0
  391. wandb/sdk/internal/sender.py +1692 -0
  392. wandb/sdk/internal/sender_config.py +203 -0
  393. wandb/sdk/internal/settings_static.py +40 -0
  394. wandb/sdk/internal/tb_watcher.py +519 -0
  395. wandb/sdk/internal/thread_local_settings.py +18 -0
  396. wandb/sdk/launch/__init__.py +15 -0
  397. wandb/sdk/launch/_launch.py +331 -0
  398. wandb/sdk/launch/_launch_add.py +255 -0
  399. wandb/sdk/launch/_project_spec.py +565 -0
  400. wandb/sdk/launch/agent/__init__.py +5 -0
  401. wandb/sdk/launch/agent/agent.py +931 -0
  402. wandb/sdk/launch/agent/config.py +296 -0
  403. wandb/sdk/launch/agent/job_status_tracker.py +55 -0
  404. wandb/sdk/launch/agent/run_queue_item_file_saver.py +39 -0
  405. wandb/sdk/launch/builder/__init__.py +0 -0
  406. wandb/sdk/launch/builder/abstract.py +156 -0
  407. wandb/sdk/launch/builder/build.py +296 -0
  408. wandb/sdk/launch/builder/context_manager.py +235 -0
  409. wandb/sdk/launch/builder/docker_builder.py +177 -0
  410. wandb/sdk/launch/builder/kaniko_builder.py +595 -0
  411. wandb/sdk/launch/builder/noop.py +58 -0
  412. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +188 -0
  413. wandb/sdk/launch/builder/templates/dockerfile.py +92 -0
  414. wandb/sdk/launch/create_job.py +541 -0
  415. wandb/sdk/launch/environment/abstract.py +29 -0
  416. wandb/sdk/launch/environment/aws_environment.py +322 -0
  417. wandb/sdk/launch/environment/azure_environment.py +105 -0
  418. wandb/sdk/launch/environment/gcp_environment.py +334 -0
  419. wandb/sdk/launch/environment/local_environment.py +65 -0
  420. wandb/sdk/launch/errors.py +13 -0
  421. wandb/sdk/launch/git_reference.py +109 -0
  422. wandb/sdk/launch/inputs/files.py +148 -0
  423. wandb/sdk/launch/inputs/internal.py +315 -0
  424. wandb/sdk/launch/inputs/manage.py +113 -0
  425. wandb/sdk/launch/inputs/schema.py +70 -0
  426. wandb/sdk/launch/loader.py +249 -0
  427. wandb/sdk/launch/registry/abstract.py +48 -0
  428. wandb/sdk/launch/registry/anon.py +29 -0
  429. wandb/sdk/launch/registry/azure_container_registry.py +124 -0
  430. wandb/sdk/launch/registry/elastic_container_registry.py +192 -0
  431. wandb/sdk/launch/registry/google_artifact_registry.py +219 -0
  432. wandb/sdk/launch/registry/local_registry.py +65 -0
  433. wandb/sdk/launch/runner/__init__.py +0 -0
  434. wandb/sdk/launch/runner/abstract.py +185 -0
  435. wandb/sdk/launch/runner/kubernetes_monitor.py +473 -0
  436. wandb/sdk/launch/runner/kubernetes_runner.py +1290 -0
  437. wandb/sdk/launch/runner/local_container.py +301 -0
  438. wandb/sdk/launch/runner/local_process.py +78 -0
  439. wandb/sdk/launch/runner/sagemaker_runner.py +424 -0
  440. wandb/sdk/launch/runner/vertex_runner.py +225 -0
  441. wandb/sdk/launch/sweeps/__init__.py +37 -0
  442. wandb/sdk/launch/sweeps/scheduler.py +739 -0
  443. wandb/sdk/launch/sweeps/scheduler_sweep.py +90 -0
  444. wandb/sdk/launch/sweeps/utils.py +324 -0
  445. wandb/sdk/launch/utils.py +827 -0
  446. wandb/sdk/launch/wandb_reference.py +138 -0
  447. wandb/sdk/lib/__init__.py +5 -0
  448. wandb/sdk/lib/apikey.py +334 -0
  449. wandb/sdk/lib/asyncio_compat.py +278 -0
  450. wandb/sdk/lib/asyncio_manager.py +252 -0
  451. wandb/sdk/lib/capped_dict.py +26 -0
  452. wandb/sdk/lib/config_util.py +101 -0
  453. wandb/sdk/lib/console_capture.py +219 -0
  454. wandb/sdk/lib/credentials.py +141 -0
  455. wandb/sdk/lib/deprecate.py +27 -0
  456. wandb/sdk/lib/disabled.py +30 -0
  457. wandb/sdk/lib/exit_hooks.py +54 -0
  458. wandb/sdk/lib/file_stream_utils.py +118 -0
  459. wandb/sdk/lib/filenames.py +64 -0
  460. wandb/sdk/lib/filesystem.py +372 -0
  461. wandb/sdk/lib/fsm.py +165 -0
  462. wandb/sdk/lib/gitlib.py +240 -0
  463. wandb/sdk/lib/gql_request.py +76 -0
  464. wandb/sdk/lib/handler_util.py +21 -0
  465. wandb/sdk/lib/hashutil.py +106 -0
  466. wandb/sdk/lib/import_hooks.py +275 -0
  467. wandb/sdk/lib/interrupt.py +37 -0
  468. wandb/sdk/lib/ipython.py +126 -0
  469. wandb/sdk/lib/json_util.py +75 -0
  470. wandb/sdk/lib/lazyloader.py +63 -0
  471. wandb/sdk/lib/module.py +72 -0
  472. wandb/sdk/lib/paths.py +108 -0
  473. wandb/sdk/lib/preinit.py +42 -0
  474. wandb/sdk/lib/printer.py +567 -0
  475. wandb/sdk/lib/printer_asyncio.py +48 -0
  476. wandb/sdk/lib/progress.py +325 -0
  477. wandb/sdk/lib/proto_util.py +90 -0
  478. wandb/sdk/lib/redirect.py +876 -0
  479. wandb/sdk/lib/retry.py +395 -0
  480. wandb/sdk/lib/run_moment.py +82 -0
  481. wandb/sdk/lib/runid.py +12 -0
  482. wandb/sdk/lib/server.py +58 -0
  483. wandb/sdk/lib/service/ipc_support.py +13 -0
  484. wandb/sdk/lib/service/service_client.py +102 -0
  485. wandb/sdk/lib/service/service_connection.py +238 -0
  486. wandb/sdk/lib/service/service_port_file.py +105 -0
  487. wandb/sdk/lib/service/service_process.py +111 -0
  488. wandb/sdk/lib/service/service_token.py +181 -0
  489. wandb/sdk/lib/sparkline.py +44 -0
  490. wandb/sdk/lib/telemetry.py +100 -0
  491. wandb/sdk/lib/timed_input.py +133 -0
  492. wandb/sdk/lib/timer.py +19 -0
  493. wandb/sdk/lib/wb_logging.py +161 -0
  494. wandb/sdk/mailbox/__init__.py +23 -0
  495. wandb/sdk/mailbox/mailbox.py +143 -0
  496. wandb/sdk/mailbox/mailbox_handle.py +134 -0
  497. wandb/sdk/mailbox/response_handle.py +99 -0
  498. wandb/sdk/mailbox/wait_with_progress.py +100 -0
  499. wandb/sdk/projects/_generated/__init__.py +26 -0
  500. wandb/sdk/projects/_generated/delete_project.py +22 -0
  501. wandb/sdk/projects/_generated/enums.py +4 -0
  502. wandb/sdk/projects/_generated/fetch_registry.py +22 -0
  503. wandb/sdk/projects/_generated/fragments.py +41 -0
  504. wandb/sdk/projects/_generated/input_types.py +13 -0
  505. wandb/sdk/projects/_generated/operations.py +88 -0
  506. wandb/sdk/projects/_generated/rename_project.py +27 -0
  507. wandb/sdk/projects/_generated/upsert_registry_project.py +27 -0
  508. wandb/sdk/verify/__init__.py +0 -0
  509. wandb/sdk/verify/verify.py +555 -0
  510. wandb/sdk/wandb_alerts.py +12 -0
  511. wandb/sdk/wandb_config.py +323 -0
  512. wandb/sdk/wandb_helper.py +54 -0
  513. wandb/sdk/wandb_init.py +1601 -0
  514. wandb/sdk/wandb_login.py +358 -0
  515. wandb/sdk/wandb_metric.py +112 -0
  516. wandb/sdk/wandb_require.py +88 -0
  517. wandb/sdk/wandb_require_helpers.py +44 -0
  518. wandb/sdk/wandb_run.py +4102 -0
  519. wandb/sdk/wandb_settings.py +2197 -0
  520. wandb/sdk/wandb_setup.py +560 -0
  521. wandb/sdk/wandb_summary.py +150 -0
  522. wandb/sdk/wandb_sweep.py +120 -0
  523. wandb/sdk/wandb_sync.py +71 -0
  524. wandb/sdk/wandb_watch.py +146 -0
  525. wandb/sklearn.py +35 -0
  526. wandb/sync/__init__.py +3 -0
  527. wandb/sync/sync.py +457 -0
  528. wandb/trigger.py +29 -0
  529. wandb/util.py +2040 -0
  530. wandb/vendor/__init__.py +0 -0
  531. wandb/vendor/gql-0.2.0/setup.py +40 -0
  532. wandb/vendor/gql-0.2.0/tests/__init__.py +0 -0
  533. wandb/vendor/gql-0.2.0/tests/starwars/__init__.py +0 -0
  534. wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py +96 -0
  535. wandb/vendor/gql-0.2.0/tests/starwars/schema.py +146 -0
  536. wandb/vendor/gql-0.2.0/tests/starwars/test_dsl.py +293 -0
  537. wandb/vendor/gql-0.2.0/tests/starwars/test_query.py +355 -0
  538. wandb/vendor/gql-0.2.0/tests/starwars/test_validation.py +171 -0
  539. wandb/vendor/gql-0.2.0/tests/test_client.py +31 -0
  540. wandb/vendor/gql-0.2.0/tests/test_transport.py +89 -0
  541. wandb/vendor/gql-0.2.0/wandb_gql/__init__.py +4 -0
  542. wandb/vendor/gql-0.2.0/wandb_gql/client.py +75 -0
  543. wandb/vendor/gql-0.2.0/wandb_gql/dsl.py +152 -0
  544. wandb/vendor/gql-0.2.0/wandb_gql/gql.py +10 -0
  545. wandb/vendor/gql-0.2.0/wandb_gql/transport/__init__.py +0 -0
  546. wandb/vendor/gql-0.2.0/wandb_gql/transport/http.py +6 -0
  547. wandb/vendor/gql-0.2.0/wandb_gql/transport/local_schema.py +15 -0
  548. wandb/vendor/gql-0.2.0/wandb_gql/transport/requests.py +46 -0
  549. wandb/vendor/gql-0.2.0/wandb_gql/utils.py +21 -0
  550. wandb/vendor/graphql-core-1.1/setup.py +86 -0
  551. wandb/vendor/graphql-core-1.1/wandb_graphql/__init__.py +287 -0
  552. wandb/vendor/graphql-core-1.1/wandb_graphql/error/__init__.py +6 -0
  553. wandb/vendor/graphql-core-1.1/wandb_graphql/error/base.py +42 -0
  554. wandb/vendor/graphql-core-1.1/wandb_graphql/error/format_error.py +11 -0
  555. wandb/vendor/graphql-core-1.1/wandb_graphql/error/located_error.py +29 -0
  556. wandb/vendor/graphql-core-1.1/wandb_graphql/error/syntax_error.py +36 -0
  557. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/__init__.py +26 -0
  558. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/base.py +311 -0
  559. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executor.py +398 -0
  560. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/__init__.py +0 -0
  561. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/asyncio.py +53 -0
  562. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/gevent.py +22 -0
  563. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/process.py +32 -0
  564. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/sync.py +7 -0
  565. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/thread.py +35 -0
  566. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/utils.py +6 -0
  567. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/__init__.py +0 -0
  568. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/executor.py +66 -0
  569. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/fragment.py +252 -0
  570. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/resolver.py +151 -0
  571. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/utils.py +7 -0
  572. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/middleware.py +57 -0
  573. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/values.py +145 -0
  574. wandb/vendor/graphql-core-1.1/wandb_graphql/graphql.py +60 -0
  575. wandb/vendor/graphql-core-1.1/wandb_graphql/language/__init__.py +0 -0
  576. wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py +1349 -0
  577. wandb/vendor/graphql-core-1.1/wandb_graphql/language/base.py +19 -0
  578. wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py +435 -0
  579. wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py +30 -0
  580. wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py +779 -0
  581. wandb/vendor/graphql-core-1.1/wandb_graphql/language/printer.py +193 -0
  582. wandb/vendor/graphql-core-1.1/wandb_graphql/language/source.py +18 -0
  583. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py +222 -0
  584. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor_meta.py +82 -0
  585. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/__init__.py +0 -0
  586. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/cached_property.py +17 -0
  587. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/contain_subset.py +28 -0
  588. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/default_ordered_dict.py +40 -0
  589. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/ordereddict.py +8 -0
  590. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/pair_set.py +43 -0
  591. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/version.py +78 -0
  592. wandb/vendor/graphql-core-1.1/wandb_graphql/type/__init__.py +67 -0
  593. wandb/vendor/graphql-core-1.1/wandb_graphql/type/definition.py +619 -0
  594. wandb/vendor/graphql-core-1.1/wandb_graphql/type/directives.py +132 -0
  595. wandb/vendor/graphql-core-1.1/wandb_graphql/type/introspection.py +440 -0
  596. wandb/vendor/graphql-core-1.1/wandb_graphql/type/scalars.py +131 -0
  597. wandb/vendor/graphql-core-1.1/wandb_graphql/type/schema.py +100 -0
  598. wandb/vendor/graphql-core-1.1/wandb_graphql/type/typemap.py +145 -0
  599. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/__init__.py +0 -0
  600. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/assert_valid_name.py +9 -0
  601. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_from_value.py +65 -0
  602. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_code.py +49 -0
  603. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_dict.py +24 -0
  604. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/base.py +75 -0
  605. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_ast_schema.py +291 -0
  606. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_client_schema.py +250 -0
  607. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/concat_ast.py +9 -0
  608. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/extend_schema.py +357 -0
  609. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_field_def.py +27 -0
  610. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_operation_ast.py +21 -0
  611. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/introspection_query.py +90 -0
  612. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_literal_value.py +67 -0
  613. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_value.py +66 -0
  614. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/quoted_or_list.py +21 -0
  615. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/schema_printer.py +168 -0
  616. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/suggestion_list.py +56 -0
  617. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_comparators.py +69 -0
  618. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_from_ast.py +21 -0
  619. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_info.py +149 -0
  620. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/value_from_ast.py +69 -0
  621. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/__init__.py +4 -0
  622. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/__init__.py +79 -0
  623. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/arguments_of_correct_type.py +24 -0
  624. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/base.py +8 -0
  625. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/default_values_of_correct_type.py +44 -0
  626. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fields_on_correct_type.py +113 -0
  627. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fragments_on_composite_types.py +33 -0
  628. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_argument_names.py +70 -0
  629. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_directives.py +97 -0
  630. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_fragment_names.py +19 -0
  631. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_type_names.py +43 -0
  632. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/lone_anonymous_operation.py +23 -0
  633. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_fragment_cycles.py +59 -0
  634. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_undefined_variables.py +36 -0
  635. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_fragments.py +38 -0
  636. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_variables.py +37 -0
  637. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/overlapping_fields_can_be_merged.py +529 -0
  638. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/possible_fragment_spreads.py +44 -0
  639. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/provided_non_null_arguments.py +46 -0
  640. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/scalar_leafs.py +33 -0
  641. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_argument_names.py +32 -0
  642. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_fragment_names.py +28 -0
  643. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_input_field_names.py +33 -0
  644. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_operation_names.py +31 -0
  645. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_variable_names.py +27 -0
  646. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_are_input_types.py +21 -0
  647. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_in_allowed_position.py +53 -0
  648. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/validation.py +158 -0
  649. wandb/vendor/promise-2.3.0/conftest.py +30 -0
  650. wandb/vendor/promise-2.3.0/setup.py +64 -0
  651. wandb/vendor/promise-2.3.0/tests/__init__.py +0 -0
  652. wandb/vendor/promise-2.3.0/tests/conftest.py +8 -0
  653. wandb/vendor/promise-2.3.0/tests/test_awaitable.py +32 -0
  654. wandb/vendor/promise-2.3.0/tests/test_awaitable_35.py +47 -0
  655. wandb/vendor/promise-2.3.0/tests/test_benchmark.py +116 -0
  656. wandb/vendor/promise-2.3.0/tests/test_complex_threads.py +23 -0
  657. wandb/vendor/promise-2.3.0/tests/test_dataloader.py +452 -0
  658. wandb/vendor/promise-2.3.0/tests/test_dataloader_awaitable_35.py +99 -0
  659. wandb/vendor/promise-2.3.0/tests/test_dataloader_extra.py +65 -0
  660. wandb/vendor/promise-2.3.0/tests/test_extra.py +670 -0
  661. wandb/vendor/promise-2.3.0/tests/test_issues.py +132 -0
  662. wandb/vendor/promise-2.3.0/tests/test_promise_list.py +70 -0
  663. wandb/vendor/promise-2.3.0/tests/test_spec.py +584 -0
  664. wandb/vendor/promise-2.3.0/tests/test_thread_safety.py +115 -0
  665. wandb/vendor/promise-2.3.0/tests/utils.py +3 -0
  666. wandb/vendor/promise-2.3.0/wandb_promise/__init__.py +38 -0
  667. wandb/vendor/promise-2.3.0/wandb_promise/async_.py +135 -0
  668. wandb/vendor/promise-2.3.0/wandb_promise/compat.py +32 -0
  669. wandb/vendor/promise-2.3.0/wandb_promise/dataloader.py +326 -0
  670. wandb/vendor/promise-2.3.0/wandb_promise/iterate_promise.py +12 -0
  671. wandb/vendor/promise-2.3.0/wandb_promise/promise.py +848 -0
  672. wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py +151 -0
  673. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/__init__.py +0 -0
  674. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/version.py +83 -0
  675. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/__init__.py +0 -0
  676. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/asyncio.py +22 -0
  677. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/gevent.py +21 -0
  678. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/immediate.py +27 -0
  679. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/thread.py +18 -0
  680. wandb/vendor/promise-2.3.0/wandb_promise/utils.py +56 -0
  681. wandb/vendor/pygments/__init__.py +90 -0
  682. wandb/vendor/pygments/cmdline.py +568 -0
  683. wandb/vendor/pygments/console.py +74 -0
  684. wandb/vendor/pygments/filter.py +74 -0
  685. wandb/vendor/pygments/filters/__init__.py +350 -0
  686. wandb/vendor/pygments/formatter.py +95 -0
  687. wandb/vendor/pygments/formatters/__init__.py +153 -0
  688. wandb/vendor/pygments/formatters/_mapping.py +85 -0
  689. wandb/vendor/pygments/formatters/bbcode.py +109 -0
  690. wandb/vendor/pygments/formatters/html.py +851 -0
  691. wandb/vendor/pygments/formatters/img.py +600 -0
  692. wandb/vendor/pygments/formatters/irc.py +182 -0
  693. wandb/vendor/pygments/formatters/latex.py +482 -0
  694. wandb/vendor/pygments/formatters/other.py +160 -0
  695. wandb/vendor/pygments/formatters/rtf.py +147 -0
  696. wandb/vendor/pygments/formatters/svg.py +153 -0
  697. wandb/vendor/pygments/formatters/terminal.py +136 -0
  698. wandb/vendor/pygments/formatters/terminal256.py +309 -0
  699. wandb/vendor/pygments/lexer.py +871 -0
  700. wandb/vendor/pygments/lexers/__init__.py +329 -0
  701. wandb/vendor/pygments/lexers/_asy_builtins.py +1645 -0
  702. wandb/vendor/pygments/lexers/_cl_builtins.py +232 -0
  703. wandb/vendor/pygments/lexers/_cocoa_builtins.py +72 -0
  704. wandb/vendor/pygments/lexers/_csound_builtins.py +1346 -0
  705. wandb/vendor/pygments/lexers/_lasso_builtins.py +5327 -0
  706. wandb/vendor/pygments/lexers/_lua_builtins.py +295 -0
  707. wandb/vendor/pygments/lexers/_mapping.py +500 -0
  708. wandb/vendor/pygments/lexers/_mql_builtins.py +1172 -0
  709. wandb/vendor/pygments/lexers/_openedge_builtins.py +2547 -0
  710. wandb/vendor/pygments/lexers/_php_builtins.py +4756 -0
  711. wandb/vendor/pygments/lexers/_postgres_builtins.py +621 -0
  712. wandb/vendor/pygments/lexers/_scilab_builtins.py +3094 -0
  713. wandb/vendor/pygments/lexers/_sourcemod_builtins.py +1163 -0
  714. wandb/vendor/pygments/lexers/_stan_builtins.py +532 -0
  715. wandb/vendor/pygments/lexers/_stata_builtins.py +419 -0
  716. wandb/vendor/pygments/lexers/_tsql_builtins.py +1004 -0
  717. wandb/vendor/pygments/lexers/_vim_builtins.py +1939 -0
  718. wandb/vendor/pygments/lexers/actionscript.py +240 -0
  719. wandb/vendor/pygments/lexers/agile.py +24 -0
  720. wandb/vendor/pygments/lexers/algebra.py +221 -0
  721. wandb/vendor/pygments/lexers/ambient.py +76 -0
  722. wandb/vendor/pygments/lexers/ampl.py +87 -0
  723. wandb/vendor/pygments/lexers/apl.py +101 -0
  724. wandb/vendor/pygments/lexers/archetype.py +318 -0
  725. wandb/vendor/pygments/lexers/asm.py +641 -0
  726. wandb/vendor/pygments/lexers/automation.py +374 -0
  727. wandb/vendor/pygments/lexers/basic.py +500 -0
  728. wandb/vendor/pygments/lexers/bibtex.py +160 -0
  729. wandb/vendor/pygments/lexers/business.py +612 -0
  730. wandb/vendor/pygments/lexers/c_cpp.py +252 -0
  731. wandb/vendor/pygments/lexers/c_like.py +541 -0
  732. wandb/vendor/pygments/lexers/capnproto.py +78 -0
  733. wandb/vendor/pygments/lexers/chapel.py +102 -0
  734. wandb/vendor/pygments/lexers/clean.py +288 -0
  735. wandb/vendor/pygments/lexers/compiled.py +34 -0
  736. wandb/vendor/pygments/lexers/configs.py +833 -0
  737. wandb/vendor/pygments/lexers/console.py +114 -0
  738. wandb/vendor/pygments/lexers/crystal.py +393 -0
  739. wandb/vendor/pygments/lexers/csound.py +366 -0
  740. wandb/vendor/pygments/lexers/css.py +689 -0
  741. wandb/vendor/pygments/lexers/d.py +251 -0
  742. wandb/vendor/pygments/lexers/dalvik.py +125 -0
  743. wandb/vendor/pygments/lexers/data.py +555 -0
  744. wandb/vendor/pygments/lexers/diff.py +165 -0
  745. wandb/vendor/pygments/lexers/dotnet.py +691 -0
  746. wandb/vendor/pygments/lexers/dsls.py +878 -0
  747. wandb/vendor/pygments/lexers/dylan.py +289 -0
  748. wandb/vendor/pygments/lexers/ecl.py +125 -0
  749. wandb/vendor/pygments/lexers/eiffel.py +65 -0
  750. wandb/vendor/pygments/lexers/elm.py +121 -0
  751. wandb/vendor/pygments/lexers/erlang.py +533 -0
  752. wandb/vendor/pygments/lexers/esoteric.py +277 -0
  753. wandb/vendor/pygments/lexers/ezhil.py +69 -0
  754. wandb/vendor/pygments/lexers/factor.py +344 -0
  755. wandb/vendor/pygments/lexers/fantom.py +250 -0
  756. wandb/vendor/pygments/lexers/felix.py +273 -0
  757. wandb/vendor/pygments/lexers/forth.py +177 -0
  758. wandb/vendor/pygments/lexers/fortran.py +205 -0
  759. wandb/vendor/pygments/lexers/foxpro.py +428 -0
  760. wandb/vendor/pygments/lexers/functional.py +21 -0
  761. wandb/vendor/pygments/lexers/go.py +101 -0
  762. wandb/vendor/pygments/lexers/grammar_notation.py +213 -0
  763. wandb/vendor/pygments/lexers/graph.py +80 -0
  764. wandb/vendor/pygments/lexers/graphics.py +553 -0
  765. wandb/vendor/pygments/lexers/haskell.py +843 -0
  766. wandb/vendor/pygments/lexers/haxe.py +936 -0
  767. wandb/vendor/pygments/lexers/hdl.py +382 -0
  768. wandb/vendor/pygments/lexers/hexdump.py +103 -0
  769. wandb/vendor/pygments/lexers/html.py +602 -0
  770. wandb/vendor/pygments/lexers/idl.py +270 -0
  771. wandb/vendor/pygments/lexers/igor.py +288 -0
  772. wandb/vendor/pygments/lexers/inferno.py +96 -0
  773. wandb/vendor/pygments/lexers/installers.py +322 -0
  774. wandb/vendor/pygments/lexers/int_fiction.py +1343 -0
  775. wandb/vendor/pygments/lexers/iolang.py +63 -0
  776. wandb/vendor/pygments/lexers/j.py +146 -0
  777. wandb/vendor/pygments/lexers/javascript.py +1525 -0
  778. wandb/vendor/pygments/lexers/julia.py +333 -0
  779. wandb/vendor/pygments/lexers/jvm.py +1573 -0
  780. wandb/vendor/pygments/lexers/lisp.py +2621 -0
  781. wandb/vendor/pygments/lexers/make.py +202 -0
  782. wandb/vendor/pygments/lexers/markup.py +595 -0
  783. wandb/vendor/pygments/lexers/math.py +21 -0
  784. wandb/vendor/pygments/lexers/matlab.py +663 -0
  785. wandb/vendor/pygments/lexers/ml.py +769 -0
  786. wandb/vendor/pygments/lexers/modeling.py +358 -0
  787. wandb/vendor/pygments/lexers/modula2.py +1561 -0
  788. wandb/vendor/pygments/lexers/monte.py +204 -0
  789. wandb/vendor/pygments/lexers/ncl.py +894 -0
  790. wandb/vendor/pygments/lexers/nimrod.py +159 -0
  791. wandb/vendor/pygments/lexers/nit.py +64 -0
  792. wandb/vendor/pygments/lexers/nix.py +136 -0
  793. wandb/vendor/pygments/lexers/oberon.py +105 -0
  794. wandb/vendor/pygments/lexers/objective.py +504 -0
  795. wandb/vendor/pygments/lexers/ooc.py +85 -0
  796. wandb/vendor/pygments/lexers/other.py +41 -0
  797. wandb/vendor/pygments/lexers/parasail.py +79 -0
  798. wandb/vendor/pygments/lexers/parsers.py +835 -0
  799. wandb/vendor/pygments/lexers/pascal.py +644 -0
  800. wandb/vendor/pygments/lexers/pawn.py +199 -0
  801. wandb/vendor/pygments/lexers/perl.py +620 -0
  802. wandb/vendor/pygments/lexers/php.py +267 -0
  803. wandb/vendor/pygments/lexers/praat.py +294 -0
  804. wandb/vendor/pygments/lexers/prolog.py +306 -0
  805. wandb/vendor/pygments/lexers/python.py +939 -0
  806. wandb/vendor/pygments/lexers/qvt.py +152 -0
  807. wandb/vendor/pygments/lexers/r.py +453 -0
  808. wandb/vendor/pygments/lexers/rdf.py +270 -0
  809. wandb/vendor/pygments/lexers/rebol.py +431 -0
  810. wandb/vendor/pygments/lexers/resource.py +85 -0
  811. wandb/vendor/pygments/lexers/rnc.py +67 -0
  812. wandb/vendor/pygments/lexers/roboconf.py +82 -0
  813. wandb/vendor/pygments/lexers/robotframework.py +560 -0
  814. wandb/vendor/pygments/lexers/ruby.py +519 -0
  815. wandb/vendor/pygments/lexers/rust.py +220 -0
  816. wandb/vendor/pygments/lexers/sas.py +228 -0
  817. wandb/vendor/pygments/lexers/scripting.py +1222 -0
  818. wandb/vendor/pygments/lexers/shell.py +794 -0
  819. wandb/vendor/pygments/lexers/smalltalk.py +195 -0
  820. wandb/vendor/pygments/lexers/smv.py +79 -0
  821. wandb/vendor/pygments/lexers/snobol.py +83 -0
  822. wandb/vendor/pygments/lexers/special.py +103 -0
  823. wandb/vendor/pygments/lexers/sql.py +681 -0
  824. wandb/vendor/pygments/lexers/stata.py +108 -0
  825. wandb/vendor/pygments/lexers/supercollider.py +90 -0
  826. wandb/vendor/pygments/lexers/tcl.py +145 -0
  827. wandb/vendor/pygments/lexers/templates.py +2283 -0
  828. wandb/vendor/pygments/lexers/testing.py +207 -0
  829. wandb/vendor/pygments/lexers/text.py +25 -0
  830. wandb/vendor/pygments/lexers/textedit.py +169 -0
  831. wandb/vendor/pygments/lexers/textfmts.py +297 -0
  832. wandb/vendor/pygments/lexers/theorem.py +458 -0
  833. wandb/vendor/pygments/lexers/trafficscript.py +54 -0
  834. wandb/vendor/pygments/lexers/typoscript.py +226 -0
  835. wandb/vendor/pygments/lexers/urbi.py +133 -0
  836. wandb/vendor/pygments/lexers/varnish.py +190 -0
  837. wandb/vendor/pygments/lexers/verification.py +111 -0
  838. wandb/vendor/pygments/lexers/web.py +24 -0
  839. wandb/vendor/pygments/lexers/webmisc.py +988 -0
  840. wandb/vendor/pygments/lexers/whiley.py +116 -0
  841. wandb/vendor/pygments/lexers/x10.py +69 -0
  842. wandb/vendor/pygments/modeline.py +44 -0
  843. wandb/vendor/pygments/plugin.py +68 -0
  844. wandb/vendor/pygments/regexopt.py +92 -0
  845. wandb/vendor/pygments/scanner.py +105 -0
  846. wandb/vendor/pygments/sphinxext.py +158 -0
  847. wandb/vendor/pygments/style.py +155 -0
  848. wandb/vendor/pygments/styles/__init__.py +80 -0
  849. wandb/vendor/pygments/styles/abap.py +29 -0
  850. wandb/vendor/pygments/styles/algol.py +63 -0
  851. wandb/vendor/pygments/styles/algol_nu.py +63 -0
  852. wandb/vendor/pygments/styles/arduino.py +98 -0
  853. wandb/vendor/pygments/styles/autumn.py +65 -0
  854. wandb/vendor/pygments/styles/borland.py +51 -0
  855. wandb/vendor/pygments/styles/bw.py +49 -0
  856. wandb/vendor/pygments/styles/colorful.py +81 -0
  857. wandb/vendor/pygments/styles/default.py +73 -0
  858. wandb/vendor/pygments/styles/emacs.py +72 -0
  859. wandb/vendor/pygments/styles/friendly.py +72 -0
  860. wandb/vendor/pygments/styles/fruity.py +42 -0
  861. wandb/vendor/pygments/styles/igor.py +29 -0
  862. wandb/vendor/pygments/styles/lovelace.py +97 -0
  863. wandb/vendor/pygments/styles/manni.py +75 -0
  864. wandb/vendor/pygments/styles/monokai.py +106 -0
  865. wandb/vendor/pygments/styles/murphy.py +80 -0
  866. wandb/vendor/pygments/styles/native.py +65 -0
  867. wandb/vendor/pygments/styles/paraiso_dark.py +125 -0
  868. wandb/vendor/pygments/styles/paraiso_light.py +125 -0
  869. wandb/vendor/pygments/styles/pastie.py +75 -0
  870. wandb/vendor/pygments/styles/perldoc.py +69 -0
  871. wandb/vendor/pygments/styles/rainbow_dash.py +89 -0
  872. wandb/vendor/pygments/styles/rrt.py +33 -0
  873. wandb/vendor/pygments/styles/sas.py +44 -0
  874. wandb/vendor/pygments/styles/stata.py +40 -0
  875. wandb/vendor/pygments/styles/tango.py +141 -0
  876. wandb/vendor/pygments/styles/trac.py +63 -0
  877. wandb/vendor/pygments/styles/vim.py +63 -0
  878. wandb/vendor/pygments/styles/vs.py +38 -0
  879. wandb/vendor/pygments/styles/xcode.py +51 -0
  880. wandb/vendor/pygments/token.py +213 -0
  881. wandb/vendor/pygments/unistring.py +217 -0
  882. wandb/vendor/pygments/util.py +388 -0
  883. wandb/vendor/watchdog_0_9_0/wandb_watchdog/__init__.py +17 -0
  884. wandb/vendor/watchdog_0_9_0/wandb_watchdog/events.py +615 -0
  885. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/__init__.py +98 -0
  886. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/api.py +369 -0
  887. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents.py +172 -0
  888. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents2.py +239 -0
  889. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify.py +218 -0
  890. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_buffer.py +81 -0
  891. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_c.py +575 -0
  892. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/kqueue.py +730 -0
  893. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/polling.py +145 -0
  894. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/read_directory_changes.py +133 -0
  895. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/winapi.py +348 -0
  896. wandb/vendor/watchdog_0_9_0/wandb_watchdog/patterns.py +265 -0
  897. wandb/vendor/watchdog_0_9_0/wandb_watchdog/tricks/__init__.py +174 -0
  898. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/__init__.py +151 -0
  899. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/bricks.py +249 -0
  900. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/compat.py +29 -0
  901. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/decorators.py +198 -0
  902. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/delayed_queue.py +88 -0
  903. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/dirsnapshot.py +293 -0
  904. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/echo.py +157 -0
  905. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/event_backport.py +41 -0
  906. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/importlib2.py +40 -0
  907. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/platform.py +57 -0
  908. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/unicode_paths.py +64 -0
  909. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/win32stat.py +123 -0
  910. wandb/vendor/watchdog_0_9_0/wandb_watchdog/version.py +28 -0
  911. wandb/vendor/watchdog_0_9_0/wandb_watchdog/watchmedo.py +577 -0
  912. wandb/wandb_agent.py +611 -0
  913. wandb/wandb_controller.py +719 -0
  914. wandb/wandb_run.py +8 -0
  915. wandb-0.22.1.dist-info/METADATA +223 -0
  916. wandb-0.22.1.dist-info/RECORD +919 -0
  917. wandb-0.22.1.dist-info/WHEEL +4 -0
  918. wandb-0.22.1.dist-info/entry_points.txt +3 -0
  919. wandb-0.22.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,2197 @@
1
+ from __future__ import annotations
2
+
3
+ import configparser
4
+ import json
5
+ import logging
6
+ import os
7
+ import pathlib
8
+ import platform
9
+ import re
10
+ import shutil
11
+ import socket
12
+ import sys
13
+ from datetime import datetime
14
+
15
+ # Optional and Union are used for type hinting instead of | because
16
+ # the latter is not supported in pydantic<2.6 and Python<3.10.
17
+ # Dict, List, and Tuple are used for backwards compatibility
18
+ # with pydantic v1 and Python<3.9.
19
+ from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Union
20
+ from urllib.parse import quote, unquote, urlencode
21
+
22
+ from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue, Int32Value, StringValue
23
+ from pydantic import BaseModel, ConfigDict, Field
24
+ from typing_extensions import Self
25
+
26
+ import wandb
27
+ from wandb import env, util
28
+ from wandb._pydantic import (
29
+ IS_PYDANTIC_V2,
30
+ AliasChoices,
31
+ computed_field,
32
+ field_validator,
33
+ model_validator,
34
+ )
35
+ from wandb.errors import UsageError
36
+ from wandb.proto import wandb_settings_pb2
37
+
38
+ from .lib import apikey, credentials, ipython
39
+ from .lib.gitlib import GitRepo
40
+ from .lib.run_moment import RunMoment
41
+
42
+ validate_url: Callable[[str], None]
43
+
44
+ if IS_PYDANTIC_V2:
45
+ from pydantic_core import SchemaValidator, core_schema
46
+
47
+ def validate_url(url: str) -> None:
48
+ """Validate a URL string."""
49
+ url_validator = SchemaValidator(
50
+ core_schema.url_schema(
51
+ allowed_schemes=["http", "https"],
52
+ strict=True,
53
+ )
54
+ )
55
+ url_validator.validate_python(url)
56
+ else:
57
+ from pydantic import root_validator
58
+
59
+ def validate_url(url: str) -> None:
60
+ """Validate the base url of the wandb server.
61
+
62
+ param value: URL to validate
63
+
64
+ Based on the Django URLValidator, but with a few additional checks.
65
+
66
+ Copyright (c) Django Software Foundation and individual contributors.
67
+ All rights reserved.
68
+
69
+ Redistribution and use in source and binary forms, with or without modification,
70
+ are permitted provided that the following conditions are met:
71
+
72
+ 1. Redistributions of source code must retain the above copyright notice,
73
+ this list of conditions and the following disclaimer.
74
+
75
+ 2. Redistributions in binary form must reproduce the above copyright
76
+ notice, this list of conditions and the following disclaimer in the
77
+ documentation and/or other materials provided with the distribution.
78
+
79
+ 3. Neither the name of Django nor the names of its contributors may be used
80
+ to endorse or promote products derived from this software without
81
+ specific prior written permission.
82
+
83
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
84
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
85
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
86
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
87
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
88
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
89
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
90
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
91
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
92
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
93
+ """
94
+ from urllib.parse import urlparse, urlsplit
95
+
96
+ if url is None:
97
+ return
98
+
99
+ ul = "\u00a1-\uffff" # Unicode letters range (must not be a raw string).
100
+
101
+ # IP patterns
102
+ ipv4_re = (
103
+ r"(?:0|25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?)"
104
+ r"(?:\.(?:0|25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?)){3}"
105
+ )
106
+ ipv6_re = r"\[[0-9a-f:.]+\]" # (simple regex, validated later)
107
+
108
+ # Host patterns
109
+ hostname_re = (
110
+ r"[a-z" + ul + r"0-9](?:[a-z" + ul + r"0-9-]{0,61}[a-z" + ul + r"0-9])?"
111
+ )
112
+ # Max length for domain name labels is 63 characters per RFC 1034 sec. 3.1
113
+ domain_re = r"(?:\.(?!-)[a-z" + ul + r"0-9-]{1,63}(?<!-))*"
114
+ tld_re = (
115
+ r"\." # dot
116
+ r"(?!-)" # can't start with a dash
117
+ r"(?:[a-z" + ul + "-]{2,63}" # domain label
118
+ r"|xn--[a-z0-9]{1,59})" # or punycode label
119
+ r"(?<!-)" # can't end with a dash
120
+ r"\.?" # may have a trailing dot
121
+ )
122
+ # host_re = "(" + hostname_re + domain_re + tld_re + "|localhost)"
123
+ # todo?: allow hostname to be just a hostname (no tld)?
124
+ host_re = "(" + hostname_re + domain_re + f"({tld_re})?" + "|localhost)"
125
+
126
+ regex = re.compile(
127
+ r"^(?:[a-z0-9.+-]*)://" # scheme is validated separately
128
+ r"(?:[^\s:@/]+(?::[^\s:@/]*)?@)?" # user:pass authentication
129
+ r"(?:" + ipv4_re + "|" + ipv6_re + "|" + host_re + ")"
130
+ r"(?::[0-9]{1,5})?" # port
131
+ r"(?:[/?#][^\s]*)?" # resource path
132
+ r"\Z",
133
+ re.IGNORECASE,
134
+ )
135
+ schemes = {"http", "https"}
136
+ unsafe_chars = frozenset("\t\r\n")
137
+
138
+ scheme = url.split("://")[0].lower()
139
+ split_url = urlsplit(url)
140
+ parsed_url = urlparse(url)
141
+
142
+ if parsed_url.netloc == "":
143
+ raise ValueError(f"Invalid URL: {url}")
144
+ elif unsafe_chars.intersection(url):
145
+ raise ValueError("URL cannot contain unsafe characters")
146
+ elif scheme not in schemes:
147
+ raise ValueError("URL must start with `http(s)://`")
148
+ elif not regex.search(url):
149
+ raise ValueError(f"{url} is not a valid server address")
150
+ elif split_url.hostname is None or len(split_url.hostname) > 253:
151
+ raise ValueError("hostname is invalid")
152
+
153
+
154
+ def _path_convert(*args: str) -> str:
155
+ """Join path and apply os.path.expanduser to it."""
156
+ return os.path.expanduser(os.path.join(*args))
157
+
158
+
159
+ CLIENT_ONLY_SETTINGS = (
160
+ "reinit",
161
+ "max_end_of_run_history_metrics",
162
+ "max_end_of_run_summary_metrics",
163
+ "x_sync_dir_suffix",
164
+ )
165
+ """Python-only keys that are not fields on the settings proto."""
166
+
167
+
168
+ class Settings(BaseModel, validate_assignment=True):
169
+ """Settings for the W&B SDK.
170
+
171
+ This class manages configuration settings for the W&B SDK,
172
+ ensuring type safety and validation of all settings. Settings are accessible
173
+ as attributes and can be initialized programmatically, through environment
174
+ variables (`WANDB_ prefix`), and with configuration files.
175
+
176
+ The settings are organized into three categories:
177
+ 1. Public settings: Core configuration options that users can safely modify to customize
178
+ W&B's behavior for their specific needs.
179
+ 2. Internal settings: Settings prefixed with 'x_' that handle low-level SDK behavior.
180
+ These settings are primarily for internal use and debugging. While they can be modified,
181
+ they are not considered part of the public API and may change without notice in future
182
+ versions.
183
+ 3. Computed settings: Read-only settings that are automatically derived from other settings or
184
+ the environment.
185
+ """
186
+
187
+ # Pydantic Model configuration.
188
+ model_config = ConfigDict(
189
+ extra="forbid", # throw an error if extra fields are provided
190
+ validate_default=True, # validate default values
191
+ use_attribute_docstrings=True, # for field descriptions
192
+ revalidate_instances="always",
193
+ )
194
+
195
+ # Public settings.
196
+
197
+ allow_offline_artifacts: bool = True
198
+ """Flag to allow table artifacts to be synced in offline mode.
199
+
200
+ To revert to the old behavior, set this to False.
201
+ """
202
+
203
+ allow_val_change: bool = False
204
+ """Flag to allow modification of `Config` values after they've been set."""
205
+
206
+ anonymous: Optional[Literal["allow", "must", "never"]] = None
207
+ """Controls anonymous data logging.
208
+
209
+ Possible values are:
210
+ - "never": requires you to link your W&B account before
211
+ tracking the run, so you don't accidentally create an anonymous
212
+ run.
213
+ - "allow": lets a logged-in user track runs with their account, but
214
+ lets someone who is running the script without a W&B account see
215
+ the charts in the UI.
216
+ - "must": sends the run to an anonymous account instead of to a
217
+ signed-up user account.
218
+ """
219
+
220
+ api_key: Optional[str] = None
221
+ """The W&B API key."""
222
+
223
+ azure_account_url_to_access_key: Optional[Dict[str, str]] = None
224
+ """Mapping of Azure account URLs to their corresponding access keys for Azure integration."""
225
+
226
+ base_url: str = "https://api.wandb.ai"
227
+ """The URL of the W&B backend for data synchronization."""
228
+
229
+ code_dir: Optional[str] = None
230
+ """Directory containing the code to be tracked by W&B."""
231
+
232
+ config_paths: Optional[Sequence[str]] = None
233
+ """Paths to files to load configuration from into the `Config` object."""
234
+
235
+ console: Literal["auto", "off", "wrap", "redirect", "wrap_raw", "wrap_emu"] = Field(
236
+ default="auto",
237
+ validate_default=True,
238
+ )
239
+ """The type of console capture to be applied.
240
+
241
+ Possible values are:
242
+ "auto" - Automatically selects the console capture method based on the
243
+ system environment and settings.
244
+
245
+ "off" - Disables console capture.
246
+
247
+ "redirect" - Redirects low-level file descriptors for capturing output.
248
+
249
+ "wrap" - Overrides the write methods of sys.stdout/sys.stderr. Will be
250
+ mapped to either "wrap_raw" or "wrap_emu" based on the state of the system.
251
+
252
+ "wrap_raw" - Same as "wrap" but captures raw output directly instead of
253
+ through an emulator. Derived from the `wrap` setting and should not be set manually.
254
+
255
+ "wrap_emu" - Same as "wrap" but captures output through an emulator.
256
+ Derived from the `wrap` setting and should not be set manually.
257
+ """
258
+
259
+ console_multipart: bool = False
260
+ """Whether to produce multipart console log files."""
261
+
262
+ credentials_file: str = Field(
263
+ default_factory=lambda: str(credentials.DEFAULT_WANDB_CREDENTIALS_FILE)
264
+ )
265
+ """Path to file for writing temporary access tokens."""
266
+
267
+ disable_code: bool = False
268
+ """Whether to disable capturing the code."""
269
+
270
+ disable_git: bool = False
271
+ """Whether to disable capturing the git state."""
272
+
273
+ disable_job_creation: bool = True
274
+ """Whether to disable the creation of a job artifact for W&B Launch."""
275
+
276
+ docker: Optional[str] = None
277
+ """The Docker image used to execute the script."""
278
+
279
+ email: Optional[str] = None
280
+ """The email address of the user."""
281
+
282
+ entity: Optional[str] = None
283
+ """The W&B entity, such as a user or a team."""
284
+
285
+ organization: Optional[str] = None
286
+ """The W&B organization."""
287
+
288
+ force: bool = False
289
+ """Whether to pass the `force` flag to `wandb.login()`."""
290
+
291
+ fork_from: Optional[RunMoment] = None
292
+ """Specifies a point in a previous execution of a run to fork from.
293
+
294
+ The point is defined by the run ID, a metric, and its value.
295
+ Currently, only the metric '_step' is supported.
296
+ """
297
+
298
+ git_commit: Optional[str] = None
299
+ """The git commit hash to associate with the run."""
300
+
301
+ git_remote: str = "origin"
302
+ """The git remote to associate with the run."""
303
+
304
+ git_remote_url: Optional[str] = None
305
+ """The URL of the git remote repository."""
306
+
307
+ git_root: Optional[str] = None
308
+ """Root directory of the git repository."""
309
+
310
+ heartbeat_seconds: int = 30
311
+ """Interval in seconds between heartbeat signals sent to the W&B servers.
312
+
313
+ <!-- lazydoc-ignore-class-attributes -->
314
+ """
315
+
316
+ host: Optional[str] = None
317
+ """Hostname of the machine running the script."""
318
+
319
+ http_proxy: Optional[str] = None
320
+ """Custom proxy servers for http requests to W&B."""
321
+
322
+ https_proxy: Optional[str] = None
323
+ """Custom proxy servers for https requests to W&B."""
324
+
325
+ identity_token_file: Optional[str] = None
326
+ """Path to file containing an identity token (JWT) for authentication."""
327
+
328
+ ignore_globs: Sequence[str] = ()
329
+ """Unix glob patterns relative to `files_dir` specifying files to exclude from upload."""
330
+
331
+ init_timeout: float = 90.0
332
+ """Time in seconds to wait for the `wandb.init` call to complete before timing out."""
333
+
334
+ insecure_disable_ssl: bool = False
335
+ """Whether to insecurely disable SSL verification."""
336
+
337
+ job_name: Optional[str] = None
338
+ """Name of the Launch job running the script."""
339
+
340
+ job_source: Optional[Literal["repo", "artifact", "image"]] = None
341
+ """Source type for Launch."""
342
+
343
+ label_disable: bool = False
344
+ """Whether to disable automatic labeling features."""
345
+
346
+ launch: bool = False
347
+ """Flag to indicate if the run is being launched through W&B Launch.
348
+
349
+ <!-- lazydoc-ignore-class-attributes -->
350
+ """
351
+
352
+ launch_config_path: Optional[str] = None
353
+ """Path to the launch configuration file."""
354
+
355
+ login_timeout: Optional[float] = None
356
+ """Time in seconds to wait for login operations before timing out."""
357
+
358
+ mode: Literal["online", "offline", "shared", "disabled", "dryrun", "run"] = Field(
359
+ default="online",
360
+ validate_default=True,
361
+ )
362
+ """The operating mode for W&B logging and synchronization."""
363
+
364
+ notebook_name: Optional[str] = None
365
+ """Name of the notebook if running in a Jupyter-like environment."""
366
+
367
+ program: Optional[str] = None
368
+ """Path to the script that created the run, if available."""
369
+
370
+ program_abspath: Optional[str] = None
371
+ """The absolute path from the root repository directory to the script that
372
+ created the run.
373
+
374
+ Root repository directory is defined as the directory containing the
375
+ .git directory, if it exists. Otherwise, it's the current working directory.
376
+ """
377
+
378
+ program_relpath: Optional[str] = None
379
+ """The relative path to the script that created the run."""
380
+
381
+ project: Optional[str] = None
382
+ """The W&B project ID."""
383
+
384
+ quiet: bool = False
385
+ """Flag to suppress non-essential output."""
386
+
387
+ reinit: Union[
388
+ Literal[
389
+ "default",
390
+ "return_previous",
391
+ "finish_previous",
392
+ "create_new",
393
+ ],
394
+ bool,
395
+ ] = "default"
396
+ """What to do when `wandb.init()` is called while a run is active.
397
+
398
+ Options:
399
+ - "default": Use "finish_previous" in notebooks and "return_previous"
400
+ otherwise.
401
+ - "return_previous": Return the most recently created run
402
+ that is not yet finished. This does not update `wandb.run`; see
403
+ the "create_new" option.
404
+ - "finish_previous": Finish all active runs, then return a new run.
405
+ - "create_new": Create a new run without modifying other active runs.
406
+ Does not update `wandb.run` and top-level functions like `wandb.log`.
407
+ Because of this, some older integrations that rely on the global run
408
+ will not work.
409
+
410
+ Can also be a boolean, but this is deprecated. False is the same as
411
+ "return_previous", and True is the same as "finish_previous".
412
+ """
413
+
414
+ relogin: bool = False
415
+ """Flag to force a new login attempt."""
416
+
417
+ resume: Optional[Literal["allow", "must", "never", "auto"]] = None
418
+ """Specifies the resume behavior for the run.
419
+
420
+ Options:
421
+ - "must": Resumes from an existing run with the same ID. If no such run exists,
422
+ it will result in failure.
423
+ - "allow": Attempts to resume from an existing run with the same ID. If none is
424
+ found, a new run will be created.
425
+ - "never": Always starts a new run. If a run with the same ID already exists,
426
+ it will result in failure.
427
+ - "auto": Automatically resumes from the most recent failed run on the same
428
+ machine.
429
+ """
430
+
431
+ resume_from: Optional[RunMoment] = None
432
+ """Specifies a point in a previous execution of a run to resume from.
433
+
434
+ The point is defined by the run ID, a metric, and its value.
435
+ Currently, only the metric '_step' is supported.
436
+ """
437
+
438
+ resumed: bool = False
439
+ """Indication from the server about the state of the run.
440
+
441
+ This is different from resume, a user provided flag.
442
+ <!-- lazydoc-ignore-class-attributes -->
443
+ """
444
+
445
+ root_dir: str = Field(default_factory=lambda: os.path.abspath(os.getcwd()))
446
+ """The root directory to use as the base for all run-related paths.
447
+
448
+ In particular, this is used to derive the wandb directory and the run directory.
449
+ """
450
+
451
+ run_group: Optional[str] = None
452
+ """Group identifier for related runs.
453
+
454
+ Used for grouping runs in the UI.
455
+ """
456
+
457
+ run_id: Optional[str] = None
458
+ """The ID of the run."""
459
+
460
+ run_job_type: Optional[str] = None
461
+ """Type of job being run (e.g., training, evaluation)."""
462
+
463
+ run_name: Optional[str] = None
464
+ """Human-readable name for the run."""
465
+
466
+ run_notes: Optional[str] = None
467
+ """Additional notes or description for the run."""
468
+
469
+ run_tags: Optional[Tuple[str, ...]] = None
470
+ """Tags to associate with the run for organization and filtering."""
471
+
472
+ sagemaker_disable: bool = False
473
+ """Flag to disable SageMaker-specific functionality."""
474
+
475
+ save_code: Optional[bool] = None
476
+ """Whether to save the code associated with the run."""
477
+
478
+ settings_system: Optional[str] = None
479
+ """Path to the system-wide settings file."""
480
+
481
+ max_end_of_run_history_metrics: int = 10
482
+ """Maximum number of history sparklines to display at the end of a run."""
483
+
484
+ max_end_of_run_summary_metrics: int = 10
485
+ """Maximum number of summary metrics to display at the end of a run."""
486
+
487
+ show_colors: Optional[bool] = None
488
+ """Whether to use colored output in the console.
489
+
490
+ <!-- lazydoc-ignore-class-attributes -->
491
+ """
492
+
493
+ show_emoji: Optional[bool] = None
494
+ """Whether to show emoji in the console output.
495
+
496
+ <!-- lazydoc-ignore-class-attributes -->
497
+ """
498
+
499
+ show_errors: bool = True
500
+ """Whether to display error messages."""
501
+
502
+ show_info: bool = True
503
+ """Whether to display informational messages."""
504
+
505
+ show_warnings: bool = True
506
+ """Whether to display warning messages."""
507
+
508
+ silent: bool = False
509
+ """Flag to suppress all output."""
510
+
511
+ start_method: Optional[str] = None
512
+ """Method to use for starting subprocesses.
513
+
514
+ This is deprecated and will be removed in a future release.
515
+ <!-- lazydoc-ignore-class-attributes -->
516
+ """
517
+
518
+ strict: Optional[bool] = None
519
+ """Whether to enable strict mode for validation and error checking."""
520
+
521
+ summary_timeout: int = 60
522
+ """Time in seconds to wait for summary operations before timing out."""
523
+
524
+ summary_warnings: int = 5
525
+ """Maximum number of summary warnings to display.
526
+
527
+ <!-- lazydoc-ignore-class-attributes -->
528
+ """
529
+
530
+ sweep_id: Optional[str] = None
531
+ """Identifier of the sweep this run belongs to."""
532
+
533
+ sweep_param_path: Optional[str] = None
534
+ """Path to the sweep parameters configuration."""
535
+
536
+ symlink: bool = Field(
537
+ default_factory=lambda: False if platform.system() == "Windows" else True
538
+ )
539
+ """Whether to use symlinks (True by default except on Windows)."""
540
+
541
+ sync_tensorboard: Optional[bool] = None
542
+ """Whether to synchronize TensorBoard logs with W&B."""
543
+
544
+ table_raise_on_max_row_limit_exceeded: bool = False
545
+ """Whether to raise an exception when table row limits are exceeded."""
546
+
547
+ username: Optional[str] = None
548
+ """Username."""
549
+
550
+ # Internal settings.
551
+ #
552
+ # These are typically not meant to be set by the user and should not be considered
553
+ # a part of the public API as they may change or be removed in future versions.
554
+
555
+ x_cli_only_mode: bool = False
556
+ """Flag to indicate that the SDK is running in CLI-only mode.
557
+
558
+ <!-- lazydoc-ignore-class-attributes -->
559
+ """
560
+
561
+ x_disable_meta: bool = False
562
+ """Flag to disable the collection of system metadata."""
563
+
564
+ x_disable_stats: bool = False
565
+ """Flag to disable the collection of system metrics."""
566
+
567
+ x_disable_viewer: bool = False
568
+ """Flag to disable the early viewer query.
569
+
570
+ <!-- lazydoc-ignore-class-attributes -->
571
+ """
572
+
573
+ x_disable_machine_info: bool = False
574
+ """Flag to disable automatic machine info collection.
575
+
576
+ <!-- lazydoc-ignore-class-attributes -->
577
+ """
578
+
579
+ x_executable: Optional[str] = None
580
+ """Path to the Python executable.
581
+
582
+ <!-- lazydoc-ignore-class-attributes -->
583
+ """
584
+
585
+ x_extra_http_headers: Optional[Dict[str, str]] = None
586
+ """Additional headers to add to all outgoing HTTP requests."""
587
+
588
+ x_file_stream_max_bytes: Optional[int] = None
589
+ """An approximate maximum request size for the filestream API.
590
+
591
+ Its purpose is to prevent HTTP requests from failing due to
592
+ containing too much data. This number is approximate:
593
+ requests will be slightly larger.
594
+ <!-- lazydoc-ignore-class-attributes -->
595
+ """
596
+
597
+ x_file_stream_max_line_bytes: Optional[int] = None
598
+ """Maximum line length for filestream JSONL files.
599
+
600
+ <!-- lazydoc-ignore-class-attributes -->
601
+ """
602
+
603
+ x_file_stream_transmit_interval: Optional[float] = None
604
+ """Interval in seconds between filestream transmissions.
605
+
606
+ <!-- lazydoc-ignore-class-attributes -->
607
+ """
608
+
609
+ # Filestream retry client configuration.
610
+
611
+ x_file_stream_retry_max: Optional[int] = None
612
+ """Max number of retries for filestream operations.
613
+
614
+ <!-- lazydoc-ignore-class-attributes -->
615
+ """
616
+
617
+ x_file_stream_retry_wait_min_seconds: Optional[float] = None
618
+ """Minimum wait time between retries for filestream operations.
619
+
620
+ <!-- lazydoc-ignore-class-attributes -->
621
+ """
622
+
623
+ x_file_stream_retry_wait_max_seconds: Optional[float] = None
624
+ """Maximum wait time between retries for filestream operations.
625
+
626
+ <!-- lazydoc-ignore-class-attributes -->
627
+ """
628
+
629
+ x_file_stream_timeout_seconds: Optional[float] = None
630
+ """Timeout in seconds for individual filestream HTTP requests.
631
+
632
+ <!-- lazydoc-ignore-class-attributes -->
633
+ """
634
+
635
+ # file transfer retry client configuration
636
+
637
+ x_file_transfer_retry_max: Optional[int] = None
638
+ """Max number of retries for file transfer operations.
639
+
640
+ <!-- lazydoc-ignore-class-attributes -->
641
+ """
642
+
643
+ x_file_transfer_retry_wait_min_seconds: Optional[float] = None
644
+ """Minimum wait time between retries for file transfer operations.
645
+
646
+ <!-- lazydoc-ignore-class-attributes -->
647
+ """
648
+
649
+ x_file_transfer_retry_wait_max_seconds: Optional[float] = None
650
+ """Maximum wait time between retries for file transfer operations.
651
+
652
+ <!-- lazydoc-ignore-class-attributes -->
653
+ """
654
+
655
+ x_file_transfer_timeout_seconds: Optional[float] = None
656
+ """Timeout in seconds for individual file transfer HTTP requests.
657
+
658
+ <!-- lazydoc-ignore-class-attributes -->
659
+ """
660
+
661
+ x_files_dir: Optional[str] = None
662
+ """Override setting for the computed files_dir.
663
+
664
+ <!-- lazydoc-ignore-class-attributes -->
665
+ """
666
+
667
+ x_flow_control_custom: Optional[bool] = None
668
+ """Flag indicating custom flow control for filestream.
669
+
670
+ TODO: Not implemented in wandb-core.
671
+ <!-- lazydoc-ignore-class-attributes -->
672
+ """
673
+
674
+ x_flow_control_disabled: Optional[bool] = None
675
+ """Flag indicating flow control is disabled for filestream.
676
+
677
+ TODO: Not implemented in wandb-core.
678
+ <!-- lazydoc-ignore-class-attributes -->
679
+ """
680
+
681
+ # graphql retry client configuration
682
+
683
+ x_graphql_retry_max: Optional[int] = None
684
+ """Max number of retries for GraphQL operations.
685
+
686
+ <!-- lazydoc-ignore-class-attributes -->
687
+ """
688
+
689
+ x_graphql_retry_wait_min_seconds: Optional[float] = None
690
+ """Minimum wait time between retries for GraphQL operations.
691
+
692
+ <!-- lazydoc-ignore-class-attributes -->
693
+ """
694
+
695
+ x_graphql_retry_wait_max_seconds: Optional[float] = None
696
+ """Maximum wait time between retries for GraphQL operations.
697
+
698
+ <!-- lazydoc-ignore-class-attributes -->
699
+ """
700
+
701
+ x_graphql_timeout_seconds: Optional[float] = None
702
+ """Timeout in seconds for individual GraphQL requests.
703
+
704
+ <!-- lazydoc-ignore-class-attributes -->
705
+ """
706
+
707
+ x_internal_check_process: float = 8.0
708
+ """Interval for internal process health checks in seconds.
709
+
710
+ <!-- lazydoc-ignore-class-attributes -->
711
+ """
712
+
713
+ x_jupyter_name: Optional[str] = None
714
+ """Name of the Jupyter notebook.
715
+
716
+ <!-- lazydoc-ignore-class-attributes -->
717
+ """
718
+
719
+ x_jupyter_path: Optional[str] = None
720
+ """Path to the Jupyter notebook.
721
+
722
+ <!-- lazydoc-ignore-class-attributes -->
723
+ """
724
+
725
+ x_jupyter_root: Optional[str] = None
726
+ """Root directory of the Jupyter notebook.
727
+
728
+ <!-- lazydoc-ignore-class-attributes -->
729
+ """
730
+
731
+ x_label: Optional[str] = None
732
+ """Label to assign to system metrics and console logs collected for the run.
733
+
734
+ This is used to group data by on the frontend and can be used to distinguish data
735
+ from different processes in a distributed training job.
736
+ """
737
+
738
+ x_live_policy_rate_limit: Optional[int] = None
739
+ """Rate limit for live policy updates in seconds.
740
+
741
+ <!-- lazydoc-ignore-class-attributes -->
742
+ """
743
+
744
+ x_live_policy_wait_time: Optional[int] = None
745
+ """Wait time between live policy updates in seconds.
746
+
747
+ <!-- lazydoc-ignore-class-attributes -->
748
+ """
749
+
750
+ x_log_level: int = logging.INFO
751
+ """Logging level for internal operations.
752
+
753
+ <!-- lazydoc-ignore-class-attributes -->
754
+ """
755
+
756
+ x_network_buffer: Optional[int] = None
757
+ """Size of the network buffer used in flow control.
758
+
759
+ TODO: Not implemented in wandb-core.
760
+ <!-- lazydoc-ignore-class-attributes -->
761
+ """
762
+
763
+ x_primary: bool = Field(
764
+ default=True, validation_alias=AliasChoices("x_primary", "x_primary_node")
765
+ )
766
+ """Determines whether to save internal wandb files and metadata.
767
+
768
+ In a distributed setting, this is useful for avoiding file overwrites
769
+ from secondary processes when only system metrics and logs are needed,
770
+ as the primary process handles the main logging.
771
+ """
772
+
773
+ x_proxies: Optional[Dict[str, str]] = None
774
+ """Custom proxy servers for requests to W&B.
775
+
776
+ This is deprecated and will be removed in a future release.
777
+ Please use `http_proxy` and `https_proxy` instead.
778
+ <!-- lazydoc-ignore-class-attributes -->
779
+ """
780
+
781
+ x_runqueue_item_id: Optional[str] = None
782
+ """ID of the Launch run queue item being processed.
783
+
784
+ <!-- lazydoc-ignore-class-attributes -->
785
+ """
786
+
787
+ x_save_requirements: bool = True
788
+ """Flag to save the requirements file."""
789
+
790
+ x_server_side_derived_summary: bool = False
791
+ """Flag to delegate automatic computation of summary from history to the server.
792
+
793
+ This does not disable user-provided summary updates.
794
+ """
795
+
796
+ x_server_side_expand_glob_metrics: bool = True
797
+ """Flag to delegate glob matching of metrics in define_metric to the server.
798
+
799
+ If the server does not support this, the client will perform the glob matching.
800
+ <!-- lazydoc-ignore-class-attributes -->
801
+ """
802
+
803
+ x_service_transport: Optional[str] = None
804
+ """Transport method for communication with the wandb service.
805
+
806
+ <!-- lazydoc-ignore-class-attributes -->
807
+ """
808
+
809
+ x_service_wait: float = 30.0
810
+ """Time in seconds to wait for the wandb-core internal service to start."""
811
+
812
+ x_skip_transaction_log: bool = False
813
+ """Whether to skip saving the run events to the transaction log.
814
+
815
+ This is only relevant for online runs. Can be used to reduce the amount of
816
+ data written to disk.
817
+
818
+ Should be used with caution, as it removes the gurantees about
819
+ recoverability.
820
+ """
821
+
822
+ x_start_time: Optional[float] = None
823
+ """The start time of the run in seconds since the Unix epoch.
824
+
825
+ <!-- lazydoc-ignore-class-attributes -->
826
+ """
827
+
828
+ x_stats_pid: int = os.getpid()
829
+ """PID of the process that started the wandb-core process to collect system stats for.
830
+
831
+ <!-- lazydoc-ignore-class-attributes -->
832
+ """
833
+
834
+ x_stats_sampling_interval: float = Field(default=15.0)
835
+ """Sampling interval for the system monitor in seconds."""
836
+
837
+ x_stats_neuron_monitor_config_path: Optional[str] = None
838
+ """Path to the default config file for the neuron-monitor tool.
839
+
840
+ This is used to monitor AWS Trainium devices.
841
+ <!-- lazydoc-ignore-class-attributes -->
842
+ """
843
+
844
+ x_stats_dcgm_exporter: Optional[str] = None
845
+ """Endpoint to extract Nvidia DCGM metrics from.
846
+
847
+ Options:
848
+ - Extract DCGM-related metrics from a query to the Prometheus `/api/v1/query` endpoint.
849
+ It is a common practice to aggregate metrics reported by the instances of the DCGM Exporter
850
+ running on different nodes in a cluster using Prometheus.
851
+ - TODO: Parse metrics directly from the `/metrics` endpoint of the DCGM Exporter.
852
+
853
+ Examples:
854
+ - `http://localhost:9400/api/v1/query?query=DCGM_FI_DEV_GPU_TEMP{node="l1337", cluster="globular"}`.
855
+ - TODO: `http://192.168.0.1:9400/metrics`.
856
+ <!-- lazydoc-ignore-class-attributes -->
857
+ """
858
+
859
+ x_stats_open_metrics_endpoints: Optional[Dict[str, str]] = None
860
+ """OpenMetrics `/metrics` endpoints to monitor for system metrics."""
861
+
862
+ x_stats_open_metrics_filters: Union[
863
+ Dict[str, Dict[str, str]], Sequence[str], None
864
+ ] = None
865
+ """Filter to apply to metrics collected from OpenMetrics `/metrics` endpoints.
866
+
867
+ Supports two formats:
868
+ - {"metric regex pattern, including endpoint name as prefix": {"label": "label value regex pattern"}}
869
+ - ("metric regex pattern 1", "metric regex pattern 2", ...)
870
+ """
871
+
872
+ x_stats_open_metrics_http_headers: Optional[Dict[str, str]] = None
873
+ """HTTP headers to add to OpenMetrics requests."""
874
+
875
+ x_stats_disk_paths: Optional[Sequence[str]] = ("/",)
876
+ """System paths to monitor for disk usage."""
877
+
878
+ x_stats_cpu_count: Optional[int] = None
879
+ """System CPU count.
880
+
881
+ If set, overrides the auto-detected value in the run metadata.
882
+ """
883
+
884
+ x_stats_cpu_logical_count: Optional[int] = None
885
+ """Logical CPU count.
886
+
887
+ If set, overrides the auto-detected value in the run metadata.
888
+ """
889
+
890
+ x_stats_gpu_count: Optional[int] = None
891
+ """GPU device count.
892
+
893
+ If set, overrides the auto-detected value in the run metadata.
894
+ """
895
+
896
+ x_stats_gpu_type: Optional[str] = None
897
+ """GPU device type.
898
+
899
+ If set, overrides the auto-detected value in the run metadata.
900
+ """
901
+
902
+ x_stats_gpu_device_ids: Optional[Sequence[int]] = None
903
+ """GPU device indices to monitor.
904
+
905
+ If not set, the system monitor captures metrics for all GPUs.
906
+ Assumes 0-based indexing matching CUDA/ROCm device enumeration.
907
+ """
908
+
909
+ x_stats_buffer_size: int = 0
910
+ """Number of system metric samples to buffer in memory in the wandb-core process.
911
+
912
+ Can be accessed via run._system_metrics.
913
+ <!-- lazydoc-ignore-class-attributes -->
914
+ """
915
+
916
+ x_stats_coreweave_metadata_base_url: str = "http://169.254.169.254"
917
+ """The scheme and hostname for contacting the CoreWeave metadata server.
918
+
919
+ Only accessible from within a CoreWeave cluster.
920
+ <!-- lazydoc-ignore-class-attributes -->
921
+ """
922
+
923
+ x_stats_coreweave_metadata_endpoint: str = "/api/v2/cloud-init/meta-data"
924
+ """The relative path on the CoreWeave metadata server to which to make requests.
925
+
926
+ This must not include the schema and hostname prefix.
927
+ Only accessible from within a CoreWeave cluster.
928
+ <!-- lazydoc-ignore-class-attributes -->
929
+ """
930
+
931
+ x_stats_track_process_tree: bool = False
932
+ """Monitor the entire process tree for resource usage, starting from `x_stats_pid`.
933
+
934
+ When `True`, the system monitor aggregates the RSS, CPU%, and thread count
935
+ from the process with PID `x_stats_pid` and all of its descendants.
936
+ This can have a performance overhead and is disabled by default.
937
+ """
938
+
939
+ x_sync: bool = False
940
+ """Flag to indicate whether we are syncing a run from the transaction log.
941
+
942
+ <!-- lazydoc-ignore-class-attributes -->
943
+ """
944
+
945
+ x_sync_dir_suffix: str = ""
946
+ """Suffix to add to the run's directory name (sync_dir).
947
+
948
+ This is set in wandb.init() to avoid naming conflicts.
949
+ If set, it is joined to the default name with a dash.
950
+ """
951
+
952
+ x_update_finish_state: bool = True
953
+ """Flag to indicate whether this process can update the run's final state on the server.
954
+
955
+ Set to False in distributed training when only the main process should determine the final state.
956
+ """
957
+
958
+ # Model validator to catch legacy settings.
959
+ @model_validator(mode="before")
960
+ @classmethod
961
+ def catch_private_settings(cls, values):
962
+ """Check if a private field is provided and assign to the corresponding public one.
963
+
964
+ This is a compatibility layer to handle previous versions of the settings.
965
+
966
+ <!-- lazydoc-ignore: internal -->
967
+ """
968
+ new_values = {}
969
+ for key in values:
970
+ # Internal settings are prefixed with "x_" instead of "_"
971
+ # as Pydantic does not allow "_" in field names.
972
+ if key.startswith("_"):
973
+ new_values["x" + key] = values[key]
974
+ else:
975
+ new_values[key] = values[key]
976
+ return new_values
977
+
978
+ if IS_PYDANTIC_V2:
979
+
980
+ @model_validator(mode="after")
981
+ def validate_mutual_exclusion_of_branching_args(self) -> Self:
982
+ """Check if `fork_from`, `resume`, and `resume_from` are mutually exclusive.
983
+
984
+ <!-- lazydoc-ignore: internal -->
985
+ """
986
+ if (
987
+ sum(
988
+ o is not None
989
+ for o in [self.fork_from, self.resume, self.resume_from]
990
+ )
991
+ > 1
992
+ ):
993
+ raise ValueError(
994
+ "`fork_from`, `resume`, or `resume_from` are mutually exclusive. "
995
+ "Please specify only one of them."
996
+ )
997
+ return self
998
+
999
+ @model_validator(mode="after")
1000
+ def validate_skip_transaction_log(self):
1001
+ """Validate x_skip_transaction_log.
1002
+
1003
+ <!-- lazydoc-ignore: internal -->
1004
+ """
1005
+ if self._offline and self.x_skip_transaction_log:
1006
+ raise ValueError("Cannot skip transaction log in offline mode")
1007
+ return self
1008
+ else:
1009
+
1010
+ @root_validator(pre=False) # type: ignore [call-overload]
1011
+ @classmethod
1012
+ def validate_mutual_exclusion_of_branching_args(cls, values):
1013
+ if (
1014
+ sum(
1015
+ values.get(o) is not None
1016
+ for o in ["fork_from", "resume", "resume_from"]
1017
+ )
1018
+ > 1
1019
+ ):
1020
+ raise ValueError(
1021
+ "`fork_from`, `resume`, or `resume_from` are mutually exclusive. "
1022
+ "Please specify only one of them."
1023
+ )
1024
+ return values
1025
+
1026
+ @root_validator(pre=False) # type: ignore [call-overload]
1027
+ @classmethod
1028
+ def validate_skip_transaction_log(cls, values):
1029
+ if values.get("_offline") and values.get("x_skip_transaction_log"):
1030
+ raise ValueError("Cannot skip transaction log in offline mode")
1031
+ return values
1032
+
1033
+ # Field validators.
1034
+ @field_validator("api_key", mode="after")
1035
+ @classmethod
1036
+ def validate_api_key(cls, value):
1037
+ """Validate the API key.
1038
+
1039
+ <!-- lazydoc-ignore-classmethod: internal -->
1040
+ """
1041
+ if value is not None and (len(value) > len(value.strip())):
1042
+ raise UsageError("API key cannot start or end with whitespace")
1043
+ return value
1044
+
1045
+ @field_validator("base_url", mode="after")
1046
+ @classmethod
1047
+ def validate_base_url(cls, value):
1048
+ """Validate the base URL.
1049
+
1050
+ <!-- lazydoc-ignore-classmethod: internal -->
1051
+ """
1052
+ validate_url(value)
1053
+ # wandb.ai-specific checks
1054
+ if re.match(r".*wandb\.ai[^\.]*$", value) and "api." not in value:
1055
+ # user might guess app.wandb.ai or wandb.ai is the default cloud server
1056
+ raise ValueError(
1057
+ f"{value} is not a valid server address, did you mean https://api.wandb.ai?"
1058
+ )
1059
+ elif re.match(r".*wandb\.ai[^\.]*$", value) and not value.startswith("https"):
1060
+ raise ValueError("http is not secure, please use https://api.wandb.ai")
1061
+ return value.rstrip("/")
1062
+
1063
+ @field_validator("code_dir", mode="before")
1064
+ @classmethod
1065
+ def validate_code_dir(cls, value):
1066
+ """Validate the code directory.
1067
+
1068
+ <!-- lazydoc-ignore-classmethod: internal -->
1069
+ """
1070
+ # TODO: add native support for pathlib.Path
1071
+ if isinstance(value, pathlib.Path):
1072
+ return str(value)
1073
+ return value
1074
+
1075
+ @field_validator("console", mode="after")
1076
+ @classmethod
1077
+ def validate_console(cls, value, values):
1078
+ """Validate the console capture method.
1079
+
1080
+ <!-- lazydoc-ignore-classmethod: internal -->
1081
+ """
1082
+ if value != "auto":
1083
+ return value
1084
+
1085
+ return "wrap"
1086
+
1087
+ @field_validator("x_executable", mode="before")
1088
+ @classmethod
1089
+ def validate_x_executable(cls, value):
1090
+ """Validate the Python executable path.
1091
+
1092
+ <!-- lazydoc-ignore-classmethod: internal -->
1093
+ """
1094
+ # TODO: add native support for pathlib.Path
1095
+ if isinstance(value, pathlib.Path):
1096
+ return str(value)
1097
+ return value
1098
+
1099
+ @field_validator("x_extra_http_headers", mode="before")
1100
+ @classmethod
1101
+ def validate_x_extra_http_headers(cls, value):
1102
+ if isinstance(value, str):
1103
+ return json.loads(value)
1104
+ return value
1105
+
1106
+ @field_validator("x_file_stream_max_line_bytes", mode="after")
1107
+ @classmethod
1108
+ def validate_file_stream_max_line_bytes(cls, value):
1109
+ """Validate the maximum line length for filestream JSONL files.
1110
+
1111
+ <!-- lazydoc-ignore-classmethod: internal -->
1112
+ """
1113
+ if value is not None and value < 1:
1114
+ raise ValueError("File stream max line bytes must be greater than 0")
1115
+ return value
1116
+
1117
+ @field_validator("x_files_dir", mode="before")
1118
+ @classmethod
1119
+ def validate_x_files_dir(cls, value):
1120
+ """Validate the files directory.
1121
+
1122
+ <!-- lazydoc-ignore-classmethod: internal -->
1123
+ """
1124
+ # TODO: add native support for pathlib.Path
1125
+ if isinstance(value, pathlib.Path):
1126
+ return str(value)
1127
+ return value
1128
+
1129
+ @field_validator("fork_from", mode="before")
1130
+ @classmethod
1131
+ def validate_fork_from(cls, value, values) -> Optional[RunMoment]:
1132
+ """Validate the fork_from field.
1133
+
1134
+ <!-- lazydoc-ignore-classmethod: internal -->
1135
+ """
1136
+ run_moment = cls._runmoment_preprocessor(value)
1137
+
1138
+ if hasattr(values, "data"):
1139
+ # pydantic v2
1140
+ values = values.data
1141
+ else:
1142
+ # pydantic v1
1143
+ values = values
1144
+
1145
+ if (
1146
+ run_moment
1147
+ and values.get("run_id") is not None
1148
+ and values.get("run_id") == run_moment.run
1149
+ ):
1150
+ raise ValueError(
1151
+ "Provided `run_id` is the same as the run to `fork_from`. "
1152
+ "Please provide a different `run_id` or remove the `run_id` argument. "
1153
+ "If you want to rewind the current run, please use `resume_from` instead."
1154
+ )
1155
+ return run_moment
1156
+
1157
+ @field_validator("http_proxy", mode="after")
1158
+ @classmethod
1159
+ def validate_http_proxy(cls, value):
1160
+ """Validate the HTTP proxy.
1161
+
1162
+ <!-- lazydoc-ignore-classmethod: internal -->
1163
+ """
1164
+ if value is None:
1165
+ return None
1166
+ validate_url(value)
1167
+ return value.rstrip("/")
1168
+
1169
+ @field_validator("https_proxy", mode="after")
1170
+ @classmethod
1171
+ def validate_https_proxy(cls, value):
1172
+ """Validate the HTTPS proxy.
1173
+
1174
+ <!-- lazydoc-ignore-classmethod: internal -->
1175
+ """
1176
+ if value is None:
1177
+ return None
1178
+ validate_url(value)
1179
+ return value.rstrip("/")
1180
+
1181
+ @field_validator("ignore_globs", mode="after")
1182
+ @classmethod
1183
+ def validate_ignore_globs(cls, value):
1184
+ """Validate the ignore globs.
1185
+
1186
+ <!-- lazydoc-ignore-classmethod: internal -->
1187
+ """
1188
+ return tuple(value) if not isinstance(value, tuple) else value
1189
+
1190
+ @field_validator("program", mode="before")
1191
+ @classmethod
1192
+ def validate_program(cls, value):
1193
+ """Validate the program path.
1194
+
1195
+ <!-- lazydoc-ignore-classmethod: internal -->
1196
+ """
1197
+ # TODO: add native support for pathlib.Path
1198
+ if isinstance(value, pathlib.Path):
1199
+ return str(value)
1200
+ return value
1201
+
1202
+ @field_validator("program_abspath", mode="before")
1203
+ @classmethod
1204
+ def validate_program_abspath(cls, value):
1205
+ """Validate the absolute program path.
1206
+
1207
+ <!-- lazydoc-ignore-classmethod: internal -->
1208
+ """
1209
+ # TODO: add native support for pathlib.Path
1210
+ if isinstance(value, pathlib.Path):
1211
+ return str(value)
1212
+ return value
1213
+
1214
+ @field_validator("program_relpath", mode="before")
1215
+ @classmethod
1216
+ def validate_program_relpath(cls, value):
1217
+ """Validate the relative program path.
1218
+
1219
+ <!-- lazydoc-ignore-classmethod: internal -->
1220
+ """
1221
+ # TODO: add native support for pathlib.Path
1222
+ if isinstance(value, pathlib.Path):
1223
+ return str(value)
1224
+ return value
1225
+
1226
+ @field_validator("project", mode="after")
1227
+ @classmethod
1228
+ def validate_project(cls, value, values):
1229
+ """Validate the project name.
1230
+
1231
+ <!-- lazydoc-ignore-classmethod: internal -->
1232
+ """
1233
+ if value is None:
1234
+ return None
1235
+ invalid_chars_list = list("/\\#?%:")
1236
+ if len(value) > 128:
1237
+ raise UsageError(f"Invalid project name {value!r}: exceeded 128 characters")
1238
+ invalid_chars = {char for char in invalid_chars_list if char in value}
1239
+ if invalid_chars:
1240
+ raise UsageError(
1241
+ f"Invalid project name {value!r}: "
1242
+ f"cannot contain characters {','.join(invalid_chars_list)!r}, "
1243
+ f"found {','.join(invalid_chars)!r}"
1244
+ )
1245
+ return value
1246
+
1247
+ @field_validator("resume", mode="before")
1248
+ @classmethod
1249
+ def validate_resume(cls, value):
1250
+ """Validate the resume behavior.
1251
+
1252
+ <!-- lazydoc-ignore-classmethod: internal -->
1253
+ """
1254
+ if value is False:
1255
+ return None
1256
+ if value is True:
1257
+ return "auto"
1258
+ return value
1259
+
1260
+ @field_validator("resume_from", mode="before")
1261
+ @classmethod
1262
+ def validate_resume_from(cls, value, values) -> Optional[RunMoment]:
1263
+ """Validate the resume_from field.
1264
+
1265
+ <!-- lazydoc-ignore-classmethod: internal -->
1266
+ """
1267
+ run_moment = cls._runmoment_preprocessor(value)
1268
+
1269
+ if hasattr(values, "data"):
1270
+ # pydantic v2
1271
+ values = values.data
1272
+ else:
1273
+ # pydantic v1
1274
+ values = values
1275
+
1276
+ if (
1277
+ run_moment
1278
+ and values.get("run_id") is not None
1279
+ and values.get("run_id") != run_moment.run
1280
+ ):
1281
+ raise ValueError(
1282
+ "Both `run_id` and `resume_from` have been specified with different ids."
1283
+ )
1284
+ return run_moment
1285
+
1286
+ @field_validator("root_dir", mode="before")
1287
+ @classmethod
1288
+ def validate_root_dir(cls, value):
1289
+ """Validate the root directory.
1290
+
1291
+ <!-- lazydoc-ignore-classmethod: internal -->
1292
+ """
1293
+ # TODO: add native support for pathlib.Path
1294
+ if isinstance(value, pathlib.Path):
1295
+ return str(value)
1296
+ return value
1297
+
1298
+ @field_validator("run_id", mode="after")
1299
+ @classmethod
1300
+ def validate_run_id(cls, value, values):
1301
+ """Validate the run ID.
1302
+
1303
+ <!-- lazydoc-ignore-classmethod: internal -->
1304
+ """
1305
+ if value is None:
1306
+ return None
1307
+
1308
+ if len(value) == 0:
1309
+ raise UsageError("Run ID cannot be empty")
1310
+ if len(value) > len(value.strip()):
1311
+ raise UsageError("Run ID cannot start or end with whitespace")
1312
+ if not bool(value.strip()):
1313
+ raise UsageError("Run ID cannot contain only whitespace")
1314
+
1315
+ # check if the run id contains any reserved characters
1316
+ reserved_chars = ":;,#?/'"
1317
+ if any(char in reserved_chars for char in value):
1318
+ raise UsageError(f"Run ID cannot contain the characters: {reserved_chars}")
1319
+ return value
1320
+
1321
+ @field_validator("settings_system", mode="after")
1322
+ @classmethod
1323
+ def validate_settings_system(cls, value):
1324
+ """Validate the system settings file path.
1325
+
1326
+ <!-- lazydoc-ignore-classmethod: internal -->
1327
+ """
1328
+ if value is None:
1329
+ return None
1330
+ elif isinstance(value, pathlib.Path):
1331
+ return str(_path_convert(value))
1332
+ else:
1333
+ return _path_convert(value)
1334
+
1335
+ @field_validator("x_service_wait", mode="after")
1336
+ @classmethod
1337
+ def validate_service_wait(cls, value):
1338
+ """Validate the service wait time.
1339
+
1340
+ <!-- lazydoc-ignore-classmethod: internal -->
1341
+ """
1342
+ if value < 0:
1343
+ raise UsageError("Service wait time cannot be negative")
1344
+ return value
1345
+
1346
+ @field_validator("start_method", mode="after")
1347
+ @classmethod
1348
+ def validate_start_method(cls, value):
1349
+ """Validate the start method for subprocesses.
1350
+
1351
+ <!-- lazydoc-ignore-classmethod: internal -->
1352
+ """
1353
+ if value is None:
1354
+ return value
1355
+ wandb.termwarn(
1356
+ "`start_method` is deprecated and will be removed in a future version "
1357
+ "of wandb. This setting is currently non-functional and safely ignored.",
1358
+ repeat=False,
1359
+ )
1360
+ return value
1361
+
1362
+ @field_validator("x_stats_coreweave_metadata_base_url", mode="after")
1363
+ @classmethod
1364
+ def validate_x_stats_coreweave_metadata_base_url(cls, value):
1365
+ validate_url(value)
1366
+ return value.rstrip("/")
1367
+
1368
+ @field_validator("x_stats_gpu_device_ids", mode="before")
1369
+ @classmethod
1370
+ def validate_x_stats_gpu_device_ids(cls, value):
1371
+ """Validate the GPU device IDs.
1372
+
1373
+ <!-- lazydoc-ignore-classmethod: internal -->
1374
+ """
1375
+ if isinstance(value, str):
1376
+ return json.loads(value)
1377
+ return value
1378
+
1379
+ @field_validator("x_stats_neuron_monitor_config_path", mode="before")
1380
+ @classmethod
1381
+ def validate_x_stats_neuron_monitor_config_path(cls, value):
1382
+ """Validate the path to the neuron-monitor config file.
1383
+
1384
+ <!-- lazydoc-ignore-classmethod: internal -->
1385
+ """
1386
+ # TODO: add native support for pathlib.Path
1387
+ if isinstance(value, pathlib.Path):
1388
+ return str(value)
1389
+ return value
1390
+
1391
+ @field_validator("x_stats_open_metrics_endpoints", mode="before")
1392
+ @classmethod
1393
+ def validate_stats_open_metrics_endpoints(cls, value):
1394
+ """Validate the OpenMetrics endpoints.
1395
+
1396
+ <!-- lazydoc-ignore-classmethod: internal -->
1397
+ """
1398
+ if isinstance(value, str):
1399
+ return json.loads(value)
1400
+ return value
1401
+
1402
+ @field_validator("x_stats_open_metrics_filters", mode="before")
1403
+ @classmethod
1404
+ def validate_stats_open_metrics_filters(cls, value):
1405
+ """Validate the OpenMetrics filters.
1406
+
1407
+ <!-- lazydoc-ignore-classmethod: internal -->
1408
+ """
1409
+ if isinstance(value, str):
1410
+ return json.loads(value)
1411
+ return value
1412
+
1413
+ @field_validator("x_stats_open_metrics_http_headers", mode="before")
1414
+ @classmethod
1415
+ def validate_stats_open_metrics_http_headers(cls, value):
1416
+ """Validate the OpenMetrics HTTP headers.
1417
+
1418
+ <!-- lazydoc-ignore-classmethod: internal -->
1419
+ """
1420
+ if isinstance(value, str):
1421
+ return json.loads(value)
1422
+ return value
1423
+
1424
+ @field_validator("x_stats_sampling_interval", mode="after")
1425
+ @classmethod
1426
+ def validate_stats_sampling_interval(cls, value):
1427
+ """Validate the stats sampling interval.
1428
+
1429
+ <!-- lazydoc-ignore-classmethod: internal -->
1430
+ """
1431
+ if value < 0.1:
1432
+ raise UsageError("Stats sampling interval cannot be less than 0.1 seconds")
1433
+ return value
1434
+
1435
+ @field_validator("sweep_id", mode="after")
1436
+ @classmethod
1437
+ def validate_sweep_id(cls, value):
1438
+ """Validate the sweep ID.
1439
+
1440
+ <!-- lazydoc-ignore-classmethod: internal -->
1441
+ """
1442
+ if value is None:
1443
+ return None
1444
+ if len(value) == 0:
1445
+ raise UsageError("Sweep ID cannot be empty")
1446
+ if len(value) > len(value.strip()):
1447
+ raise UsageError("Sweep ID cannot start or end with whitespace")
1448
+ if not bool(value.strip()):
1449
+ raise UsageError("Sweep ID cannot contain only whitespace")
1450
+ return value
1451
+
1452
+ @field_validator("run_tags", mode="before")
1453
+ @classmethod
1454
+ def validate_run_tags(cls, value):
1455
+ """Validate run tags.
1456
+
1457
+ Validates that each tag:
1458
+ - Is between 1 and 64 characters in length (inclusive)
1459
+ - Converts single string values to tuple format
1460
+ - Preserves None values
1461
+
1462
+ <!-- lazydoc-ignore-classmethod: internal -->
1463
+
1464
+ Args:
1465
+ value: A string, list, tuple, or None representing tags
1466
+
1467
+ Returns:
1468
+ tuple: A tuple of validated tags, or None
1469
+
1470
+ Raises:
1471
+ ValueError: If any tag is empty or exceeds 64 characters
1472
+ """
1473
+ if value is None:
1474
+ return None
1475
+
1476
+ # Convert to tuple if needed
1477
+ if isinstance(value, str):
1478
+ tags = (value,)
1479
+ else:
1480
+ tags = tuple(value)
1481
+
1482
+ # Validate each tag and accumulate errors
1483
+ errors = []
1484
+ for i, tag in enumerate(tags):
1485
+ tag_str = str(tag)
1486
+ if len(tag_str) == 0:
1487
+ errors.append(
1488
+ f"Tag at index {i} is empty. Tags must be between 1 and 64 characters"
1489
+ )
1490
+ elif len(tag_str) > 64:
1491
+ # Truncate long tags for display
1492
+ display_tag = (
1493
+ f"{tag_str[:20]}...{tag_str[-20:]}"
1494
+ if len(tag_str) > 43
1495
+ else tag_str
1496
+ )
1497
+ errors.append(
1498
+ f"Tag '{display_tag}' is {len(tag_str)} characters. Tags must be between 1 and 64 characters"
1499
+ )
1500
+
1501
+ # Raise combined error if any validation issues were found
1502
+ if errors:
1503
+ raise ValueError("; ".join(errors))
1504
+
1505
+ return tags
1506
+
1507
+ @field_validator("sweep_param_path", mode="before")
1508
+ @classmethod
1509
+ def validate_sweep_param_path(cls, value):
1510
+ """Validate the sweep parameter path.
1511
+
1512
+ <!-- lazydoc-ignore-classmethod: internal -->
1513
+ """
1514
+ # TODO: add native support for pathlib.Path
1515
+ if isinstance(value, pathlib.Path):
1516
+ return str(value)
1517
+ return value
1518
+
1519
+ # Computed fields.
1520
+
1521
+ @computed_field # type: ignore[prop-decorator]
1522
+ @property
1523
+ def _args(self) -> List[str]:
1524
+ if not self._jupyter:
1525
+ return sys.argv[1:]
1526
+ return []
1527
+
1528
+ @computed_field # type: ignore[prop-decorator]
1529
+ @property
1530
+ def _aws_lambda(self) -> bool:
1531
+ """Check if we are running in a lambda environment."""
1532
+ from sentry_sdk.integrations.aws_lambda import ( # type: ignore[import-not-found]
1533
+ get_lambda_bootstrap,
1534
+ )
1535
+
1536
+ lambda_bootstrap = get_lambda_bootstrap()
1537
+ if not lambda_bootstrap or not hasattr(
1538
+ lambda_bootstrap, "handle_event_request"
1539
+ ):
1540
+ return False
1541
+ return True
1542
+
1543
+ @computed_field # type: ignore[prop-decorator]
1544
+ @property
1545
+ def _code_path_local(self) -> Optional[str]:
1546
+ """The relative path from the current working directory to the code path.
1547
+
1548
+ For example, if the code path is /home/user/project/example.py, and the
1549
+ current working directory is /home/user/project, then the code path local
1550
+ is example.py.
1551
+
1552
+ If couldn't find the relative path, this will be an empty string.
1553
+ """
1554
+ return self._get_program_relpath(self.program) if self.program else None
1555
+
1556
+ @computed_field # type: ignore[prop-decorator]
1557
+ @property
1558
+ def _colab(self) -> bool:
1559
+ return "google.colab" in sys.modules
1560
+
1561
+ @computed_field # type: ignore[prop-decorator]
1562
+ @property
1563
+ def _ipython(self) -> bool:
1564
+ return ipython.in_ipython()
1565
+
1566
+ @computed_field # type: ignore[prop-decorator]
1567
+ @property
1568
+ def _jupyter(self) -> bool:
1569
+ return ipython.in_jupyter()
1570
+
1571
+ @computed_field # type: ignore[prop-decorator]
1572
+ @property
1573
+ def _kaggle(self) -> bool:
1574
+ return util._is_likely_kaggle()
1575
+
1576
+ @computed_field # type: ignore[prop-decorator]
1577
+ @property
1578
+ def _noop(self) -> bool:
1579
+ return self.mode == "disabled"
1580
+
1581
+ @computed_field # type: ignore[prop-decorator]
1582
+ @property
1583
+ def _notebook(self) -> bool:
1584
+ return self._ipython or self._jupyter or self._colab or self._kaggle
1585
+
1586
+ @computed_field # type: ignore[prop-decorator]
1587
+ @property
1588
+ def _offline(self) -> bool:
1589
+ return self.mode in ("offline", "dryrun")
1590
+
1591
+ @computed_field # type: ignore[prop-decorator]
1592
+ @property
1593
+ def _os(self) -> str:
1594
+ """The operating system of the machine running the script."""
1595
+ return platform.platform(aliased=True)
1596
+
1597
+ @computed_field # type: ignore[prop-decorator]
1598
+ @property
1599
+ def _platform(self) -> str:
1600
+ return f"{platform.system()}-{platform.machine()}".lower()
1601
+
1602
+ @computed_field # type: ignore[prop-decorator]
1603
+ @property
1604
+ def _python(self) -> str:
1605
+ return f"{platform.python_implementation()} {platform.python_version()}"
1606
+
1607
+ @computed_field # type: ignore[prop-decorator]
1608
+ @property
1609
+ def _shared(self) -> bool:
1610
+ """Whether we are in shared mode.
1611
+
1612
+ In "shared" mode, multiple processes can write to the same run,
1613
+ for example from different machines.
1614
+ """
1615
+ return self.mode == "shared"
1616
+
1617
+ @computed_field # type: ignore[prop-decorator]
1618
+ @property
1619
+ def _start_datetime(self) -> str:
1620
+ if self.x_start_time is None:
1621
+ return ""
1622
+ datetime_now = datetime.fromtimestamp(self.x_start_time)
1623
+ return datetime_now.strftime("%Y%m%d_%H%M%S")
1624
+
1625
+ @computed_field # type: ignore[prop-decorator]
1626
+ @property
1627
+ def _tmp_code_dir(self) -> str:
1628
+ return _path_convert(self.sync_dir, "tmp", "code")
1629
+
1630
+ @computed_field # type: ignore[prop-decorator]
1631
+ @property
1632
+ def _windows(self) -> bool:
1633
+ return platform.system() == "Windows"
1634
+
1635
+ @computed_field # type: ignore[prop-decorator]
1636
+ @property
1637
+ def colab_url(self) -> Optional[str]:
1638
+ """The URL to the Colab notebook, if running in Colab."""
1639
+ if not self._colab:
1640
+ return None
1641
+ if self.x_jupyter_path and self.x_jupyter_path.startswith("fileId="):
1642
+ unescaped = unquote(self.x_jupyter_path)
1643
+ return "https://colab.research.google.com/notebook#" + unescaped
1644
+ return None
1645
+
1646
+ @computed_field # type: ignore[prop-decorator]
1647
+ @property
1648
+ def deployment(self) -> Literal["local", "cloud"]:
1649
+ return "local" if self.is_local else "cloud"
1650
+
1651
+ @computed_field # type: ignore[prop-decorator]
1652
+ @property
1653
+ def files_dir(self) -> str:
1654
+ """Absolute path to the local directory where the run's files are stored."""
1655
+ return self.x_files_dir or _path_convert(self.sync_dir, "files")
1656
+
1657
+ @computed_field # type: ignore[prop-decorator]
1658
+ @property
1659
+ def is_local(self) -> bool:
1660
+ return str(self.base_url) != "https://api.wandb.ai"
1661
+
1662
+ @computed_field # type: ignore[prop-decorator]
1663
+ @property
1664
+ def log_dir(self) -> str:
1665
+ """The directory for storing log files."""
1666
+ return _path_convert(self.sync_dir, "logs")
1667
+
1668
+ @computed_field # type: ignore[prop-decorator]
1669
+ @property
1670
+ def log_internal(self) -> str:
1671
+ """The path to the file to use for internal logs."""
1672
+ return _path_convert(self.log_dir, "debug-internal.log")
1673
+
1674
+ @computed_field # type: ignore[prop-decorator]
1675
+ @property
1676
+ def log_symlink_internal(self) -> str:
1677
+ """The path to the symlink to the internal log file of the most recent run."""
1678
+ return _path_convert(self.wandb_dir, "debug-internal.log")
1679
+
1680
+ @computed_field # type: ignore[prop-decorator]
1681
+ @property
1682
+ def log_symlink_user(self) -> str:
1683
+ """The path to the symlink to the user-process log file of the most recent run."""
1684
+ return _path_convert(self.wandb_dir, "debug.log")
1685
+
1686
+ @computed_field # type: ignore[prop-decorator]
1687
+ @property
1688
+ def log_user(self) -> str:
1689
+ """The path to the file to use for user-process logs."""
1690
+ return _path_convert(self.log_dir, "debug.log")
1691
+
1692
+ @computed_field # type: ignore[prop-decorator]
1693
+ @property
1694
+ def project_url(self) -> str:
1695
+ """The W&B URL where the project can be viewed."""
1696
+ project_url = self._project_url_base()
1697
+ if not project_url:
1698
+ return ""
1699
+
1700
+ query = self._get_url_query_string()
1701
+
1702
+ return f"{project_url}{query}"
1703
+
1704
+ @computed_field # type: ignore[prop-decorator]
1705
+ @property
1706
+ def resume_fname(self) -> str:
1707
+ """The path to the resume file."""
1708
+ return _path_convert(self.wandb_dir, "wandb-resume.json")
1709
+
1710
+ @computed_field # type: ignore[prop-decorator]
1711
+ @property
1712
+ def run_mode(self) -> Literal["run", "offline-run"]:
1713
+ """The mode of the run. Can be either "run" or "offline-run"."""
1714
+ return "run" if not self._offline else "offline-run"
1715
+
1716
+ @computed_field # type: ignore[prop-decorator]
1717
+ @property
1718
+ def run_url(self) -> str:
1719
+ """The W&B URL where the run can be viewed."""
1720
+ project_url = self._project_url_base()
1721
+ if not all([project_url, self.run_id]):
1722
+ return ""
1723
+
1724
+ query = self._get_url_query_string()
1725
+ # Exclude specific safe characters from URL encoding to prevent 404 errors
1726
+ safe_chars = "=+&$@"
1727
+ return f"{project_url}/runs/{quote(self.run_id or '', safe=safe_chars)}{query}"
1728
+
1729
+ @computed_field # type: ignore[prop-decorator]
1730
+ @property
1731
+ def settings_workspace(self) -> str:
1732
+ """The path to the workspace settings file."""
1733
+ return _path_convert(self.wandb_dir, "settings")
1734
+
1735
+ @computed_field # type: ignore[prop-decorator]
1736
+ @property
1737
+ def sweep_url(self) -> str:
1738
+ """The W&B URL where the sweep can be viewed."""
1739
+ project_url = self._project_url_base()
1740
+ if not all([project_url, self.sweep_id]):
1741
+ return ""
1742
+
1743
+ query = self._get_url_query_string()
1744
+ return f"{project_url}/sweeps/{quote(self.sweep_id or '')}{query}"
1745
+
1746
+ @computed_field # type: ignore[prop-decorator]
1747
+ @property
1748
+ def sync_dir(self) -> str:
1749
+ """The directory for storing the run's files."""
1750
+ name = f"{self.run_mode}-{self.timespec}-{self.run_id}"
1751
+
1752
+ if self.x_sync_dir_suffix:
1753
+ name += f"-{self.x_sync_dir_suffix}"
1754
+
1755
+ return _path_convert(self.wandb_dir, name)
1756
+
1757
+ @computed_field # type: ignore[prop-decorator]
1758
+ @property
1759
+ def sync_file(self) -> str:
1760
+ """Path to the append-only binary transaction log file."""
1761
+ return _path_convert(self.sync_dir, f"run-{self.run_id}.wandb")
1762
+
1763
+ @computed_field # type: ignore[prop-decorator]
1764
+ @property
1765
+ def sync_symlink_latest(self) -> str:
1766
+ """Path to the symlink to the most recent run's transaction log file."""
1767
+ return _path_convert(self.wandb_dir, "latest-run")
1768
+
1769
+ @computed_field # type: ignore[prop-decorator]
1770
+ @property
1771
+ def timespec(self) -> str:
1772
+ """The time specification for the run."""
1773
+ return self._start_datetime
1774
+
1775
+ @computed_field # type: ignore[prop-decorator]
1776
+ @property
1777
+ def wandb_dir(self) -> str:
1778
+ """Full path to the wandb directory."""
1779
+ stage_dir = (
1780
+ ".wandb" + os.sep
1781
+ if os.path.exists(os.path.join(self.root_dir, ".wandb"))
1782
+ else "wandb" + os.sep
1783
+ )
1784
+ path = os.path.join(self.root_dir, stage_dir)
1785
+ return os.path.expanduser(path)
1786
+
1787
+ # Methods to collect and update settings from different sources.
1788
+ #
1789
+ # The Settings class does not track the source of the settings,
1790
+ # so it is up to the developer to ensure that the settings are applied
1791
+ # in the correct order. Most of the updates are done in
1792
+ # wandb/sdk/wandb_setup.py::_WandbSetup._settings_setup.
1793
+
1794
+ def update_from_system_config_file(self):
1795
+ """Update settings from the system config file.
1796
+
1797
+ <!-- lazydoc-ignore: internal -->
1798
+ """
1799
+ if not self.settings_system or not os.path.exists(self.settings_system):
1800
+ return
1801
+ for key, value in self._load_config_file(self.settings_system).items():
1802
+ if value is not None:
1803
+ setattr(self, key, value)
1804
+
1805
+ def update_from_workspace_config_file(self):
1806
+ """Update settings from the workspace config file.
1807
+
1808
+ <!-- lazydoc-ignore: internal -->
1809
+ """
1810
+ if not self.settings_workspace or not os.path.exists(self.settings_workspace):
1811
+ return
1812
+ for key, value in self._load_config_file(self.settings_workspace).items():
1813
+ if value is not None:
1814
+ setattr(self, key, value)
1815
+
1816
+ def update_from_env_vars(self, environ: Dict[str, Any]):
1817
+ """Update settings from environment variables.
1818
+
1819
+ <!-- lazydoc-ignore: internal -->
1820
+ """
1821
+ env_prefix: str = "WANDB_"
1822
+ private_env_prefix: str = env_prefix + "_"
1823
+ special_env_var_names = {
1824
+ "WANDB_SERVICE_TRANSPORT": "x_service_transport",
1825
+ "WANDB_DIR": "root_dir",
1826
+ "WANDB_NAME": "run_name",
1827
+ "WANDB_NOTES": "run_notes",
1828
+ "WANDB_TAGS": "run_tags",
1829
+ "WANDB_JOB_TYPE": "run_job_type",
1830
+ "WANDB_HTTP_TIMEOUT": "x_graphql_timeout_seconds",
1831
+ "WANDB_FILE_PUSHER_TIMEOUT": "x_file_transfer_timeout_seconds",
1832
+ "WANDB_USER_EMAIL": "email",
1833
+ }
1834
+ env = dict()
1835
+ for setting, value in environ.items():
1836
+ if not setting.startswith(env_prefix):
1837
+ continue
1838
+
1839
+ if setting in special_env_var_names:
1840
+ key = special_env_var_names[setting]
1841
+ elif setting.startswith(private_env_prefix):
1842
+ key = "x_" + setting[len(private_env_prefix) :].lower()
1843
+ else:
1844
+ # otherwise, strip the prefix and convert to lowercase
1845
+ key = setting[len(env_prefix) :].lower()
1846
+
1847
+ if key in self.__dict__:
1848
+ if key in ("ignore_globs", "run_tags"):
1849
+ value = value.split(",")
1850
+ env[key] = value
1851
+
1852
+ for key, value in env.items():
1853
+ if value is not None:
1854
+ setattr(self, key, value)
1855
+
1856
+ def update_from_system_environment(self):
1857
+ """Update settings from the system environment.
1858
+
1859
+ <!-- lazydoc-ignore: internal -->
1860
+ """
1861
+ # For code saving, only allow env var override if value from server is true, or
1862
+ # if no preference was specified.
1863
+ if (self.save_code is True or self.save_code is None) and (
1864
+ os.getenv(env.SAVE_CODE) is not None
1865
+ or os.getenv(env.DISABLE_CODE) is not None
1866
+ ):
1867
+ self.save_code = env.should_save_code()
1868
+
1869
+ if os.getenv(env.DISABLE_GIT) is not None:
1870
+ self.disable_git = env.disable_git()
1871
+
1872
+ # Attempt to get notebook information if not already set by the user
1873
+ if self._jupyter and (self.notebook_name is None or self.notebook_name == ""):
1874
+ meta = wandb.jupyter.notebook_metadata(self.silent) # type: ignore
1875
+ self.x_jupyter_path = meta.get("path")
1876
+ self.x_jupyter_name = meta.get("name")
1877
+ self.x_jupyter_root = meta.get("root")
1878
+ elif (
1879
+ self._jupyter
1880
+ and self.notebook_name is not None
1881
+ and os.path.exists(self.notebook_name)
1882
+ ):
1883
+ self.x_jupyter_path = self.notebook_name
1884
+ self.x_jupyter_name = self.notebook_name
1885
+ self.x_jupyter_root = os.getcwd()
1886
+ elif self._jupyter:
1887
+ wandb.termwarn(
1888
+ "WANDB_NOTEBOOK_NAME should be a path to a notebook file, "
1889
+ f"couldn't find {self.notebook_name}.",
1890
+ )
1891
+
1892
+ # host is populated by update_from_env_vars if the corresponding env
1893
+ # vars exist -- but if they don't, we'll fill them in here.
1894
+ if self.host is None:
1895
+ self.host = socket.gethostname() # type: ignore
1896
+
1897
+ _executable = (
1898
+ self.x_executable
1899
+ or os.environ.get(env._EXECUTABLE)
1900
+ or sys.executable
1901
+ or shutil.which("python3")
1902
+ or "python3"
1903
+ )
1904
+ self.x_executable = _executable
1905
+
1906
+ if self.docker is None:
1907
+ self.docker = env.get_docker(util.image_id_from_k8s())
1908
+
1909
+ # proceed if not in CLI mode
1910
+ if self.x_cli_only_mode:
1911
+ return
1912
+
1913
+ program = self.program or self._get_program()
1914
+
1915
+ if program is not None:
1916
+ try:
1917
+ root = (
1918
+ GitRepo().root or os.getcwd()
1919
+ if not self.disable_git
1920
+ else os.getcwd()
1921
+ )
1922
+ except Exception:
1923
+ # if the git command fails, fall back to the current working directory
1924
+ root = os.getcwd()
1925
+
1926
+ self.program_relpath = self.program_relpath or self._get_program_relpath(
1927
+ program, root
1928
+ )
1929
+ program_abspath = os.path.abspath(
1930
+ os.path.join(root, os.path.relpath(os.getcwd(), root), program)
1931
+ )
1932
+ if os.path.exists(program_abspath):
1933
+ self.program_abspath = program_abspath
1934
+ else:
1935
+ program = "<python with no main file>"
1936
+
1937
+ self.program = program
1938
+
1939
+ def update_from_dict(self, settings: Dict[str, Any]) -> None:
1940
+ """Update settings from a dictionary.
1941
+
1942
+ <!-- lazydoc-ignore: internal -->
1943
+ """
1944
+ for key, value in dict(settings).items():
1945
+ if value is not None:
1946
+ setattr(self, key, value)
1947
+
1948
+ def update_from_settings(self, settings: Settings) -> None:
1949
+ """Update settings from another instance of `Settings`.
1950
+
1951
+ <!-- lazydoc-ignore: internal -->
1952
+ """
1953
+ d = {field: getattr(settings, field) for field in settings.model_fields_set}
1954
+ if d:
1955
+ self.update_from_dict(d)
1956
+
1957
+ # Helper methods.
1958
+
1959
+ def to_proto(self) -> wandb_settings_pb2.Settings:
1960
+ """Generate a protobuf representation of the settings.
1961
+
1962
+ <!-- lazydoc-ignore: internal -->
1963
+ """
1964
+ settings_proto = wandb_settings_pb2.Settings()
1965
+ for k, v in self.model_dump(exclude_none=True).items():
1966
+ if k in CLIENT_ONLY_SETTINGS:
1967
+ continue
1968
+
1969
+ # Special case for x_stats_open_metrics_filters.
1970
+ if k == "x_stats_open_metrics_filters":
1971
+ if isinstance(v, (list, set, tuple)):
1972
+ setting = getattr(settings_proto, k)
1973
+ setting.sequence.value.extend(v)
1974
+ elif isinstance(v, dict):
1975
+ setting = getattr(settings_proto, k)
1976
+ for key, value in v.items():
1977
+ for kk, vv in value.items():
1978
+ setting.mapping.value[key].value[kk] = vv
1979
+ else:
1980
+ raise TypeError(f"Unsupported type {type(v)} for setting {k}")
1981
+ continue
1982
+
1983
+ # Special case for RunMoment fields.
1984
+ if k in ("fork_from", "resume_from"):
1985
+ run_moment = (
1986
+ v
1987
+ if isinstance(v, RunMoment)
1988
+ else RunMoment(
1989
+ run=v.get("run"),
1990
+ value=v.get("value"),
1991
+ metric=v.get("metric"),
1992
+ )
1993
+ )
1994
+ getattr(settings_proto, k).CopyFrom(
1995
+ wandb_settings_pb2.RunMoment(
1996
+ run=run_moment.run,
1997
+ value=run_moment.value,
1998
+ metric=run_moment.metric,
1999
+ )
2000
+ )
2001
+ continue
2002
+
2003
+ if isinstance(v, bool):
2004
+ getattr(settings_proto, k).CopyFrom(BoolValue(value=v))
2005
+ elif isinstance(v, int):
2006
+ getattr(settings_proto, k).CopyFrom(Int32Value(value=v))
2007
+ elif isinstance(v, float):
2008
+ getattr(settings_proto, k).CopyFrom(DoubleValue(value=v))
2009
+ elif isinstance(v, str):
2010
+ getattr(settings_proto, k).CopyFrom(StringValue(value=v))
2011
+ elif isinstance(v, (list, set, tuple)):
2012
+ # we only support sequences of strings for now
2013
+ sequence = getattr(settings_proto, k)
2014
+ sequence.value.extend(v)
2015
+ elif isinstance(v, dict):
2016
+ mapping = getattr(settings_proto, k)
2017
+ for key, value in v.items():
2018
+ # we only support dicts with string values for now
2019
+ mapping.value[key] = value
2020
+ elif v is None:
2021
+ # None means that the setting value was not set.
2022
+ pass
2023
+ else:
2024
+ raise TypeError(f"Unsupported type {type(v)} for setting {k}")
2025
+
2026
+ return settings_proto
2027
+
2028
+ def _get_program(self) -> Optional[str]:
2029
+ """Get the program that started the current process."""
2030
+ if self._jupyter:
2031
+ # If in a notebook, try to get the program from the notebook metadata.
2032
+ if self.notebook_name:
2033
+ return self.notebook_name
2034
+
2035
+ if not self.x_jupyter_path:
2036
+ return self.program
2037
+
2038
+ if self.x_jupyter_path.startswith("fileId="):
2039
+ return self.x_jupyter_name
2040
+
2041
+ return self.x_jupyter_path
2042
+
2043
+ # If not in a notebook, try to get the program from the environment
2044
+ # or the __main__ module for scripts run as `python -m ...`.
2045
+ program = os.getenv(env.PROGRAM)
2046
+ if program is not None:
2047
+ return program
2048
+
2049
+ try:
2050
+ import __main__
2051
+ except ImportError:
2052
+ return None
2053
+
2054
+ try:
2055
+ if __main__.__spec__ is None:
2056
+ python_args = __main__.__file__
2057
+ else:
2058
+ python_args = f"-m {__main__.__spec__.name}"
2059
+ except AttributeError:
2060
+ return None
2061
+
2062
+ return python_args
2063
+
2064
+ @staticmethod
2065
+ def _get_program_relpath(program: str, root: Optional[str] = None) -> Optional[str]:
2066
+ """Get the relative path to the program from the root directory."""
2067
+ if not program:
2068
+ return None
2069
+
2070
+ root = root or os.getcwd()
2071
+ if not root:
2072
+ return None
2073
+
2074
+ # For windows if the root and program are on different drives,
2075
+ # os.path.relpath will raise a ValueError.
2076
+ if not util.are_paths_on_same_drive(root, program):
2077
+ return None
2078
+
2079
+ full_path_to_program = os.path.join(
2080
+ root, os.path.relpath(os.getcwd(), root), program
2081
+ )
2082
+ if os.path.exists(full_path_to_program):
2083
+ relative_path = os.path.relpath(full_path_to_program, start=root)
2084
+ if "../" in relative_path:
2085
+ return None
2086
+ return relative_path
2087
+
2088
+ return None
2089
+
2090
+ @staticmethod
2091
+ def _load_config_file(file_name: str, section: str = "default") -> dict:
2092
+ """Load a config file and return the settings for a given section."""
2093
+ parser = configparser.ConfigParser()
2094
+ parser.add_section(section)
2095
+ parser.read(file_name)
2096
+ config: Dict[str, Any] = dict()
2097
+ for k in parser[section]:
2098
+ config[k] = parser[section][k]
2099
+ if k == "ignore_globs":
2100
+ config[k] = config[k].split(",")
2101
+ return config
2102
+
2103
+ def _project_url_base(self) -> str:
2104
+ """Construct the base URL for the project."""
2105
+ if not all([self.entity, self.project]):
2106
+ return ""
2107
+
2108
+ app_url = util.app_url(self.base_url)
2109
+ return f"{app_url}/{quote(self.entity or '')}/{quote(self.project or '')}"
2110
+
2111
+ def _get_url_query_string(self) -> str:
2112
+ """Construct the query string for project, run, and sweep URLs."""
2113
+ # TODO: remove dependency on Api()
2114
+ if self.anonymous not in ["allow", "must"]:
2115
+ return ""
2116
+
2117
+ api_key = apikey.api_key(settings=self)
2118
+
2119
+ return f"?{urlencode({'apiKey': api_key})}"
2120
+
2121
+ @staticmethod
2122
+ def _runmoment_preprocessor(
2123
+ val: Union[RunMoment, str, None],
2124
+ ) -> Optional[RunMoment]:
2125
+ """Preprocess the setting for forking or resuming a run."""
2126
+ if isinstance(val, RunMoment) or val is None:
2127
+ return val
2128
+ elif isinstance(val, str):
2129
+ return RunMoment.from_uri(val)
2130
+
2131
+ if not IS_PYDANTIC_V2:
2132
+
2133
+ def model_copy(self, *args, **kwargs):
2134
+ return self.copy(*args, **kwargs)
2135
+
2136
+ def model_dump(self, **kwargs):
2137
+ """Compatibility method for Pydantic v1 to mimic v2's model_dump.
2138
+
2139
+ In v1, this is equivalent to dict() but also includes computed properties.
2140
+
2141
+ Args:
2142
+ **kwargs: Options passed to the dict method
2143
+ - exclude_none: Whether to exclude fields with None values
2144
+
2145
+ Returns:
2146
+ A dictionary of the model's fields and computed properties
2147
+ """
2148
+ # Handle exclude_none separately since it's named differently in v1
2149
+ exclude_none = kwargs.pop("exclude_none", False)
2150
+
2151
+ # Start with regular fields from dict()
2152
+ result = self.dict(**kwargs)
2153
+
2154
+ # Get all computed properties
2155
+ for name in dir(self.__class__):
2156
+ attr = getattr(self.__class__, name, None)
2157
+ if isinstance(attr, property):
2158
+ try:
2159
+ # Only include properties that don't raise errors
2160
+ value = getattr(self, name)
2161
+ result[name] = value
2162
+ except (AttributeError, NotImplementedError, TypeError, ValueError):
2163
+ # Skip properties that can't be accessed or raise errors
2164
+ pass
2165
+ elif isinstance(attr, RunMoment):
2166
+ value = getattr(self, name)
2167
+ result[name] = value
2168
+
2169
+ # Special Pydantic attributes that should always be excluded
2170
+ exclude_fields = {
2171
+ "model_config",
2172
+ "model_fields",
2173
+ "model_fields_set",
2174
+ "__fields__",
2175
+ "__model_fields_set",
2176
+ "__pydantic_self__",
2177
+ "__pydantic_initialised__",
2178
+ }
2179
+
2180
+ # Remove special Pydantic attributes
2181
+ for field in exclude_fields:
2182
+ if field in result:
2183
+ del result[field]
2184
+
2185
+ if exclude_none:
2186
+ # Remove None values from the result
2187
+ return {k: v for k, v in result.items() if v is not None}
2188
+
2189
+ return result
2190
+
2191
+ @property
2192
+ def model_fields_set(self) -> set:
2193
+ """Return a set of fields that have been explicitly set.
2194
+
2195
+ This is a compatibility property for Pydantic v1 to mimic v2's model_fields_set.
2196
+ """
2197
+ return getattr(self, "__fields_set__", set())