wandb 0.19.1__py3-none-musllinux_1_2_aarch64.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (822) hide show
  1. package_readme.md +97 -0
  2. wandb/__init__.py +246 -0
  3. wandb/__init__.pyi +1197 -0
  4. wandb/__main__.py +3 -0
  5. wandb/_globals.py +19 -0
  6. wandb/agents/__init__.py +0 -0
  7. wandb/agents/pyagent.py +363 -0
  8. wandb/analytics/__init__.py +3 -0
  9. wandb/analytics/sentry.py +263 -0
  10. wandb/apis/__init__.py +48 -0
  11. wandb/apis/attrs.py +51 -0
  12. wandb/apis/importers/__init__.py +1 -0
  13. wandb/apis/importers/internals/internal.py +385 -0
  14. wandb/apis/importers/internals/protocols.py +103 -0
  15. wandb/apis/importers/internals/util.py +78 -0
  16. wandb/apis/importers/mlflow.py +254 -0
  17. wandb/apis/importers/validation.py +108 -0
  18. wandb/apis/importers/wandb.py +1603 -0
  19. wandb/apis/internal.py +232 -0
  20. wandb/apis/normalize.py +73 -0
  21. wandb/apis/paginator.py +81 -0
  22. wandb/apis/public/__init__.py +34 -0
  23. wandb/apis/public/api.py +1387 -0
  24. wandb/apis/public/artifacts.py +1095 -0
  25. wandb/apis/public/const.py +4 -0
  26. wandb/apis/public/files.py +263 -0
  27. wandb/apis/public/history.py +149 -0
  28. wandb/apis/public/jobs.py +653 -0
  29. wandb/apis/public/projects.py +154 -0
  30. wandb/apis/public/query_generator.py +166 -0
  31. wandb/apis/public/reports.py +458 -0
  32. wandb/apis/public/runs.py +1012 -0
  33. wandb/apis/public/sweeps.py +240 -0
  34. wandb/apis/public/teams.py +198 -0
  35. wandb/apis/public/users.py +136 -0
  36. wandb/apis/public/utils.py +68 -0
  37. wandb/apis/reports/__init__.py +1 -0
  38. wandb/apis/reports/v1/__init__.py +8 -0
  39. wandb/apis/reports/v2/__init__.py +8 -0
  40. wandb/apis/workspaces/__init__.py +8 -0
  41. wandb/beta/workflows.py +288 -0
  42. wandb/bin/gpu_stats +0 -0
  43. wandb/bin/wandb-core +0 -0
  44. wandb/cli/__init__.py +0 -0
  45. wandb/cli/beta.py +178 -0
  46. wandb/cli/cli.py +2812 -0
  47. wandb/data_types.py +66 -0
  48. wandb/docker/__init__.py +343 -0
  49. wandb/docker/auth.py +435 -0
  50. wandb/docker/wandb-entrypoint.sh +33 -0
  51. wandb/docker/www_authenticate.py +94 -0
  52. wandb/env.py +513 -0
  53. wandb/errors/__init__.py +17 -0
  54. wandb/errors/errors.py +37 -0
  55. wandb/errors/links.py +73 -0
  56. wandb/errors/term.py +415 -0
  57. wandb/errors/util.py +57 -0
  58. wandb/errors/warnings.py +2 -0
  59. wandb/filesync/__init__.py +0 -0
  60. wandb/filesync/dir_watcher.py +403 -0
  61. wandb/filesync/stats.py +100 -0
  62. wandb/filesync/step_checksum.py +142 -0
  63. wandb/filesync/step_prepare.py +179 -0
  64. wandb/filesync/step_upload.py +287 -0
  65. wandb/filesync/upload_job.py +142 -0
  66. wandb/integration/__init__.py +0 -0
  67. wandb/integration/catboost/__init__.py +5 -0
  68. wandb/integration/catboost/catboost.py +178 -0
  69. wandb/integration/cohere/__init__.py +3 -0
  70. wandb/integration/cohere/cohere.py +21 -0
  71. wandb/integration/cohere/resolver.py +347 -0
  72. wandb/integration/diffusers/__init__.py +3 -0
  73. wandb/integration/diffusers/autologger.py +76 -0
  74. wandb/integration/diffusers/pipeline_resolver.py +50 -0
  75. wandb/integration/diffusers/resolvers/__init__.py +9 -0
  76. wandb/integration/diffusers/resolvers/multimodal.py +882 -0
  77. wandb/integration/diffusers/resolvers/utils.py +102 -0
  78. wandb/integration/fastai/__init__.py +245 -0
  79. wandb/integration/gym/__init__.py +99 -0
  80. wandb/integration/huggingface/__init__.py +3 -0
  81. wandb/integration/huggingface/huggingface.py +18 -0
  82. wandb/integration/huggingface/resolver.py +213 -0
  83. wandb/integration/keras/__init__.py +11 -0
  84. wandb/integration/keras/callbacks/__init__.py +5 -0
  85. wandb/integration/keras/callbacks/metrics_logger.py +129 -0
  86. wandb/integration/keras/callbacks/model_checkpoint.py +188 -0
  87. wandb/integration/keras/callbacks/tables_builder.py +228 -0
  88. wandb/integration/keras/keras.py +1089 -0
  89. wandb/integration/kfp/__init__.py +6 -0
  90. wandb/integration/kfp/helpers.py +28 -0
  91. wandb/integration/kfp/kfp_patch.py +334 -0
  92. wandb/integration/kfp/wandb_logging.py +182 -0
  93. wandb/integration/langchain/__init__.py +3 -0
  94. wandb/integration/langchain/wandb_tracer.py +48 -0
  95. wandb/integration/lightgbm/__init__.py +239 -0
  96. wandb/integration/lightning/__init__.py +0 -0
  97. wandb/integration/lightning/fabric/__init__.py +3 -0
  98. wandb/integration/lightning/fabric/logger.py +764 -0
  99. wandb/integration/metaflow/__init__.py +3 -0
  100. wandb/integration/metaflow/metaflow.py +383 -0
  101. wandb/integration/openai/__init__.py +3 -0
  102. wandb/integration/openai/fine_tuning.py +480 -0
  103. wandb/integration/openai/openai.py +22 -0
  104. wandb/integration/openai/resolver.py +240 -0
  105. wandb/integration/prodigy/__init__.py +3 -0
  106. wandb/integration/prodigy/prodigy.py +299 -0
  107. wandb/integration/sacred/__init__.py +117 -0
  108. wandb/integration/sagemaker/__init__.py +12 -0
  109. wandb/integration/sagemaker/auth.py +28 -0
  110. wandb/integration/sagemaker/config.py +49 -0
  111. wandb/integration/sagemaker/files.py +3 -0
  112. wandb/integration/sagemaker/resources.py +34 -0
  113. wandb/integration/sb3/__init__.py +3 -0
  114. wandb/integration/sb3/sb3.py +147 -0
  115. wandb/integration/sklearn/__init__.py +37 -0
  116. wandb/integration/sklearn/calculate/__init__.py +32 -0
  117. wandb/integration/sklearn/calculate/calibration_curves.py +125 -0
  118. wandb/integration/sklearn/calculate/class_proportions.py +68 -0
  119. wandb/integration/sklearn/calculate/confusion_matrix.py +93 -0
  120. wandb/integration/sklearn/calculate/decision_boundaries.py +40 -0
  121. wandb/integration/sklearn/calculate/elbow_curve.py +55 -0
  122. wandb/integration/sklearn/calculate/feature_importances.py +67 -0
  123. wandb/integration/sklearn/calculate/learning_curve.py +64 -0
  124. wandb/integration/sklearn/calculate/outlier_candidates.py +69 -0
  125. wandb/integration/sklearn/calculate/residuals.py +86 -0
  126. wandb/integration/sklearn/calculate/silhouette.py +118 -0
  127. wandb/integration/sklearn/calculate/summary_metrics.py +62 -0
  128. wandb/integration/sklearn/plot/__init__.py +35 -0
  129. wandb/integration/sklearn/plot/classifier.py +329 -0
  130. wandb/integration/sklearn/plot/clusterer.py +146 -0
  131. wandb/integration/sklearn/plot/regressor.py +121 -0
  132. wandb/integration/sklearn/plot/shared.py +91 -0
  133. wandb/integration/sklearn/utils.py +183 -0
  134. wandb/integration/tensorboard/__init__.py +10 -0
  135. wandb/integration/tensorboard/log.py +354 -0
  136. wandb/integration/tensorboard/monkeypatch.py +186 -0
  137. wandb/integration/tensorflow/__init__.py +5 -0
  138. wandb/integration/tensorflow/estimator_hook.py +54 -0
  139. wandb/integration/torch/__init__.py +0 -0
  140. wandb/integration/torch/wandb_torch.py +554 -0
  141. wandb/integration/ultralytics/__init__.py +11 -0
  142. wandb/integration/ultralytics/bbox_utils.py +215 -0
  143. wandb/integration/ultralytics/callback.py +524 -0
  144. wandb/integration/ultralytics/classification_utils.py +83 -0
  145. wandb/integration/ultralytics/mask_utils.py +202 -0
  146. wandb/integration/ultralytics/pose_utils.py +103 -0
  147. wandb/integration/xgboost/__init__.py +11 -0
  148. wandb/integration/xgboost/xgboost.py +189 -0
  149. wandb/integration/yolov8/__init__.py +0 -0
  150. wandb/integration/yolov8/yolov8.py +284 -0
  151. wandb/jupyter.py +513 -0
  152. wandb/mpmain/__init__.py +0 -0
  153. wandb/mpmain/__main__.py +1 -0
  154. wandb/old/__init__.py +0 -0
  155. wandb/old/core.py +53 -0
  156. wandb/old/settings.py +173 -0
  157. wandb/old/summary.py +440 -0
  158. wandb/plot/__init__.py +28 -0
  159. wandb/plot/bar.py +70 -0
  160. wandb/plot/confusion_matrix.py +181 -0
  161. wandb/plot/custom_chart.py +124 -0
  162. wandb/plot/histogram.py +65 -0
  163. wandb/plot/line.py +74 -0
  164. wandb/plot/line_series.py +176 -0
  165. wandb/plot/pr_curve.py +185 -0
  166. wandb/plot/roc_curve.py +163 -0
  167. wandb/plot/scatter.py +66 -0
  168. wandb/plot/utils.py +183 -0
  169. wandb/plot/viz.py +41 -0
  170. wandb/proto/__init__.py +0 -0
  171. wandb/proto/v3/__init__.py +0 -0
  172. wandb/proto/v3/wandb_base_pb2.py +55 -0
  173. wandb/proto/v3/wandb_internal_pb2.py +1658 -0
  174. wandb/proto/v3/wandb_server_pb2.py +228 -0
  175. wandb/proto/v3/wandb_settings_pb2.py +122 -0
  176. wandb/proto/v3/wandb_telemetry_pb2.py +106 -0
  177. wandb/proto/v4/__init__.py +0 -0
  178. wandb/proto/v4/wandb_base_pb2.py +30 -0
  179. wandb/proto/v4/wandb_internal_pb2.py +370 -0
  180. wandb/proto/v4/wandb_server_pb2.py +67 -0
  181. wandb/proto/v4/wandb_settings_pb2.py +47 -0
  182. wandb/proto/v4/wandb_telemetry_pb2.py +41 -0
  183. wandb/proto/v5/wandb_base_pb2.py +31 -0
  184. wandb/proto/v5/wandb_internal_pb2.py +371 -0
  185. wandb/proto/v5/wandb_server_pb2.py +68 -0
  186. wandb/proto/v5/wandb_settings_pb2.py +48 -0
  187. wandb/proto/v5/wandb_telemetry_pb2.py +42 -0
  188. wandb/proto/wandb_base_pb2.py +10 -0
  189. wandb/proto/wandb_deprecated.py +45 -0
  190. wandb/proto/wandb_generate_deprecated.py +30 -0
  191. wandb/proto/wandb_generate_proto.py +49 -0
  192. wandb/proto/wandb_internal_pb2.py +16 -0
  193. wandb/proto/wandb_server_pb2.py +10 -0
  194. wandb/proto/wandb_settings_pb2.py +10 -0
  195. wandb/proto/wandb_telemetry_pb2.py +10 -0
  196. wandb/py.typed +0 -0
  197. wandb/sdk/__init__.py +37 -0
  198. wandb/sdk/artifacts/__init__.py +0 -0
  199. wandb/sdk/artifacts/_validators.py +121 -0
  200. wandb/sdk/artifacts/artifact.py +2364 -0
  201. wandb/sdk/artifacts/artifact_download_logger.py +43 -0
  202. wandb/sdk/artifacts/artifact_file_cache.py +249 -0
  203. wandb/sdk/artifacts/artifact_instance_cache.py +17 -0
  204. wandb/sdk/artifacts/artifact_manifest.py +75 -0
  205. wandb/sdk/artifacts/artifact_manifest_entry.py +249 -0
  206. wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
  207. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +92 -0
  208. wandb/sdk/artifacts/artifact_saver.py +265 -0
  209. wandb/sdk/artifacts/artifact_state.py +11 -0
  210. wandb/sdk/artifacts/artifact_ttl.py +7 -0
  211. wandb/sdk/artifacts/exceptions.py +57 -0
  212. wandb/sdk/artifacts/staging.py +25 -0
  213. wandb/sdk/artifacts/storage_handler.py +62 -0
  214. wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
  215. wandb/sdk/artifacts/storage_handlers/azure_handler.py +213 -0
  216. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +224 -0
  217. wandb/sdk/artifacts/storage_handlers/http_handler.py +114 -0
  218. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +139 -0
  219. wandb/sdk/artifacts/storage_handlers/multi_handler.py +56 -0
  220. wandb/sdk/artifacts/storage_handlers/s3_handler.py +298 -0
  221. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +72 -0
  222. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +135 -0
  223. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +74 -0
  224. wandb/sdk/artifacts/storage_layout.py +6 -0
  225. wandb/sdk/artifacts/storage_policies/__init__.py +4 -0
  226. wandb/sdk/artifacts/storage_policies/register.py +1 -0
  227. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +378 -0
  228. wandb/sdk/artifacts/storage_policy.py +72 -0
  229. wandb/sdk/backend/__init__.py +0 -0
  230. wandb/sdk/backend/backend.py +221 -0
  231. wandb/sdk/data_types/__init__.py +0 -0
  232. wandb/sdk/data_types/_dtypes.py +918 -0
  233. wandb/sdk/data_types/_private.py +10 -0
  234. wandb/sdk/data_types/audio.py +165 -0
  235. wandb/sdk/data_types/base_types/__init__.py +0 -0
  236. wandb/sdk/data_types/base_types/json_metadata.py +55 -0
  237. wandb/sdk/data_types/base_types/media.py +376 -0
  238. wandb/sdk/data_types/base_types/wb_value.py +282 -0
  239. wandb/sdk/data_types/bokeh.py +70 -0
  240. wandb/sdk/data_types/graph.py +405 -0
  241. wandb/sdk/data_types/helper_types/__init__.py +0 -0
  242. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +305 -0
  243. wandb/sdk/data_types/helper_types/classes.py +159 -0
  244. wandb/sdk/data_types/helper_types/image_mask.py +241 -0
  245. wandb/sdk/data_types/histogram.py +94 -0
  246. wandb/sdk/data_types/html.py +115 -0
  247. wandb/sdk/data_types/image.py +847 -0
  248. wandb/sdk/data_types/molecule.py +241 -0
  249. wandb/sdk/data_types/object_3d.py +470 -0
  250. wandb/sdk/data_types/plotly.py +82 -0
  251. wandb/sdk/data_types/saved_model.py +445 -0
  252. wandb/sdk/data_types/table.py +1204 -0
  253. wandb/sdk/data_types/trace_tree.py +438 -0
  254. wandb/sdk/data_types/utils.py +228 -0
  255. wandb/sdk/data_types/video.py +268 -0
  256. wandb/sdk/integration_utils/__init__.py +0 -0
  257. wandb/sdk/integration_utils/auto_logging.py +232 -0
  258. wandb/sdk/integration_utils/data_logging.py +475 -0
  259. wandb/sdk/interface/__init__.py +0 -0
  260. wandb/sdk/interface/constants.py +4 -0
  261. wandb/sdk/interface/interface.py +1010 -0
  262. wandb/sdk/interface/interface_queue.py +53 -0
  263. wandb/sdk/interface/interface_relay.py +53 -0
  264. wandb/sdk/interface/interface_shared.py +546 -0
  265. wandb/sdk/interface/interface_sock.py +61 -0
  266. wandb/sdk/interface/message_future.py +27 -0
  267. wandb/sdk/interface/message_future_poll.py +50 -0
  268. wandb/sdk/interface/router.py +115 -0
  269. wandb/sdk/interface/router_queue.py +41 -0
  270. wandb/sdk/interface/router_relay.py +37 -0
  271. wandb/sdk/interface/router_sock.py +36 -0
  272. wandb/sdk/interface/summary_record.py +67 -0
  273. wandb/sdk/internal/__init__.py +0 -0
  274. wandb/sdk/internal/context.py +89 -0
  275. wandb/sdk/internal/datastore.py +297 -0
  276. wandb/sdk/internal/file_pusher.py +181 -0
  277. wandb/sdk/internal/file_stream.py +695 -0
  278. wandb/sdk/internal/flow_control.py +263 -0
  279. wandb/sdk/internal/handler.py +905 -0
  280. wandb/sdk/internal/internal.py +403 -0
  281. wandb/sdk/internal/internal_api.py +4587 -0
  282. wandb/sdk/internal/internal_util.py +97 -0
  283. wandb/sdk/internal/job_builder.py +638 -0
  284. wandb/sdk/internal/profiler.py +78 -0
  285. wandb/sdk/internal/progress.py +79 -0
  286. wandb/sdk/internal/run.py +25 -0
  287. wandb/sdk/internal/sample.py +70 -0
  288. wandb/sdk/internal/sender.py +1696 -0
  289. wandb/sdk/internal/sender_config.py +197 -0
  290. wandb/sdk/internal/settings_static.py +97 -0
  291. wandb/sdk/internal/system/__init__.py +0 -0
  292. wandb/sdk/internal/system/assets/__init__.py +25 -0
  293. wandb/sdk/internal/system/assets/aggregators.py +37 -0
  294. wandb/sdk/internal/system/assets/asset_registry.py +20 -0
  295. wandb/sdk/internal/system/assets/cpu.py +163 -0
  296. wandb/sdk/internal/system/assets/disk.py +210 -0
  297. wandb/sdk/internal/system/assets/gpu.py +416 -0
  298. wandb/sdk/internal/system/assets/gpu_amd.py +233 -0
  299. wandb/sdk/internal/system/assets/interfaces.py +205 -0
  300. wandb/sdk/internal/system/assets/ipu.py +177 -0
  301. wandb/sdk/internal/system/assets/memory.py +166 -0
  302. wandb/sdk/internal/system/assets/network.py +125 -0
  303. wandb/sdk/internal/system/assets/open_metrics.py +293 -0
  304. wandb/sdk/internal/system/assets/tpu.py +154 -0
  305. wandb/sdk/internal/system/assets/trainium.py +393 -0
  306. wandb/sdk/internal/system/env_probe_helpers.py +13 -0
  307. wandb/sdk/internal/system/system_info.py +250 -0
  308. wandb/sdk/internal/system/system_monitor.py +222 -0
  309. wandb/sdk/internal/tb_watcher.py +519 -0
  310. wandb/sdk/internal/thread_local_settings.py +18 -0
  311. wandb/sdk/internal/writer.py +204 -0
  312. wandb/sdk/launch/__init__.py +15 -0
  313. wandb/sdk/launch/_launch.py +331 -0
  314. wandb/sdk/launch/_launch_add.py +255 -0
  315. wandb/sdk/launch/_project_spec.py +566 -0
  316. wandb/sdk/launch/agent/__init__.py +5 -0
  317. wandb/sdk/launch/agent/agent.py +924 -0
  318. wandb/sdk/launch/agent/config.py +296 -0
  319. wandb/sdk/launch/agent/job_status_tracker.py +53 -0
  320. wandb/sdk/launch/agent/run_queue_item_file_saver.py +39 -0
  321. wandb/sdk/launch/builder/__init__.py +0 -0
  322. wandb/sdk/launch/builder/abstract.py +156 -0
  323. wandb/sdk/launch/builder/build.py +297 -0
  324. wandb/sdk/launch/builder/context_manager.py +235 -0
  325. wandb/sdk/launch/builder/docker_builder.py +177 -0
  326. wandb/sdk/launch/builder/kaniko_builder.py +594 -0
  327. wandb/sdk/launch/builder/noop.py +58 -0
  328. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +188 -0
  329. wandb/sdk/launch/builder/templates/dockerfile.py +92 -0
  330. wandb/sdk/launch/create_job.py +528 -0
  331. wandb/sdk/launch/environment/abstract.py +29 -0
  332. wandb/sdk/launch/environment/aws_environment.py +322 -0
  333. wandb/sdk/launch/environment/azure_environment.py +105 -0
  334. wandb/sdk/launch/environment/gcp_environment.py +335 -0
  335. wandb/sdk/launch/environment/local_environment.py +65 -0
  336. wandb/sdk/launch/errors.py +13 -0
  337. wandb/sdk/launch/git_reference.py +109 -0
  338. wandb/sdk/launch/inputs/files.py +148 -0
  339. wandb/sdk/launch/inputs/internal.py +315 -0
  340. wandb/sdk/launch/inputs/manage.py +113 -0
  341. wandb/sdk/launch/inputs/schema.py +39 -0
  342. wandb/sdk/launch/loader.py +249 -0
  343. wandb/sdk/launch/registry/abstract.py +48 -0
  344. wandb/sdk/launch/registry/anon.py +29 -0
  345. wandb/sdk/launch/registry/azure_container_registry.py +124 -0
  346. wandb/sdk/launch/registry/elastic_container_registry.py +192 -0
  347. wandb/sdk/launch/registry/google_artifact_registry.py +219 -0
  348. wandb/sdk/launch/registry/local_registry.py +65 -0
  349. wandb/sdk/launch/runner/__init__.py +0 -0
  350. wandb/sdk/launch/runner/abstract.py +185 -0
  351. wandb/sdk/launch/runner/kubernetes_monitor.py +472 -0
  352. wandb/sdk/launch/runner/kubernetes_runner.py +963 -0
  353. wandb/sdk/launch/runner/local_container.py +301 -0
  354. wandb/sdk/launch/runner/local_process.py +78 -0
  355. wandb/sdk/launch/runner/sagemaker_runner.py +426 -0
  356. wandb/sdk/launch/runner/vertex_runner.py +230 -0
  357. wandb/sdk/launch/sweeps/__init__.py +37 -0
  358. wandb/sdk/launch/sweeps/scheduler.py +740 -0
  359. wandb/sdk/launch/sweeps/scheduler_sweep.py +90 -0
  360. wandb/sdk/launch/sweeps/utils.py +316 -0
  361. wandb/sdk/launch/utils.py +747 -0
  362. wandb/sdk/launch/wandb_reference.py +138 -0
  363. wandb/sdk/lib/__init__.py +5 -0
  364. wandb/sdk/lib/apikey.py +269 -0
  365. wandb/sdk/lib/capped_dict.py +26 -0
  366. wandb/sdk/lib/config_util.py +101 -0
  367. wandb/sdk/lib/credentials.py +141 -0
  368. wandb/sdk/lib/deprecate.py +42 -0
  369. wandb/sdk/lib/disabled.py +29 -0
  370. wandb/sdk/lib/exit_hooks.py +54 -0
  371. wandb/sdk/lib/file_stream_utils.py +118 -0
  372. wandb/sdk/lib/filenames.py +64 -0
  373. wandb/sdk/lib/filesystem.py +372 -0
  374. wandb/sdk/lib/fsm.py +180 -0
  375. wandb/sdk/lib/gitlib.py +239 -0
  376. wandb/sdk/lib/gql_request.py +65 -0
  377. wandb/sdk/lib/handler_util.py +21 -0
  378. wandb/sdk/lib/hashutil.py +84 -0
  379. wandb/sdk/lib/import_hooks.py +275 -0
  380. wandb/sdk/lib/ipython.py +126 -0
  381. wandb/sdk/lib/json_util.py +80 -0
  382. wandb/sdk/lib/lazyloader.py +63 -0
  383. wandb/sdk/lib/mailbox.py +456 -0
  384. wandb/sdk/lib/module.py +78 -0
  385. wandb/sdk/lib/paths.py +106 -0
  386. wandb/sdk/lib/preinit.py +42 -0
  387. wandb/sdk/lib/printer.py +548 -0
  388. wandb/sdk/lib/progress.py +279 -0
  389. wandb/sdk/lib/proto_util.py +90 -0
  390. wandb/sdk/lib/redirect.py +845 -0
  391. wandb/sdk/lib/retry.py +289 -0
  392. wandb/sdk/lib/run_moment.py +72 -0
  393. wandb/sdk/lib/runid.py +12 -0
  394. wandb/sdk/lib/server.py +38 -0
  395. wandb/sdk/lib/service_connection.py +216 -0
  396. wandb/sdk/lib/service_token.py +94 -0
  397. wandb/sdk/lib/sock_client.py +290 -0
  398. wandb/sdk/lib/sparkline.py +44 -0
  399. wandb/sdk/lib/telemetry.py +100 -0
  400. wandb/sdk/lib/timed_input.py +133 -0
  401. wandb/sdk/lib/timer.py +19 -0
  402. wandb/sdk/service/__init__.py +0 -0
  403. wandb/sdk/service/_startup_debug.py +22 -0
  404. wandb/sdk/service/port_file.py +53 -0
  405. wandb/sdk/service/server.py +107 -0
  406. wandb/sdk/service/server_sock.py +274 -0
  407. wandb/sdk/service/service.py +242 -0
  408. wandb/sdk/service/streams.py +425 -0
  409. wandb/sdk/verify/__init__.py +0 -0
  410. wandb/sdk/verify/verify.py +501 -0
  411. wandb/sdk/wandb_alerts.py +12 -0
  412. wandb/sdk/wandb_config.py +322 -0
  413. wandb/sdk/wandb_helper.py +54 -0
  414. wandb/sdk/wandb_init.py +1313 -0
  415. wandb/sdk/wandb_login.py +339 -0
  416. wandb/sdk/wandb_metric.py +110 -0
  417. wandb/sdk/wandb_require.py +94 -0
  418. wandb/sdk/wandb_require_helpers.py +44 -0
  419. wandb/sdk/wandb_run.py +4066 -0
  420. wandb/sdk/wandb_settings.py +1309 -0
  421. wandb/sdk/wandb_setup.py +402 -0
  422. wandb/sdk/wandb_summary.py +150 -0
  423. wandb/sdk/wandb_sweep.py +119 -0
  424. wandb/sdk/wandb_sync.py +82 -0
  425. wandb/sdk/wandb_watch.py +150 -0
  426. wandb/sklearn.py +35 -0
  427. wandb/sync/__init__.py +3 -0
  428. wandb/sync/sync.py +442 -0
  429. wandb/trigger.py +29 -0
  430. wandb/util.py +1955 -0
  431. wandb/vendor/__init__.py +0 -0
  432. wandb/vendor/gql-0.2.0/setup.py +40 -0
  433. wandb/vendor/gql-0.2.0/tests/__init__.py +0 -0
  434. wandb/vendor/gql-0.2.0/tests/starwars/__init__.py +0 -0
  435. wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py +96 -0
  436. wandb/vendor/gql-0.2.0/tests/starwars/schema.py +146 -0
  437. wandb/vendor/gql-0.2.0/tests/starwars/test_dsl.py +293 -0
  438. wandb/vendor/gql-0.2.0/tests/starwars/test_query.py +355 -0
  439. wandb/vendor/gql-0.2.0/tests/starwars/test_validation.py +171 -0
  440. wandb/vendor/gql-0.2.0/tests/test_client.py +31 -0
  441. wandb/vendor/gql-0.2.0/tests/test_transport.py +89 -0
  442. wandb/vendor/gql-0.2.0/wandb_gql/__init__.py +4 -0
  443. wandb/vendor/gql-0.2.0/wandb_gql/client.py +75 -0
  444. wandb/vendor/gql-0.2.0/wandb_gql/dsl.py +152 -0
  445. wandb/vendor/gql-0.2.0/wandb_gql/gql.py +10 -0
  446. wandb/vendor/gql-0.2.0/wandb_gql/transport/__init__.py +0 -0
  447. wandb/vendor/gql-0.2.0/wandb_gql/transport/http.py +6 -0
  448. wandb/vendor/gql-0.2.0/wandb_gql/transport/local_schema.py +15 -0
  449. wandb/vendor/gql-0.2.0/wandb_gql/transport/requests.py +46 -0
  450. wandb/vendor/gql-0.2.0/wandb_gql/utils.py +21 -0
  451. wandb/vendor/graphql-core-1.1/setup.py +86 -0
  452. wandb/vendor/graphql-core-1.1/wandb_graphql/__init__.py +287 -0
  453. wandb/vendor/graphql-core-1.1/wandb_graphql/error/__init__.py +6 -0
  454. wandb/vendor/graphql-core-1.1/wandb_graphql/error/base.py +42 -0
  455. wandb/vendor/graphql-core-1.1/wandb_graphql/error/format_error.py +11 -0
  456. wandb/vendor/graphql-core-1.1/wandb_graphql/error/located_error.py +29 -0
  457. wandb/vendor/graphql-core-1.1/wandb_graphql/error/syntax_error.py +36 -0
  458. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/__init__.py +26 -0
  459. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/base.py +311 -0
  460. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executor.py +398 -0
  461. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/__init__.py +0 -0
  462. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/asyncio.py +53 -0
  463. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/gevent.py +22 -0
  464. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/process.py +32 -0
  465. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/sync.py +7 -0
  466. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/thread.py +35 -0
  467. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/utils.py +6 -0
  468. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/__init__.py +0 -0
  469. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/executor.py +66 -0
  470. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/fragment.py +252 -0
  471. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/resolver.py +151 -0
  472. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/utils.py +7 -0
  473. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/middleware.py +57 -0
  474. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/values.py +145 -0
  475. wandb/vendor/graphql-core-1.1/wandb_graphql/graphql.py +60 -0
  476. wandb/vendor/graphql-core-1.1/wandb_graphql/language/__init__.py +0 -0
  477. wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py +1349 -0
  478. wandb/vendor/graphql-core-1.1/wandb_graphql/language/base.py +19 -0
  479. wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py +435 -0
  480. wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py +30 -0
  481. wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py +779 -0
  482. wandb/vendor/graphql-core-1.1/wandb_graphql/language/printer.py +193 -0
  483. wandb/vendor/graphql-core-1.1/wandb_graphql/language/source.py +18 -0
  484. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py +222 -0
  485. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor_meta.py +82 -0
  486. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/__init__.py +0 -0
  487. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/cached_property.py +17 -0
  488. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/contain_subset.py +28 -0
  489. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/default_ordered_dict.py +40 -0
  490. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/ordereddict.py +8 -0
  491. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/pair_set.py +43 -0
  492. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/version.py +78 -0
  493. wandb/vendor/graphql-core-1.1/wandb_graphql/type/__init__.py +67 -0
  494. wandb/vendor/graphql-core-1.1/wandb_graphql/type/definition.py +619 -0
  495. wandb/vendor/graphql-core-1.1/wandb_graphql/type/directives.py +132 -0
  496. wandb/vendor/graphql-core-1.1/wandb_graphql/type/introspection.py +440 -0
  497. wandb/vendor/graphql-core-1.1/wandb_graphql/type/scalars.py +131 -0
  498. wandb/vendor/graphql-core-1.1/wandb_graphql/type/schema.py +100 -0
  499. wandb/vendor/graphql-core-1.1/wandb_graphql/type/typemap.py +145 -0
  500. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/__init__.py +0 -0
  501. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/assert_valid_name.py +9 -0
  502. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_from_value.py +65 -0
  503. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_code.py +49 -0
  504. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_dict.py +24 -0
  505. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/base.py +75 -0
  506. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_ast_schema.py +291 -0
  507. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_client_schema.py +250 -0
  508. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/concat_ast.py +9 -0
  509. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/extend_schema.py +357 -0
  510. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_field_def.py +27 -0
  511. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_operation_ast.py +21 -0
  512. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/introspection_query.py +90 -0
  513. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_literal_value.py +67 -0
  514. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_value.py +66 -0
  515. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/quoted_or_list.py +21 -0
  516. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/schema_printer.py +168 -0
  517. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/suggestion_list.py +56 -0
  518. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_comparators.py +69 -0
  519. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_from_ast.py +21 -0
  520. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_info.py +149 -0
  521. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/value_from_ast.py +69 -0
  522. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/__init__.py +4 -0
  523. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/__init__.py +79 -0
  524. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/arguments_of_correct_type.py +24 -0
  525. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/base.py +8 -0
  526. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/default_values_of_correct_type.py +44 -0
  527. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fields_on_correct_type.py +113 -0
  528. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fragments_on_composite_types.py +33 -0
  529. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_argument_names.py +70 -0
  530. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_directives.py +97 -0
  531. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_fragment_names.py +19 -0
  532. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_type_names.py +43 -0
  533. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/lone_anonymous_operation.py +23 -0
  534. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_fragment_cycles.py +59 -0
  535. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_undefined_variables.py +36 -0
  536. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_fragments.py +38 -0
  537. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_variables.py +37 -0
  538. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/overlapping_fields_can_be_merged.py +529 -0
  539. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/possible_fragment_spreads.py +44 -0
  540. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/provided_non_null_arguments.py +46 -0
  541. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/scalar_leafs.py +33 -0
  542. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_argument_names.py +32 -0
  543. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_fragment_names.py +28 -0
  544. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_input_field_names.py +33 -0
  545. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_operation_names.py +31 -0
  546. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_variable_names.py +27 -0
  547. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_are_input_types.py +21 -0
  548. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_in_allowed_position.py +53 -0
  549. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/validation.py +158 -0
  550. wandb/vendor/promise-2.3.0/conftest.py +30 -0
  551. wandb/vendor/promise-2.3.0/setup.py +64 -0
  552. wandb/vendor/promise-2.3.0/tests/__init__.py +0 -0
  553. wandb/vendor/promise-2.3.0/tests/conftest.py +8 -0
  554. wandb/vendor/promise-2.3.0/tests/test_awaitable.py +32 -0
  555. wandb/vendor/promise-2.3.0/tests/test_awaitable_35.py +47 -0
  556. wandb/vendor/promise-2.3.0/tests/test_benchmark.py +116 -0
  557. wandb/vendor/promise-2.3.0/tests/test_complex_threads.py +23 -0
  558. wandb/vendor/promise-2.3.0/tests/test_dataloader.py +452 -0
  559. wandb/vendor/promise-2.3.0/tests/test_dataloader_awaitable_35.py +99 -0
  560. wandb/vendor/promise-2.3.0/tests/test_dataloader_extra.py +65 -0
  561. wandb/vendor/promise-2.3.0/tests/test_extra.py +670 -0
  562. wandb/vendor/promise-2.3.0/tests/test_issues.py +132 -0
  563. wandb/vendor/promise-2.3.0/tests/test_promise_list.py +70 -0
  564. wandb/vendor/promise-2.3.0/tests/test_spec.py +584 -0
  565. wandb/vendor/promise-2.3.0/tests/test_thread_safety.py +115 -0
  566. wandb/vendor/promise-2.3.0/tests/utils.py +3 -0
  567. wandb/vendor/promise-2.3.0/wandb_promise/__init__.py +38 -0
  568. wandb/vendor/promise-2.3.0/wandb_promise/async_.py +135 -0
  569. wandb/vendor/promise-2.3.0/wandb_promise/compat.py +32 -0
  570. wandb/vendor/promise-2.3.0/wandb_promise/dataloader.py +326 -0
  571. wandb/vendor/promise-2.3.0/wandb_promise/iterate_promise.py +12 -0
  572. wandb/vendor/promise-2.3.0/wandb_promise/promise.py +848 -0
  573. wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py +151 -0
  574. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/__init__.py +0 -0
  575. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/version.py +83 -0
  576. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/__init__.py +0 -0
  577. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/asyncio.py +22 -0
  578. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/gevent.py +21 -0
  579. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/immediate.py +27 -0
  580. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/thread.py +18 -0
  581. wandb/vendor/promise-2.3.0/wandb_promise/utils.py +56 -0
  582. wandb/vendor/pygments/__init__.py +90 -0
  583. wandb/vendor/pygments/cmdline.py +568 -0
  584. wandb/vendor/pygments/console.py +74 -0
  585. wandb/vendor/pygments/filter.py +74 -0
  586. wandb/vendor/pygments/filters/__init__.py +350 -0
  587. wandb/vendor/pygments/formatter.py +95 -0
  588. wandb/vendor/pygments/formatters/__init__.py +153 -0
  589. wandb/vendor/pygments/formatters/_mapping.py +85 -0
  590. wandb/vendor/pygments/formatters/bbcode.py +109 -0
  591. wandb/vendor/pygments/formatters/html.py +851 -0
  592. wandb/vendor/pygments/formatters/img.py +600 -0
  593. wandb/vendor/pygments/formatters/irc.py +182 -0
  594. wandb/vendor/pygments/formatters/latex.py +482 -0
  595. wandb/vendor/pygments/formatters/other.py +160 -0
  596. wandb/vendor/pygments/formatters/rtf.py +147 -0
  597. wandb/vendor/pygments/formatters/svg.py +153 -0
  598. wandb/vendor/pygments/formatters/terminal.py +136 -0
  599. wandb/vendor/pygments/formatters/terminal256.py +309 -0
  600. wandb/vendor/pygments/lexer.py +871 -0
  601. wandb/vendor/pygments/lexers/__init__.py +329 -0
  602. wandb/vendor/pygments/lexers/_asy_builtins.py +1645 -0
  603. wandb/vendor/pygments/lexers/_cl_builtins.py +232 -0
  604. wandb/vendor/pygments/lexers/_cocoa_builtins.py +72 -0
  605. wandb/vendor/pygments/lexers/_csound_builtins.py +1346 -0
  606. wandb/vendor/pygments/lexers/_lasso_builtins.py +5327 -0
  607. wandb/vendor/pygments/lexers/_lua_builtins.py +295 -0
  608. wandb/vendor/pygments/lexers/_mapping.py +500 -0
  609. wandb/vendor/pygments/lexers/_mql_builtins.py +1172 -0
  610. wandb/vendor/pygments/lexers/_openedge_builtins.py +2547 -0
  611. wandb/vendor/pygments/lexers/_php_builtins.py +4756 -0
  612. wandb/vendor/pygments/lexers/_postgres_builtins.py +621 -0
  613. wandb/vendor/pygments/lexers/_scilab_builtins.py +3094 -0
  614. wandb/vendor/pygments/lexers/_sourcemod_builtins.py +1163 -0
  615. wandb/vendor/pygments/lexers/_stan_builtins.py +532 -0
  616. wandb/vendor/pygments/lexers/_stata_builtins.py +419 -0
  617. wandb/vendor/pygments/lexers/_tsql_builtins.py +1004 -0
  618. wandb/vendor/pygments/lexers/_vim_builtins.py +1939 -0
  619. wandb/vendor/pygments/lexers/actionscript.py +240 -0
  620. wandb/vendor/pygments/lexers/agile.py +24 -0
  621. wandb/vendor/pygments/lexers/algebra.py +221 -0
  622. wandb/vendor/pygments/lexers/ambient.py +76 -0
  623. wandb/vendor/pygments/lexers/ampl.py +87 -0
  624. wandb/vendor/pygments/lexers/apl.py +101 -0
  625. wandb/vendor/pygments/lexers/archetype.py +318 -0
  626. wandb/vendor/pygments/lexers/asm.py +641 -0
  627. wandb/vendor/pygments/lexers/automation.py +374 -0
  628. wandb/vendor/pygments/lexers/basic.py +500 -0
  629. wandb/vendor/pygments/lexers/bibtex.py +160 -0
  630. wandb/vendor/pygments/lexers/business.py +612 -0
  631. wandb/vendor/pygments/lexers/c_cpp.py +252 -0
  632. wandb/vendor/pygments/lexers/c_like.py +541 -0
  633. wandb/vendor/pygments/lexers/capnproto.py +78 -0
  634. wandb/vendor/pygments/lexers/chapel.py +102 -0
  635. wandb/vendor/pygments/lexers/clean.py +288 -0
  636. wandb/vendor/pygments/lexers/compiled.py +34 -0
  637. wandb/vendor/pygments/lexers/configs.py +833 -0
  638. wandb/vendor/pygments/lexers/console.py +114 -0
  639. wandb/vendor/pygments/lexers/crystal.py +393 -0
  640. wandb/vendor/pygments/lexers/csound.py +366 -0
  641. wandb/vendor/pygments/lexers/css.py +689 -0
  642. wandb/vendor/pygments/lexers/d.py +251 -0
  643. wandb/vendor/pygments/lexers/dalvik.py +125 -0
  644. wandb/vendor/pygments/lexers/data.py +555 -0
  645. wandb/vendor/pygments/lexers/diff.py +165 -0
  646. wandb/vendor/pygments/lexers/dotnet.py +691 -0
  647. wandb/vendor/pygments/lexers/dsls.py +878 -0
  648. wandb/vendor/pygments/lexers/dylan.py +289 -0
  649. wandb/vendor/pygments/lexers/ecl.py +125 -0
  650. wandb/vendor/pygments/lexers/eiffel.py +65 -0
  651. wandb/vendor/pygments/lexers/elm.py +121 -0
  652. wandb/vendor/pygments/lexers/erlang.py +533 -0
  653. wandb/vendor/pygments/lexers/esoteric.py +277 -0
  654. wandb/vendor/pygments/lexers/ezhil.py +69 -0
  655. wandb/vendor/pygments/lexers/factor.py +344 -0
  656. wandb/vendor/pygments/lexers/fantom.py +250 -0
  657. wandb/vendor/pygments/lexers/felix.py +273 -0
  658. wandb/vendor/pygments/lexers/forth.py +177 -0
  659. wandb/vendor/pygments/lexers/fortran.py +205 -0
  660. wandb/vendor/pygments/lexers/foxpro.py +428 -0
  661. wandb/vendor/pygments/lexers/functional.py +21 -0
  662. wandb/vendor/pygments/lexers/go.py +101 -0
  663. wandb/vendor/pygments/lexers/grammar_notation.py +213 -0
  664. wandb/vendor/pygments/lexers/graph.py +80 -0
  665. wandb/vendor/pygments/lexers/graphics.py +553 -0
  666. wandb/vendor/pygments/lexers/haskell.py +843 -0
  667. wandb/vendor/pygments/lexers/haxe.py +936 -0
  668. wandb/vendor/pygments/lexers/hdl.py +382 -0
  669. wandb/vendor/pygments/lexers/hexdump.py +103 -0
  670. wandb/vendor/pygments/lexers/html.py +602 -0
  671. wandb/vendor/pygments/lexers/idl.py +270 -0
  672. wandb/vendor/pygments/lexers/igor.py +288 -0
  673. wandb/vendor/pygments/lexers/inferno.py +96 -0
  674. wandb/vendor/pygments/lexers/installers.py +322 -0
  675. wandb/vendor/pygments/lexers/int_fiction.py +1343 -0
  676. wandb/vendor/pygments/lexers/iolang.py +63 -0
  677. wandb/vendor/pygments/lexers/j.py +146 -0
  678. wandb/vendor/pygments/lexers/javascript.py +1525 -0
  679. wandb/vendor/pygments/lexers/julia.py +333 -0
  680. wandb/vendor/pygments/lexers/jvm.py +1573 -0
  681. wandb/vendor/pygments/lexers/lisp.py +2621 -0
  682. wandb/vendor/pygments/lexers/make.py +202 -0
  683. wandb/vendor/pygments/lexers/markup.py +595 -0
  684. wandb/vendor/pygments/lexers/math.py +21 -0
  685. wandb/vendor/pygments/lexers/matlab.py +663 -0
  686. wandb/vendor/pygments/lexers/ml.py +769 -0
  687. wandb/vendor/pygments/lexers/modeling.py +358 -0
  688. wandb/vendor/pygments/lexers/modula2.py +1561 -0
  689. wandb/vendor/pygments/lexers/monte.py +204 -0
  690. wandb/vendor/pygments/lexers/ncl.py +894 -0
  691. wandb/vendor/pygments/lexers/nimrod.py +159 -0
  692. wandb/vendor/pygments/lexers/nit.py +64 -0
  693. wandb/vendor/pygments/lexers/nix.py +136 -0
  694. wandb/vendor/pygments/lexers/oberon.py +105 -0
  695. wandb/vendor/pygments/lexers/objective.py +504 -0
  696. wandb/vendor/pygments/lexers/ooc.py +85 -0
  697. wandb/vendor/pygments/lexers/other.py +41 -0
  698. wandb/vendor/pygments/lexers/parasail.py +79 -0
  699. wandb/vendor/pygments/lexers/parsers.py +835 -0
  700. wandb/vendor/pygments/lexers/pascal.py +644 -0
  701. wandb/vendor/pygments/lexers/pawn.py +199 -0
  702. wandb/vendor/pygments/lexers/perl.py +620 -0
  703. wandb/vendor/pygments/lexers/php.py +267 -0
  704. wandb/vendor/pygments/lexers/praat.py +294 -0
  705. wandb/vendor/pygments/lexers/prolog.py +306 -0
  706. wandb/vendor/pygments/lexers/python.py +939 -0
  707. wandb/vendor/pygments/lexers/qvt.py +152 -0
  708. wandb/vendor/pygments/lexers/r.py +453 -0
  709. wandb/vendor/pygments/lexers/rdf.py +270 -0
  710. wandb/vendor/pygments/lexers/rebol.py +431 -0
  711. wandb/vendor/pygments/lexers/resource.py +85 -0
  712. wandb/vendor/pygments/lexers/rnc.py +67 -0
  713. wandb/vendor/pygments/lexers/roboconf.py +82 -0
  714. wandb/vendor/pygments/lexers/robotframework.py +560 -0
  715. wandb/vendor/pygments/lexers/ruby.py +519 -0
  716. wandb/vendor/pygments/lexers/rust.py +220 -0
  717. wandb/vendor/pygments/lexers/sas.py +228 -0
  718. wandb/vendor/pygments/lexers/scripting.py +1222 -0
  719. wandb/vendor/pygments/lexers/shell.py +794 -0
  720. wandb/vendor/pygments/lexers/smalltalk.py +195 -0
  721. wandb/vendor/pygments/lexers/smv.py +79 -0
  722. wandb/vendor/pygments/lexers/snobol.py +83 -0
  723. wandb/vendor/pygments/lexers/special.py +103 -0
  724. wandb/vendor/pygments/lexers/sql.py +681 -0
  725. wandb/vendor/pygments/lexers/stata.py +108 -0
  726. wandb/vendor/pygments/lexers/supercollider.py +90 -0
  727. wandb/vendor/pygments/lexers/tcl.py +145 -0
  728. wandb/vendor/pygments/lexers/templates.py +2283 -0
  729. wandb/vendor/pygments/lexers/testing.py +207 -0
  730. wandb/vendor/pygments/lexers/text.py +25 -0
  731. wandb/vendor/pygments/lexers/textedit.py +169 -0
  732. wandb/vendor/pygments/lexers/textfmts.py +297 -0
  733. wandb/vendor/pygments/lexers/theorem.py +458 -0
  734. wandb/vendor/pygments/lexers/trafficscript.py +54 -0
  735. wandb/vendor/pygments/lexers/typoscript.py +226 -0
  736. wandb/vendor/pygments/lexers/urbi.py +133 -0
  737. wandb/vendor/pygments/lexers/varnish.py +190 -0
  738. wandb/vendor/pygments/lexers/verification.py +111 -0
  739. wandb/vendor/pygments/lexers/web.py +24 -0
  740. wandb/vendor/pygments/lexers/webmisc.py +988 -0
  741. wandb/vendor/pygments/lexers/whiley.py +116 -0
  742. wandb/vendor/pygments/lexers/x10.py +69 -0
  743. wandb/vendor/pygments/modeline.py +44 -0
  744. wandb/vendor/pygments/plugin.py +68 -0
  745. wandb/vendor/pygments/regexopt.py +92 -0
  746. wandb/vendor/pygments/scanner.py +105 -0
  747. wandb/vendor/pygments/sphinxext.py +158 -0
  748. wandb/vendor/pygments/style.py +155 -0
  749. wandb/vendor/pygments/styles/__init__.py +80 -0
  750. wandb/vendor/pygments/styles/abap.py +29 -0
  751. wandb/vendor/pygments/styles/algol.py +63 -0
  752. wandb/vendor/pygments/styles/algol_nu.py +63 -0
  753. wandb/vendor/pygments/styles/arduino.py +98 -0
  754. wandb/vendor/pygments/styles/autumn.py +65 -0
  755. wandb/vendor/pygments/styles/borland.py +51 -0
  756. wandb/vendor/pygments/styles/bw.py +49 -0
  757. wandb/vendor/pygments/styles/colorful.py +81 -0
  758. wandb/vendor/pygments/styles/default.py +73 -0
  759. wandb/vendor/pygments/styles/emacs.py +72 -0
  760. wandb/vendor/pygments/styles/friendly.py +72 -0
  761. wandb/vendor/pygments/styles/fruity.py +42 -0
  762. wandb/vendor/pygments/styles/igor.py +29 -0
  763. wandb/vendor/pygments/styles/lovelace.py +97 -0
  764. wandb/vendor/pygments/styles/manni.py +75 -0
  765. wandb/vendor/pygments/styles/monokai.py +106 -0
  766. wandb/vendor/pygments/styles/murphy.py +80 -0
  767. wandb/vendor/pygments/styles/native.py +65 -0
  768. wandb/vendor/pygments/styles/paraiso_dark.py +125 -0
  769. wandb/vendor/pygments/styles/paraiso_light.py +125 -0
  770. wandb/vendor/pygments/styles/pastie.py +75 -0
  771. wandb/vendor/pygments/styles/perldoc.py +69 -0
  772. wandb/vendor/pygments/styles/rainbow_dash.py +89 -0
  773. wandb/vendor/pygments/styles/rrt.py +33 -0
  774. wandb/vendor/pygments/styles/sas.py +44 -0
  775. wandb/vendor/pygments/styles/stata.py +40 -0
  776. wandb/vendor/pygments/styles/tango.py +141 -0
  777. wandb/vendor/pygments/styles/trac.py +63 -0
  778. wandb/vendor/pygments/styles/vim.py +63 -0
  779. wandb/vendor/pygments/styles/vs.py +38 -0
  780. wandb/vendor/pygments/styles/xcode.py +51 -0
  781. wandb/vendor/pygments/token.py +213 -0
  782. wandb/vendor/pygments/unistring.py +217 -0
  783. wandb/vendor/pygments/util.py +388 -0
  784. wandb/vendor/pynvml/__init__.py +0 -0
  785. wandb/vendor/pynvml/pynvml.py +4779 -0
  786. wandb/vendor/watchdog_0_9_0/wandb_watchdog/__init__.py +17 -0
  787. wandb/vendor/watchdog_0_9_0/wandb_watchdog/events.py +615 -0
  788. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/__init__.py +98 -0
  789. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/api.py +369 -0
  790. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents.py +172 -0
  791. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents2.py +239 -0
  792. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify.py +218 -0
  793. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_buffer.py +81 -0
  794. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_c.py +575 -0
  795. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/kqueue.py +730 -0
  796. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/polling.py +145 -0
  797. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/read_directory_changes.py +133 -0
  798. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/winapi.py +348 -0
  799. wandb/vendor/watchdog_0_9_0/wandb_watchdog/patterns.py +265 -0
  800. wandb/vendor/watchdog_0_9_0/wandb_watchdog/tricks/__init__.py +174 -0
  801. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/__init__.py +151 -0
  802. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/bricks.py +249 -0
  803. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/compat.py +29 -0
  804. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/decorators.py +198 -0
  805. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/delayed_queue.py +88 -0
  806. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/dirsnapshot.py +293 -0
  807. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/echo.py +157 -0
  808. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/event_backport.py +41 -0
  809. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/importlib2.py +40 -0
  810. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/platform.py +57 -0
  811. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/unicode_paths.py +64 -0
  812. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/win32stat.py +123 -0
  813. wandb/vendor/watchdog_0_9_0/wandb_watchdog/version.py +28 -0
  814. wandb/vendor/watchdog_0_9_0/wandb_watchdog/watchmedo.py +577 -0
  815. wandb/wandb_agent.py +588 -0
  816. wandb/wandb_controller.py +719 -0
  817. wandb/wandb_run.py +9 -0
  818. wandb-0.19.1.dist-info/METADATA +223 -0
  819. wandb-0.19.1.dist-info/RECORD +822 -0
  820. wandb-0.19.1.dist-info/WHEEL +5 -0
  821. wandb-0.19.1.dist-info/entry_points.txt +3 -0
  822. wandb-0.19.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,1309 @@
1
+ from __future__ import annotations
2
+
3
+ import configparser
4
+ import json
5
+ import logging
6
+ import multiprocessing
7
+ import os
8
+ import pathlib
9
+ import platform
10
+ import re
11
+ import shutil
12
+ import socket
13
+ import sys
14
+ import tempfile
15
+ from datetime import datetime
16
+ from typing import Any, Literal, Sequence
17
+ from urllib.parse import quote, unquote, urlencode
18
+
19
+ if sys.version_info >= (3, 11):
20
+ from typing import Self
21
+ else:
22
+ from typing_extensions import Self
23
+
24
+ from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue, Int32Value, StringValue
25
+ from pydantic import (
26
+ BaseModel,
27
+ ConfigDict,
28
+ Field,
29
+ computed_field,
30
+ field_validator,
31
+ model_validator,
32
+ )
33
+ from pydantic_core import SchemaValidator, core_schema
34
+
35
+ import wandb
36
+ from wandb import env, termwarn, util
37
+ from wandb.apis.internal import Api
38
+ from wandb.errors import UsageError
39
+ from wandb.proto import wandb_settings_pb2
40
+
41
+ from .lib import apikey, credentials, filesystem, ipython
42
+ from .lib.gitlib import GitRepo
43
+ from .lib.run_moment import RunMoment
44
+ from .lib.runid import generate_id
45
+
46
+
47
+ def _path_convert(*args: str) -> str:
48
+ """Join path and apply os.path.expanduser to it."""
49
+ return os.path.expanduser(os.path.join(*args))
50
+
51
+
52
+ class Settings(BaseModel, validate_assignment=True):
53
+ """Settings for the W&B SDK."""
54
+
55
+ # Pydantic configuration.
56
+ model_config = ConfigDict(
57
+ extra="forbid", # throw an error if extra fields are provided
58
+ # validate_default=True, # validate default values
59
+ )
60
+
61
+ # Public settings.
62
+
63
+ # Flag to allow table artifacts to be synced in offline mode.
64
+ #
65
+ # To revert to the old behavior, set this to False.
66
+ allow_offline_artifacts: bool = True
67
+ allow_val_change: bool = False
68
+ # Controls anonymous data logging. Possible values are:
69
+ # - "never": requires you to link your W&B account before
70
+ # tracking the run, so you don't accidentally create an anonymous
71
+ # run.
72
+ # - "allow": lets a logged-in user track runs with their account, but
73
+ # lets someone who is running the script without a W&B account see
74
+ # the charts in the UI.
75
+ # - "must": sends the run to an anonymous account instead of to a
76
+ # signed-up user account.
77
+ anonymous: Literal["allow", "must", "never"] | None = None
78
+ # The W&B API key.
79
+ api_key: str | None = None
80
+ azure_account_url_to_access_key: dict[str, str] | None = None
81
+ # The URL of the W&B backend, used for GraphQL and filestream operations.
82
+ base_url: str = "https://api.wandb.ai"
83
+ code_dir: str | None = None
84
+ config_paths: Sequence[str] | None = None
85
+ # The type of console capture to be applied. Possible values are:
86
+ # "auto" - Automatically selects the console capture method based on the
87
+ # system environment and settings.
88
+ #
89
+ # "off" - Disables console capture.
90
+ #
91
+ # "redirect" - Redirects low-level file descriptors for capturing output.
92
+ #
93
+ # "wrap" - Overrides the write methods of sys.stdout/sys.stderr. Will be
94
+ # mapped to either "wrap_raw" or "wrap_emu" based on the state of the system.
95
+ #
96
+ # "wrap_raw" - Same as "wrap" but captures raw output directly instead of
97
+ # through an emulator.
98
+ #
99
+ # "wrap_emu" - Same as "wrap" but captures output through an emulator.
100
+ console: Literal["auto", "off", "wrap", "redirect", "wrap_raw", "wrap_emu"] = Field(
101
+ default="auto",
102
+ validate_default=True,
103
+ )
104
+ # Whether to produce multipart console log files.
105
+ console_multipart: bool = False
106
+ # Path to file for writing temporary access tokens.
107
+ credentials_file: str = Field(
108
+ default_factory=lambda: str(credentials.DEFAULT_WANDB_CREDENTIALS_FILE)
109
+ )
110
+ # Whether to disable code saving.
111
+ disable_code: bool = False
112
+ # Whether to disable capturing the git state.
113
+ disable_git: bool = False
114
+ # Whether to disable the creation of a job artifact for W&B Launch.
115
+ disable_job_creation: bool = True
116
+ # The Docker image used to execute the script.
117
+ docker: str | None = None
118
+ # The email address of the user.
119
+ email: str | None = None
120
+ # The W&B entity, like a user or a team.
121
+ entity: str | None = None
122
+ force: bool = False
123
+ fork_from: RunMoment | None = None
124
+ git_commit: str | None = None
125
+ git_remote: str = "origin"
126
+ git_remote_url: str | None = None
127
+ git_root: str | None = None
128
+ heartbeat_seconds: int = 30
129
+ host: str | None = None
130
+ # The custom proxy servers for http requests to W&B.
131
+ http_proxy: str | None = None
132
+ # The custom proxy servers for https requests to W&B.
133
+ https_proxy: str | None = None
134
+ # Path to file containing an identity token (JWT) for authentication.
135
+ identity_token_file: str | None = None
136
+ # Unix glob patterns relative to `files_dir` to not upload.
137
+ ignore_globs: tuple[str, ...] = ()
138
+ # Time in seconds to wait for the wandb.init call to complete before timing out.
139
+ init_timeout: float = 90.0
140
+ # Whether to insecurely disable SSL verification.
141
+ insecure_disable_ssl: bool = False
142
+ job_name: str | None = None
143
+ job_source: Literal["repo", "artifact", "image"] | None = None
144
+ label_disable: bool = False
145
+ launch: bool = False
146
+ launch_config_path: str | None = None
147
+ login_timeout: float | None = None
148
+ mode: Literal["online", "offline", "dryrun", "disabled", "run", "shared"] = Field(
149
+ default="online",
150
+ validate_default=True,
151
+ )
152
+ notebook_name: str | None = None
153
+ # Path to the script that created the run, if available.
154
+ program: str | None = None
155
+ # The absolute path from the root repository directory to the script that
156
+ # created the run.
157
+ #
158
+ # Root repository directory is defined as the directory containing the
159
+ # .git directory, if it exists. Otherwise, it's the current working directory.
160
+ program_abspath: str | None = None
161
+ program_relpath: str | None = None
162
+ # The W&B project ID.
163
+ project: str | None = None
164
+ quiet: bool = False
165
+ reinit: bool = False
166
+ relogin: bool = False
167
+ # Specifies the resume behavior for the run. The available options are:
168
+ #
169
+ # "must": Resumes from an existing run with the same ID. If no such run exists,
170
+ # it will result in failure.
171
+ #
172
+ # "allow": Attempts to resume from an existing run with the same ID. If none is
173
+ # found, a new run will be created.
174
+ #
175
+ # "never": Always starts a new run. If a run with the same ID already exists,
176
+ # it will result in failure.
177
+ #
178
+ # "auto": Automatically resumes from the most recent failed run on the same
179
+ # machine.
180
+ resume: Literal["allow", "must", "never", "auto"] | None = None
181
+ resume_from: RunMoment | None = None
182
+ # Indication from the server about the state of the run.
183
+ #
184
+ # This is different from resume, a user provided flag.
185
+ resumed: bool = False
186
+ # The root directory that will be used to derive other paths,
187
+ # such as the wandb directory, and the run directory.
188
+ root_dir: str = Field(default_factory=lambda: os.path.abspath(os.getcwd()))
189
+ run_group: str | None = None
190
+ # The ID of the run.
191
+ run_id: str | None = None
192
+ run_job_type: str | None = None
193
+ run_name: str | None = None
194
+ run_notes: str | None = None
195
+ run_tags: tuple[str, ...] | None = None
196
+ sagemaker_disable: bool = False
197
+ save_code: bool | None = None
198
+ settings_system: str = Field(
199
+ default_factory=lambda: _path_convert(
200
+ os.path.join("~", ".config", "wandb", "settings")
201
+ )
202
+ )
203
+ show_colors: bool | None = None
204
+ show_emoji: bool | None = None
205
+ show_errors: bool = True
206
+ show_info: bool = True
207
+ show_warnings: bool = True
208
+ silent: bool = False
209
+ start_method: str | None = None
210
+ strict: bool | None = None
211
+ summary_timeout: int = 60
212
+ summary_warnings: int = 5 # TODO: kill this with fire
213
+ sweep_id: str | None = None
214
+ sweep_param_path: str | None = None
215
+ symlink: bool = Field(
216
+ default_factory=lambda: False if platform.system() == "Windows" else True
217
+ )
218
+ sync_tensorboard: bool | None = None
219
+ table_raise_on_max_row_limit_exceeded: bool = False
220
+ username: str | None = None
221
+
222
+ # Internal settings.
223
+ #
224
+ # These are typically not meant to be set by the user and should not be considered
225
+ # a part of the public API as they may change or be removed in future versions.
226
+
227
+ # CLI mode.
228
+ x_cli_only_mode: bool = False
229
+ # Disable the collection of system metadata.
230
+ x_disable_meta: bool = False
231
+ # Pre-wandb-core, this setting was used to disable the (now legacy) wandb service.
232
+ #
233
+ # TODO: this is deprecated and will be removed in future versions.
234
+ x_disable_service: bool = False
235
+ # Do not use setproctitle for internal process in legacy service.
236
+ x_disable_setproctitle: bool = False
237
+ # Disable system metrics collection.
238
+ x_disable_stats: bool = False
239
+ # Disable check for latest version of wandb, from PyPI.
240
+ x_disable_update_check: bool = False
241
+ # Prevent early viewer query.
242
+ x_disable_viewer: bool = False
243
+ # Disable automatic machine info collection.
244
+ x_disable_machine_info: bool = False
245
+ # Python executable
246
+ x_executable: str | None = None
247
+ # Additional headers to add to all outgoing HTTP requests.
248
+ x_extra_http_headers: dict[str, str] | None = None
249
+ # An approximate maximum request size for the filestream API.
250
+ #
251
+ # This applies when wandb-core is enabled. Its purpose is to prevent
252
+ # HTTP requests from failing due to containing too much data.
253
+ #
254
+ # This number is approximate: requests will be slightly larger.
255
+ x_file_stream_max_bytes: int | None = None
256
+ # Max line length for filestream jsonl files.
257
+ x_file_stream_max_line_bytes: int | None = None
258
+ # Interval in seconds between filestream transmissions.
259
+ x_file_stream_transmit_interval: float | None = None
260
+ # Filestream retry client configuration.
261
+ # max number of retries
262
+ x_file_stream_retry_max: int | None = None
263
+ # min wait time between retries
264
+ x_file_stream_retry_wait_min_seconds: float | None = None
265
+ # max wait time between retries
266
+ x_file_stream_retry_wait_max_seconds: float | None = None
267
+ # timeout for individual HTTP requests
268
+ x_file_stream_timeout_seconds: float | None = None
269
+ # file transfer retry client configuration
270
+ x_file_transfer_retry_max: int | None = None
271
+ x_file_transfer_retry_wait_min_seconds: float | None = None
272
+ x_file_transfer_retry_wait_max_seconds: float | None = None
273
+ x_file_transfer_timeout_seconds: float | None = None
274
+ # override setting for the computed files_dir
275
+ x_files_dir: str | None = None
276
+ # flow control configuration for file stream
277
+ x_flow_control_custom: bool | None = None
278
+ x_flow_control_disabled: bool | None = None
279
+ # graphql retry client configuration
280
+ x_graphql_retry_max: int | None = None
281
+ x_graphql_retry_wait_min_seconds: float | None = None
282
+ x_graphql_retry_wait_max_seconds: float | None = None
283
+ x_graphql_timeout_seconds: float | None = None
284
+ x_internal_check_process: float = 8.0
285
+ x_jupyter_name: str | None = None
286
+ x_jupyter_path: str | None = None
287
+ x_jupyter_root: str | None = None
288
+ # Label to assign to system metrics and console logs collected for the run
289
+ # to group by on the frontend. Can be used to distinguish data from different
290
+ # nodes in a distributed training job.
291
+ x_label: str | None = None
292
+ x_live_policy_rate_limit: int | None = None
293
+ x_live_policy_wait_time: int | None = None
294
+ x_log_level: int = logging.INFO
295
+ x_network_buffer: int | None = None
296
+ # Determines whether to save internal wandb files and metadata.
297
+ # In a distributed setting, this is useful for avoiding file overwrites on secondary nodes
298
+ # when only system metrics and logs are needed, as the primary node handles the main logging.
299
+ x_primary_node: bool = True
300
+ # [deprecated, use http(s)_proxy] custom proxy servers for the requests to W&B
301
+ # [scheme -> url].
302
+ x_proxies: dict[str, str] | None = None
303
+ x_runqueue_item_id: str | None = None
304
+ x_require_legacy_service: bool = False
305
+ x_save_requirements: bool = True
306
+ x_service_transport: str | None = None
307
+ x_service_wait: float = 30.0
308
+ x_show_operation_stats: bool = True
309
+ # The start time of the run in seconds since the Unix epoch.
310
+ x_start_time: float | None = None
311
+ # PID of the process that started the wandb-core process to collect system stats for.
312
+ x_stats_pid: int = os.getpid()
313
+ # Sampling interval for the system monitor in seconds.
314
+ x_stats_sampling_interval: float = Field(default=10.0)
315
+ # Path to store the default config file for the neuron-monitor tool
316
+ # used to monitor AWS Trainium devices.
317
+ x_stats_neuron_monitor_config_path: str | None = None
318
+ # Open metrics endpoint names and urls.
319
+ x_stats_open_metrics_endpoints: dict[str, str] | None = None
320
+ # Filter to apply to metrics collected from OpenMetrics endpoints.
321
+ # Supports two formats:
322
+ # - {"metric regex pattern, including endpoint name as prefix": {"label": "label value regex pattern"}}
323
+ # - ("metric regex pattern 1", "metric regex pattern 2", ...)
324
+ x_stats_open_metrics_filters: dict[str, dict[str, str]] | Sequence[str] | None = (
325
+ None
326
+ )
327
+ # HTTP headers to add to OpenMetrics requests.
328
+ x_stats_open_metrics_http_headers: dict[str, str] | None = None
329
+ # System paths to monitor for disk usage.
330
+ x_stats_disk_paths: Sequence[str] | None = Field(
331
+ default_factory=lambda: ("/", "/System/Volumes/Data")
332
+ if platform.system() == "Darwin"
333
+ else ("/",)
334
+ )
335
+ # GPU device indices to monitor (e.g. [0, 1, 2]).
336
+ # If not set, captures metrics for all GPUs.
337
+ # Assumes 0-based indexing matching CUDA/ROCm device enumeration.
338
+ x_stats_gpu_device_ids: Sequence[int] | None = None
339
+ # Number of system metric samples to buffer in memory in the wandb-core process.
340
+ # Can be accessed via run._system_metrics.
341
+ x_stats_buffer_size: int = 0
342
+ # Flag to indicate whether we are syncing a run from the transaction log.
343
+ x_sync: bool = False
344
+ # Controls whether this process can update the run's final state (finished/failed) on the server.
345
+ # Set to False in distributed training when only the main process should determine the final state.
346
+ x_update_finish_state: bool = True
347
+
348
+ # Model validator to catch legacy settings.
349
+ @model_validator(mode="before")
350
+ @classmethod
351
+ def catch_private_settings(cls, values):
352
+ """Check if a private field is provided and assign to the corrsponding public one.
353
+
354
+ This is a compatibility layer to handle previous versions of the settings.
355
+ """
356
+ new_values = {}
357
+ for key in values:
358
+ # Internal settings are prefixed with "x_" instead of "_"
359
+ # as Pydantic does not allow "_" in field names.
360
+ if key.startswith("_"):
361
+ new_values["x" + key] = values[key]
362
+ else:
363
+ new_values[key] = values[key]
364
+ return new_values
365
+
366
+ @model_validator(mode="after")
367
+ def validate_mutual_exclusion_of_branching_args(self) -> Self:
368
+ if (
369
+ sum(
370
+ o is not None
371
+ for o in [
372
+ self.fork_from,
373
+ self.resume,
374
+ self.resume_from,
375
+ ]
376
+ )
377
+ > 1
378
+ ):
379
+ raise ValueError(
380
+ "`fork_from`, `resume`, or `resume_from` are mutually exclusive. "
381
+ "Please specify only one of them."
382
+ )
383
+ return self
384
+
385
+ # Field validators.
386
+
387
+ @field_validator("x_disable_service", mode="after")
388
+ @classmethod
389
+ def validate_disable_service(cls, value):
390
+ if value:
391
+ termwarn(
392
+ "Disabling the wandb service is deprecated as of version 0.18.0 "
393
+ "and will be removed in future versions. ",
394
+ repeat=False,
395
+ )
396
+ return value
397
+
398
+ @field_validator("api_key", mode="after")
399
+ @classmethod
400
+ def validate_api_key(cls, value):
401
+ if value is not None and (len(value) > len(value.strip())):
402
+ raise UsageError("API key cannot start or end with whitespace")
403
+ return value
404
+
405
+ @field_validator("base_url", mode="after")
406
+ @classmethod
407
+ def validate_base_url(cls, value):
408
+ cls.validate_url(value)
409
+ # wandb.ai-specific checks
410
+ if re.match(r".*wandb\.ai[^\.]*$", value) and "api." not in value:
411
+ # user might guess app.wandb.ai or wandb.ai is the default cloud server
412
+ raise ValueError(
413
+ f"{value} is not a valid server address, did you mean https://api.wandb.ai?"
414
+ )
415
+ elif re.match(r".*wandb\.ai[^\.]*$", value) and not value.startswith("https"):
416
+ raise ValueError("http is not secure, please use https://api.wandb.ai")
417
+ return value.rstrip("/")
418
+
419
+ @field_validator("code_dir", mode="before")
420
+ @classmethod
421
+ def validate_code_dir(cls, value):
422
+ # TODO: add native support for pathlib.Path
423
+ if isinstance(value, pathlib.Path):
424
+ return str(value)
425
+ return value
426
+
427
+ @field_validator("console", mode="after")
428
+ @classmethod
429
+ def validate_console(cls, value, info):
430
+ if value != "auto":
431
+ return value
432
+ if (
433
+ ipython.in_jupyter()
434
+ or (info.data.get("start_method") == "thread")
435
+ or not info.data.get("disable_service")
436
+ or platform.system() == "Windows"
437
+ ):
438
+ value = "wrap"
439
+ else:
440
+ value = "redirect"
441
+ return value
442
+
443
+ @field_validator("x_executable", mode="before")
444
+ @classmethod
445
+ def validate_x_executable(cls, value):
446
+ # TODO: add native support for pathlib.Path
447
+ if isinstance(value, pathlib.Path):
448
+ return str(value)
449
+ return value
450
+
451
+ @field_validator("x_file_stream_max_line_bytes", mode="after")
452
+ @classmethod
453
+ def validate_file_stream_max_line_bytes(cls, value):
454
+ if value is not None and value < 1:
455
+ raise ValueError("File stream max line bytes must be greater than 0")
456
+ return value
457
+
458
+ @field_validator("x_files_dir", mode="before")
459
+ @classmethod
460
+ def validate_x_files_dir(cls, value):
461
+ # TODO: add native support for pathlib.Path
462
+ if isinstance(value, pathlib.Path):
463
+ return str(value)
464
+ return value
465
+
466
+ @field_validator("fork_from", mode="before")
467
+ @classmethod
468
+ def validate_fork_from(cls, value, info) -> RunMoment | None:
469
+ run_moment = cls._runmoment_preprocessor(value)
470
+ if run_moment and info.data.get("run_id") == run_moment.run:
471
+ raise ValueError(
472
+ "Provided `run_id` is the same as the run to `fork_from`. "
473
+ "Please provide a different `run_id` or remove the `run_id` argument. "
474
+ "If you want to rewind the current run, please use `resume_from` instead."
475
+ )
476
+ return run_moment
477
+
478
+ @field_validator("http_proxy", mode="after")
479
+ @classmethod
480
+ def validate_http_proxy(cls, value):
481
+ if value is None:
482
+ return None
483
+ cls.validate_url(value)
484
+ return value.rstrip("/")
485
+
486
+ @field_validator("https_proxy", mode="after")
487
+ @classmethod
488
+ def validate_https_proxy(cls, value):
489
+ if value is None:
490
+ return None
491
+ cls.validate_url(value)
492
+ return value.rstrip("/")
493
+
494
+ @field_validator("ignore_globs", mode="after")
495
+ @classmethod
496
+ def validate_ignore_globs(cls, value):
497
+ return tuple(value) if not isinstance(value, tuple) else value
498
+
499
+ @field_validator("program", mode="before")
500
+ @classmethod
501
+ def validate_program(cls, value):
502
+ # TODO: add native support for pathlib.Path
503
+ if isinstance(value, pathlib.Path):
504
+ return str(value)
505
+ return value
506
+
507
+ @field_validator("program_abspath", mode="before")
508
+ @classmethod
509
+ def validate_program_abspath(cls, value):
510
+ # TODO: add native support for pathlib.Path
511
+ if isinstance(value, pathlib.Path):
512
+ return str(value)
513
+ return value
514
+
515
+ @field_validator("program_relpath", mode="before")
516
+ @classmethod
517
+ def validate_program_relpath(cls, value):
518
+ # TODO: add native support for pathlib.Path
519
+ if isinstance(value, pathlib.Path):
520
+ return str(value)
521
+ return value
522
+
523
+ @field_validator("project", mode="after")
524
+ @classmethod
525
+ def validate_project(cls, value, info):
526
+ if value is None:
527
+ return None
528
+ invalid_chars_list = list("/\\#?%:")
529
+ if len(value) > 128:
530
+ raise UsageError(f"Invalid project name {value!r}: exceeded 128 characters")
531
+ invalid_chars = {char for char in invalid_chars_list if char in value}
532
+ if invalid_chars:
533
+ raise UsageError(
534
+ f"Invalid project name {value!r}: "
535
+ f"cannot contain characters {','.join(invalid_chars_list)!r}, "
536
+ f"found {','.join(invalid_chars)!r}"
537
+ )
538
+ return value
539
+
540
+ @field_validator("resume", mode="before")
541
+ @classmethod
542
+ def validate_resume(cls, value):
543
+ if value is False:
544
+ return None
545
+ if value is True:
546
+ return "auto"
547
+ return value
548
+
549
+ @field_validator("resume_from", mode="before")
550
+ @classmethod
551
+ def validate_resume_from(cls, value, info) -> RunMoment | None:
552
+ run_moment = cls._runmoment_preprocessor(value)
553
+ if run_moment and info.data.get("run_id") != run_moment.run:
554
+ raise ValueError(
555
+ "Both `run_id` and `resume_from` have been specified with different ids."
556
+ )
557
+ return run_moment
558
+
559
+ @field_validator("root_dir", mode="before")
560
+ @classmethod
561
+ def validate_root_dir(cls, value):
562
+ # TODO: add native support for pathlib.Path
563
+ if isinstance(value, pathlib.Path):
564
+ return str(value)
565
+ return value
566
+
567
+ @field_validator("run_id", mode="after")
568
+ @classmethod
569
+ def validate_run_id(cls, value, info):
570
+ if value is None:
571
+ return None
572
+
573
+ if len(value) == 0:
574
+ raise UsageError("Run ID cannot be empty")
575
+ if len(value) > len(value.strip()):
576
+ raise UsageError("Run ID cannot start or end with whitespace")
577
+ if not bool(value.strip()):
578
+ raise UsageError("Run ID cannot contain only whitespace")
579
+ return value
580
+
581
+ @field_validator("settings_system", mode="after")
582
+ @classmethod
583
+ def validate_settings_system(cls, value):
584
+ if isinstance(value, pathlib.Path):
585
+ return str(_path_convert(value))
586
+ return _path_convert(value)
587
+
588
+ @field_validator("x_service_wait", mode="after")
589
+ @classmethod
590
+ def validate_service_wait(cls, value):
591
+ if value < 0:
592
+ raise UsageError("Service wait time cannot be negative")
593
+ return value
594
+
595
+ @field_validator("start_method")
596
+ @classmethod
597
+ def validate_start_method(cls, value):
598
+ if value is None:
599
+ return value
600
+ available_methods = ["thread"]
601
+ if hasattr(multiprocessing, "get_all_start_methods"):
602
+ available_methods += multiprocessing.get_all_start_methods()
603
+ if value not in available_methods:
604
+ raise UsageError(
605
+ f"Settings field `start_method`: {value!r} not in {available_methods}"
606
+ )
607
+ return value
608
+
609
+ @field_validator("x_stats_gpu_device_ids", mode="before")
610
+ @classmethod
611
+ def validate_x_stats_gpu_device_ids(cls, value):
612
+ if isinstance(value, str):
613
+ return json.loads(value)
614
+ return value
615
+
616
+ @field_validator("x_stats_neuron_monitor_config_path", mode="before")
617
+ @classmethod
618
+ def validate_x_stats_neuron_monitor_config_path(cls, value):
619
+ # TODO: add native support for pathlib.Path
620
+ if isinstance(value, pathlib.Path):
621
+ return str(value)
622
+ return value
623
+
624
+ @field_validator("x_stats_open_metrics_endpoints", mode="before")
625
+ @classmethod
626
+ def validate_stats_open_metrics_endpoints(cls, value):
627
+ if isinstance(value, str):
628
+ return json.loads(value)
629
+ return value
630
+
631
+ @field_validator("x_stats_open_metrics_filters", mode="before")
632
+ @classmethod
633
+ def validate_stats_open_metrics_filters(cls, value):
634
+ if isinstance(value, str):
635
+ return json.loads(value)
636
+ return value
637
+
638
+ @field_validator("x_stats_open_metrics_http_headers", mode="before")
639
+ @classmethod
640
+ def validate_stats_open_metrics_http_headers(cls, value):
641
+ if isinstance(value, str):
642
+ return json.loads(value)
643
+ return value
644
+
645
+ @field_validator("x_stats_sampling_interval", mode="after")
646
+ @classmethod
647
+ def validate_stats_sampling_interval(cls, value):
648
+ if value < 0.1:
649
+ raise UsageError("Stats sampling interval cannot be less than 0.1 seconds")
650
+ return value
651
+
652
+ @field_validator("sweep_id", mode="after")
653
+ @classmethod
654
+ def validate_sweep_id(cls, value):
655
+ if value is None:
656
+ return None
657
+ if len(value) == 0:
658
+ raise UsageError("Sweep ID cannot be empty")
659
+ if len(value) > len(value.strip()):
660
+ raise UsageError("Sweep ID cannot start or end with whitespace")
661
+ if not bool(value.strip()):
662
+ raise UsageError("Sweep ID cannot contain only whitespace")
663
+ return value
664
+
665
+ @field_validator("sweep_param_path", mode="before")
666
+ @classmethod
667
+ def validate_sweep_param_path(cls, value):
668
+ # TODO: add native support for pathlib.Path
669
+ if isinstance(value, pathlib.Path):
670
+ return str(value)
671
+ return value
672
+
673
+ # Computed fields.
674
+
675
+ @computed_field # type: ignore[prop-decorator]
676
+ @property
677
+ def _args(self) -> list[str]:
678
+ if not self._jupyter:
679
+ return sys.argv[1:]
680
+ return []
681
+
682
+ @computed_field # type: ignore[prop-decorator]
683
+ @property
684
+ def _aws_lambda(self) -> bool:
685
+ """Check if we are running in a lambda environment."""
686
+ from sentry_sdk.integrations.aws_lambda import ( # type: ignore[import-not-found]
687
+ get_lambda_bootstrap,
688
+ )
689
+
690
+ lambda_bootstrap = get_lambda_bootstrap()
691
+ if not lambda_bootstrap or not hasattr(
692
+ lambda_bootstrap, "handle_event_request"
693
+ ):
694
+ return False
695
+ return True
696
+
697
+ @computed_field # type: ignore[prop-decorator]
698
+ @property
699
+ def _code_path_local(self) -> str | None:
700
+ """The relative path from the current working directory to the code path.
701
+
702
+ For example, if the code path is /home/user/project/example.py, and the
703
+ current working directory is /home/user/project, then the code path local
704
+ is example.py.
705
+
706
+ If couldn't find the relative path, this will be an empty string.
707
+ """
708
+ return self._get_program_relpath(self.program) if self.program else None
709
+
710
+ @computed_field # type: ignore[prop-decorator]
711
+ @property
712
+ def _colab(self) -> bool:
713
+ return "google.colab" in sys.modules
714
+
715
+ @computed_field # type: ignore[prop-decorator]
716
+ @property
717
+ def _ipython(self) -> bool:
718
+ return ipython.in_ipython()
719
+
720
+ @computed_field # type: ignore[prop-decorator]
721
+ @property
722
+ def _jupyter(self) -> bool:
723
+ return ipython.in_jupyter()
724
+
725
+ @computed_field # type: ignore[prop-decorator]
726
+ @property
727
+ def _kaggle(self) -> bool:
728
+ return util._is_likely_kaggle()
729
+
730
+ @computed_field # type: ignore[prop-decorator]
731
+ @property
732
+ def _noop(self) -> bool:
733
+ return self.mode == "disabled"
734
+
735
+ @computed_field # type: ignore[prop-decorator]
736
+ @property
737
+ def _notebook(self) -> bool:
738
+ return self._ipython or self._jupyter or self._colab or self._kaggle
739
+
740
+ @computed_field # type: ignore[prop-decorator]
741
+ @property
742
+ def _offline(self) -> bool:
743
+ return self.mode in ("offline", "dryrun")
744
+
745
+ @computed_field # type: ignore[prop-decorator]
746
+ @property
747
+ def _os(self) -> str:
748
+ """The operating system of the machine running the script."""
749
+ return platform.platform(aliased=True)
750
+
751
+ @computed_field # type: ignore[prop-decorator]
752
+ @property
753
+ def _platform(self) -> str:
754
+ return f"{platform.system()}-{platform.machine()}".lower()
755
+
756
+ @computed_field # type: ignore[prop-decorator]
757
+ @property
758
+ def _python(self) -> str:
759
+ return f"{platform.python_implementation()} {platform.python_version()}"
760
+
761
+ @computed_field # type: ignore[prop-decorator]
762
+ @property
763
+ def _shared(self) -> bool:
764
+ """Whether we are in shared mode.
765
+
766
+ In "shared" mode, multiple processes can write to the same run,
767
+ for example from different machines.
768
+ """
769
+ return self.mode == "shared"
770
+
771
+ @computed_field # type: ignore[prop-decorator]
772
+ @property
773
+ def _start_datetime(self) -> str:
774
+ if self.x_start_time is None:
775
+ return ""
776
+ datetime_now = datetime.fromtimestamp(self.x_start_time)
777
+ return datetime_now.strftime("%Y%m%d_%H%M%S")
778
+
779
+ @computed_field # type: ignore[prop-decorator]
780
+ @property
781
+ def _tmp_code_dir(self) -> str:
782
+ return _path_convert(
783
+ self.wandb_dir,
784
+ f"{self.run_mode}-{self.timespec}-{self.run_id}",
785
+ "tmp",
786
+ "code",
787
+ )
788
+
789
+ @computed_field # type: ignore[prop-decorator]
790
+ @property
791
+ def _windows(self) -> bool:
792
+ return platform.system() == "Windows"
793
+
794
+ @computed_field # type: ignore[prop-decorator]
795
+ @property
796
+ def colab_url(self) -> str | None:
797
+ """The URL to the Colab notebook, if running in Colab."""
798
+ if not self._colab:
799
+ return None
800
+ if self.x_jupyter_path and self.x_jupyter_path.startswith("fileId="):
801
+ unescaped = unquote(self.x_jupyter_path)
802
+ return "https://colab.research.google.com/notebook#" + unescaped
803
+ return None
804
+
805
+ @computed_field # type: ignore[prop-decorator]
806
+ @property
807
+ def deployment(self) -> Literal["local", "cloud"]:
808
+ return "local" if self.is_local else "cloud"
809
+
810
+ @computed_field # type: ignore[prop-decorator]
811
+ @property
812
+ def files_dir(self) -> str:
813
+ """Absolute path to the local directory where the run's files are stored."""
814
+ return self.x_files_dir or _path_convert(
815
+ self.wandb_dir,
816
+ f"{self.run_mode}-{self.timespec}-{self.run_id}",
817
+ "files",
818
+ )
819
+
820
+ @computed_field # type: ignore[prop-decorator]
821
+ @property
822
+ def is_local(self) -> bool:
823
+ return str(self.base_url) != "https://api.wandb.ai"
824
+
825
+ @computed_field # type: ignore[prop-decorator]
826
+ @property
827
+ def log_dir(self) -> str:
828
+ """The directory for storing log files."""
829
+ return _path_convert(
830
+ self.wandb_dir, f"{self.run_mode}-{self.timespec}-{self.run_id}", "logs"
831
+ )
832
+
833
+ @computed_field # type: ignore[prop-decorator]
834
+ @property
835
+ def log_internal(self) -> str:
836
+ """The path to the file to use for internal logs."""
837
+ return _path_convert(self.log_dir, "debug-internal.log")
838
+
839
+ @computed_field # type: ignore[prop-decorator]
840
+ @property
841
+ def log_symlink_internal(self) -> str:
842
+ """The path to the symlink to the internal log file of the most recent run."""
843
+ return _path_convert(self.wandb_dir, "debug-internal.log")
844
+
845
+ @computed_field # type: ignore[prop-decorator]
846
+ @property
847
+ def log_symlink_user(self) -> str:
848
+ """The path to the symlink to the user-process log file of the most recent run."""
849
+ return _path_convert(self.wandb_dir, "debug.log")
850
+
851
+ @computed_field # type: ignore[prop-decorator]
852
+ @property
853
+ def log_user(self) -> str:
854
+ """The path to the file to use for user-process logs."""
855
+ return _path_convert(self.log_dir, "debug.log")
856
+
857
+ @computed_field # type: ignore[prop-decorator]
858
+ @property
859
+ def project_url(self) -> str:
860
+ """The W&B URL where the project can be viewed."""
861
+ project_url = self._project_url_base()
862
+ if not project_url:
863
+ return ""
864
+
865
+ query = self._get_url_query_string()
866
+
867
+ return f"{project_url}{query}"
868
+
869
+ @computed_field # type: ignore[prop-decorator]
870
+ @property
871
+ def resume_fname(self) -> str:
872
+ """The path to the resume file."""
873
+ return _path_convert(self.wandb_dir, "wandb-resume.json")
874
+
875
+ @computed_field # type: ignore[prop-decorator]
876
+ @property
877
+ def run_mode(self) -> Literal["run", "offline-run"]:
878
+ return "run" if not self._offline else "offline-run"
879
+
880
+ @computed_field # type: ignore[prop-decorator]
881
+ @property
882
+ def run_url(self) -> str:
883
+ """The W&B URL where the run can be viewed."""
884
+ project_url = self._project_url_base()
885
+ if not all([project_url, self.run_id]):
886
+ return ""
887
+
888
+ query = self._get_url_query_string()
889
+ return f"{project_url}/runs/{quote(self.run_id or '')}{query}"
890
+
891
+ @computed_field # type: ignore[prop-decorator]
892
+ @property
893
+ def settings_workspace(self) -> str:
894
+ """The path to the workspace settings file."""
895
+ return _path_convert(self.wandb_dir, "settings")
896
+
897
+ @computed_field # type: ignore[prop-decorator]
898
+ @property
899
+ def sweep_url(self) -> str:
900
+ """The W&B URL where the sweep can be viewed."""
901
+ project_url = self._project_url_base()
902
+ if not all([project_url, self.sweep_id]):
903
+ return ""
904
+
905
+ query = self._get_url_query_string()
906
+ return f"{project_url}/sweeps/{quote(self.sweep_id or '')}{query}"
907
+
908
+ @computed_field # type: ignore[prop-decorator]
909
+ @property
910
+ def sync_dir(self) -> str:
911
+ return _path_convert(
912
+ self.wandb_dir, f"{self.run_mode}-{self.timespec}-{self.run_id}"
913
+ )
914
+
915
+ @computed_field # type: ignore[prop-decorator]
916
+ @property
917
+ def sync_file(self) -> str:
918
+ """Path to the append-only binary transaction log file."""
919
+ return _path_convert(self.sync_dir, f"run-{self.run_id}.wandb")
920
+
921
+ @computed_field # type: ignore[prop-decorator]
922
+ @property
923
+ def sync_symlink_latest(self) -> str:
924
+ return _path_convert(self.wandb_dir, "latest-run")
925
+
926
+ @computed_field # type: ignore[prop-decorator]
927
+ @property
928
+ def timespec(self) -> str:
929
+ return self._start_datetime
930
+
931
+ @computed_field # type: ignore[prop-decorator]
932
+ @property
933
+ def wandb_dir(self) -> str:
934
+ """Full path to the wandb directory.
935
+
936
+ The setting exposed to users as `dir=` or `WANDB_DIR` is the `root_dir`.
937
+ We add the `__stage_dir__` to it to get the full `wandb_dir`
938
+ """
939
+ root_dir = self.root_dir or ""
940
+
941
+ # We use the hidden version if it already exists, otherwise non-hidden.
942
+ if os.path.exists(os.path.join(root_dir, ".wandb")):
943
+ __stage_dir__ = ".wandb" + os.sep
944
+ else:
945
+ __stage_dir__ = "wandb" + os.sep
946
+
947
+ path = os.path.join(root_dir, __stage_dir__)
948
+ if not os.access(root_dir or ".", os.W_OK):
949
+ termwarn(
950
+ f"Path {path} wasn't writable, using system temp directory.",
951
+ repeat=False,
952
+ )
953
+ path = os.path.join(
954
+ tempfile.gettempdir(), __stage_dir__ or ("wandb" + os.sep)
955
+ )
956
+
957
+ return os.path.expanduser(path)
958
+
959
+ # Methods to collect and update settings from different sources.
960
+ #
961
+ # The Settings class does not track the source of the settings,
962
+ # so it is up to the developer to ensure that the settings are applied
963
+ # in the correct order. Most of the updates are done in
964
+ # wandb/sdk/wandb_setup.py::_WandbSetup__WandbSetup._settings_setup.
965
+
966
+ def update_from_system_config_file(self):
967
+ """Update settings from the system config file."""
968
+ if not self.settings_system or not os.path.exists(self.settings_system):
969
+ return
970
+ for key, value in self._load_config_file(self.settings_system).items():
971
+ if value is not None:
972
+ setattr(self, key, value)
973
+
974
+ def update_from_workspace_config_file(self):
975
+ """Update settings from the workspace config file."""
976
+ if not self.settings_workspace or not os.path.exists(self.settings_workspace):
977
+ return
978
+ for key, value in self._load_config_file(self.settings_workspace).items():
979
+ if value is not None:
980
+ setattr(self, key, value)
981
+
982
+ def update_from_env_vars(self, environ: dict[str, Any]):
983
+ """Update settings from environment variables."""
984
+ env_prefix: str = "WANDB_"
985
+ private_env_prefix: str = env_prefix + "_"
986
+ special_env_var_names = {
987
+ "WANDB_DISABLE_SERVICE": "x_disable_service",
988
+ "WANDB_SERVICE_TRANSPORT": "x_service_transport",
989
+ "WANDB_DIR": "root_dir",
990
+ "WANDB_NAME": "run_name",
991
+ "WANDB_NOTES": "run_notes",
992
+ "WANDB_TAGS": "run_tags",
993
+ "WANDB_JOB_TYPE": "run_job_type",
994
+ "WANDB_HTTP_TIMEOUT": "x_graphql_timeout_seconds",
995
+ "WANDB_FILE_PUSHER_TIMEOUT": "x_file_transfer_timeout_seconds",
996
+ "WANDB_USER_EMAIL": "email",
997
+ }
998
+ env = dict()
999
+ for setting, value in environ.items():
1000
+ if not setting.startswith(env_prefix):
1001
+ continue
1002
+
1003
+ if setting in special_env_var_names:
1004
+ key = special_env_var_names[setting]
1005
+ elif setting.startswith(private_env_prefix):
1006
+ key = "x_" + setting[len(private_env_prefix) :].lower()
1007
+ else:
1008
+ # otherwise, strip the prefix and convert to lowercase
1009
+ key = setting[len(env_prefix) :].lower()
1010
+
1011
+ if key in self.__dict__:
1012
+ if key in ("ignore_globs", "run_tags"):
1013
+ value = value.split(",")
1014
+ env[key] = value
1015
+
1016
+ for key, value in env.items():
1017
+ if value is not None:
1018
+ setattr(self, key, value)
1019
+
1020
+ def update_from_system_environment(self):
1021
+ """Update settings from the system environment."""
1022
+ # For code saving, only allow env var override if value from server is true, or
1023
+ # if no preference was specified.
1024
+ if (self.save_code is True or self.save_code is None) and (
1025
+ os.getenv(env.SAVE_CODE) is not None
1026
+ or os.getenv(env.DISABLE_CODE) is not None
1027
+ ):
1028
+ self.save_code = env.should_save_code()
1029
+
1030
+ self.disable_git = env.disable_git()
1031
+
1032
+ # Attempt to get notebook information if not already set by the user
1033
+ if self._jupyter and (self.notebook_name is None or self.notebook_name == ""):
1034
+ meta = wandb.jupyter.notebook_metadata(self.silent) # type: ignore
1035
+ self.x_jupyter_path = meta.get("path")
1036
+ self.x_jupyter_name = meta.get("name")
1037
+ self.x_jupyter_root = meta.get("root")
1038
+ elif (
1039
+ self._jupyter
1040
+ and self.notebook_name is not None
1041
+ and os.path.exists(self.notebook_name)
1042
+ ):
1043
+ self.x_jupyter_path = self.notebook_name
1044
+ self.x_jupyter_name = self.notebook_name
1045
+ self.x_jupyter_root = os.getcwd()
1046
+ elif self._jupyter:
1047
+ wandb.termwarn(
1048
+ "WANDB_NOTEBOOK_NAME should be a path to a notebook file, "
1049
+ f"couldn't find {self.notebook_name}.",
1050
+ )
1051
+
1052
+ # host and username are populated by apply_env_vars if corresponding env
1053
+ # vars exist -- but if they don't, we'll fill them in here
1054
+ if self.host is None:
1055
+ self.host = socket.gethostname() # type: ignore
1056
+
1057
+ _executable = (
1058
+ self.x_executable
1059
+ or os.environ.get(env._EXECUTABLE)
1060
+ or sys.executable
1061
+ or shutil.which("python3")
1062
+ or "python3"
1063
+ )
1064
+ self.x_executable = _executable
1065
+
1066
+ self.docker = env.get_docker(util.image_id_from_k8s())
1067
+
1068
+ # proceed if not in CLI mode
1069
+ if self.x_cli_only_mode:
1070
+ return
1071
+
1072
+ program = self.program or self._get_program()
1073
+
1074
+ if program is not None:
1075
+ repo = GitRepo()
1076
+ root = repo.root or os.getcwd()
1077
+
1078
+ self.program_relpath = self.program_relpath or self._get_program_relpath(
1079
+ program, root
1080
+ )
1081
+ program_abspath = os.path.abspath(
1082
+ os.path.join(root, os.path.relpath(os.getcwd(), root), program)
1083
+ )
1084
+ if os.path.exists(program_abspath):
1085
+ self.program_abspath = program_abspath
1086
+ else:
1087
+ program = "<python with no main file>"
1088
+
1089
+ self.program = program
1090
+
1091
+ def update_from_dict(self, settings: dict[str, Any]) -> None:
1092
+ """Update settings from a dictionary."""
1093
+ for key, value in dict(settings).items():
1094
+ if value is not None:
1095
+ setattr(self, key, value)
1096
+
1097
+ def update_from_settings(self, settings: Settings) -> None:
1098
+ """Update settings from another instance of `Settings`."""
1099
+ d = {field: getattr(settings, field) for field in settings.model_fields_set}
1100
+ if d:
1101
+ self.update_from_dict(d)
1102
+
1103
+ # Helper methods.
1104
+
1105
+ def to_proto(self) -> wandb_settings_pb2.Settings:
1106
+ """Generate a protobuf representation of the settings."""
1107
+ settings_proto = wandb_settings_pb2.Settings()
1108
+ for k, v in self.model_dump(exclude_none=True).items():
1109
+ # special case for x_stats_open_metrics_filters
1110
+ if k == "x_stats_open_metrics_filters":
1111
+ if isinstance(v, (list, set, tuple)):
1112
+ setting = getattr(settings_proto, k)
1113
+ setting.sequence.value.extend(v)
1114
+ elif isinstance(v, dict):
1115
+ setting = getattr(settings_proto, k)
1116
+ for key, value in v.items():
1117
+ for kk, vv in value.items():
1118
+ setting.mapping.value[key].value[kk] = vv
1119
+ else:
1120
+ raise TypeError(f"Unsupported type {type(v)} for setting {k}")
1121
+ continue
1122
+
1123
+ if isinstance(v, bool):
1124
+ getattr(settings_proto, k).CopyFrom(BoolValue(value=v))
1125
+ elif isinstance(v, int):
1126
+ getattr(settings_proto, k).CopyFrom(Int32Value(value=v))
1127
+ elif isinstance(v, float):
1128
+ getattr(settings_proto, k).CopyFrom(DoubleValue(value=v))
1129
+ elif isinstance(v, str):
1130
+ getattr(settings_proto, k).CopyFrom(StringValue(value=v))
1131
+ elif isinstance(v, (list, set, tuple)):
1132
+ # we only support sequences of strings for now
1133
+ sequence = getattr(settings_proto, k)
1134
+ sequence.value.extend(v)
1135
+ elif isinstance(v, dict):
1136
+ mapping = getattr(settings_proto, k)
1137
+ for key, value in v.items():
1138
+ # we only support dicts with string values for now
1139
+ mapping.value[key] = value
1140
+ elif isinstance(v, RunMoment):
1141
+ getattr(settings_proto, k).CopyFrom(
1142
+ wandb_settings_pb2.RunMoment(
1143
+ run=v.run,
1144
+ value=v.value,
1145
+ metric=v.metric,
1146
+ )
1147
+ )
1148
+ elif v is None:
1149
+ # None means that the setting value was not set.
1150
+ pass
1151
+ else:
1152
+ raise TypeError(f"Unsupported type {type(v)} for setting {k}")
1153
+
1154
+ return settings_proto
1155
+
1156
+ def handle_resume_logic(self):
1157
+ """Handle logic for resuming runs."""
1158
+ # handle auto resume logic
1159
+ if self.resume == "auto":
1160
+ if os.path.exists(self.resume_fname):
1161
+ with open(self.resume_fname) as f:
1162
+ resume_run_id = json.load(f)["run_id"]
1163
+ if self.run_id is None:
1164
+ self.run_id = resume_run_id
1165
+ elif self.run_id != resume_run_id:
1166
+ wandb.termwarn(
1167
+ "Tried to auto resume run with "
1168
+ f"id {resume_run_id} but id {self.run_id} is set.",
1169
+ )
1170
+ if self.run_id is None:
1171
+ self.run_id = generate_id()
1172
+
1173
+ # persist run_id in case of failure
1174
+ if self.resume == "auto" and self.resume_fname is not None:
1175
+ filesystem.mkdir_exists_ok(self.wandb_dir)
1176
+ with open(self.resume_fname, "w") as f:
1177
+ f.write(json.dumps({"run_id": self.run_id}))
1178
+
1179
+ def handle_sweep_logic(self):
1180
+ """Update settings based on sweep context.
1181
+
1182
+ When running a sweep, the project, entity, and run_id are handled externally,
1183
+ and should be ignored if they are set.
1184
+ """
1185
+ if self.sweep_id is None:
1186
+ return
1187
+
1188
+ for key in ("project", "entity", "run_id"):
1189
+ value = getattr(self, key)
1190
+ if value is not None:
1191
+ wandb.termwarn(f"Ignoring {key} {value!r} when running a sweep.")
1192
+ setattr(self, key, None)
1193
+
1194
+ def handle_launch_logic(self):
1195
+ """Update settings based on launch context.
1196
+
1197
+ When running in a launch context, the project, entity, and run_id are handled
1198
+ externally, and should be ignored if they are set.
1199
+ """
1200
+ if not self.launch:
1201
+ return
1202
+
1203
+ for key in ("project", "entity", "run_id"):
1204
+ value = getattr(self, key)
1205
+ if value is not None:
1206
+ wandb.termwarn(
1207
+ f"Ignoring {key} {value!r} when running from wandb launch context."
1208
+ )
1209
+ setattr(self, key, None)
1210
+
1211
+ @staticmethod
1212
+ def validate_url(url: str) -> None:
1213
+ """Validate a URL string."""
1214
+ url_validator = SchemaValidator(
1215
+ core_schema.url_schema(
1216
+ allowed_schemes=["http", "https"],
1217
+ strict=True,
1218
+ )
1219
+ )
1220
+ url_validator.validate_python(url)
1221
+
1222
+ def _get_program(self) -> str | None:
1223
+ """Get the program that started the current process."""
1224
+ if not self._jupyter:
1225
+ # If not in a notebook, try to get the program from the environment
1226
+ # or the __main__ module for scripts run as `python -m ...`.
1227
+ program = os.getenv(env.PROGRAM)
1228
+ if program is not None:
1229
+ return program
1230
+ try:
1231
+ import __main__
1232
+
1233
+ if __main__.__spec__ is None:
1234
+ return __main__.__file__
1235
+ return f"-m {__main__.__spec__.name}"
1236
+ except (ImportError, AttributeError):
1237
+ return None
1238
+ else:
1239
+ # If in a notebook, try to get the program from the notebook metadata.
1240
+ if self.notebook_name:
1241
+ return self.notebook_name
1242
+
1243
+ if not self.x_jupyter_path:
1244
+ return self.program
1245
+
1246
+ if self.x_jupyter_path.startswith("fileId="):
1247
+ return self.x_jupyter_name
1248
+ else:
1249
+ return self.x_jupyter_path
1250
+
1251
+ @staticmethod
1252
+ def _get_program_relpath(program: str, root: str | None = None) -> str | None:
1253
+ """Get the relative path to the program from the root directory."""
1254
+ if not program:
1255
+ return None
1256
+
1257
+ root = root or os.getcwd()
1258
+ if not root:
1259
+ return None
1260
+
1261
+ full_path_to_program = os.path.join(
1262
+ root, os.path.relpath(os.getcwd(), root), program
1263
+ )
1264
+ if os.path.exists(full_path_to_program):
1265
+ relative_path = os.path.relpath(full_path_to_program, start=root)
1266
+ if "../" in relative_path:
1267
+ return None
1268
+ return relative_path
1269
+
1270
+ return None
1271
+
1272
+ @staticmethod
1273
+ def _load_config_file(file_name: str, section: str = "default") -> dict:
1274
+ """Load a config file and return the settings for a given section."""
1275
+ parser = configparser.ConfigParser()
1276
+ parser.add_section(section)
1277
+ parser.read(file_name)
1278
+ config: dict[str, Any] = dict()
1279
+ for k in parser[section]:
1280
+ config[k] = parser[section][k]
1281
+ if k == "ignore_globs":
1282
+ config[k] = config[k].split(",")
1283
+ return config
1284
+
1285
+ def _project_url_base(self) -> str:
1286
+ """Construct the base URL for the project."""
1287
+ if not all([self.entity, self.project]):
1288
+ return ""
1289
+
1290
+ app_url = util.app_url(self.base_url)
1291
+ return f"{app_url}/{quote(self.entity or '')}/{quote(self.project or '')}"
1292
+
1293
+ def _get_url_query_string(self) -> str:
1294
+ """Construct the query string for project, run, and sweep URLs."""
1295
+ # TODO: remove dependency on Api()
1296
+ if Api().settings().get("anonymous") != "true":
1297
+ return ""
1298
+
1299
+ api_key = apikey.api_key(settings=self)
1300
+
1301
+ return f"?{urlencode({'apiKey': api_key})}"
1302
+
1303
+ @staticmethod
1304
+ def _runmoment_preprocessor(val: RunMoment | str | None) -> RunMoment | None:
1305
+ """Preprocess the setting for forking or resuming a run."""
1306
+ if isinstance(val, RunMoment) or val is None:
1307
+ return val
1308
+ elif isinstance(val, str):
1309
+ return RunMoment.from_uri(val)