wandb 0.17.0rc1__py3-none-win32.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (841) hide show
  1. package_readme.md +95 -0
  2. wandb/__init__.py +253 -0
  3. wandb/__main__.py +3 -0
  4. wandb/_globals.py +19 -0
  5. wandb/agents/__init__.py +0 -0
  6. wandb/agents/pyagent.py +364 -0
  7. wandb/analytics/__init__.py +3 -0
  8. wandb/analytics/sentry.py +266 -0
  9. wandb/apis/__init__.py +48 -0
  10. wandb/apis/attrs.py +40 -0
  11. wandb/apis/importers/__init__.py +1 -0
  12. wandb/apis/importers/internals/internal.py +386 -0
  13. wandb/apis/importers/internals/protocols.py +99 -0
  14. wandb/apis/importers/internals/util.py +78 -0
  15. wandb/apis/importers/mlflow.py +254 -0
  16. wandb/apis/importers/validation.py +108 -0
  17. wandb/apis/importers/wandb.py +1598 -0
  18. wandb/apis/internal.py +228 -0
  19. wandb/apis/normalize.py +89 -0
  20. wandb/apis/paginator.py +81 -0
  21. wandb/apis/public/__init__.py +34 -0
  22. wandb/apis/public/api.py +1045 -0
  23. wandb/apis/public/artifacts.py +851 -0
  24. wandb/apis/public/const.py +4 -0
  25. wandb/apis/public/files.py +195 -0
  26. wandb/apis/public/history.py +149 -0
  27. wandb/apis/public/jobs.py +634 -0
  28. wandb/apis/public/projects.py +162 -0
  29. wandb/apis/public/query_generator.py +166 -0
  30. wandb/apis/public/reports.py +469 -0
  31. wandb/apis/public/runs.py +803 -0
  32. wandb/apis/public/sweeps.py +240 -0
  33. wandb/apis/public/teams.py +198 -0
  34. wandb/apis/public/users.py +136 -0
  35. wandb/apis/reports/__init__.py +7 -0
  36. wandb/apis/reports/v1/__init__.py +30 -0
  37. wandb/apis/reports/v1/_blocks.py +1406 -0
  38. wandb/apis/reports/v1/_helpers.py +70 -0
  39. wandb/apis/reports/v1/_panels.py +1282 -0
  40. wandb/apis/reports/v1/_templates.py +478 -0
  41. wandb/apis/reports/v1/blocks.py +27 -0
  42. wandb/apis/reports/v1/helpers.py +2 -0
  43. wandb/apis/reports/v1/mutations.py +66 -0
  44. wandb/apis/reports/v1/panels.py +17 -0
  45. wandb/apis/reports/v1/report.py +268 -0
  46. wandb/apis/reports/v1/runset.py +144 -0
  47. wandb/apis/reports/v1/templates.py +7 -0
  48. wandb/apis/reports/v1/util.py +406 -0
  49. wandb/apis/reports/v1/validators.py +131 -0
  50. wandb/apis/reports/v2/__init__.py +20 -0
  51. wandb/apis/reports/v2/blocks.py +25 -0
  52. wandb/apis/reports/v2/expr_parsing.py +257 -0
  53. wandb/apis/reports/v2/gql.py +68 -0
  54. wandb/apis/reports/v2/interface.py +1911 -0
  55. wandb/apis/reports/v2/internal.py +867 -0
  56. wandb/apis/reports/v2/metrics.py +6 -0
  57. wandb/apis/reports/v2/panels.py +15 -0
  58. wandb/beta/workflows.py +283 -0
  59. wandb/bin/wandb-core +0 -0
  60. wandb/catboost/__init__.py +9 -0
  61. wandb/cli/__init__.py +0 -0
  62. wandb/cli/cli.py +2890 -0
  63. wandb/data_types.py +2068 -0
  64. wandb/docker/__init__.py +342 -0
  65. wandb/docker/auth.py +436 -0
  66. wandb/docker/wandb-entrypoint.sh +33 -0
  67. wandb/docker/www_authenticate.py +94 -0
  68. wandb/env.py +496 -0
  69. wandb/errors/__init__.py +46 -0
  70. wandb/errors/term.py +95 -0
  71. wandb/errors/util.py +57 -0
  72. wandb/fastai/__init__.py +9 -0
  73. wandb/filesync/__init__.py +0 -0
  74. wandb/filesync/dir_watcher.py +403 -0
  75. wandb/filesync/stats.py +100 -0
  76. wandb/filesync/step_checksum.py +145 -0
  77. wandb/filesync/step_prepare.py +199 -0
  78. wandb/filesync/step_upload.py +392 -0
  79. wandb/filesync/upload_job.py +218 -0
  80. wandb/integration/__init__.py +0 -0
  81. wandb/integration/catboost/__init__.py +5 -0
  82. wandb/integration/catboost/catboost.py +178 -0
  83. wandb/integration/cohere/__init__.py +3 -0
  84. wandb/integration/cohere/cohere.py +21 -0
  85. wandb/integration/cohere/resolver.py +347 -0
  86. wandb/integration/diffusers/__init__.py +3 -0
  87. wandb/integration/diffusers/autologger.py +76 -0
  88. wandb/integration/diffusers/pipeline_resolver.py +50 -0
  89. wandb/integration/diffusers/resolvers/__init__.py +9 -0
  90. wandb/integration/diffusers/resolvers/multimodal.py +882 -0
  91. wandb/integration/diffusers/resolvers/utils.py +102 -0
  92. wandb/integration/fastai/__init__.py +249 -0
  93. wandb/integration/gym/__init__.py +85 -0
  94. wandb/integration/huggingface/__init__.py +3 -0
  95. wandb/integration/huggingface/huggingface.py +18 -0
  96. wandb/integration/huggingface/resolver.py +213 -0
  97. wandb/integration/keras/__init__.py +14 -0
  98. wandb/integration/keras/callbacks/__init__.py +5 -0
  99. wandb/integration/keras/callbacks/metrics_logger.py +130 -0
  100. wandb/integration/keras/callbacks/model_checkpoint.py +200 -0
  101. wandb/integration/keras/callbacks/tables_builder.py +226 -0
  102. wandb/integration/keras/keras.py +1080 -0
  103. wandb/integration/kfp/__init__.py +6 -0
  104. wandb/integration/kfp/helpers.py +28 -0
  105. wandb/integration/kfp/kfp_patch.py +324 -0
  106. wandb/integration/kfp/wandb_logging.py +182 -0
  107. wandb/integration/langchain/__init__.py +3 -0
  108. wandb/integration/langchain/wandb_tracer.py +48 -0
  109. wandb/integration/lightgbm/__init__.py +239 -0
  110. wandb/integration/lightning/__init__.py +0 -0
  111. wandb/integration/lightning/fabric/__init__.py +3 -0
  112. wandb/integration/lightning/fabric/logger.py +762 -0
  113. wandb/integration/magic.py +556 -0
  114. wandb/integration/metaflow/__init__.py +3 -0
  115. wandb/integration/metaflow/metaflow.py +383 -0
  116. wandb/integration/openai/__init__.py +3 -0
  117. wandb/integration/openai/fine_tuning.py +454 -0
  118. wandb/integration/openai/openai.py +22 -0
  119. wandb/integration/openai/resolver.py +240 -0
  120. wandb/integration/prodigy/__init__.py +3 -0
  121. wandb/integration/prodigy/prodigy.py +299 -0
  122. wandb/integration/sacred/__init__.py +117 -0
  123. wandb/integration/sagemaker/__init__.py +12 -0
  124. wandb/integration/sagemaker/auth.py +28 -0
  125. wandb/integration/sagemaker/config.py +49 -0
  126. wandb/integration/sagemaker/files.py +3 -0
  127. wandb/integration/sagemaker/resources.py +34 -0
  128. wandb/integration/sb3/__init__.py +3 -0
  129. wandb/integration/sb3/sb3.py +153 -0
  130. wandb/integration/tensorboard/__init__.py +10 -0
  131. wandb/integration/tensorboard/log.py +358 -0
  132. wandb/integration/tensorboard/monkeypatch.py +185 -0
  133. wandb/integration/tensorflow/__init__.py +5 -0
  134. wandb/integration/tensorflow/estimator_hook.py +54 -0
  135. wandb/integration/torch/__init__.py +0 -0
  136. wandb/integration/ultralytics/__init__.py +11 -0
  137. wandb/integration/ultralytics/bbox_utils.py +208 -0
  138. wandb/integration/ultralytics/callback.py +524 -0
  139. wandb/integration/ultralytics/classification_utils.py +83 -0
  140. wandb/integration/ultralytics/mask_utils.py +202 -0
  141. wandb/integration/ultralytics/pose_utils.py +104 -0
  142. wandb/integration/xgboost/__init__.py +11 -0
  143. wandb/integration/xgboost/xgboost.py +189 -0
  144. wandb/integration/yolov8/__init__.py +0 -0
  145. wandb/integration/yolov8/yolov8.py +284 -0
  146. wandb/jupyter.py +501 -0
  147. wandb/keras/__init__.py +19 -0
  148. wandb/lightgbm/__init__.py +9 -0
  149. wandb/magic.py +3 -0
  150. wandb/mpmain/__init__.py +0 -0
  151. wandb/mpmain/__main__.py +1 -0
  152. wandb/old/__init__.py +0 -0
  153. wandb/old/core.py +131 -0
  154. wandb/old/settings.py +173 -0
  155. wandb/old/summary.py +435 -0
  156. wandb/plot/__init__.py +19 -0
  157. wandb/plot/bar.py +42 -0
  158. wandb/plot/confusion_matrix.py +99 -0
  159. wandb/plot/histogram.py +36 -0
  160. wandb/plot/line.py +40 -0
  161. wandb/plot/line_series.py +88 -0
  162. wandb/plot/pr_curve.py +135 -0
  163. wandb/plot/roc_curve.py +117 -0
  164. wandb/plot/scatter.py +32 -0
  165. wandb/plots/__init__.py +6 -0
  166. wandb/plots/explain_text.py +36 -0
  167. wandb/plots/heatmap.py +81 -0
  168. wandb/plots/named_entity.py +43 -0
  169. wandb/plots/part_of_speech.py +50 -0
  170. wandb/plots/plot_definitions.py +768 -0
  171. wandb/plots/precision_recall.py +121 -0
  172. wandb/plots/roc.py +103 -0
  173. wandb/plots/utils.py +195 -0
  174. wandb/proto/__init__.py +0 -0
  175. wandb/proto/v3/__init__.py +0 -0
  176. wandb/proto/v3/wandb_base_pb2.py +54 -0
  177. wandb/proto/v3/wandb_internal_pb2.py +1586 -0
  178. wandb/proto/v3/wandb_server_pb2.py +207 -0
  179. wandb/proto/v3/wandb_settings_pb2.py +111 -0
  180. wandb/proto/v3/wandb_telemetry_pb2.py +105 -0
  181. wandb/proto/v4/__init__.py +0 -0
  182. wandb/proto/v4/wandb_base_pb2.py +29 -0
  183. wandb/proto/v4/wandb_internal_pb2.py +354 -0
  184. wandb/proto/v4/wandb_server_pb2.py +62 -0
  185. wandb/proto/v4/wandb_settings_pb2.py +44 -0
  186. wandb/proto/v4/wandb_telemetry_pb2.py +40 -0
  187. wandb/proto/wandb_base_pb2.py +8 -0
  188. wandb/proto/wandb_deprecated.py +37 -0
  189. wandb/proto/wandb_internal_codegen.py +83 -0
  190. wandb/proto/wandb_internal_pb2.py +8 -0
  191. wandb/proto/wandb_server_pb2.py +8 -0
  192. wandb/proto/wandb_settings_pb2.py +8 -0
  193. wandb/proto/wandb_telemetry_pb2.py +8 -0
  194. wandb/py.typed +0 -0
  195. wandb/sacred/__init__.py +3 -0
  196. wandb/sdk/__init__.py +37 -0
  197. wandb/sdk/artifacts/__init__.py +0 -0
  198. wandb/sdk/artifacts/artifact.py +2317 -0
  199. wandb/sdk/artifacts/artifact_download_logger.py +43 -0
  200. wandb/sdk/artifacts/artifact_file_cache.py +229 -0
  201. wandb/sdk/artifacts/artifact_instance_cache.py +15 -0
  202. wandb/sdk/artifacts/artifact_manifest.py +72 -0
  203. wandb/sdk/artifacts/artifact_manifest_entry.py +205 -0
  204. wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
  205. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +90 -0
  206. wandb/sdk/artifacts/artifact_saver.py +270 -0
  207. wandb/sdk/artifacts/artifact_state.py +11 -0
  208. wandb/sdk/artifacts/artifact_ttl.py +7 -0
  209. wandb/sdk/artifacts/exceptions.py +56 -0
  210. wandb/sdk/artifacts/staging.py +25 -0
  211. wandb/sdk/artifacts/storage_handler.py +60 -0
  212. wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
  213. wandb/sdk/artifacts/storage_handlers/azure_handler.py +194 -0
  214. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +195 -0
  215. wandb/sdk/artifacts/storage_handlers/http_handler.py +113 -0
  216. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +135 -0
  217. wandb/sdk/artifacts/storage_handlers/multi_handler.py +54 -0
  218. wandb/sdk/artifacts/storage_handlers/s3_handler.py +300 -0
  219. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +68 -0
  220. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +133 -0
  221. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +72 -0
  222. wandb/sdk/artifacts/storage_layout.py +6 -0
  223. wandb/sdk/artifacts/storage_policies/__init__.py +4 -0
  224. wandb/sdk/artifacts/storage_policies/register.py +1 -0
  225. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +411 -0
  226. wandb/sdk/artifacts/storage_policy.py +83 -0
  227. wandb/sdk/backend/__init__.py +0 -0
  228. wandb/sdk/backend/backend.py +240 -0
  229. wandb/sdk/data_types/__init__.py +0 -0
  230. wandb/sdk/data_types/_dtypes.py +911 -0
  231. wandb/sdk/data_types/_private.py +10 -0
  232. wandb/sdk/data_types/base_types/__init__.py +0 -0
  233. wandb/sdk/data_types/base_types/json_metadata.py +55 -0
  234. wandb/sdk/data_types/base_types/media.py +313 -0
  235. wandb/sdk/data_types/base_types/wb_value.py +274 -0
  236. wandb/sdk/data_types/helper_types/__init__.py +0 -0
  237. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +293 -0
  238. wandb/sdk/data_types/helper_types/classes.py +159 -0
  239. wandb/sdk/data_types/helper_types/image_mask.py +233 -0
  240. wandb/sdk/data_types/histogram.py +96 -0
  241. wandb/sdk/data_types/html.py +115 -0
  242. wandb/sdk/data_types/image.py +687 -0
  243. wandb/sdk/data_types/molecule.py +241 -0
  244. wandb/sdk/data_types/object_3d.py +363 -0
  245. wandb/sdk/data_types/plotly.py +82 -0
  246. wandb/sdk/data_types/saved_model.py +444 -0
  247. wandb/sdk/data_types/trace_tree.py +438 -0
  248. wandb/sdk/data_types/utils.py +180 -0
  249. wandb/sdk/data_types/video.py +245 -0
  250. wandb/sdk/integration_utils/__init__.py +0 -0
  251. wandb/sdk/integration_utils/auto_logging.py +239 -0
  252. wandb/sdk/integration_utils/data_logging.py +475 -0
  253. wandb/sdk/interface/__init__.py +0 -0
  254. wandb/sdk/interface/constants.py +4 -0
  255. wandb/sdk/interface/interface.py +949 -0
  256. wandb/sdk/interface/interface_queue.py +59 -0
  257. wandb/sdk/interface/interface_relay.py +53 -0
  258. wandb/sdk/interface/interface_shared.py +550 -0
  259. wandb/sdk/interface/interface_sock.py +61 -0
  260. wandb/sdk/interface/message_future.py +27 -0
  261. wandb/sdk/interface/message_future_poll.py +50 -0
  262. wandb/sdk/interface/router.py +118 -0
  263. wandb/sdk/interface/router_queue.py +44 -0
  264. wandb/sdk/interface/router_relay.py +39 -0
  265. wandb/sdk/interface/router_sock.py +36 -0
  266. wandb/sdk/interface/summary_record.py +67 -0
  267. wandb/sdk/internal/__init__.py +0 -0
  268. wandb/sdk/internal/context.py +89 -0
  269. wandb/sdk/internal/datastore.py +297 -0
  270. wandb/sdk/internal/file_pusher.py +184 -0
  271. wandb/sdk/internal/file_stream.py +708 -0
  272. wandb/sdk/internal/flow_control.py +263 -0
  273. wandb/sdk/internal/handler.py +909 -0
  274. wandb/sdk/internal/internal.py +417 -0
  275. wandb/sdk/internal/internal_api.py +4202 -0
  276. wandb/sdk/internal/internal_util.py +100 -0
  277. wandb/sdk/internal/job_builder.py +554 -0
  278. wandb/sdk/internal/profiler.py +78 -0
  279. wandb/sdk/internal/progress.py +111 -0
  280. wandb/sdk/internal/run.py +25 -0
  281. wandb/sdk/internal/sample.py +70 -0
  282. wandb/sdk/internal/sender.py +1642 -0
  283. wandb/sdk/internal/sender_config.py +197 -0
  284. wandb/sdk/internal/settings_static.py +83 -0
  285. wandb/sdk/internal/system/__init__.py +0 -0
  286. wandb/sdk/internal/system/assets/__init__.py +27 -0
  287. wandb/sdk/internal/system/assets/aggregators.py +37 -0
  288. wandb/sdk/internal/system/assets/asset_registry.py +20 -0
  289. wandb/sdk/internal/system/assets/cpu.py +163 -0
  290. wandb/sdk/internal/system/assets/disk.py +210 -0
  291. wandb/sdk/internal/system/assets/gpu.py +414 -0
  292. wandb/sdk/internal/system/assets/gpu_amd.py +230 -0
  293. wandb/sdk/internal/system/assets/gpu_apple.py +177 -0
  294. wandb/sdk/internal/system/assets/interfaces.py +207 -0
  295. wandb/sdk/internal/system/assets/ipu.py +177 -0
  296. wandb/sdk/internal/system/assets/memory.py +166 -0
  297. wandb/sdk/internal/system/assets/network.py +125 -0
  298. wandb/sdk/internal/system/assets/open_metrics.py +299 -0
  299. wandb/sdk/internal/system/assets/tpu.py +154 -0
  300. wandb/sdk/internal/system/assets/trainium.py +398 -0
  301. wandb/sdk/internal/system/env_probe_helpers.py +13 -0
  302. wandb/sdk/internal/system/system_info.py +247 -0
  303. wandb/sdk/internal/system/system_monitor.py +229 -0
  304. wandb/sdk/internal/tb_watcher.py +518 -0
  305. wandb/sdk/internal/thread_local_settings.py +18 -0
  306. wandb/sdk/internal/update.py +113 -0
  307. wandb/sdk/internal/writer.py +206 -0
  308. wandb/sdk/launch/__init__.py +6 -0
  309. wandb/sdk/launch/_launch.py +348 -0
  310. wandb/sdk/launch/_launch_add.py +257 -0
  311. wandb/sdk/launch/_project_spec.py +578 -0
  312. wandb/sdk/launch/agent/__init__.py +5 -0
  313. wandb/sdk/launch/agent/agent.py +878 -0
  314. wandb/sdk/launch/agent/config.py +299 -0
  315. wandb/sdk/launch/agent/job_status_tracker.py +53 -0
  316. wandb/sdk/launch/agent/run_queue_item_file_saver.py +47 -0
  317. wandb/sdk/launch/builder/__init__.py +0 -0
  318. wandb/sdk/launch/builder/abstract.py +89 -0
  319. wandb/sdk/launch/builder/build.py +706 -0
  320. wandb/sdk/launch/builder/docker_builder.py +193 -0
  321. wandb/sdk/launch/builder/kaniko_builder.py +579 -0
  322. wandb/sdk/launch/builder/noop.py +58 -0
  323. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +187 -0
  324. wandb/sdk/launch/create_job.py +520 -0
  325. wandb/sdk/launch/environment/abstract.py +29 -0
  326. wandb/sdk/launch/environment/aws_environment.py +297 -0
  327. wandb/sdk/launch/environment/azure_environment.py +105 -0
  328. wandb/sdk/launch/environment/gcp_environment.py +335 -0
  329. wandb/sdk/launch/environment/local_environment.py +66 -0
  330. wandb/sdk/launch/errors.py +19 -0
  331. wandb/sdk/launch/git_reference.py +109 -0
  332. wandb/sdk/launch/loader.py +249 -0
  333. wandb/sdk/launch/registry/abstract.py +48 -0
  334. wandb/sdk/launch/registry/anon.py +29 -0
  335. wandb/sdk/launch/registry/azure_container_registry.py +124 -0
  336. wandb/sdk/launch/registry/elastic_container_registry.py +192 -0
  337. wandb/sdk/launch/registry/google_artifact_registry.py +219 -0
  338. wandb/sdk/launch/registry/local_registry.py +67 -0
  339. wandb/sdk/launch/runner/__init__.py +0 -0
  340. wandb/sdk/launch/runner/abstract.py +195 -0
  341. wandb/sdk/launch/runner/kubernetes_monitor.py +441 -0
  342. wandb/sdk/launch/runner/kubernetes_runner.py +893 -0
  343. wandb/sdk/launch/runner/local_container.py +299 -0
  344. wandb/sdk/launch/runner/local_process.py +99 -0
  345. wandb/sdk/launch/runner/sagemaker_runner.py +422 -0
  346. wandb/sdk/launch/runner/vertex_runner.py +229 -0
  347. wandb/sdk/launch/sweeps/__init__.py +39 -0
  348. wandb/sdk/launch/sweeps/scheduler.py +738 -0
  349. wandb/sdk/launch/sweeps/scheduler_sweep.py +91 -0
  350. wandb/sdk/launch/sweeps/utils.py +316 -0
  351. wandb/sdk/launch/utils.py +866 -0
  352. wandb/sdk/launch/wandb_reference.py +138 -0
  353. wandb/sdk/lib/__init__.py +5 -0
  354. wandb/sdk/lib/_settings_toposort_generate.py +159 -0
  355. wandb/sdk/lib/_settings_toposort_generated.py +244 -0
  356. wandb/sdk/lib/_wburls_generate.py +25 -0
  357. wandb/sdk/lib/_wburls_generated.py +22 -0
  358. wandb/sdk/lib/apikey.py +258 -0
  359. wandb/sdk/lib/capped_dict.py +26 -0
  360. wandb/sdk/lib/config_util.py +101 -0
  361. wandb/sdk/lib/console.py +39 -0
  362. wandb/sdk/lib/deprecate.py +42 -0
  363. wandb/sdk/lib/disabled.py +190 -0
  364. wandb/sdk/lib/exit_hooks.py +54 -0
  365. wandb/sdk/lib/file_stream_utils.py +118 -0
  366. wandb/sdk/lib/filenames.py +64 -0
  367. wandb/sdk/lib/filesystem.py +372 -0
  368. wandb/sdk/lib/fsm.py +174 -0
  369. wandb/sdk/lib/gitlib.py +239 -0
  370. wandb/sdk/lib/gql_request.py +65 -0
  371. wandb/sdk/lib/handler_util.py +21 -0
  372. wandb/sdk/lib/hashutil.py +62 -0
  373. wandb/sdk/lib/import_hooks.py +275 -0
  374. wandb/sdk/lib/ipython.py +146 -0
  375. wandb/sdk/lib/json_util.py +80 -0
  376. wandb/sdk/lib/lazyloader.py +63 -0
  377. wandb/sdk/lib/mailbox.py +460 -0
  378. wandb/sdk/lib/module.py +69 -0
  379. wandb/sdk/lib/paths.py +106 -0
  380. wandb/sdk/lib/preinit.py +42 -0
  381. wandb/sdk/lib/printer.py +313 -0
  382. wandb/sdk/lib/proto_util.py +69 -0
  383. wandb/sdk/lib/redirect.py +840 -0
  384. wandb/sdk/lib/reporting.py +99 -0
  385. wandb/sdk/lib/retry.py +289 -0
  386. wandb/sdk/lib/run_moment.py +78 -0
  387. wandb/sdk/lib/runid.py +12 -0
  388. wandb/sdk/lib/server.py +52 -0
  389. wandb/sdk/lib/sock_client.py +291 -0
  390. wandb/sdk/lib/sparkline.py +45 -0
  391. wandb/sdk/lib/telemetry.py +100 -0
  392. wandb/sdk/lib/timed_input.py +133 -0
  393. wandb/sdk/lib/timer.py +19 -0
  394. wandb/sdk/lib/tracelog.py +255 -0
  395. wandb/sdk/lib/wburls.py +46 -0
  396. wandb/sdk/service/__init__.py +0 -0
  397. wandb/sdk/service/_startup_debug.py +22 -0
  398. wandb/sdk/service/port_file.py +53 -0
  399. wandb/sdk/service/server.py +119 -0
  400. wandb/sdk/service/server_sock.py +276 -0
  401. wandb/sdk/service/service.py +266 -0
  402. wandb/sdk/service/service_base.py +50 -0
  403. wandb/sdk/service/service_sock.py +70 -0
  404. wandb/sdk/service/streams.py +426 -0
  405. wandb/sdk/verify/__init__.py +0 -0
  406. wandb/sdk/verify/verify.py +501 -0
  407. wandb/sdk/wandb_alerts.py +12 -0
  408. wandb/sdk/wandb_config.py +319 -0
  409. wandb/sdk/wandb_helper.py +54 -0
  410. wandb/sdk/wandb_init.py +1220 -0
  411. wandb/sdk/wandb_login.py +339 -0
  412. wandb/sdk/wandb_manager.py +222 -0
  413. wandb/sdk/wandb_metric.py +110 -0
  414. wandb/sdk/wandb_require.py +92 -0
  415. wandb/sdk/wandb_require_helpers.py +44 -0
  416. wandb/sdk/wandb_run.py +4191 -0
  417. wandb/sdk/wandb_settings.py +1973 -0
  418. wandb/sdk/wandb_setup.py +335 -0
  419. wandb/sdk/wandb_summary.py +150 -0
  420. wandb/sdk/wandb_sweep.py +114 -0
  421. wandb/sdk/wandb_sync.py +75 -0
  422. wandb/sdk/wandb_watch.py +128 -0
  423. wandb/sklearn/__init__.py +37 -0
  424. wandb/sklearn/calculate/__init__.py +32 -0
  425. wandb/sklearn/calculate/calibration_curves.py +125 -0
  426. wandb/sklearn/calculate/class_proportions.py +68 -0
  427. wandb/sklearn/calculate/confusion_matrix.py +92 -0
  428. wandb/sklearn/calculate/decision_boundaries.py +40 -0
  429. wandb/sklearn/calculate/elbow_curve.py +55 -0
  430. wandb/sklearn/calculate/feature_importances.py +67 -0
  431. wandb/sklearn/calculate/learning_curve.py +64 -0
  432. wandb/sklearn/calculate/outlier_candidates.py +69 -0
  433. wandb/sklearn/calculate/residuals.py +86 -0
  434. wandb/sklearn/calculate/silhouette.py +118 -0
  435. wandb/sklearn/calculate/summary_metrics.py +62 -0
  436. wandb/sklearn/plot/__init__.py +35 -0
  437. wandb/sklearn/plot/classifier.py +331 -0
  438. wandb/sklearn/plot/clusterer.py +142 -0
  439. wandb/sklearn/plot/regressor.py +121 -0
  440. wandb/sklearn/plot/shared.py +91 -0
  441. wandb/sklearn/utils.py +183 -0
  442. wandb/sync/__init__.py +3 -0
  443. wandb/sync/sync.py +443 -0
  444. wandb/testing/relay.py +859 -0
  445. wandb/trigger.py +29 -0
  446. wandb/util.py +1925 -0
  447. wandb/vendor/__init__.py +0 -0
  448. wandb/vendor/gql-0.2.0/setup.py +40 -0
  449. wandb/vendor/gql-0.2.0/tests/__init__.py +0 -0
  450. wandb/vendor/gql-0.2.0/tests/starwars/__init__.py +0 -0
  451. wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py +96 -0
  452. wandb/vendor/gql-0.2.0/tests/starwars/schema.py +146 -0
  453. wandb/vendor/gql-0.2.0/tests/starwars/test_dsl.py +293 -0
  454. wandb/vendor/gql-0.2.0/tests/starwars/test_query.py +355 -0
  455. wandb/vendor/gql-0.2.0/tests/starwars/test_validation.py +171 -0
  456. wandb/vendor/gql-0.2.0/tests/test_client.py +31 -0
  457. wandb/vendor/gql-0.2.0/tests/test_transport.py +89 -0
  458. wandb/vendor/gql-0.2.0/wandb_gql/__init__.py +4 -0
  459. wandb/vendor/gql-0.2.0/wandb_gql/client.py +75 -0
  460. wandb/vendor/gql-0.2.0/wandb_gql/dsl.py +152 -0
  461. wandb/vendor/gql-0.2.0/wandb_gql/gql.py +10 -0
  462. wandb/vendor/gql-0.2.0/wandb_gql/transport/__init__.py +0 -0
  463. wandb/vendor/gql-0.2.0/wandb_gql/transport/http.py +6 -0
  464. wandb/vendor/gql-0.2.0/wandb_gql/transport/local_schema.py +15 -0
  465. wandb/vendor/gql-0.2.0/wandb_gql/transport/requests.py +46 -0
  466. wandb/vendor/gql-0.2.0/wandb_gql/utils.py +21 -0
  467. wandb/vendor/graphql-core-1.1/setup.py +86 -0
  468. wandb/vendor/graphql-core-1.1/wandb_graphql/__init__.py +287 -0
  469. wandb/vendor/graphql-core-1.1/wandb_graphql/error/__init__.py +6 -0
  470. wandb/vendor/graphql-core-1.1/wandb_graphql/error/base.py +42 -0
  471. wandb/vendor/graphql-core-1.1/wandb_graphql/error/format_error.py +11 -0
  472. wandb/vendor/graphql-core-1.1/wandb_graphql/error/located_error.py +29 -0
  473. wandb/vendor/graphql-core-1.1/wandb_graphql/error/syntax_error.py +36 -0
  474. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/__init__.py +26 -0
  475. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/base.py +311 -0
  476. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executor.py +398 -0
  477. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/__init__.py +0 -0
  478. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/asyncio.py +53 -0
  479. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/gevent.py +22 -0
  480. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/process.py +32 -0
  481. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/sync.py +7 -0
  482. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/thread.py +35 -0
  483. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/utils.py +6 -0
  484. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/__init__.py +0 -0
  485. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/executor.py +66 -0
  486. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/fragment.py +252 -0
  487. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/resolver.py +151 -0
  488. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/utils.py +7 -0
  489. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/middleware.py +57 -0
  490. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/values.py +145 -0
  491. wandb/vendor/graphql-core-1.1/wandb_graphql/graphql.py +60 -0
  492. wandb/vendor/graphql-core-1.1/wandb_graphql/language/__init__.py +0 -0
  493. wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py +1349 -0
  494. wandb/vendor/graphql-core-1.1/wandb_graphql/language/base.py +19 -0
  495. wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py +435 -0
  496. wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py +30 -0
  497. wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py +779 -0
  498. wandb/vendor/graphql-core-1.1/wandb_graphql/language/printer.py +193 -0
  499. wandb/vendor/graphql-core-1.1/wandb_graphql/language/source.py +18 -0
  500. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py +222 -0
  501. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor_meta.py +82 -0
  502. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/__init__.py +0 -0
  503. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/cached_property.py +17 -0
  504. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/contain_subset.py +28 -0
  505. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/default_ordered_dict.py +40 -0
  506. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/ordereddict.py +8 -0
  507. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/pair_set.py +43 -0
  508. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/version.py +78 -0
  509. wandb/vendor/graphql-core-1.1/wandb_graphql/type/__init__.py +67 -0
  510. wandb/vendor/graphql-core-1.1/wandb_graphql/type/definition.py +619 -0
  511. wandb/vendor/graphql-core-1.1/wandb_graphql/type/directives.py +132 -0
  512. wandb/vendor/graphql-core-1.1/wandb_graphql/type/introspection.py +440 -0
  513. wandb/vendor/graphql-core-1.1/wandb_graphql/type/scalars.py +131 -0
  514. wandb/vendor/graphql-core-1.1/wandb_graphql/type/schema.py +100 -0
  515. wandb/vendor/graphql-core-1.1/wandb_graphql/type/typemap.py +145 -0
  516. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/__init__.py +0 -0
  517. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/assert_valid_name.py +9 -0
  518. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_from_value.py +65 -0
  519. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_code.py +49 -0
  520. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_dict.py +24 -0
  521. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/base.py +75 -0
  522. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_ast_schema.py +291 -0
  523. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_client_schema.py +250 -0
  524. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/concat_ast.py +9 -0
  525. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/extend_schema.py +357 -0
  526. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_field_def.py +27 -0
  527. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_operation_ast.py +21 -0
  528. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/introspection_query.py +90 -0
  529. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_literal_value.py +67 -0
  530. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_value.py +66 -0
  531. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/quoted_or_list.py +21 -0
  532. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/schema_printer.py +168 -0
  533. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/suggestion_list.py +56 -0
  534. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_comparators.py +69 -0
  535. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_from_ast.py +21 -0
  536. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_info.py +149 -0
  537. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/value_from_ast.py +69 -0
  538. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/__init__.py +4 -0
  539. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/__init__.py +79 -0
  540. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/arguments_of_correct_type.py +24 -0
  541. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/base.py +8 -0
  542. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/default_values_of_correct_type.py +44 -0
  543. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fields_on_correct_type.py +113 -0
  544. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fragments_on_composite_types.py +33 -0
  545. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_argument_names.py +70 -0
  546. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_directives.py +97 -0
  547. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_fragment_names.py +19 -0
  548. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_type_names.py +43 -0
  549. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/lone_anonymous_operation.py +23 -0
  550. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_fragment_cycles.py +59 -0
  551. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_undefined_variables.py +36 -0
  552. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_fragments.py +38 -0
  553. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_variables.py +37 -0
  554. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/overlapping_fields_can_be_merged.py +529 -0
  555. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/possible_fragment_spreads.py +44 -0
  556. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/provided_non_null_arguments.py +46 -0
  557. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/scalar_leafs.py +33 -0
  558. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_argument_names.py +32 -0
  559. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_fragment_names.py +28 -0
  560. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_input_field_names.py +33 -0
  561. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_operation_names.py +31 -0
  562. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_variable_names.py +27 -0
  563. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_are_input_types.py +21 -0
  564. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_in_allowed_position.py +53 -0
  565. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/validation.py +158 -0
  566. wandb/vendor/promise-2.3.0/conftest.py +30 -0
  567. wandb/vendor/promise-2.3.0/setup.py +64 -0
  568. wandb/vendor/promise-2.3.0/tests/__init__.py +0 -0
  569. wandb/vendor/promise-2.3.0/tests/conftest.py +8 -0
  570. wandb/vendor/promise-2.3.0/tests/test_awaitable.py +32 -0
  571. wandb/vendor/promise-2.3.0/tests/test_awaitable_35.py +47 -0
  572. wandb/vendor/promise-2.3.0/tests/test_benchmark.py +116 -0
  573. wandb/vendor/promise-2.3.0/tests/test_complex_threads.py +23 -0
  574. wandb/vendor/promise-2.3.0/tests/test_dataloader.py +452 -0
  575. wandb/vendor/promise-2.3.0/tests/test_dataloader_awaitable_35.py +99 -0
  576. wandb/vendor/promise-2.3.0/tests/test_dataloader_extra.py +65 -0
  577. wandb/vendor/promise-2.3.0/tests/test_extra.py +670 -0
  578. wandb/vendor/promise-2.3.0/tests/test_issues.py +132 -0
  579. wandb/vendor/promise-2.3.0/tests/test_promise_list.py +70 -0
  580. wandb/vendor/promise-2.3.0/tests/test_spec.py +584 -0
  581. wandb/vendor/promise-2.3.0/tests/test_thread_safety.py +115 -0
  582. wandb/vendor/promise-2.3.0/tests/utils.py +3 -0
  583. wandb/vendor/promise-2.3.0/wandb_promise/__init__.py +38 -0
  584. wandb/vendor/promise-2.3.0/wandb_promise/async_.py +135 -0
  585. wandb/vendor/promise-2.3.0/wandb_promise/compat.py +32 -0
  586. wandb/vendor/promise-2.3.0/wandb_promise/dataloader.py +326 -0
  587. wandb/vendor/promise-2.3.0/wandb_promise/iterate_promise.py +12 -0
  588. wandb/vendor/promise-2.3.0/wandb_promise/promise.py +848 -0
  589. wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py +151 -0
  590. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/__init__.py +0 -0
  591. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/version.py +83 -0
  592. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/__init__.py +0 -0
  593. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/asyncio.py +22 -0
  594. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/gevent.py +21 -0
  595. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/immediate.py +27 -0
  596. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/thread.py +18 -0
  597. wandb/vendor/promise-2.3.0/wandb_promise/utils.py +56 -0
  598. wandb/vendor/pygments/__init__.py +90 -0
  599. wandb/vendor/pygments/cmdline.py +568 -0
  600. wandb/vendor/pygments/console.py +74 -0
  601. wandb/vendor/pygments/filter.py +74 -0
  602. wandb/vendor/pygments/filters/__init__.py +350 -0
  603. wandb/vendor/pygments/formatter.py +95 -0
  604. wandb/vendor/pygments/formatters/__init__.py +153 -0
  605. wandb/vendor/pygments/formatters/_mapping.py +85 -0
  606. wandb/vendor/pygments/formatters/bbcode.py +109 -0
  607. wandb/vendor/pygments/formatters/html.py +851 -0
  608. wandb/vendor/pygments/formatters/img.py +600 -0
  609. wandb/vendor/pygments/formatters/irc.py +182 -0
  610. wandb/vendor/pygments/formatters/latex.py +482 -0
  611. wandb/vendor/pygments/formatters/other.py +160 -0
  612. wandb/vendor/pygments/formatters/rtf.py +147 -0
  613. wandb/vendor/pygments/formatters/svg.py +153 -0
  614. wandb/vendor/pygments/formatters/terminal.py +136 -0
  615. wandb/vendor/pygments/formatters/terminal256.py +309 -0
  616. wandb/vendor/pygments/lexer.py +871 -0
  617. wandb/vendor/pygments/lexers/__init__.py +329 -0
  618. wandb/vendor/pygments/lexers/_asy_builtins.py +1645 -0
  619. wandb/vendor/pygments/lexers/_cl_builtins.py +232 -0
  620. wandb/vendor/pygments/lexers/_cocoa_builtins.py +72 -0
  621. wandb/vendor/pygments/lexers/_csound_builtins.py +1346 -0
  622. wandb/vendor/pygments/lexers/_lasso_builtins.py +5327 -0
  623. wandb/vendor/pygments/lexers/_lua_builtins.py +295 -0
  624. wandb/vendor/pygments/lexers/_mapping.py +500 -0
  625. wandb/vendor/pygments/lexers/_mql_builtins.py +1172 -0
  626. wandb/vendor/pygments/lexers/_openedge_builtins.py +2547 -0
  627. wandb/vendor/pygments/lexers/_php_builtins.py +4756 -0
  628. wandb/vendor/pygments/lexers/_postgres_builtins.py +621 -0
  629. wandb/vendor/pygments/lexers/_scilab_builtins.py +3094 -0
  630. wandb/vendor/pygments/lexers/_sourcemod_builtins.py +1163 -0
  631. wandb/vendor/pygments/lexers/_stan_builtins.py +532 -0
  632. wandb/vendor/pygments/lexers/_stata_builtins.py +419 -0
  633. wandb/vendor/pygments/lexers/_tsql_builtins.py +1004 -0
  634. wandb/vendor/pygments/lexers/_vim_builtins.py +1939 -0
  635. wandb/vendor/pygments/lexers/actionscript.py +240 -0
  636. wandb/vendor/pygments/lexers/agile.py +24 -0
  637. wandb/vendor/pygments/lexers/algebra.py +221 -0
  638. wandb/vendor/pygments/lexers/ambient.py +76 -0
  639. wandb/vendor/pygments/lexers/ampl.py +87 -0
  640. wandb/vendor/pygments/lexers/apl.py +101 -0
  641. wandb/vendor/pygments/lexers/archetype.py +318 -0
  642. wandb/vendor/pygments/lexers/asm.py +641 -0
  643. wandb/vendor/pygments/lexers/automation.py +374 -0
  644. wandb/vendor/pygments/lexers/basic.py +500 -0
  645. wandb/vendor/pygments/lexers/bibtex.py +160 -0
  646. wandb/vendor/pygments/lexers/business.py +612 -0
  647. wandb/vendor/pygments/lexers/c_cpp.py +252 -0
  648. wandb/vendor/pygments/lexers/c_like.py +541 -0
  649. wandb/vendor/pygments/lexers/capnproto.py +78 -0
  650. wandb/vendor/pygments/lexers/chapel.py +102 -0
  651. wandb/vendor/pygments/lexers/clean.py +288 -0
  652. wandb/vendor/pygments/lexers/compiled.py +34 -0
  653. wandb/vendor/pygments/lexers/configs.py +833 -0
  654. wandb/vendor/pygments/lexers/console.py +114 -0
  655. wandb/vendor/pygments/lexers/crystal.py +393 -0
  656. wandb/vendor/pygments/lexers/csound.py +366 -0
  657. wandb/vendor/pygments/lexers/css.py +689 -0
  658. wandb/vendor/pygments/lexers/d.py +251 -0
  659. wandb/vendor/pygments/lexers/dalvik.py +125 -0
  660. wandb/vendor/pygments/lexers/data.py +555 -0
  661. wandb/vendor/pygments/lexers/diff.py +165 -0
  662. wandb/vendor/pygments/lexers/dotnet.py +691 -0
  663. wandb/vendor/pygments/lexers/dsls.py +878 -0
  664. wandb/vendor/pygments/lexers/dylan.py +289 -0
  665. wandb/vendor/pygments/lexers/ecl.py +125 -0
  666. wandb/vendor/pygments/lexers/eiffel.py +65 -0
  667. wandb/vendor/pygments/lexers/elm.py +121 -0
  668. wandb/vendor/pygments/lexers/erlang.py +533 -0
  669. wandb/vendor/pygments/lexers/esoteric.py +277 -0
  670. wandb/vendor/pygments/lexers/ezhil.py +69 -0
  671. wandb/vendor/pygments/lexers/factor.py +344 -0
  672. wandb/vendor/pygments/lexers/fantom.py +250 -0
  673. wandb/vendor/pygments/lexers/felix.py +273 -0
  674. wandb/vendor/pygments/lexers/forth.py +177 -0
  675. wandb/vendor/pygments/lexers/fortran.py +205 -0
  676. wandb/vendor/pygments/lexers/foxpro.py +428 -0
  677. wandb/vendor/pygments/lexers/functional.py +21 -0
  678. wandb/vendor/pygments/lexers/go.py +101 -0
  679. wandb/vendor/pygments/lexers/grammar_notation.py +213 -0
  680. wandb/vendor/pygments/lexers/graph.py +80 -0
  681. wandb/vendor/pygments/lexers/graphics.py +553 -0
  682. wandb/vendor/pygments/lexers/haskell.py +843 -0
  683. wandb/vendor/pygments/lexers/haxe.py +936 -0
  684. wandb/vendor/pygments/lexers/hdl.py +382 -0
  685. wandb/vendor/pygments/lexers/hexdump.py +103 -0
  686. wandb/vendor/pygments/lexers/html.py +602 -0
  687. wandb/vendor/pygments/lexers/idl.py +270 -0
  688. wandb/vendor/pygments/lexers/igor.py +288 -0
  689. wandb/vendor/pygments/lexers/inferno.py +96 -0
  690. wandb/vendor/pygments/lexers/installers.py +322 -0
  691. wandb/vendor/pygments/lexers/int_fiction.py +1343 -0
  692. wandb/vendor/pygments/lexers/iolang.py +63 -0
  693. wandb/vendor/pygments/lexers/j.py +146 -0
  694. wandb/vendor/pygments/lexers/javascript.py +1525 -0
  695. wandb/vendor/pygments/lexers/julia.py +333 -0
  696. wandb/vendor/pygments/lexers/jvm.py +1573 -0
  697. wandb/vendor/pygments/lexers/lisp.py +2621 -0
  698. wandb/vendor/pygments/lexers/make.py +202 -0
  699. wandb/vendor/pygments/lexers/markup.py +595 -0
  700. wandb/vendor/pygments/lexers/math.py +21 -0
  701. wandb/vendor/pygments/lexers/matlab.py +663 -0
  702. wandb/vendor/pygments/lexers/ml.py +769 -0
  703. wandb/vendor/pygments/lexers/modeling.py +358 -0
  704. wandb/vendor/pygments/lexers/modula2.py +1561 -0
  705. wandb/vendor/pygments/lexers/monte.py +204 -0
  706. wandb/vendor/pygments/lexers/ncl.py +894 -0
  707. wandb/vendor/pygments/lexers/nimrod.py +159 -0
  708. wandb/vendor/pygments/lexers/nit.py +64 -0
  709. wandb/vendor/pygments/lexers/nix.py +136 -0
  710. wandb/vendor/pygments/lexers/oberon.py +105 -0
  711. wandb/vendor/pygments/lexers/objective.py +504 -0
  712. wandb/vendor/pygments/lexers/ooc.py +85 -0
  713. wandb/vendor/pygments/lexers/other.py +41 -0
  714. wandb/vendor/pygments/lexers/parasail.py +79 -0
  715. wandb/vendor/pygments/lexers/parsers.py +835 -0
  716. wandb/vendor/pygments/lexers/pascal.py +644 -0
  717. wandb/vendor/pygments/lexers/pawn.py +199 -0
  718. wandb/vendor/pygments/lexers/perl.py +620 -0
  719. wandb/vendor/pygments/lexers/php.py +267 -0
  720. wandb/vendor/pygments/lexers/praat.py +294 -0
  721. wandb/vendor/pygments/lexers/prolog.py +306 -0
  722. wandb/vendor/pygments/lexers/python.py +939 -0
  723. wandb/vendor/pygments/lexers/qvt.py +152 -0
  724. wandb/vendor/pygments/lexers/r.py +453 -0
  725. wandb/vendor/pygments/lexers/rdf.py +270 -0
  726. wandb/vendor/pygments/lexers/rebol.py +431 -0
  727. wandb/vendor/pygments/lexers/resource.py +85 -0
  728. wandb/vendor/pygments/lexers/rnc.py +67 -0
  729. wandb/vendor/pygments/lexers/roboconf.py +82 -0
  730. wandb/vendor/pygments/lexers/robotframework.py +560 -0
  731. wandb/vendor/pygments/lexers/ruby.py +519 -0
  732. wandb/vendor/pygments/lexers/rust.py +220 -0
  733. wandb/vendor/pygments/lexers/sas.py +228 -0
  734. wandb/vendor/pygments/lexers/scripting.py +1222 -0
  735. wandb/vendor/pygments/lexers/shell.py +794 -0
  736. wandb/vendor/pygments/lexers/smalltalk.py +195 -0
  737. wandb/vendor/pygments/lexers/smv.py +79 -0
  738. wandb/vendor/pygments/lexers/snobol.py +83 -0
  739. wandb/vendor/pygments/lexers/special.py +103 -0
  740. wandb/vendor/pygments/lexers/sql.py +681 -0
  741. wandb/vendor/pygments/lexers/stata.py +108 -0
  742. wandb/vendor/pygments/lexers/supercollider.py +90 -0
  743. wandb/vendor/pygments/lexers/tcl.py +145 -0
  744. wandb/vendor/pygments/lexers/templates.py +2283 -0
  745. wandb/vendor/pygments/lexers/testing.py +207 -0
  746. wandb/vendor/pygments/lexers/text.py +25 -0
  747. wandb/vendor/pygments/lexers/textedit.py +169 -0
  748. wandb/vendor/pygments/lexers/textfmts.py +297 -0
  749. wandb/vendor/pygments/lexers/theorem.py +458 -0
  750. wandb/vendor/pygments/lexers/trafficscript.py +54 -0
  751. wandb/vendor/pygments/lexers/typoscript.py +226 -0
  752. wandb/vendor/pygments/lexers/urbi.py +133 -0
  753. wandb/vendor/pygments/lexers/varnish.py +190 -0
  754. wandb/vendor/pygments/lexers/verification.py +111 -0
  755. wandb/vendor/pygments/lexers/web.py +24 -0
  756. wandb/vendor/pygments/lexers/webmisc.py +988 -0
  757. wandb/vendor/pygments/lexers/whiley.py +116 -0
  758. wandb/vendor/pygments/lexers/x10.py +69 -0
  759. wandb/vendor/pygments/modeline.py +44 -0
  760. wandb/vendor/pygments/plugin.py +68 -0
  761. wandb/vendor/pygments/regexopt.py +92 -0
  762. wandb/vendor/pygments/scanner.py +105 -0
  763. wandb/vendor/pygments/sphinxext.py +158 -0
  764. wandb/vendor/pygments/style.py +155 -0
  765. wandb/vendor/pygments/styles/__init__.py +80 -0
  766. wandb/vendor/pygments/styles/abap.py +29 -0
  767. wandb/vendor/pygments/styles/algol.py +63 -0
  768. wandb/vendor/pygments/styles/algol_nu.py +63 -0
  769. wandb/vendor/pygments/styles/arduino.py +98 -0
  770. wandb/vendor/pygments/styles/autumn.py +65 -0
  771. wandb/vendor/pygments/styles/borland.py +51 -0
  772. wandb/vendor/pygments/styles/bw.py +49 -0
  773. wandb/vendor/pygments/styles/colorful.py +81 -0
  774. wandb/vendor/pygments/styles/default.py +73 -0
  775. wandb/vendor/pygments/styles/emacs.py +72 -0
  776. wandb/vendor/pygments/styles/friendly.py +72 -0
  777. wandb/vendor/pygments/styles/fruity.py +42 -0
  778. wandb/vendor/pygments/styles/igor.py +29 -0
  779. wandb/vendor/pygments/styles/lovelace.py +97 -0
  780. wandb/vendor/pygments/styles/manni.py +75 -0
  781. wandb/vendor/pygments/styles/monokai.py +106 -0
  782. wandb/vendor/pygments/styles/murphy.py +80 -0
  783. wandb/vendor/pygments/styles/native.py +65 -0
  784. wandb/vendor/pygments/styles/paraiso_dark.py +125 -0
  785. wandb/vendor/pygments/styles/paraiso_light.py +125 -0
  786. wandb/vendor/pygments/styles/pastie.py +75 -0
  787. wandb/vendor/pygments/styles/perldoc.py +69 -0
  788. wandb/vendor/pygments/styles/rainbow_dash.py +89 -0
  789. wandb/vendor/pygments/styles/rrt.py +33 -0
  790. wandb/vendor/pygments/styles/sas.py +44 -0
  791. wandb/vendor/pygments/styles/stata.py +40 -0
  792. wandb/vendor/pygments/styles/tango.py +141 -0
  793. wandb/vendor/pygments/styles/trac.py +63 -0
  794. wandb/vendor/pygments/styles/vim.py +63 -0
  795. wandb/vendor/pygments/styles/vs.py +38 -0
  796. wandb/vendor/pygments/styles/xcode.py +51 -0
  797. wandb/vendor/pygments/token.py +213 -0
  798. wandb/vendor/pygments/unistring.py +217 -0
  799. wandb/vendor/pygments/util.py +388 -0
  800. wandb/vendor/pynvml/__init__.py +0 -0
  801. wandb/vendor/pynvml/pynvml.py +4779 -0
  802. wandb/vendor/watchdog_0_9_0/wandb_watchdog/__init__.py +17 -0
  803. wandb/vendor/watchdog_0_9_0/wandb_watchdog/events.py +615 -0
  804. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/__init__.py +98 -0
  805. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/api.py +369 -0
  806. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents.py +172 -0
  807. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents2.py +239 -0
  808. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify.py +218 -0
  809. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_buffer.py +81 -0
  810. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_c.py +575 -0
  811. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/kqueue.py +730 -0
  812. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/polling.py +145 -0
  813. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/read_directory_changes.py +133 -0
  814. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/winapi.py +348 -0
  815. wandb/vendor/watchdog_0_9_0/wandb_watchdog/patterns.py +265 -0
  816. wandb/vendor/watchdog_0_9_0/wandb_watchdog/tricks/__init__.py +174 -0
  817. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/__init__.py +151 -0
  818. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/bricks.py +249 -0
  819. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/compat.py +29 -0
  820. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/decorators.py +198 -0
  821. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/delayed_queue.py +88 -0
  822. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/dirsnapshot.py +293 -0
  823. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/echo.py +157 -0
  824. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/event_backport.py +41 -0
  825. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/importlib2.py +40 -0
  826. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/platform.py +57 -0
  827. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/unicode_paths.py +64 -0
  828. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/win32stat.py +123 -0
  829. wandb/vendor/watchdog_0_9_0/wandb_watchdog/version.py +28 -0
  830. wandb/vendor/watchdog_0_9_0/wandb_watchdog/watchmedo.py +577 -0
  831. wandb/viz.py +123 -0
  832. wandb/wandb_agent.py +586 -0
  833. wandb/wandb_controller.py +720 -0
  834. wandb/wandb_run.py +9 -0
  835. wandb/wandb_torch.py +550 -0
  836. wandb/xgboost/__init__.py +9 -0
  837. wandb-0.17.0rc1.dist-info/METADATA +219 -0
  838. wandb-0.17.0rc1.dist-info/RECORD +841 -0
  839. wandb-0.17.0rc1.dist-info/WHEEL +4 -0
  840. wandb-0.17.0rc1.dist-info/entry_points.txt +3 -0
  841. wandb-0.17.0rc1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,1973 @@
1
+ import collections.abc
2
+ import configparser
3
+ import enum
4
+ import getpass
5
+ import json
6
+ import logging
7
+ import multiprocessing
8
+ import os
9
+ import platform
10
+ import re
11
+ import shutil
12
+ import socket
13
+ import sys
14
+ import tempfile
15
+ import time
16
+ from dataclasses import dataclass
17
+ from datetime import datetime
18
+ from distutils.util import strtobool
19
+ from functools import reduce
20
+ from typing import (
21
+ Any,
22
+ Callable,
23
+ Dict,
24
+ FrozenSet,
25
+ ItemsView,
26
+ Iterable,
27
+ Mapping,
28
+ Optional,
29
+ Sequence,
30
+ Set,
31
+ Tuple,
32
+ Union,
33
+ no_type_check,
34
+ )
35
+ from urllib.parse import quote, unquote, urlencode, urlparse, urlsplit
36
+
37
+ from google.protobuf.wrappers_pb2 import BoolValue, DoubleValue, Int32Value, StringValue
38
+
39
+ import wandb
40
+ import wandb.env
41
+ from wandb import util
42
+ from wandb.apis.internal import Api
43
+ from wandb.errors import UsageError
44
+ from wandb.proto import wandb_settings_pb2
45
+ from wandb.sdk.internal.system.env_probe_helpers import is_aws_lambda
46
+ from wandb.sdk.lib import filesystem
47
+ from wandb.sdk.lib._settings_toposort_generated import SETTINGS_TOPOLOGICALLY_SORTED
48
+ from wandb.sdk.lib.run_moment import RunMoment
49
+ from wandb.sdk.wandb_setup import _EarlyLogger
50
+
51
+ from .lib import apikey
52
+ from .lib.gitlib import GitRepo
53
+ from .lib.ipython import _get_python_type
54
+ from .lib.runid import generate_id
55
+
56
+ if sys.version_info >= (3, 8):
57
+ from typing import get_args, get_origin, get_type_hints
58
+ else:
59
+ from typing_extensions import get_args, get_origin, get_type_hints
60
+
61
+
62
+ class SettingsPreprocessingError(UsageError):
63
+ """Raised when the value supplied to a wandb.Settings() setting does not pass preprocessing."""
64
+
65
+
66
+ class SettingsValidationError(UsageError):
67
+ """Raised when the value supplied to a wandb.Settings() setting does not pass validation."""
68
+
69
+
70
+ class SettingsUnexpectedArgsError(UsageError):
71
+ """Raised when unexpected arguments are passed to wandb.Settings()."""
72
+
73
+
74
+ def _get_wandb_dir(root_dir: str) -> str:
75
+ """Get the full path to the wandb directory.
76
+
77
+ The setting exposed to users as `dir=` or `WANDB_DIR` is the `root_dir`.
78
+ We add the `__stage_dir__` to it to get the full `wandb_dir`
79
+ """
80
+ # We use the hidden version if it already exists, otherwise non-hidden.
81
+ if os.path.exists(os.path.join(root_dir, ".wandb")):
82
+ __stage_dir__ = ".wandb" + os.sep
83
+ else:
84
+ __stage_dir__ = "wandb" + os.sep
85
+
86
+ path = os.path.join(root_dir, __stage_dir__)
87
+ if not os.access(root_dir or ".", os.W_OK):
88
+ wandb.termwarn(
89
+ f"Path {path} wasn't writable, using system temp directory.",
90
+ repeat=False,
91
+ )
92
+ path = os.path.join(tempfile.gettempdir(), __stage_dir__ or ("wandb" + os.sep))
93
+
94
+ return os.path.expanduser(path)
95
+
96
+
97
+ def _str_as_bool(val: Union[str, bool]) -> bool:
98
+ """Parse a string as a bool."""
99
+ if isinstance(val, bool):
100
+ return val
101
+ try:
102
+ ret_val = bool(strtobool(str(val)))
103
+ return ret_val
104
+ except (AttributeError, ValueError):
105
+ pass
106
+
107
+ raise UsageError(f"Could not parse value {val} as a bool.")
108
+
109
+
110
+ def _str_as_json(val: Union[str, Dict[str, Any]]) -> Any:
111
+ """Parse a string as a json object."""
112
+ if not isinstance(val, str):
113
+ return val
114
+ try:
115
+ return json.loads(val)
116
+ except (AttributeError, ValueError):
117
+ pass
118
+
119
+ raise UsageError(f"Could not parse value {val} as JSON.")
120
+
121
+
122
+ def _str_as_tuple(val: Union[str, Sequence[str]]) -> Tuple[str, ...]:
123
+ """Parse a (potentially comma-separated) string as a tuple."""
124
+ if isinstance(val, str):
125
+ return tuple(val.split(","))
126
+ return tuple(val)
127
+
128
+
129
+ def _datetime_as_str(val: Union[datetime, str]) -> str:
130
+ """Parse a datetime object as a string."""
131
+ if isinstance(val, datetime):
132
+ return datetime.strftime(val, "%Y%m%d_%H%M%S")
133
+ return val
134
+
135
+
136
+ def _redact_dict(
137
+ d: Dict[str, Any],
138
+ unsafe_keys: Union[Set[str], FrozenSet[str]] = frozenset({"api_key"}),
139
+ redact_str: str = "***REDACTED***",
140
+ ) -> Dict[str, Any]:
141
+ """Redact a dict of unsafe values specified by their key."""
142
+ if not d or unsafe_keys.isdisjoint(d):
143
+ return d
144
+ safe_dict = d.copy()
145
+ safe_dict.update({k: redact_str for k in unsafe_keys.intersection(d)})
146
+ return safe_dict
147
+
148
+
149
+ def _get_program() -> Optional[str]:
150
+ program = os.getenv(wandb.env.PROGRAM)
151
+ if program is not None:
152
+ return program
153
+ try:
154
+ import __main__
155
+
156
+ if __main__.__spec__ is None:
157
+ return __main__.__file__
158
+ # likely run as `python -m ...`
159
+ return f"-m {__main__.__spec__.name}"
160
+ except (ImportError, AttributeError):
161
+ return None
162
+
163
+
164
+ def _runmoment_preprocessor(val: Any) -> Optional[RunMoment]:
165
+ if isinstance(val, RunMoment) or val is None:
166
+ return val
167
+ elif isinstance(val, str):
168
+ return RunMoment.from_uri(val)
169
+ raise UsageError(f"Could not parse value {val} as a RunMoment.")
170
+
171
+
172
+ def _get_program_relpath(
173
+ program: str, root: Optional[str] = None, _logger: Optional[_EarlyLogger] = None
174
+ ) -> Optional[str]:
175
+ if not program:
176
+ if _logger is not None:
177
+ _logger.warning("Empty program passed to get_program_relpath")
178
+ return None
179
+
180
+ root = root or os.getcwd()
181
+ if not root:
182
+ return None
183
+
184
+ full_path_to_program = os.path.join(
185
+ root, os.path.relpath(os.getcwd(), root), program
186
+ )
187
+ if os.path.exists(full_path_to_program):
188
+ relative_path = os.path.relpath(full_path_to_program, start=root)
189
+ if "../" in relative_path:
190
+ if _logger is not None:
191
+ _logger.warning(f"Could not save program above cwd: {program}")
192
+ return None
193
+ return relative_path
194
+
195
+ if _logger is not None:
196
+ _logger.warning(f"Could not find program at {program}")
197
+ return None
198
+
199
+
200
+ def is_instance_recursive(obj: Any, type_hint: Any) -> bool: # noqa: C901
201
+ if type_hint is Any:
202
+ return True
203
+
204
+ origin = get_origin(type_hint)
205
+ args = get_args(type_hint)
206
+
207
+ if origin is None:
208
+ return isinstance(obj, type_hint)
209
+
210
+ if origin is Union:
211
+ return any(is_instance_recursive(obj, arg) for arg in args)
212
+
213
+ if issubclass(origin, collections.abc.Mapping):
214
+ if not isinstance(obj, collections.abc.Mapping):
215
+ return False
216
+ key_type, value_type = args
217
+
218
+ for key, value in obj.items():
219
+ if not is_instance_recursive(key, key_type) or not is_instance_recursive(
220
+ value, value_type
221
+ ):
222
+ return False
223
+
224
+ return True
225
+
226
+ if issubclass(origin, collections.abc.Sequence):
227
+ if not isinstance(obj, collections.abc.Sequence) or isinstance(
228
+ obj, (str, bytes, bytearray)
229
+ ):
230
+ return False
231
+
232
+ if len(args) == 1 and args[0] != ...:
233
+ (item_type,) = args
234
+ for item in obj:
235
+ if not is_instance_recursive(item, item_type):
236
+ return False
237
+ elif len(args) == 2 and args[-1] == ...:
238
+ item_type = args[0]
239
+ for item in obj:
240
+ if not is_instance_recursive(item, item_type):
241
+ return False
242
+ elif len(args) == len(obj):
243
+ for item, item_type in zip(obj, args):
244
+ if not is_instance_recursive(item, item_type):
245
+ return False
246
+ else:
247
+ return False
248
+
249
+ return True
250
+
251
+ if issubclass(origin, collections.abc.Set):
252
+ if not isinstance(obj, collections.abc.Set):
253
+ return False
254
+
255
+ (item_type,) = args
256
+ for item in obj:
257
+ if not is_instance_recursive(item, item_type):
258
+ return False
259
+
260
+ return True
261
+
262
+ return False
263
+
264
+
265
+ @enum.unique
266
+ class Source(enum.IntEnum):
267
+ OVERRIDE: int = 0
268
+ BASE: int = 1 # todo: audit this
269
+ ORG: int = 2
270
+ ENTITY: int = 3
271
+ PROJECT: int = 4
272
+ USER: int = 5
273
+ SYSTEM: int = 6
274
+ WORKSPACE: int = 7
275
+ ENV: int = 8
276
+ SETUP: int = 9
277
+ LOGIN: int = 10
278
+ INIT: int = 11
279
+ SETTINGS: int = 12
280
+ ARGS: int = 13
281
+ RUN: int = 14
282
+
283
+
284
+ ConsoleValue = {
285
+ "auto",
286
+ "off",
287
+ "wrap",
288
+ "redirect",
289
+ # internal console states
290
+ "wrap_raw",
291
+ "wrap_emu",
292
+ }
293
+
294
+
295
+ @dataclass()
296
+ class SettingsData:
297
+ """Settings for the W&B SDK."""
298
+
299
+ _args: Sequence[str]
300
+ _aws_lambda: bool
301
+ _async_upload_concurrency_limit: int
302
+ _cli_only_mode: bool # Avoid running any code specific for runs
303
+ _code_path_local: str
304
+ _colab: bool
305
+ # _config_dict: Config
306
+ _cuda: str
307
+ _disable_meta: bool # Do not collect system metadata
308
+ _disable_service: (
309
+ bool # Disable wandb-service, spin up internal process the old way
310
+ )
311
+ _disable_setproctitle: bool # Do not use setproctitle on internal process
312
+ _disable_stats: bool # Do not collect system metrics
313
+ _disable_update_check: bool # Disable version check
314
+ _disable_viewer: bool # Prevent early viewer query
315
+ _disable_machine_info: bool # Disable automatic machine info collection
316
+ _except_exit: bool
317
+ _executable: str
318
+ _extra_http_headers: Mapping[str, str]
319
+ # file stream retry client configuration
320
+ _file_stream_retry_max: int # max number of retries
321
+ _file_stream_retry_wait_min_seconds: float # min wait time between retries
322
+ _file_stream_retry_wait_max_seconds: float # max wait time between retries
323
+ _file_stream_timeout_seconds: float # timeout for individual HTTP requests
324
+ # file transfer retry client configuration
325
+ _file_transfer_retry_max: int
326
+ _file_transfer_retry_wait_min_seconds: float
327
+ _file_transfer_retry_wait_max_seconds: float
328
+ _file_transfer_timeout_seconds: float
329
+ _flow_control_custom: bool
330
+ _flow_control_disabled: bool
331
+ # graphql retry client configuration
332
+ _graphql_retry_max: int
333
+ _graphql_retry_wait_min_seconds: float
334
+ _graphql_retry_wait_max_seconds: float
335
+ _graphql_timeout_seconds: float
336
+ _internal_check_process: float
337
+ _internal_queue_timeout: float
338
+ _ipython: bool
339
+ _jupyter: bool
340
+ _jupyter_name: str
341
+ _jupyter_path: str
342
+ _jupyter_root: str
343
+ _kaggle: bool
344
+ _live_policy_rate_limit: int
345
+ _live_policy_wait_time: int
346
+ _log_level: int
347
+ _network_buffer: int
348
+ _noop: bool
349
+ _notebook: bool
350
+ _offline: bool
351
+ _sync: bool
352
+ _os: str
353
+ _platform: str
354
+ _proxies: Mapping[str, str] # dedicated global proxy servers [scheme -> url]
355
+ _python: str
356
+ _runqueue_item_id: str
357
+ _require_core: bool
358
+ _save_requirements: bool
359
+ _service_transport: str
360
+ _service_wait: float
361
+ _shared: bool
362
+ _start_datetime: str
363
+ _start_time: float
364
+ _stats_pid: int # (internal) base pid for system stats
365
+ _stats_sample_rate_seconds: float
366
+ _stats_samples_to_average: int
367
+ _stats_join_assets: (
368
+ bool # join metrics from different assets before sending to backend
369
+ )
370
+ _stats_neuron_monitor_config_path: (
371
+ str # path to place config file for neuron-monitor (AWS Trainium)
372
+ )
373
+ _stats_open_metrics_endpoints: Mapping[str, str] # open metrics endpoint names/urls
374
+ # open metrics filters in one of the two formats:
375
+ # - {"metric regex pattern, including endpoint name as prefix": {"label": "label value regex pattern"}}
376
+ # - ("metric regex pattern 1", "metric regex pattern 2", ...)
377
+ _stats_open_metrics_filters: Union[Sequence[str], Mapping[str, Mapping[str, str]]]
378
+ _stats_disk_paths: Sequence[str] # paths to monitor disk usage
379
+ _stats_buffer_size: int # number of consolidated samples to buffer before flushing, available in run obj
380
+ _tmp_code_dir: str
381
+ _tracelog: str
382
+ _unsaved_keys: Sequence[str]
383
+ _windows: bool
384
+ allow_val_change: bool
385
+ anonymous: str
386
+ api_key: str
387
+ azure_account_url_to_access_key: Dict[str, str]
388
+ base_url: str # The base url for the wandb api
389
+ code_dir: str
390
+ colab_url: str
391
+ config_paths: Sequence[str]
392
+ console: str
393
+ deployment: str
394
+ disable_code: bool
395
+ disable_git: bool
396
+ disable_hints: bool
397
+ disable_job_creation: bool
398
+ disabled: bool # Alias for mode=dryrun, not supported yet
399
+ docker: str
400
+ email: str
401
+ entity: str
402
+ files_dir: str
403
+ force: bool
404
+ fork_from: Optional[RunMoment]
405
+ git_commit: str
406
+ git_remote: str
407
+ git_remote_url: str
408
+ git_root: str
409
+ heartbeat_seconds: int
410
+ host: str
411
+ ignore_globs: Tuple[str]
412
+ init_timeout: float
413
+ is_local: bool
414
+ job_name: str
415
+ job_source: str
416
+ label_disable: bool
417
+ launch: bool
418
+ launch_config_path: str
419
+ log_dir: str
420
+ log_internal: str
421
+ log_symlink_internal: str
422
+ log_symlink_user: str
423
+ log_user: str
424
+ login_timeout: float
425
+ # magic: Union[str, bool, dict] # never used in code, deprecated
426
+ mode: str
427
+ notebook_name: str
428
+ problem: str
429
+ program: str
430
+ program_abspath: str
431
+ program_relpath: str
432
+ project: str
433
+ project_url: str
434
+ quiet: bool
435
+ reinit: bool
436
+ relogin: bool
437
+ # todo: add a preprocessing step to convert this to string
438
+ resume: Union[str, bool]
439
+ resume_fname: str
440
+ resumed: bool # indication from the server about the state of the run (different from resume - user provided flag)
441
+ root_dir: str
442
+ run_group: str
443
+ run_id: str
444
+ run_job_type: str
445
+ run_mode: str
446
+ run_name: str
447
+ run_notes: str
448
+ run_tags: Tuple[str]
449
+ run_url: str
450
+ sagemaker_disable: bool
451
+ save_code: bool
452
+ settings_system: str
453
+ settings_workspace: str
454
+ show_colors: bool
455
+ show_emoji: bool
456
+ show_errors: bool
457
+ show_info: bool
458
+ show_warnings: bool
459
+ silent: bool
460
+ start_method: str
461
+ strict: bool
462
+ summary_errors: int
463
+ summary_timeout: int
464
+ summary_warnings: int
465
+ sweep_id: str
466
+ sweep_param_path: str
467
+ sweep_url: str
468
+ symlink: bool
469
+ sync_dir: str
470
+ sync_file: str
471
+ sync_symlink_latest: str
472
+ system_sample: int
473
+ system_sample_seconds: int
474
+ table_raise_on_max_row_limit_exceeded: bool
475
+ timespec: str
476
+ tmp_dir: str
477
+ username: str
478
+ wandb_dir: str
479
+
480
+
481
+ class Property:
482
+ """A class to represent attributes (individual settings) of the Settings object.
483
+
484
+ - Encapsulates the logic of how to preprocess and validate values of settings
485
+ throughout the lifetime of a class instance.
486
+ - Allows for runtime modification of settings with hooks, e.g. in the case when
487
+ a setting depends on another setting.
488
+ - The update() method is used to update the value of a setting.
489
+ - The `is_policy` attribute determines the source priority when updating the property value.
490
+ E.g. if `is_policy` is True, the smallest `Source` value takes precedence.
491
+ """
492
+
493
+ def __init__( # pylint: disable=unused-argument
494
+ self,
495
+ name: str,
496
+ value: Optional[Any] = None,
497
+ preprocessor: Union[Callable, Sequence[Callable], None] = None,
498
+ # validators allow programming by contract
499
+ validator: Union[Callable, Sequence[Callable], None] = None,
500
+ # runtime converter (hook): properties can be e.g. tied to other properties
501
+ hook: Union[Callable, Sequence[Callable], None] = None,
502
+ # always apply hook even if value is None. can be used to replace @property's
503
+ auto_hook: bool = False,
504
+ is_policy: bool = False,
505
+ frozen: bool = False,
506
+ source: int = Source.BASE,
507
+ **kwargs: Any,
508
+ ):
509
+ self.name = name
510
+ self._preprocessor = preprocessor
511
+ self._validator = validator
512
+ self._hook = hook
513
+ self._auto_hook = auto_hook
514
+ self._is_policy = is_policy
515
+ self._source = source
516
+
517
+ # preprocess and validate value
518
+ self._value = self._validate(self._preprocess(value))
519
+
520
+ self.__frozen = frozen
521
+
522
+ @property
523
+ def value(self) -> Any:
524
+ """Apply the runtime modifier(s) (if any) and return the value."""
525
+ _value = self._value
526
+ if (_value is not None or self._auto_hook) and self._hook is not None:
527
+ _hook = [self._hook] if callable(self._hook) else self._hook
528
+ for h in _hook:
529
+ _value = h(_value)
530
+ return _value
531
+
532
+ @property
533
+ def is_policy(self) -> bool:
534
+ return self._is_policy
535
+
536
+ @property
537
+ def source(self) -> int:
538
+ return self._source
539
+
540
+ def _preprocess(self, value: Any) -> Any:
541
+ if value is not None and self._preprocessor is not None:
542
+ _preprocessor = (
543
+ [self._preprocessor]
544
+ if callable(self._preprocessor)
545
+ else self._preprocessor
546
+ )
547
+ for p in _preprocessor:
548
+ try:
549
+ value = p(value)
550
+ except Exception:
551
+ raise SettingsPreprocessingError(
552
+ f"Unable to preprocess value for property {self.name}: {value}."
553
+ )
554
+ return value
555
+
556
+ def _validate(self, value: Any) -> Any:
557
+ if value is not None and self._validator is not None:
558
+ _validator = (
559
+ [self._validator] if callable(self._validator) else self._validator
560
+ )
561
+ for v in _validator:
562
+ if not v(value):
563
+ # failed validation will likely cause a downstream error
564
+ # when trying to convert to protobuf, so we raise a hard error
565
+ raise SettingsValidationError(
566
+ f"Invalid value for property {self.name}: {value}."
567
+ )
568
+ return value
569
+
570
+ def update(self, value: Any, source: int = Source.OVERRIDE) -> None:
571
+ """Update the value of the property."""
572
+ if self.__frozen:
573
+ raise TypeError("Property object is frozen")
574
+ # - always update value if source == Source.OVERRIDE
575
+ # - if not previously overridden:
576
+ # - update value if source is lower than or equal to current source and property is policy
577
+ # - update value if source is higher than or equal to current source and property is not policy
578
+ if (
579
+ (source == Source.OVERRIDE)
580
+ or (
581
+ self._is_policy
582
+ and self._source != Source.OVERRIDE
583
+ and source <= self._source
584
+ )
585
+ or (
586
+ not self._is_policy
587
+ and self._source != Source.OVERRIDE
588
+ and source >= self._source
589
+ )
590
+ ):
591
+ # self.__dict__["_value"] = self._validate(self._preprocess(value))
592
+ self._value = self._validate(self._preprocess(value))
593
+ self._source = source
594
+
595
+ def __setattr__(self, key: str, value: Any) -> None:
596
+ if "_Property__frozen" in self.__dict__ and self.__frozen:
597
+ raise TypeError(f"Property object {self.name} is frozen")
598
+ if key == "value":
599
+ raise AttributeError("Use update() to update property value")
600
+ self.__dict__[key] = value
601
+
602
+ def __str__(self) -> str:
603
+ return f"{self.value!r}" if isinstance(self.value, str) else f"{self.value}"
604
+
605
+ def __repr__(self) -> str:
606
+ return (
607
+ f"<Property {self.name}: value={self.value} "
608
+ f"_value={self._value} source={self._source} is_policy={self._is_policy}>"
609
+ )
610
+ # return f"<Property {self.name}: value={self.value}>"
611
+ # return self.__dict__.__repr__()
612
+
613
+
614
+ class Settings(SettingsData):
615
+ """A class to represent modifiable settings."""
616
+
617
+ def _default_props(self) -> Dict[str, Dict[str, Any]]:
618
+ """Initialize instance attributes (individual settings) as Property objects.
619
+
620
+ Helper method that is used in `__init__` together with the class attributes.
621
+ Note that key names must be the same as the class attribute names.
622
+ """
623
+ props: Dict[str, Dict[str, Any]] = dict(
624
+ _async_upload_concurrency_limit={
625
+ "preprocessor": int,
626
+ "validator": self._validate__async_upload_concurrency_limit,
627
+ },
628
+ _aws_lambda={
629
+ "hook": lambda _: is_aws_lambda(),
630
+ "auto_hook": True,
631
+ },
632
+ _code_path_local={
633
+ "hook": lambda _: _get_program_relpath(self.program),
634
+ "auto_hook": True,
635
+ },
636
+ _colab={
637
+ "hook": lambda _: "google.colab" in sys.modules,
638
+ "auto_hook": True,
639
+ },
640
+ _disable_machine_info={
641
+ "value": False,
642
+ "preprocessor": _str_as_bool,
643
+ },
644
+ _disable_meta={
645
+ "value": False,
646
+ "preprocessor": _str_as_bool,
647
+ "hook": lambda x: self._disable_machine_info or x,
648
+ },
649
+ _disable_service={
650
+ "value": False,
651
+ "preprocessor": _str_as_bool,
652
+ "is_policy": True,
653
+ },
654
+ _disable_setproctitle={"value": False, "preprocessor": _str_as_bool},
655
+ _disable_stats={
656
+ "value": False,
657
+ "preprocessor": _str_as_bool,
658
+ "hook": lambda x: self._disable_machine_info or x,
659
+ },
660
+ _disable_update_check={"preprocessor": _str_as_bool},
661
+ _disable_viewer={"preprocessor": _str_as_bool},
662
+ _extra_http_headers={"preprocessor": _str_as_json},
663
+ # Retry filestream requests for 2 hours before dropping chunk (how do we recover?)
664
+ # retry_count = seconds_in_2_hours / max_retry_time + num_retries_until_max_60_sec
665
+ # = 7200 / 60 + ceil(log2(60/2))
666
+ # = 120 + 5
667
+ _file_stream_retry_max={"value": 125, "preprocessor": int},
668
+ _file_stream_retry_wait_min_seconds={"value": 2, "preprocessor": float},
669
+ _file_stream_retry_wait_max_seconds={"value": 60, "preprocessor": float},
670
+ # A 3 minute timeout for all filestream post requests
671
+ _file_stream_timeout_seconds={"value": 180, "preprocessor": float},
672
+ _file_transfer_retry_max={"value": 20, "preprocessor": int},
673
+ _file_transfer_retry_wait_min_seconds={"value": 2, "preprocessor": float},
674
+ _file_transfer_retry_wait_max_seconds={"value": 60, "preprocessor": float},
675
+ _file_transfer_timeout_seconds={"value": 0, "preprocessor": float},
676
+ _flow_control_disabled={
677
+ "hook": lambda _: self._network_buffer == 0,
678
+ "auto_hook": True,
679
+ },
680
+ _flow_control_custom={
681
+ "hook": lambda _: bool(self._network_buffer),
682
+ "auto_hook": True,
683
+ },
684
+ _graphql_retry_max={"value": 20, "preprocessor": int},
685
+ _graphql_retry_wait_min_seconds={"value": 2, "preprocessor": float},
686
+ _graphql_retry_wait_max_seconds={"value": 60, "preprocessor": float},
687
+ _graphql_timeout_seconds={"value": 30.0, "preprocessor": float},
688
+ _internal_check_process={"value": 8, "preprocessor": float},
689
+ _internal_queue_timeout={"value": 2, "preprocessor": float},
690
+ _ipython={
691
+ "hook": lambda _: _get_python_type() == "ipython",
692
+ "auto_hook": True,
693
+ },
694
+ _jupyter={
695
+ "hook": lambda _: _get_python_type() == "jupyter",
696
+ "auto_hook": True,
697
+ },
698
+ _kaggle={"hook": lambda _: util._is_likely_kaggle(), "auto_hook": True},
699
+ _log_level={"value": logging.DEBUG},
700
+ _network_buffer={"preprocessor": int},
701
+ _noop={"hook": lambda _: self.mode == "disabled", "auto_hook": True},
702
+ _notebook={
703
+ "hook": lambda _: self._ipython
704
+ or self._jupyter
705
+ or self._colab
706
+ or self._kaggle,
707
+ "auto_hook": True,
708
+ },
709
+ _offline={
710
+ "hook": (
711
+ lambda _: True
712
+ if self.disabled or (self.mode in ("dryrun", "offline"))
713
+ else False
714
+ ),
715
+ "auto_hook": True,
716
+ },
717
+ _platform={"value": util.get_platform_name()},
718
+ _proxies={
719
+ "preprocessor": _str_as_json,
720
+ },
721
+ _require_core={"value": False, "preprocessor": _str_as_bool},
722
+ _save_requirements={"value": True, "preprocessor": _str_as_bool},
723
+ _service_wait={
724
+ "value": 30,
725
+ "preprocessor": float,
726
+ "validator": self._validate__service_wait,
727
+ },
728
+ _shared={
729
+ "hook": lambda _: self.mode == "shared",
730
+ "auto_hook": True,
731
+ },
732
+ _start_datetime={"preprocessor": _datetime_as_str},
733
+ _stats_sample_rate_seconds={
734
+ "value": 2.0,
735
+ "preprocessor": float,
736
+ "validator": self._validate__stats_sample_rate_seconds,
737
+ },
738
+ _stats_samples_to_average={
739
+ "value": 15,
740
+ "preprocessor": int,
741
+ "validator": self._validate__stats_samples_to_average,
742
+ },
743
+ _stats_join_assets={"value": True, "preprocessor": _str_as_bool},
744
+ _stats_neuron_monitor_config_path={
745
+ "hook": lambda x: self._path_convert(x),
746
+ },
747
+ _stats_open_metrics_endpoints={
748
+ "preprocessor": _str_as_json,
749
+ },
750
+ _stats_open_metrics_filters={
751
+ # capture all metrics on all endpoints by default
752
+ "value": (".*",),
753
+ "preprocessor": _str_as_json,
754
+ },
755
+ _stats_disk_paths={
756
+ "value": ("/",),
757
+ "preprocessor": _str_as_json,
758
+ },
759
+ _stats_buffer_size={
760
+ "value": 0,
761
+ "preprocessor": int,
762
+ },
763
+ _sync={"value": False},
764
+ _tmp_code_dir={
765
+ "value": "code",
766
+ "hook": lambda x: self._path_convert(self.tmp_dir, x),
767
+ },
768
+ _windows={
769
+ "hook": lambda _: platform.system() == "Windows",
770
+ "auto_hook": True,
771
+ },
772
+ anonymous={"validator": self._validate_anonymous},
773
+ api_key={"validator": self._validate_api_key},
774
+ base_url={
775
+ "value": "https://api.wandb.ai",
776
+ "preprocessor": lambda x: str(x).strip().rstrip("/"),
777
+ "validator": self._validate_base_url,
778
+ },
779
+ colab_url={
780
+ "hook": lambda _: self._get_colab_url(),
781
+ "auto_hook": True,
782
+ },
783
+ config_paths={"preprocessor": _str_as_tuple},
784
+ console={
785
+ "value": "auto",
786
+ "validator": self._validate_console,
787
+ "hook": lambda x: self._convert_console(x),
788
+ "auto_hook": True,
789
+ },
790
+ deployment={
791
+ "hook": lambda _: "local" if self.is_local else "cloud",
792
+ "auto_hook": True,
793
+ },
794
+ disable_code={
795
+ "value": False,
796
+ "preprocessor": _str_as_bool,
797
+ "hook": lambda x: self._disable_machine_info or x,
798
+ },
799
+ disable_hints={"preprocessor": _str_as_bool},
800
+ disable_git={
801
+ "value": False,
802
+ "preprocessor": _str_as_bool,
803
+ "hook": lambda x: self._disable_machine_info or x,
804
+ },
805
+ disable_job_creation={
806
+ "value": False,
807
+ "preprocessor": _str_as_bool,
808
+ "hook": lambda x: self._disable_machine_info or x,
809
+ },
810
+ disabled={"value": False, "preprocessor": _str_as_bool},
811
+ files_dir={
812
+ "value": "files",
813
+ "hook": lambda x: self._path_convert(
814
+ self.wandb_dir, f"{self.run_mode}-{self.timespec}-{self.run_id}", x
815
+ ),
816
+ },
817
+ force={"preprocessor": _str_as_bool},
818
+ fork_from={
819
+ "value": None,
820
+ "preprocessor": _runmoment_preprocessor,
821
+ },
822
+ git_remote={"value": "origin"},
823
+ heartbeat_seconds={"value": 30},
824
+ ignore_globs={
825
+ "value": tuple(),
826
+ "preprocessor": lambda x: tuple(x) if not isinstance(x, tuple) else x,
827
+ },
828
+ init_timeout={"value": 90, "preprocessor": lambda x: float(x)},
829
+ is_local={
830
+ "hook": (
831
+ lambda _: self.base_url != "https://api.wandb.ai"
832
+ if self.base_url is not None
833
+ else False
834
+ ),
835
+ "auto_hook": True,
836
+ },
837
+ job_name={"preprocessor": str},
838
+ job_source={"validator": self._validate_job_source},
839
+ label_disable={"preprocessor": _str_as_bool},
840
+ launch={"preprocessor": _str_as_bool},
841
+ log_dir={
842
+ "value": "logs",
843
+ "hook": lambda x: self._path_convert(
844
+ self.wandb_dir, f"{self.run_mode}-{self.timespec}-{self.run_id}", x
845
+ ),
846
+ },
847
+ log_internal={
848
+ "value": "debug-internal.log",
849
+ "hook": lambda x: self._path_convert(self.log_dir, x),
850
+ },
851
+ log_symlink_internal={
852
+ "value": "debug-internal.log",
853
+ "hook": lambda x: self._path_convert(self.wandb_dir, x),
854
+ },
855
+ log_symlink_user={
856
+ "value": "debug.log",
857
+ "hook": lambda x: self._path_convert(self.wandb_dir, x),
858
+ },
859
+ log_user={
860
+ "value": "debug.log",
861
+ "hook": lambda x: self._path_convert(self.log_dir, x),
862
+ },
863
+ login_timeout={"preprocessor": lambda x: float(x)},
864
+ mode={"value": "online", "validator": self._validate_mode},
865
+ problem={"value": "fatal", "validator": self._validate_problem},
866
+ program={
867
+ "hook": lambda x: self._get_program(x),
868
+ },
869
+ project={"validator": self._validate_project},
870
+ project_url={"hook": lambda _: self._project_url(), "auto_hook": True},
871
+ quiet={"preprocessor": _str_as_bool},
872
+ reinit={"preprocessor": _str_as_bool},
873
+ relogin={"preprocessor": _str_as_bool},
874
+ # todo: hack to make to_proto() always happy
875
+ resume={"preprocessor": lambda x: None if x is False else x},
876
+ resume_fname={
877
+ "value": "wandb-resume.json",
878
+ "hook": lambda x: self._path_convert(self.wandb_dir, x),
879
+ },
880
+ resumed={"value": "False", "preprocessor": _str_as_bool},
881
+ root_dir={
882
+ "preprocessor": lambda x: str(x),
883
+ "value": os.path.abspath(os.getcwd()),
884
+ },
885
+ run_id={
886
+ "validator": self._validate_run_id,
887
+ },
888
+ run_mode={
889
+ "hook": lambda _: "offline-run" if self._offline else "run",
890
+ "auto_hook": True,
891
+ },
892
+ run_tags={
893
+ "preprocessor": lambda x: tuple(x) if not isinstance(x, tuple) else x,
894
+ },
895
+ run_url={"hook": lambda _: self._run_url(), "auto_hook": True},
896
+ sagemaker_disable={"preprocessor": _str_as_bool},
897
+ save_code={"preprocessor": _str_as_bool},
898
+ settings_system={
899
+ "value": os.path.join("~", ".config", "wandb", "settings"),
900
+ "hook": lambda x: self._path_convert(x),
901
+ },
902
+ settings_workspace={
903
+ "value": "settings",
904
+ "hook": lambda x: self._path_convert(self.wandb_dir, x),
905
+ },
906
+ show_colors={"preprocessor": _str_as_bool},
907
+ show_emoji={"preprocessor": _str_as_bool},
908
+ show_errors={"value": "True", "preprocessor": _str_as_bool},
909
+ show_info={"value": "True", "preprocessor": _str_as_bool},
910
+ show_warnings={"value": "True", "preprocessor": _str_as_bool},
911
+ silent={"value": "False", "preprocessor": _str_as_bool},
912
+ start_method={"validator": self._validate_start_method},
913
+ strict={"preprocessor": _str_as_bool},
914
+ summary_timeout={"value": 60, "preprocessor": lambda x: int(x)},
915
+ summary_warnings={
916
+ "value": 5,
917
+ "preprocessor": lambda x: int(x),
918
+ "is_policy": True,
919
+ },
920
+ sweep_url={"hook": lambda _: self._sweep_url(), "auto_hook": True},
921
+ symlink={"preprocessor": _str_as_bool},
922
+ sync_dir={
923
+ "hook": [
924
+ lambda _: self._path_convert(
925
+ self.wandb_dir, f"{self.run_mode}-{self.timespec}-{self.run_id}"
926
+ )
927
+ ],
928
+ "auto_hook": True,
929
+ },
930
+ sync_file={
931
+ "hook": lambda _: self._path_convert(
932
+ self.sync_dir, f"run-{self.run_id}.wandb"
933
+ ),
934
+ "auto_hook": True,
935
+ },
936
+ sync_symlink_latest={
937
+ "value": "latest-run",
938
+ "hook": lambda x: self._path_convert(self.wandb_dir, x),
939
+ },
940
+ system_sample={"value": 15},
941
+ system_sample_seconds={"value": 2},
942
+ table_raise_on_max_row_limit_exceeded={
943
+ "value": False,
944
+ "preprocessor": _str_as_bool,
945
+ },
946
+ timespec={
947
+ "hook": lambda _: self._start_datetime,
948
+ "auto_hook": True,
949
+ },
950
+ tmp_dir={
951
+ "value": "tmp",
952
+ "hook": lambda x: (
953
+ self._path_convert(
954
+ self.wandb_dir,
955
+ f"{self.run_mode}-{self.timespec}-{self.run_id}",
956
+ x,
957
+ )
958
+ or tempfile.gettempdir()
959
+ ),
960
+ },
961
+ wandb_dir={
962
+ "hook": lambda _: _get_wandb_dir(self.root_dir or ""),
963
+ "auto_hook": True,
964
+ },
965
+ )
966
+ return props
967
+
968
+ # helper methods for validating values
969
+ @staticmethod
970
+ def _validator_factory(hint: Any) -> Callable[[Any], bool]: # noqa: C901
971
+ """Return a factory for setting type validators."""
972
+
973
+ def helper(value: Any) -> bool:
974
+ try:
975
+ is_valid = is_instance_recursive(value, hint)
976
+ except Exception:
977
+ # instance check failed, but let's not crash and only print a warning
978
+ is_valid = False
979
+
980
+ return is_valid
981
+
982
+ return helper
983
+
984
+ @staticmethod
985
+ def _validate_mode(value: str) -> bool:
986
+ choices: Set[str] = {"dryrun", "run", "offline", "online", "disabled", "shared"}
987
+ if value not in choices:
988
+ raise UsageError(f"Settings field `mode`: {value!r} not in {choices}")
989
+ return True
990
+
991
+ @staticmethod
992
+ def _validate_project(value: Optional[str]) -> bool:
993
+ invalid_chars_list = list("/\\#?%:")
994
+ if value is not None:
995
+ if len(value) > 128:
996
+ raise UsageError(
997
+ f"Invalid project name {value!r}: exceeded 128 characters"
998
+ )
999
+ invalid_chars = {char for char in invalid_chars_list if char in value}
1000
+ if invalid_chars:
1001
+ raise UsageError(
1002
+ f"Invalid project name {value!r}: "
1003
+ f"cannot contain characters {','.join(invalid_chars_list)!r}, "
1004
+ f"found {','.join(invalid_chars)!r}"
1005
+ )
1006
+ return True
1007
+
1008
+ @staticmethod
1009
+ def _validate_start_method(value: str) -> bool:
1010
+ available_methods = ["thread"]
1011
+ if hasattr(multiprocessing, "get_all_start_methods"):
1012
+ available_methods += multiprocessing.get_all_start_methods()
1013
+ if value not in available_methods:
1014
+ raise UsageError(
1015
+ f"Settings field `start_method`: {value!r} not in {available_methods}"
1016
+ )
1017
+ return True
1018
+
1019
+ @staticmethod
1020
+ def _validate_console(value: str) -> bool:
1021
+ choices = ConsoleValue
1022
+ if value not in choices:
1023
+ # do not advertise internal console states
1024
+ choices -= {"wrap_emu", "wrap_raw"}
1025
+ raise UsageError(f"Settings field `console`: {value!r} not in {choices}")
1026
+ return True
1027
+
1028
+ @staticmethod
1029
+ def _validate_problem(value: str) -> bool:
1030
+ choices: Set[str] = {"fatal", "warn", "silent"}
1031
+ if value not in choices:
1032
+ raise UsageError(f"Settings field `problem`: {value!r} not in {choices}")
1033
+ return True
1034
+
1035
+ @staticmethod
1036
+ def _validate_anonymous(value: str) -> bool:
1037
+ choices: Set[str] = {"allow", "must", "never", "false", "true"}
1038
+ if value not in choices:
1039
+ raise UsageError(f"Settings field `anonymous`: {value!r} not in {choices}")
1040
+ return True
1041
+
1042
+ @staticmethod
1043
+ def _validate_run_id(value: str) -> bool:
1044
+ # if len(value) > len(value.strip()):
1045
+ # raise UsageError("Run ID cannot start or end with whitespace")
1046
+ return bool(value.strip())
1047
+
1048
+ @staticmethod
1049
+ def _validate_api_key(value: str) -> bool:
1050
+ if len(value) > len(value.strip()):
1051
+ raise UsageError("API key cannot start or end with whitespace")
1052
+
1053
+ # todo: move this check to the post-init validation step
1054
+ # if value.startswith("local") and not self.is_local:
1055
+ # raise UsageError(
1056
+ # "Attempting to use a local API key to connect to https://api.wandb.ai"
1057
+ # )
1058
+ # todo: move here the logic from sdk/lib/apikey.py
1059
+
1060
+ return True
1061
+
1062
+ @staticmethod
1063
+ def _validate_base_url(value: Optional[str]) -> bool:
1064
+ """Validate the base url of the wandb server.
1065
+
1066
+ param value: URL to validate
1067
+
1068
+ Based on the Django URLValidator, but with a few additional checks.
1069
+
1070
+ Copyright (c) Django Software Foundation and individual contributors.
1071
+ All rights reserved.
1072
+
1073
+ Redistribution and use in source and binary forms, with or without modification,
1074
+ are permitted provided that the following conditions are met:
1075
+
1076
+ 1. Redistributions of source code must retain the above copyright notice,
1077
+ this list of conditions and the following disclaimer.
1078
+
1079
+ 2. Redistributions in binary form must reproduce the above copyright
1080
+ notice, this list of conditions and the following disclaimer in the
1081
+ documentation and/or other materials provided with the distribution.
1082
+
1083
+ 3. Neither the name of Django nor the names of its contributors may be used
1084
+ to endorse or promote products derived from this software without
1085
+ specific prior written permission.
1086
+
1087
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
1088
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1089
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1090
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
1091
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1092
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1093
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
1094
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1095
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1096
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1097
+ """
1098
+ if value is None:
1099
+ return True
1100
+
1101
+ ul = "\u00a1-\uffff" # Unicode letters range (must not be a raw string).
1102
+
1103
+ # IP patterns
1104
+ ipv4_re = (
1105
+ r"(?:0|25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?)"
1106
+ r"(?:\.(?:0|25[0-5]|2[0-4][0-9]|1[0-9]?[0-9]?|[1-9][0-9]?)){3}"
1107
+ )
1108
+ ipv6_re = r"\[[0-9a-f:.]+\]" # (simple regex, validated later)
1109
+
1110
+ # Host patterns
1111
+ hostname_re = (
1112
+ r"[a-z" + ul + r"0-9](?:[a-z" + ul + r"0-9-]{0,61}[a-z" + ul + r"0-9])?"
1113
+ )
1114
+ # Max length for domain name labels is 63 characters per RFC 1034 sec. 3.1
1115
+ domain_re = r"(?:\.(?!-)[a-z" + ul + r"0-9-]{1,63}(?<!-))*"
1116
+ tld_re = (
1117
+ r"\." # dot
1118
+ r"(?!-)" # can't start with a dash
1119
+ r"(?:[a-z" + ul + "-]{2,63}" # domain label
1120
+ r"|xn--[a-z0-9]{1,59})" # or punycode label
1121
+ r"(?<!-)" # can't end with a dash
1122
+ r"\.?" # may have a trailing dot
1123
+ )
1124
+ # host_re = "(" + hostname_re + domain_re + tld_re + "|localhost)"
1125
+ # todo?: allow hostname to be just a hostname (no tld)?
1126
+ host_re = "(" + hostname_re + domain_re + f"({tld_re})?" + "|localhost)"
1127
+
1128
+ regex = re.compile(
1129
+ r"^(?:[a-z0-9.+-]*)://" # scheme is validated separately
1130
+ r"(?:[^\s:@/]+(?::[^\s:@/]*)?@)?" # user:pass authentication
1131
+ r"(?:" + ipv4_re + "|" + ipv6_re + "|" + host_re + ")"
1132
+ r"(?::[0-9]{1,5})?" # port
1133
+ r"(?:[/?#][^\s]*)?" # resource path
1134
+ r"\Z",
1135
+ re.IGNORECASE,
1136
+ )
1137
+ schemes = {"http", "https"}
1138
+ unsafe_chars = frozenset("\t\r\n")
1139
+
1140
+ scheme = value.split("://")[0].lower()
1141
+ split_url = urlsplit(value)
1142
+ parsed_url = urlparse(value)
1143
+
1144
+ if re.match(r".*wandb\.ai[^\.]*$", value) and "api." not in value:
1145
+ # user might guess app.wandb.ai or wandb.ai is the default cloud server
1146
+ raise UsageError(
1147
+ f"{value} is not a valid server address, did you mean https://api.wandb.ai?"
1148
+ )
1149
+ elif re.match(r".*wandb\.ai[^\.]*$", value) and scheme != "https":
1150
+ raise UsageError("http is not secure, please use https://api.wandb.ai")
1151
+ elif parsed_url.netloc == "":
1152
+ raise UsageError(f"Invalid URL: {value}")
1153
+ elif unsafe_chars.intersection(value):
1154
+ raise UsageError("URL cannot contain unsafe characters")
1155
+ elif scheme not in schemes:
1156
+ raise UsageError("URL must start with `http(s)://`")
1157
+ elif not regex.search(value):
1158
+ raise UsageError(f"{value} is not a valid server address")
1159
+ elif split_url.hostname is None or len(split_url.hostname) > 253:
1160
+ raise UsageError("hostname is invalid")
1161
+
1162
+ return True
1163
+
1164
+ @staticmethod
1165
+ def _validate__service_wait(value: float) -> bool:
1166
+ if value <= 0:
1167
+ raise UsageError("_service_wait must be a positive number")
1168
+ return True
1169
+
1170
+ @staticmethod
1171
+ def _validate__stats_sample_rate_seconds(value: float) -> bool:
1172
+ if value < 0.1:
1173
+ raise UsageError("_stats_sample_rate_seconds must be >= 0.1")
1174
+ return True
1175
+
1176
+ @staticmethod
1177
+ def _validate__stats_samples_to_average(value: int) -> bool:
1178
+ if value < 1 or value > 30:
1179
+ raise UsageError("_stats_samples_to_average must be between 1 and 30")
1180
+ return True
1181
+
1182
+ @staticmethod
1183
+ def _validate__async_upload_concurrency_limit(value: int) -> bool:
1184
+ if value <= 0:
1185
+ raise UsageError("_async_upload_concurrency_limit must be positive")
1186
+
1187
+ try:
1188
+ import resource # not always available on Windows
1189
+
1190
+ file_limit = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
1191
+ except Exception:
1192
+ # Couldn't get the open-file-limit for some reason,
1193
+ # probably very platform-specific. Not a problem,
1194
+ # we just won't use it to cap the concurrency.
1195
+ pass
1196
+ else:
1197
+ if value > file_limit:
1198
+ wandb.termwarn(
1199
+ (
1200
+ "_async_upload_concurrency_limit setting of"
1201
+ f" {value} exceeds this process's limit"
1202
+ f" on open files ({file_limit}); may cause file-upload failures."
1203
+ " Try decreasing _async_upload_concurrency_limit,"
1204
+ " or increasing your file limit with `ulimit -n`."
1205
+ ),
1206
+ repeat=False,
1207
+ )
1208
+
1209
+ return True
1210
+
1211
+ @staticmethod
1212
+ def _validate_job_source(value: str) -> bool:
1213
+ valid_sources = ["repo", "artifact", "image"]
1214
+ if value not in valid_sources:
1215
+ raise UsageError(
1216
+ f"Settings field `job_source`: {value!r} not in {valid_sources}"
1217
+ )
1218
+ return True
1219
+
1220
+ # other helper methods
1221
+ @staticmethod
1222
+ def _path_convert(*args: str) -> str:
1223
+ """Join path and apply os.path.expanduser to it."""
1224
+ return os.path.expanduser(os.path.join(*args))
1225
+
1226
+ def _convert_console(self, console: str) -> str:
1227
+ if console == "auto":
1228
+ if (
1229
+ self._jupyter
1230
+ or (self.start_method == "thread")
1231
+ or not self._disable_service
1232
+ or self._windows
1233
+ ):
1234
+ console = "wrap"
1235
+ else:
1236
+ console = "redirect"
1237
+ return console
1238
+
1239
+ def _get_colab_url(self) -> Optional[str]:
1240
+ if not self._colab:
1241
+ return None
1242
+ if self._jupyter_path and self._jupyter_path.startswith("fileId="):
1243
+ unescaped = unquote(self._jupyter_path)
1244
+ return "https://colab.research.google.com/notebook#" + unescaped
1245
+ return None
1246
+
1247
+ def _get_program(self, program: Optional[str]) -> Optional[str]:
1248
+ if program is not None and program != "<python with no main file>":
1249
+ return program
1250
+
1251
+ if not self._jupyter:
1252
+ return program
1253
+
1254
+ if self.notebook_name:
1255
+ return self.notebook_name
1256
+
1257
+ if not self._jupyter_path:
1258
+ return program
1259
+
1260
+ if self._jupyter_path.startswith("fileId="):
1261
+ return self._jupyter_name
1262
+ else:
1263
+ return self._jupyter_path
1264
+
1265
+ def _get_url_query_string(self) -> str:
1266
+ # TODO(settings) use `wandb_setting` (if self.anonymous != "true":)
1267
+ if Api().settings().get("anonymous") != "true":
1268
+ return ""
1269
+
1270
+ api_key = apikey.api_key(settings=self)
1271
+
1272
+ return f"?{urlencode({'apiKey': api_key})}"
1273
+
1274
+ def _project_url_base(self) -> str:
1275
+ if not all([self.entity, self.project]):
1276
+ return ""
1277
+
1278
+ app_url = wandb.util.app_url(self.base_url)
1279
+ return f"{app_url}/{quote(self.entity)}/{quote(self.project)}"
1280
+
1281
+ def _project_url(self) -> str:
1282
+ project_url = self._project_url_base()
1283
+ if not project_url:
1284
+ return ""
1285
+
1286
+ query = self._get_url_query_string()
1287
+
1288
+ return f"{project_url}{query}"
1289
+
1290
+ def _run_url(self) -> str:
1291
+ """Return the run url."""
1292
+ project_url = self._project_url_base()
1293
+ if not all([project_url, self.run_id]):
1294
+ return ""
1295
+
1296
+ query = self._get_url_query_string()
1297
+ return f"{project_url}/runs/{quote(self.run_id)}{query}"
1298
+
1299
+ def _set_run_start_time(self, source: int = Source.BASE) -> None:
1300
+ """Set the time stamps for the settings.
1301
+
1302
+ Called once the run is initialized.
1303
+ """
1304
+ time_stamp: float = time.time()
1305
+ datetime_now: datetime = datetime.fromtimestamp(time_stamp)
1306
+ datetime_now_str = _datetime_as_str(datetime_now)
1307
+ object.__setattr__(self, "_Settings_start_datetime", datetime_now_str)
1308
+ object.__setattr__(self, "_Settings_start_time", time_stamp)
1309
+ self.update(
1310
+ _start_datetime=datetime_now_str,
1311
+ _start_time=time_stamp,
1312
+ source=source,
1313
+ )
1314
+
1315
+ def _sweep_url(self) -> str:
1316
+ """Return the sweep url."""
1317
+ project_url = self._project_url_base()
1318
+ if not all([project_url, self.sweep_id]):
1319
+ return ""
1320
+
1321
+ query = self._get_url_query_string()
1322
+ return f"{project_url}/sweeps/{quote(self.sweep_id)}{query}"
1323
+
1324
+ def __init__(self, **kwargs: Any) -> None:
1325
+ self.__frozen: bool = False
1326
+ self.__initialized: bool = False
1327
+
1328
+ self.__modification_order = SETTINGS_TOPOLOGICALLY_SORTED
1329
+
1330
+ # Set default settings values
1331
+ # We start off with the class attributes and `default_props` dicts
1332
+ # and then create Property objects.
1333
+ # Once initialized, attributes are to only be updated using the `update` method
1334
+ default_props = self._default_props()
1335
+
1336
+ # Init instance attributes as Property objects.
1337
+ # Type hints of class attributes are used to generate a type validator function
1338
+ # for runtime checks for each attribute.
1339
+ # These are defaults, using Source.BASE for non-policy attributes and Source.RUN for policies.
1340
+ for prop, type_hint in get_type_hints(SettingsData).items():
1341
+ validators = [self._validator_factory(type_hint)]
1342
+
1343
+ if prop in default_props:
1344
+ validator = default_props[prop].pop("validator", [])
1345
+ # Property validator could be either Callable or Sequence[Callable]
1346
+ if callable(validator):
1347
+ validators.append(validator)
1348
+ elif isinstance(validator, Sequence):
1349
+ validators.extend(list(validator))
1350
+ object.__setattr__(
1351
+ self,
1352
+ prop,
1353
+ Property(
1354
+ name=prop,
1355
+ **default_props[prop],
1356
+ validator=validators,
1357
+ # todo: double-check this logic:
1358
+ source=Source.RUN
1359
+ if default_props[prop].get("is_policy", False)
1360
+ else Source.BASE,
1361
+ ),
1362
+ )
1363
+ else:
1364
+ object.__setattr__(
1365
+ self,
1366
+ prop,
1367
+ Property(
1368
+ name=prop,
1369
+ validator=validators,
1370
+ source=Source.BASE,
1371
+ ),
1372
+ )
1373
+
1374
+ # update overridden defaults from kwargs
1375
+ unexpected_arguments = [k for k in kwargs.keys() if k not in self.__dict__]
1376
+ # allow only explicitly defined arguments
1377
+ if unexpected_arguments:
1378
+ raise SettingsUnexpectedArgsError(
1379
+ f"Got unexpected arguments: {unexpected_arguments}. "
1380
+ )
1381
+
1382
+ # automatically inspect setting validators and runtime hooks and topologically sort them
1383
+ # so that we can safely update them. throw error if there are cycles.
1384
+ for prop in self.__modification_order:
1385
+ if prop in kwargs:
1386
+ source = Source.RUN if self.__dict__[prop].is_policy else Source.BASE
1387
+ self.update({prop: kwargs[prop]}, source=source)
1388
+ kwargs.pop(prop)
1389
+
1390
+ for k, v in kwargs.items():
1391
+ # todo: double-check this logic:
1392
+ source = Source.RUN if self.__dict__[k].is_policy else Source.BASE
1393
+ self.update({k: v}, source=source)
1394
+
1395
+ # setup private attributes
1396
+ object.__setattr__(self, "_Settings_start_datetime", None)
1397
+ object.__setattr__(self, "_Settings_start_time", None)
1398
+
1399
+ # done with init, use self.update() to update attributes from now on
1400
+ self.__initialized = True
1401
+
1402
+ # todo? freeze settings to prevent accidental changes
1403
+ # self.freeze()
1404
+
1405
+ def __str__(self) -> str:
1406
+ # get attributes that are instances of the Property class:
1407
+ representation = {
1408
+ k: v.value for k, v in self.__dict__.items() if isinstance(v, Property)
1409
+ }
1410
+ return f"<Settings {_redact_dict(representation)}>"
1411
+
1412
+ def __repr__(self) -> str:
1413
+ # private attributes
1414
+ private = {k: v for k, v in self.__dict__.items() if k.startswith("_Settings")}
1415
+ # get attributes that are instances of the Property class:
1416
+ attributes = {
1417
+ k: f"<Property value={v.value} source={v.source}>"
1418
+ for k, v in self.__dict__.items()
1419
+ if isinstance(v, Property)
1420
+ }
1421
+ representation = {**private, **attributes}
1422
+ return f"<Settings {representation}>"
1423
+
1424
+ def __copy__(self) -> "Settings":
1425
+ """Ensure that a copy of the settings object is a truly deep copy.
1426
+
1427
+ Note that the copied object will not be frozen todo? why is this needed?
1428
+ """
1429
+ # get attributes that are instances of the Property class:
1430
+ attributes = {k: v for k, v in self.__dict__.items() if isinstance(v, Property)}
1431
+ new = Settings()
1432
+ # update properties that have deps or are dependent on in the topologically-sorted order
1433
+ for prop in self.__modification_order:
1434
+ new.update({prop: attributes[prop]._value}, source=attributes[prop].source)
1435
+ attributes.pop(prop)
1436
+
1437
+ # update the remaining attributes
1438
+ for k, v in attributes.items():
1439
+ # make sure to use the raw property value (v._value),
1440
+ # not the potential result of runtime hooks applied to it (v.value)
1441
+ new.update({k: v._value}, source=v.source)
1442
+ new.unfreeze()
1443
+
1444
+ return new
1445
+
1446
+ def __deepcopy__(self, memo: dict) -> "Settings":
1447
+ return self.__copy__()
1448
+
1449
+ # attribute access methods
1450
+ @no_type_check # this is a hack to make mypy happy
1451
+ def __getattribute__(self, name: str) -> Any:
1452
+ """Expose `attribute.value` if `attribute` is a Property."""
1453
+ item = object.__getattribute__(self, name)
1454
+ if isinstance(item, Property):
1455
+ return item.value
1456
+ return item
1457
+
1458
+ def __setattr__(self, key: str, value: Any) -> None:
1459
+ if "_Settings__initialized" in self.__dict__ and self.__initialized:
1460
+ raise TypeError(f"Please use update() to update attribute `{key}` value")
1461
+ object.__setattr__(self, key, value)
1462
+
1463
+ def __iter__(self) -> Iterable:
1464
+ return iter(self.to_dict())
1465
+
1466
+ def copy(self) -> "Settings":
1467
+ return self.__copy__()
1468
+
1469
+ # implement the Mapping interface
1470
+ def keys(self) -> Iterable[str]:
1471
+ return self.to_dict().keys()
1472
+
1473
+ @no_type_check # this is a hack to make mypy happy
1474
+ def __getitem__(self, name: str) -> Any:
1475
+ """Expose attribute.value if attribute is a Property."""
1476
+ item = object.__getattribute__(self, name)
1477
+ if isinstance(item, Property):
1478
+ return item.value
1479
+ return item
1480
+
1481
+ def update(
1482
+ self,
1483
+ settings: Optional[Union[Dict[str, Any], "Settings"]] = None,
1484
+ source: int = Source.OVERRIDE,
1485
+ **kwargs: Any,
1486
+ ) -> None:
1487
+ """Update individual settings."""
1488
+ if "_Settings__frozen" in self.__dict__ and self.__frozen:
1489
+ raise TypeError("Settings object is frozen")
1490
+
1491
+ if isinstance(settings, Settings):
1492
+ # If a Settings object is passed, detect the settings that differ
1493
+ # from defaults, collect them into a dict, and apply them using `source`.
1494
+ # This comes up in `wandb.init(settings=wandb.Settings(...))` and
1495
+ # seems like the behavior that the user would expect when calling init that way.
1496
+ defaults = Settings()
1497
+ settings_dict = dict()
1498
+ for k, v in settings.__dict__.items():
1499
+ if isinstance(v, Property):
1500
+ if v._value != defaults.__dict__[k]._value:
1501
+ settings_dict[k] = v._value
1502
+ # replace with the generated dict
1503
+ settings = settings_dict
1504
+
1505
+ # add kwargs to settings
1506
+ settings = settings or dict()
1507
+ # explicit kwargs take precedence over settings
1508
+ settings = {**settings, **kwargs}
1509
+ unknown_properties = []
1510
+ for key in settings.keys():
1511
+ # only allow updating known Properties
1512
+ if key not in self.__dict__ or not isinstance(self.__dict__[key], Property):
1513
+ unknown_properties.append(key)
1514
+ if unknown_properties:
1515
+ raise KeyError(f"Unknown settings: {unknown_properties}")
1516
+ # only if all keys are valid, update them
1517
+
1518
+ # store settings to be updated in a dict to preserve stats on preprocessing and validation errors
1519
+ settings.copy()
1520
+
1521
+ # update properties that have deps or are dependent on in the topologically-sorted order
1522
+ for key in self.__modification_order:
1523
+ if key in settings:
1524
+ self.__dict__[key].update(settings.pop(key), source=source)
1525
+
1526
+ # update the remaining properties
1527
+ for key, value in settings.items():
1528
+ self.__dict__[key].update(value, source)
1529
+
1530
+ def items(self) -> ItemsView[str, Any]:
1531
+ return self.to_dict().items()
1532
+
1533
+ def get(self, key: str, default: Optional[Any] = None) -> Any:
1534
+ return self.to_dict().get(key, default)
1535
+
1536
+ def freeze(self) -> None:
1537
+ object.__setattr__(self, "_Settings__frozen", True)
1538
+
1539
+ def unfreeze(self) -> None:
1540
+ object.__setattr__(self, "_Settings__frozen", False)
1541
+
1542
+ def is_frozen(self) -> bool:
1543
+ return self.__frozen
1544
+
1545
+ def to_dict(self) -> Dict[str, Any]:
1546
+ """Return a dict representation of the settings."""
1547
+ # get attributes that are instances of the Property class:
1548
+ attributes = {
1549
+ k: v.value for k, v in self.__dict__.items() if isinstance(v, Property)
1550
+ }
1551
+ return attributes
1552
+
1553
+ def to_proto(self) -> wandb_settings_pb2.Settings:
1554
+ """Generate a protobuf representation of the settings."""
1555
+ from dataclasses import fields
1556
+
1557
+ settings = wandb_settings_pb2.Settings()
1558
+ for field in fields(SettingsData):
1559
+ k = field.name
1560
+ v = getattr(self, k)
1561
+ # special case for _stats_open_metrics_filters
1562
+ if k == "_stats_open_metrics_filters":
1563
+ if isinstance(v, (list, set, tuple)):
1564
+ setting = getattr(settings, k)
1565
+ setting.sequence.value.extend(v)
1566
+ elif isinstance(v, dict):
1567
+ setting = getattr(settings, k)
1568
+ for key, value in v.items():
1569
+ for kk, vv in value.items():
1570
+ setting.mapping.value[key].value[kk] = vv
1571
+ else:
1572
+ raise TypeError(f"Unsupported type {type(v)} for setting {k}")
1573
+ continue
1574
+
1575
+ if isinstance(v, bool):
1576
+ getattr(settings, k).CopyFrom(BoolValue(value=v))
1577
+ elif isinstance(v, int):
1578
+ getattr(settings, k).CopyFrom(Int32Value(value=v))
1579
+ elif isinstance(v, float):
1580
+ getattr(settings, k).CopyFrom(DoubleValue(value=v))
1581
+ elif isinstance(v, str):
1582
+ getattr(settings, k).CopyFrom(StringValue(value=v))
1583
+ elif isinstance(v, (list, set, tuple)):
1584
+ # we only support sequences of strings for now
1585
+ sequence = getattr(settings, k)
1586
+ sequence.value.extend(v)
1587
+ elif isinstance(v, dict):
1588
+ mapping = getattr(settings, k)
1589
+ for key, value in v.items():
1590
+ # we only support dicts with string values for now
1591
+ mapping.value[key] = value
1592
+ elif isinstance(v, RunMoment):
1593
+ getattr(settings, k).CopyFrom(
1594
+ wandb_settings_pb2.RunMoment(
1595
+ run=v.run,
1596
+ value=v.value,
1597
+ metric=v.metric,
1598
+ )
1599
+ )
1600
+ elif v is None:
1601
+ # None is the default value for all settings, so we don't need to set it,
1602
+ # i.e. None means that the value was not set.
1603
+ pass
1604
+ else:
1605
+ raise TypeError(f"Unsupported type {type(v)} for setting {k}")
1606
+ # TODO: store property sources in the protobuf so that we can reconstruct the
1607
+ # settings object from the protobuf
1608
+ return settings
1609
+
1610
+ # apply settings from different sources
1611
+ # TODO(dd): think about doing some|all of that at init
1612
+ def _apply_settings(
1613
+ self,
1614
+ settings: "Settings",
1615
+ _logger: Optional[_EarlyLogger] = None,
1616
+ ) -> None:
1617
+ """Apply settings from a Settings object."""
1618
+ if _logger is not None:
1619
+ _logger.info(f"Applying settings from {settings}")
1620
+ attributes = {
1621
+ k: v for k, v in settings.__dict__.items() if isinstance(v, Property)
1622
+ }
1623
+ # update properties that have deps or are dependent on in the topologically-sorted order
1624
+ for prop in self.__modification_order:
1625
+ self.update({prop: attributes[prop]._value}, source=attributes[prop].source)
1626
+ attributes.pop(prop)
1627
+ # update the remaining properties
1628
+ for k, v in attributes.items():
1629
+ # note that only the same/higher priority settings are propagated
1630
+ self.update({k: v._value}, source=v.source)
1631
+
1632
+ @staticmethod
1633
+ def _load_config_file(file_name: str, section: str = "default") -> dict:
1634
+ parser = configparser.ConfigParser()
1635
+ parser.add_section(section)
1636
+ parser.read(file_name)
1637
+ config: Dict[str, Any] = dict()
1638
+ for k in parser[section]:
1639
+ config[k] = parser[section][k]
1640
+ # TODO (cvp): we didn't do this in the old cli, but it seems necessary
1641
+ if k == "ignore_globs":
1642
+ config[k] = config[k].split(",")
1643
+ return config
1644
+
1645
+ def _apply_base(self, pid: int, _logger: Optional[_EarlyLogger] = None) -> None:
1646
+ if _logger is not None:
1647
+ _logger.info(f"Current SDK version is {wandb.__version__}")
1648
+ _logger.info(f"Configure stats pid to {pid}")
1649
+ self.update({"_stats_pid": pid}, source=Source.SETUP)
1650
+
1651
+ def _apply_config_files(self, _logger: Optional[_EarlyLogger] = None) -> None:
1652
+ # TODO(jhr): permit setting of config in system and workspace
1653
+ if self.settings_system is not None:
1654
+ if _logger is not None:
1655
+ _logger.info(f"Loading settings from {self.settings_system}")
1656
+ self.update(
1657
+ self._load_config_file(self.settings_system),
1658
+ source=Source.SYSTEM,
1659
+ )
1660
+ if self.settings_workspace is not None:
1661
+ if _logger is not None:
1662
+ _logger.info(f"Loading settings from {self.settings_workspace}")
1663
+ self.update(
1664
+ self._load_config_file(self.settings_workspace),
1665
+ source=Source.WORKSPACE,
1666
+ )
1667
+
1668
+ def _apply_env_vars(
1669
+ self,
1670
+ environ: Mapping[str, Any],
1671
+ _logger: Optional[_EarlyLogger] = None,
1672
+ ) -> None:
1673
+ env_prefix: str = "WANDB_"
1674
+ special_env_var_names = {
1675
+ "WANDB_TRACELOG": "_tracelog",
1676
+ "WANDB_DISABLE_SERVICE": "_disable_service",
1677
+ "WANDB_SERVICE_TRANSPORT": "_service_transport",
1678
+ "WANDB_DIR": "root_dir",
1679
+ "WANDB_NAME": "run_name",
1680
+ "WANDB_NOTES": "run_notes",
1681
+ "WANDB_TAGS": "run_tags",
1682
+ "WANDB_JOB_TYPE": "run_job_type",
1683
+ "WANDB_HTTP_TIMEOUT": "_graphql_timeout_seconds",
1684
+ "WANDB_FILE_PUSHER_TIMEOUT": "_file_transfer_timeout_seconds",
1685
+ "WANDB_USER_EMAIL": "email",
1686
+ }
1687
+ env = dict()
1688
+ for setting, value in environ.items():
1689
+ if not setting.startswith(env_prefix):
1690
+ continue
1691
+
1692
+ if setting in special_env_var_names:
1693
+ key = special_env_var_names[setting]
1694
+ else:
1695
+ # otherwise, strip the prefix and convert to lowercase
1696
+ key = setting[len(env_prefix) :].lower()
1697
+
1698
+ if key in self.__dict__:
1699
+ if key in ("ignore_globs", "run_tags"):
1700
+ value = value.split(",")
1701
+ env[key] = value
1702
+ elif _logger is not None:
1703
+ _logger.warning(f"Unknown environment variable: {setting}")
1704
+
1705
+ if _logger is not None:
1706
+ _logger.info(
1707
+ f"Loading settings from environment variables: {_redact_dict(env)}"
1708
+ )
1709
+ self.update(env, source=Source.ENV)
1710
+
1711
+ def _infer_settings_from_environment(
1712
+ self, _logger: Optional[_EarlyLogger] = None
1713
+ ) -> None:
1714
+ """Modify settings based on environment (for runs and cli)."""
1715
+ settings: Dict[str, Union[bool, str, Sequence, None]] = dict()
1716
+ # disable symlinks if on windows (requires admin or developer setup)
1717
+ settings["symlink"] = True
1718
+ if self._windows:
1719
+ settings["symlink"] = False
1720
+
1721
+ # TODO(jhr): this needs to be moved last in setting up settings ?
1722
+ # (dd): loading order does not matter as long as source is set correctly
1723
+
1724
+ # For code saving, only allow env var override if value from server is true, or
1725
+ # if no preference was specified.
1726
+ if (self.save_code is True or self.save_code is None) and (
1727
+ os.getenv(wandb.env.SAVE_CODE) is not None
1728
+ or os.getenv(wandb.env.DISABLE_CODE) is not None
1729
+ ):
1730
+ settings["save_code"] = wandb.env.should_save_code()
1731
+
1732
+ settings["disable_git"] = wandb.env.disable_git()
1733
+
1734
+ # Attempt to get notebook information if not already set by the user
1735
+ if self._jupyter and (self.notebook_name is None or self.notebook_name == ""):
1736
+ meta = wandb.jupyter.notebook_metadata(self.silent)
1737
+ settings["_jupyter_path"] = meta.get("path")
1738
+ settings["_jupyter_name"] = meta.get("name")
1739
+ settings["_jupyter_root"] = meta.get("root")
1740
+ elif (
1741
+ self._jupyter
1742
+ and self.notebook_name is not None
1743
+ and os.path.exists(self.notebook_name)
1744
+ ):
1745
+ settings["_jupyter_path"] = self.notebook_name
1746
+ settings["_jupyter_name"] = self.notebook_name
1747
+ settings["_jupyter_root"] = os.getcwd()
1748
+ elif self._jupyter:
1749
+ wandb.termwarn(
1750
+ "WANDB_NOTEBOOK_NAME should be a path to a notebook file, "
1751
+ f"couldn't find {self.notebook_name}.",
1752
+ )
1753
+
1754
+ # host and username are populated by apply_env_vars if corresponding env
1755
+ # vars exist -- but if they don't, we'll fill them in here
1756
+ if self.host is None:
1757
+ settings["host"] = socket.gethostname() # type: ignore
1758
+
1759
+ if self.username is None:
1760
+ try: # type: ignore
1761
+ settings["username"] = getpass.getuser()
1762
+ except KeyError:
1763
+ # getuser() could raise KeyError in restricted environments like
1764
+ # chroot jails or docker containers. Return user id in these cases.
1765
+ settings["username"] = str(os.getuid())
1766
+
1767
+ _executable = (
1768
+ self._executable
1769
+ or os.environ.get(wandb.env._EXECUTABLE)
1770
+ or sys.executable
1771
+ or shutil.which("python3")
1772
+ or "python3"
1773
+ )
1774
+ settings["_executable"] = _executable
1775
+
1776
+ settings["docker"] = wandb.env.get_docker(wandb.util.image_id_from_k8s())
1777
+
1778
+ # TODO: we should use the cuda library to collect this
1779
+ if os.path.exists("/usr/local/cuda/version.txt"):
1780
+ with open("/usr/local/cuda/version.txt") as f:
1781
+ settings["_cuda"] = f.read().split(" ")[-1].strip()
1782
+ if not self._jupyter:
1783
+ settings["_args"] = sys.argv[1:]
1784
+ settings["_os"] = platform.platform(aliased=True)
1785
+ settings["_python"] = platform.python_version()
1786
+ # hack to make sure we don't hang on windows
1787
+ if self._windows and self._except_exit is None:
1788
+ settings["_except_exit"] = True # type: ignore
1789
+
1790
+ if _logger is not None:
1791
+ _logger.info(
1792
+ f"Inferring settings from compute environment: {_redact_dict(settings)}"
1793
+ )
1794
+
1795
+ self.update(settings, source=Source.ENV)
1796
+
1797
+ def _infer_run_settings_from_environment(
1798
+ self,
1799
+ _logger: Optional[_EarlyLogger] = None,
1800
+ ) -> None:
1801
+ """Modify settings based on environment (for runs only)."""
1802
+ # If there's not already a program file, infer it now.
1803
+ settings: Dict[str, Union[bool, str, None]] = dict()
1804
+ program = self.program or _get_program()
1805
+ if program is not None:
1806
+ repo = GitRepo()
1807
+ root = repo.root or os.getcwd()
1808
+
1809
+ program_relpath = self.program_relpath or _get_program_relpath(
1810
+ program, repo.root, _logger=_logger
1811
+ )
1812
+ settings["program_relpath"] = program_relpath
1813
+ program_abspath = os.path.abspath(
1814
+ os.path.join(root, os.path.relpath(os.getcwd(), root), program)
1815
+ )
1816
+ if os.path.exists(program_abspath):
1817
+ settings["program_abspath"] = program_abspath
1818
+ else:
1819
+ program = "<python with no main file>"
1820
+
1821
+ settings["program"] = program
1822
+
1823
+ if _logger is not None:
1824
+ _logger.info(
1825
+ f"Inferring run settings from compute environment: {_redact_dict(settings)}"
1826
+ )
1827
+
1828
+ self.update(settings, source=Source.ENV)
1829
+
1830
+ def _apply_setup(
1831
+ self, setup_settings: Dict[str, Any], _logger: Optional[_EarlyLogger] = None
1832
+ ) -> None:
1833
+ if _logger:
1834
+ _logger.info(f"Applying setup settings: {_redact_dict(setup_settings)}")
1835
+ self.update(setup_settings, source=Source.SETUP)
1836
+
1837
+ def _apply_user(
1838
+ self, user_settings: Dict[str, Any], _logger: Optional[_EarlyLogger] = None
1839
+ ) -> None:
1840
+ if _logger:
1841
+ _logger.info(f"Applying user settings: {_redact_dict(user_settings)}")
1842
+ self.update(user_settings, source=Source.USER)
1843
+
1844
+ def _apply_init(self, init_settings: Dict[str, Union[str, int, None]]) -> None:
1845
+ # pop magic from init settings
1846
+ init_settings.pop("magic", None)
1847
+
1848
+ # prevent setting project, entity if in sweep
1849
+ # TODO(jhr): these should be locked elements in the future
1850
+ if self.sweep_id:
1851
+ for key in ("project", "entity", "id"):
1852
+ val = init_settings.pop(key, None)
1853
+ if val:
1854
+ wandb.termwarn(
1855
+ f"Ignored wandb.init() arg {key} when running a sweep."
1856
+ )
1857
+ if self.launch:
1858
+ if self.project is not None and init_settings.pop("project", None):
1859
+ wandb.termwarn(
1860
+ "Project is ignored when running from wandb launch context. "
1861
+ "Ignored wandb.init() arg project when running running from launch.",
1862
+ )
1863
+ for key in ("entity", "id"):
1864
+ # Init settings cannot override launch settings.
1865
+ if init_settings.pop(key, None):
1866
+ wandb.termwarn(
1867
+ "Project, entity and id are ignored when running from wandb launch context. "
1868
+ f"Ignored wandb.init() arg {key} when running running from launch.",
1869
+ )
1870
+
1871
+ # strip out items where value is None
1872
+ param_map = dict(
1873
+ name="run_name",
1874
+ id="run_id",
1875
+ tags="run_tags",
1876
+ group="run_group",
1877
+ job_type="run_job_type",
1878
+ notes="run_notes",
1879
+ dir="root_dir",
1880
+ sweep_id="sweep_id",
1881
+ )
1882
+ init_settings = {
1883
+ param_map.get(k, k): v for k, v in init_settings.items() if v is not None
1884
+ }
1885
+ # fun logic to convert the resume init arg
1886
+ if init_settings.get("resume"):
1887
+ if isinstance(init_settings["resume"], str):
1888
+ if init_settings["resume"] not in ("allow", "must", "never", "auto"):
1889
+ if init_settings.get("run_id") is None:
1890
+ # TODO: deprecate or don't support
1891
+ init_settings["run_id"] = init_settings["resume"]
1892
+ init_settings["resume"] = "allow"
1893
+ elif init_settings["resume"] is True:
1894
+ # todo: add deprecation warning, switch to literal strings for resume
1895
+ init_settings["resume"] = "auto"
1896
+
1897
+ # update settings
1898
+ self.update(init_settings, source=Source.INIT)
1899
+
1900
+ # handle auto resume logic
1901
+ if self.resume == "auto":
1902
+ if os.path.exists(self.resume_fname):
1903
+ with open(self.resume_fname) as f:
1904
+ resume_run_id = json.load(f)["run_id"]
1905
+ if self.run_id is None:
1906
+ self.update({"run_id": resume_run_id}, source=Source.INIT) # type: ignore
1907
+ elif self.run_id != resume_run_id:
1908
+ wandb.termwarn(
1909
+ "Tried to auto resume run with "
1910
+ f"id {resume_run_id} but id {self.run_id} is set.",
1911
+ )
1912
+ self.update({"run_id": self.run_id or generate_id()}, source=Source.INIT)
1913
+ # persist our run id in case of failure
1914
+ # check None for mypy
1915
+ if self.resume == "auto" and self.resume_fname is not None:
1916
+ filesystem.mkdir_exists_ok(self.wandb_dir)
1917
+ with open(self.resume_fname, "w") as f:
1918
+ f.write(json.dumps({"run_id": self.run_id}))
1919
+
1920
+ def _apply_login(
1921
+ self,
1922
+ login_settings: Dict[str, Any],
1923
+ _logger: Optional[_EarlyLogger] = None,
1924
+ ) -> None:
1925
+ key_map = {
1926
+ "key": "api_key",
1927
+ "host": "base_url",
1928
+ "timeout": "login_timeout",
1929
+ }
1930
+
1931
+ # Rename keys and keep only the non-None values.
1932
+ #
1933
+ # The input keys are parameters to wandb.login(), but we use different
1934
+ # names for some of them in Settings.
1935
+ login_settings = {
1936
+ key_map.get(key, key): value
1937
+ for key, value in login_settings.items()
1938
+ if value is not None
1939
+ }
1940
+
1941
+ if _logger:
1942
+ _logger.info(f"Applying login settings: {_redact_dict(login_settings)}")
1943
+
1944
+ self.update(
1945
+ login_settings,
1946
+ source=Source.LOGIN,
1947
+ )
1948
+
1949
+ def _apply_run_start(self, run_start_settings: Dict[str, Any]) -> None:
1950
+ # This dictionary maps from the "run message dict" to relevant fields in settings
1951
+ # Note: that config is missing
1952
+ param_map = {
1953
+ "run_id": "run_id",
1954
+ "entity": "entity",
1955
+ "project": "project",
1956
+ "run_group": "run_group",
1957
+ "job_type": "run_job_type",
1958
+ "display_name": "run_name",
1959
+ "notes": "run_notes",
1960
+ "tags": "run_tags",
1961
+ "sweep_id": "sweep_id",
1962
+ "host": "host",
1963
+ "resumed": "resumed",
1964
+ "git.remote_url": "git_remote_url",
1965
+ "git.commit": "git_commit",
1966
+ }
1967
+ run_settings = {
1968
+ name: reduce(lambda d, k: d.get(k, {}), attr.split("."), run_start_settings)
1969
+ for attr, name in param_map.items()
1970
+ }
1971
+ run_settings = {key: value for key, value in run_settings.items() if value}
1972
+ if run_settings:
1973
+ self.update(run_settings, source=Source.RUN)