wandb 0.13.10__py3-none-any.whl → 0.14.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. wandb/__init__.py +2 -3
  2. wandb/apis/__init__.py +1 -3
  3. wandb/apis/importers/__init__.py +4 -0
  4. wandb/apis/importers/base.py +312 -0
  5. wandb/apis/importers/mlflow.py +113 -0
  6. wandb/apis/internal.py +29 -2
  7. wandb/apis/normalize.py +6 -5
  8. wandb/apis/public.py +163 -180
  9. wandb/apis/reports/_templates.py +6 -12
  10. wandb/apis/reports/report.py +1 -1
  11. wandb/apis/reports/runset.py +1 -3
  12. wandb/apis/reports/util.py +12 -10
  13. wandb/beta/workflows.py +57 -34
  14. wandb/catboost/__init__.py +1 -2
  15. wandb/cli/cli.py +215 -133
  16. wandb/data_types.py +63 -56
  17. wandb/docker/__init__.py +78 -16
  18. wandb/docker/auth.py +21 -22
  19. wandb/env.py +0 -1
  20. wandb/errors/__init__.py +8 -116
  21. wandb/errors/term.py +1 -1
  22. wandb/fastai/__init__.py +1 -2
  23. wandb/filesync/dir_watcher.py +8 -5
  24. wandb/filesync/step_prepare.py +76 -75
  25. wandb/filesync/step_upload.py +1 -2
  26. wandb/integration/catboost/__init__.py +1 -3
  27. wandb/integration/catboost/catboost.py +8 -14
  28. wandb/integration/fastai/__init__.py +7 -13
  29. wandb/integration/gym/__init__.py +35 -4
  30. wandb/integration/keras/__init__.py +3 -3
  31. wandb/integration/keras/callbacks/metrics_logger.py +9 -8
  32. wandb/integration/keras/callbacks/model_checkpoint.py +9 -9
  33. wandb/integration/keras/callbacks/tables_builder.py +31 -19
  34. wandb/integration/kfp/kfp_patch.py +20 -17
  35. wandb/integration/kfp/wandb_logging.py +1 -2
  36. wandb/integration/lightgbm/__init__.py +21 -19
  37. wandb/integration/prodigy/prodigy.py +6 -7
  38. wandb/integration/sacred/__init__.py +9 -12
  39. wandb/integration/sagemaker/__init__.py +1 -3
  40. wandb/integration/sagemaker/auth.py +0 -1
  41. wandb/integration/sagemaker/config.py +1 -1
  42. wandb/integration/sagemaker/resources.py +1 -1
  43. wandb/integration/sb3/sb3.py +8 -4
  44. wandb/integration/tensorboard/__init__.py +1 -3
  45. wandb/integration/tensorboard/log.py +8 -8
  46. wandb/integration/tensorboard/monkeypatch.py +11 -9
  47. wandb/integration/tensorflow/__init__.py +1 -3
  48. wandb/integration/xgboost/__init__.py +4 -6
  49. wandb/integration/yolov8/__init__.py +7 -0
  50. wandb/integration/yolov8/yolov8.py +250 -0
  51. wandb/jupyter.py +31 -35
  52. wandb/lightgbm/__init__.py +1 -2
  53. wandb/old/settings.py +2 -2
  54. wandb/plot/bar.py +1 -2
  55. wandb/plot/confusion_matrix.py +1 -3
  56. wandb/plot/histogram.py +1 -2
  57. wandb/plot/line.py +1 -2
  58. wandb/plot/line_series.py +4 -4
  59. wandb/plot/pr_curve.py +17 -20
  60. wandb/plot/roc_curve.py +1 -3
  61. wandb/plot/scatter.py +1 -2
  62. wandb/proto/v3/wandb_server_pb2.py +85 -39
  63. wandb/proto/v3/wandb_telemetry_pb2.py +10 -10
  64. wandb/proto/v4/wandb_server_pb2.py +51 -39
  65. wandb/proto/v4/wandb_telemetry_pb2.py +10 -10
  66. wandb/sdk/__init__.py +1 -3
  67. wandb/sdk/backend/backend.py +1 -1
  68. wandb/sdk/data_types/_dtypes.py +38 -30
  69. wandb/sdk/data_types/base_types/json_metadata.py +1 -3
  70. wandb/sdk/data_types/base_types/media.py +17 -17
  71. wandb/sdk/data_types/base_types/wb_value.py +33 -26
  72. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +91 -125
  73. wandb/sdk/data_types/helper_types/classes.py +1 -1
  74. wandb/sdk/data_types/helper_types/image_mask.py +12 -12
  75. wandb/sdk/data_types/histogram.py +5 -4
  76. wandb/sdk/data_types/html.py +1 -2
  77. wandb/sdk/data_types/image.py +11 -11
  78. wandb/sdk/data_types/molecule.py +3 -6
  79. wandb/sdk/data_types/object_3d.py +1 -2
  80. wandb/sdk/data_types/plotly.py +1 -2
  81. wandb/sdk/data_types/saved_model.py +10 -8
  82. wandb/sdk/data_types/video.py +1 -1
  83. wandb/sdk/integration_utils/data_logging.py +5 -5
  84. wandb/sdk/interface/artifacts.py +288 -266
  85. wandb/sdk/interface/interface.py +2 -3
  86. wandb/sdk/interface/interface_grpc.py +1 -1
  87. wandb/sdk/interface/interface_queue.py +1 -1
  88. wandb/sdk/interface/interface_relay.py +1 -1
  89. wandb/sdk/interface/interface_shared.py +1 -2
  90. wandb/sdk/interface/interface_sock.py +1 -1
  91. wandb/sdk/interface/message_future.py +1 -1
  92. wandb/sdk/interface/message_future_poll.py +1 -1
  93. wandb/sdk/interface/router.py +1 -1
  94. wandb/sdk/interface/router_queue.py +1 -1
  95. wandb/sdk/interface/router_relay.py +1 -1
  96. wandb/sdk/interface/router_sock.py +1 -1
  97. wandb/sdk/interface/summary_record.py +1 -1
  98. wandb/sdk/internal/artifacts.py +1 -1
  99. wandb/sdk/internal/datastore.py +2 -3
  100. wandb/sdk/internal/file_pusher.py +5 -3
  101. wandb/sdk/internal/file_stream.py +22 -19
  102. wandb/sdk/internal/handler.py +5 -4
  103. wandb/sdk/internal/internal.py +1 -1
  104. wandb/sdk/internal/internal_api.py +115 -55
  105. wandb/sdk/internal/job_builder.py +1 -3
  106. wandb/sdk/internal/profiler.py +1 -1
  107. wandb/sdk/internal/progress.py +4 -6
  108. wandb/sdk/internal/sample.py +1 -3
  109. wandb/sdk/internal/sender.py +28 -16
  110. wandb/sdk/internal/settings_static.py +5 -5
  111. wandb/sdk/internal/system/assets/__init__.py +1 -0
  112. wandb/sdk/internal/system/assets/cpu.py +3 -9
  113. wandb/sdk/internal/system/assets/disk.py +2 -4
  114. wandb/sdk/internal/system/assets/gpu.py +6 -18
  115. wandb/sdk/internal/system/assets/gpu_apple.py +2 -4
  116. wandb/sdk/internal/system/assets/interfaces.py +50 -22
  117. wandb/sdk/internal/system/assets/ipu.py +1 -3
  118. wandb/sdk/internal/system/assets/memory.py +7 -13
  119. wandb/sdk/internal/system/assets/network.py +4 -8
  120. wandb/sdk/internal/system/assets/open_metrics.py +283 -0
  121. wandb/sdk/internal/system/assets/tpu.py +1 -4
  122. wandb/sdk/internal/system/assets/trainium.py +26 -14
  123. wandb/sdk/internal/system/system_info.py +2 -3
  124. wandb/sdk/internal/system/system_monitor.py +52 -20
  125. wandb/sdk/internal/tb_watcher.py +12 -13
  126. wandb/sdk/launch/_project_spec.py +54 -65
  127. wandb/sdk/launch/agent/agent.py +374 -90
  128. wandb/sdk/launch/builder/abstract.py +61 -7
  129. wandb/sdk/launch/builder/build.py +81 -110
  130. wandb/sdk/launch/builder/docker_builder.py +181 -0
  131. wandb/sdk/launch/builder/kaniko_builder.py +419 -0
  132. wandb/sdk/launch/builder/noop.py +31 -12
  133. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +70 -20
  134. wandb/sdk/launch/environment/abstract.py +28 -0
  135. wandb/sdk/launch/environment/aws_environment.py +276 -0
  136. wandb/sdk/launch/environment/gcp_environment.py +271 -0
  137. wandb/sdk/launch/environment/local_environment.py +65 -0
  138. wandb/sdk/launch/github_reference.py +3 -8
  139. wandb/sdk/launch/launch.py +38 -29
  140. wandb/sdk/launch/launch_add.py +6 -8
  141. wandb/sdk/launch/loader.py +230 -0
  142. wandb/sdk/launch/registry/abstract.py +54 -0
  143. wandb/sdk/launch/registry/elastic_container_registry.py +163 -0
  144. wandb/sdk/launch/registry/google_artifact_registry.py +203 -0
  145. wandb/sdk/launch/registry/local_registry.py +62 -0
  146. wandb/sdk/launch/runner/abstract.py +1 -16
  147. wandb/sdk/launch/runner/{kubernetes.py → kubernetes_runner.py} +83 -95
  148. wandb/sdk/launch/runner/local_container.py +46 -22
  149. wandb/sdk/launch/runner/local_process.py +1 -4
  150. wandb/sdk/launch/runner/{aws.py → sagemaker_runner.py} +53 -212
  151. wandb/sdk/launch/runner/{gcp_vertex.py → vertex_runner.py} +38 -55
  152. wandb/sdk/launch/sweeps/__init__.py +3 -2
  153. wandb/sdk/launch/sweeps/scheduler.py +132 -39
  154. wandb/sdk/launch/sweeps/scheduler_sweep.py +80 -89
  155. wandb/sdk/launch/utils.py +101 -30
  156. wandb/sdk/launch/wandb_reference.py +2 -7
  157. wandb/sdk/lib/_settings_toposort_generate.py +166 -0
  158. wandb/sdk/lib/_settings_toposort_generated.py +201 -0
  159. wandb/sdk/lib/apikey.py +2 -4
  160. wandb/sdk/lib/config_util.py +4 -1
  161. wandb/sdk/lib/console.py +1 -3
  162. wandb/sdk/lib/deprecate.py +3 -3
  163. wandb/sdk/lib/file_stream_utils.py +7 -5
  164. wandb/sdk/lib/filenames.py +1 -1
  165. wandb/sdk/lib/filesystem.py +61 -5
  166. wandb/sdk/lib/git.py +1 -3
  167. wandb/sdk/lib/import_hooks.py +4 -7
  168. wandb/sdk/lib/ipython.py +8 -5
  169. wandb/sdk/lib/lazyloader.py +1 -3
  170. wandb/sdk/lib/mailbox.py +14 -4
  171. wandb/sdk/lib/proto_util.py +10 -5
  172. wandb/sdk/lib/redirect.py +15 -22
  173. wandb/sdk/lib/reporting.py +1 -3
  174. wandb/sdk/lib/retry.py +4 -5
  175. wandb/sdk/lib/runid.py +1 -3
  176. wandb/sdk/lib/server.py +15 -9
  177. wandb/sdk/lib/sock_client.py +1 -1
  178. wandb/sdk/lib/sparkline.py +1 -1
  179. wandb/sdk/lib/wburls.py +1 -1
  180. wandb/sdk/service/port_file.py +1 -2
  181. wandb/sdk/service/service.py +36 -13
  182. wandb/sdk/service/service_base.py +12 -1
  183. wandb/sdk/verify/verify.py +5 -7
  184. wandb/sdk/wandb_artifacts.py +142 -177
  185. wandb/sdk/wandb_config.py +5 -8
  186. wandb/sdk/wandb_helper.py +1 -1
  187. wandb/sdk/wandb_init.py +24 -13
  188. wandb/sdk/wandb_login.py +9 -9
  189. wandb/sdk/wandb_manager.py +39 -4
  190. wandb/sdk/wandb_metric.py +2 -6
  191. wandb/sdk/wandb_require.py +4 -15
  192. wandb/sdk/wandb_require_helpers.py +1 -9
  193. wandb/sdk/wandb_run.py +95 -141
  194. wandb/sdk/wandb_save.py +1 -3
  195. wandb/sdk/wandb_settings.py +149 -54
  196. wandb/sdk/wandb_setup.py +66 -46
  197. wandb/sdk/wandb_summary.py +13 -10
  198. wandb/sdk/wandb_sweep.py +6 -7
  199. wandb/sdk/wandb_watch.py +1 -1
  200. wandb/sklearn/calculate/confusion_matrix.py +1 -1
  201. wandb/sklearn/calculate/learning_curve.py +1 -1
  202. wandb/sklearn/calculate/summary_metrics.py +1 -3
  203. wandb/sklearn/plot/__init__.py +1 -1
  204. wandb/sklearn/plot/classifier.py +27 -18
  205. wandb/sklearn/plot/clusterer.py +4 -5
  206. wandb/sklearn/plot/regressor.py +4 -4
  207. wandb/sklearn/plot/shared.py +2 -2
  208. wandb/sync/__init__.py +1 -3
  209. wandb/sync/sync.py +4 -5
  210. wandb/testing/relay.py +11 -10
  211. wandb/trigger.py +1 -1
  212. wandb/util.py +106 -81
  213. wandb/viz.py +4 -4
  214. wandb/wandb_agent.py +50 -50
  215. wandb/wandb_controller.py +2 -3
  216. wandb/wandb_run.py +1 -2
  217. wandb/wandb_torch.py +1 -1
  218. wandb/xgboost/__init__.py +1 -2
  219. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/METADATA +6 -2
  220. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/RECORD +224 -209
  221. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/WHEEL +1 -1
  222. wandb/sdk/launch/builder/docker.py +0 -80
  223. wandb/sdk/launch/builder/kaniko.py +0 -393
  224. wandb/sdk/launch/builder/loader.py +0 -32
  225. wandb/sdk/launch/runner/loader.py +0 -50
  226. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/LICENSE +0 -0
  227. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/entry_points.txt +0 -0
  228. {wandb-0.13.10.dist-info → wandb-0.14.0.dist-info}/top_level.txt +0 -0
wandb/cli/cli.py CHANGED
@@ -24,16 +24,19 @@ from click.exceptions import ClickException
24
24
  from dockerpycreds.utils import find_executable
25
25
 
26
26
  import wandb
27
+ import wandb.env
27
28
 
28
29
  # from wandb.old.core import wandb_dir
29
30
  import wandb.sdk.verify.verify as wandb_verify
30
31
  from wandb import Config, Error, env, util, wandb_agent, wandb_sdk
31
32
  from wandb.apis import InternalApi, PublicApi
32
- from wandb.errors import ExecutionError, LaunchError
33
33
  from wandb.integration.magic import magic_install
34
34
  from wandb.sdk.launch.launch_add import _launch_add
35
+ from wandb.sdk.launch.sweeps import SCHEDULER_URI
35
36
  from wandb.sdk.launch.utils import (
36
37
  LAUNCH_DEFAULT_PROJECT,
38
+ ExecutionError,
39
+ LaunchError,
37
40
  check_logged_in,
38
41
  construct_launch_spec,
39
42
  )
@@ -86,15 +89,14 @@ class ClickWandbException(ClickException):
86
89
  if issubclass(self.orig_type, Error):
87
90
  return click.style(str(self.message), fg="red")
88
91
  else:
89
- return "An Exception was raised, see %s for full traceback.\n" "%s: %s" % (
90
- log_file,
91
- orig_type,
92
- self.message,
92
+ return (
93
+ f"An Exception was raised, see {log_file} for full traceback.\n"
94
+ f"{orig_type}: {self.message}"
93
95
  )
94
96
 
95
97
 
96
98
  def display_error(func):
97
- """Function decorator for catching common errors and re-raising as wandb.Error"""
99
+ """Function decorator for catching common errors and re-raising as wandb.Error."""
98
100
 
99
101
  @wraps(func)
100
102
  def wrapper(*args, **kwargs):
@@ -660,7 +662,7 @@ def sync(
660
662
  _summary()
661
663
 
662
664
 
663
- @cli.command(context_settings=CONTEXT, help="Create a sweep") # noqa: C901
665
+ @cli.command(context_settings=CONTEXT, help="Create a sweep")
664
666
  @click.pass_context
665
667
  @click.option("--project", "-p", default=None, help="The project of the sweep.")
666
668
  @click.option("--entity", "-e", default=None, help="The entity scope for the project.")
@@ -702,6 +704,7 @@ def sync(
702
704
  )
703
705
  @click.option(
704
706
  "--queue",
707
+ "-q",
705
708
  default=None,
706
709
  help="The name of a launch queue (configured with a resource), available in the current user or team.",
707
710
  )
@@ -730,7 +733,7 @@ def sweep(
730
733
  config_yaml_or_sweep_id,
731
734
  queue,
732
735
  project_queue,
733
- ): # noqa: C901
736
+ ):
734
737
  state_args = "stop", "cancel", "pause", "resume"
735
738
  lcls = locals()
736
739
  is_state_change_command = sum(lcls[k] for k in state_args)
@@ -768,7 +771,7 @@ def sweep(
768
771
  config_yaml = config_yaml_or_sweep_id
769
772
 
770
773
  def _parse_settings(settings):
771
- """settings could be json or comma seperated assignments."""
774
+ """Parse settings from json or comma separated assignments."""
772
775
  ret = {}
773
776
  # TODO(jhr): merge with magic:_parse_magic
774
777
  if settings.find("=") > 0:
@@ -894,64 +897,82 @@ def sweep(
894
897
  launch_config = {}
895
898
  wandb.termlog(f"Using launch 🚀 with config: {launch_config}")
896
899
 
897
- if entity is None or project is None:
898
- _msg = "Must specify --entity and --project flags when using launch."
900
+ if entity is None:
901
+ _msg = "Must specify --entity flag when using launch."
902
+ wandb.termerror(_msg)
903
+ raise LaunchError(_msg)
904
+ elif project is None:
905
+ _msg = "A project must be configured when using launch."
899
906
  wandb.termerror(_msg)
900
907
  raise LaunchError(_msg)
901
908
 
902
909
  # Try and get job from sweep config
903
- _job = config.get("job", None)
904
- if _job is None:
905
- wandb.termlog("No job found in sweep config, looking in launch config.")
906
- _job = launch_config.get("job", None)
907
- if _job is None:
908
- wandb.termlog("No job found in launch config, using placeholder.")
909
- _job = "placeholder-job"
910
+ _job = config.get("job")
911
+ _image_uri = config.get("image_uri")
912
+ if not _job and not _image_uri: # don't allow empty string
913
+ raise LaunchError("No 'job' or 'image_uri' found in sweep config")
914
+ elif _job and _image_uri:
915
+ raise LaunchError("Sweep has both 'job' and 'image_uri'")
916
+
917
+ if not queue:
918
+ if launch_config.get("queue"):
919
+ queue = launch_config["queue"]
920
+ else:
921
+ raise LaunchError(
922
+ "No queue passed from CLI or in launch config for launch-sweep."
923
+ )
924
+
925
+ scheduler_config = launch_config.get("scheduler", {})
926
+ num_workers = f'{scheduler_config.get("num_workers")}'
927
+ if num_workers is None or not str.isdigit(num_workers):
928
+ num_workers = "8"
929
+
930
+ scheduler_entrypoint = [
931
+ "wandb",
932
+ "scheduler",
933
+ "WANDB_SWEEP_ID",
934
+ "--queue",
935
+ f"{queue!r}",
936
+ "--project",
937
+ project,
938
+ "--num_workers",
939
+ num_workers,
940
+ ]
941
+
942
+ if _job:
943
+ if ":" not in _job:
944
+ wandb.termwarn("No alias specified for job, defaulting to 'latest'")
945
+ _job += ":latest"
946
+
947
+ scheduler_entrypoint += [
948
+ "--job",
949
+ _job,
950
+ ]
951
+ elif _image_uri:
952
+ scheduler_entrypoint += ["--image_uri", _image_uri]
910
953
 
911
954
  # Launch job spec for the Scheduler
912
955
  _launch_scheduler_spec = json.dumps(
913
956
  {
914
- "queue": queue or launch_config.get("queue", "default"),
957
+ "queue": queue,
915
958
  "run_queue_project": project_queue,
916
959
  "run_spec": json.dumps(
917
960
  construct_launch_spec(
918
- "placeholder-uri-scheduler", # uri
919
- None, # job
920
- api,
921
- "Scheduler.WANDB_SWEEP_ID", # name,
922
- project,
923
- entity,
924
- launch_config.get("scheduler", {}).get(
925
- "docker_image", None
926
- ), # docker_image,
927
- launch_config.get("scheduler", {}).get(
928
- "resource", "local-process"
929
- ), # resource,
930
- [
931
- "wandb",
932
- "scheduler",
933
- "WANDB_SWEEP_ID",
934
- "--queue",
935
- f"{(queue or launch_config.get('queue', 'default'))!r}",
936
- "--project",
937
- project,
938
- "--job",
939
- _job,
940
- # TODO(hupo): Add num-workers as option in launch config
941
- # "--num_workers",
942
- # launch_config.get("scheduler", {}).get("num_workers", 1),
943
- ], # entry_point,
944
- None, # version,
945
- None, # parameters,
946
- launch_config.get("scheduler", {}).get(
947
- "resource_args", None
948
- ), # resource_args,
949
- None, # launch_config,
950
- None, # cuda,
951
- None, # run_id,
952
- launch_config.get("registry", {}).get(
953
- "url", None
954
- ), # repository
961
+ uri=SCHEDULER_URI,
962
+ job=None,
963
+ api=api,
964
+ name="Scheduler.WANDB_SWEEP_ID",
965
+ project=project,
966
+ entity=entity,
967
+ docker_image=scheduler_config.get("docker_image"),
968
+ resource=scheduler_config.get("resource", "local-process"),
969
+ entry_point=scheduler_entrypoint,
970
+ version=None,
971
+ parameters=None,
972
+ resource_args=scheduler_config.get("resource_args", {}),
973
+ launch_config=None,
974
+ run_id=None,
975
+ repository=launch_config.get("registry", {}).get("url", None),
955
976
  )
956
977
  ),
957
978
  }
@@ -1015,7 +1036,7 @@ def sweep(
1015
1036
  "uri of the form https://wandb.ai/entity/project/runs/run_id, "
1016
1037
  "or a git uri pointing to a remote repository, or path to a local directory.",
1017
1038
  )
1018
- @click.argument("uri", nargs=1, required=False)
1039
+ @click.option("--uri", "-u", metavar="(str)", default=None, hidden=True)
1019
1040
  @click.option(
1020
1041
  "--job",
1021
1042
  "-j",
@@ -1037,6 +1058,7 @@ def sweep(
1037
1058
  "--git-version",
1038
1059
  "-g",
1039
1060
  metavar="GIT-VERSION",
1061
+ hidden=True,
1040
1062
  help="Version of the project to run, as a Git commit reference for Git projects.",
1041
1063
  )
1042
1064
  @click.option(
@@ -1120,18 +1142,11 @@ def sweep(
1120
1142
  "as resource args to the compute resource. The exact content which should be "
1121
1143
  "provided is different for each execution backend. See documentation for layout of this file.",
1122
1144
  )
1123
- @click.option(
1124
- "--cuda",
1125
- is_flag=False,
1126
- flag_value=True,
1127
- default=None,
1128
- help="Flag to build an image with CUDA enabled. If reproducing a previous wandb run that ran on GPU, a CUDA-enabled image will be "
1129
- "built by default and you must set --cuda=False to build a CPU-only image.",
1130
- )
1131
1145
  @click.option(
1132
1146
  "--build",
1133
1147
  "-b",
1134
1148
  is_flag=True,
1149
+ hidden=True,
1135
1150
  help="Flag to build an associated job and push to queue as an image job.",
1136
1151
  )
1137
1152
  @click.option(
@@ -1139,6 +1154,7 @@ def sweep(
1139
1154
  "-rg",
1140
1155
  is_flag=False,
1141
1156
  default=None,
1157
+ hidden=True,
1142
1158
  help="Name of a remote repository. Will be used to push a built image to.",
1143
1159
  )
1144
1160
  # TODO: this is only included for back compat. But we should remove this in the future
@@ -1164,23 +1180,24 @@ def launch(
1164
1180
  queue,
1165
1181
  run_async,
1166
1182
  resource_args,
1167
- cuda,
1168
1183
  build,
1169
1184
  repository,
1170
1185
  project_queue,
1171
1186
  ):
1172
- """
1173
- Run a W&B run from the given URI, which can be a wandb URI or a GitHub repo uri or a local path.
1174
- In the case of a wandb URI the arguments used in the original run will be used by default.
1175
- These arguments can be overridden using the args option, or specifying those arguments
1176
- in the config's 'overrides' key, 'args' field as a list of strings.
1187
+ """Start a W&B run from the given URI.
1188
+
1189
+ The URI can bea wandb URI, a GitHub repo uri, or a local path). In the case of a
1190
+ wandb URI the arguments used in the original run will be used by default. These
1191
+ arguments can be overridden using the args option, or specifying those arguments in
1192
+ the config's 'overrides' key, 'args' field as a list of strings.
1177
1193
 
1178
- Running `wandb launch [URI]` will launch the run directly. To add the run to a queue, run
1179
- `wandb launch [URI] --queue [optional queuename]`.
1194
+ Running `wandb launch [URI]` will launch the run directly. To add the run to a
1195
+ queue, run `wandb launch [URI] --queue [optional queuename]`.
1180
1196
  """
1181
1197
  logger.info(
1182
1198
  f"=== Launch called with kwargs {locals()} CLI Version: {wandb.__version__}==="
1183
1199
  )
1200
+ util.sentry_set_scope(process_context="launch_cli")
1184
1201
  from wandb.sdk.launch import launch as wandb_launch
1185
1202
 
1186
1203
  wandb.termlog(
@@ -1193,18 +1210,6 @@ def launch(
1193
1210
  "Cannot use both --async and --queue with wandb launch, see help for details."
1194
1211
  )
1195
1212
 
1196
- # we take a string for the `cuda` arg in order to accept None values, then convert it to a bool
1197
- if cuda is not None:
1198
- # preserve cuda=None as unspecified, otherwise convert to bool
1199
- if cuda == "True":
1200
- cuda = True
1201
- elif cuda == "False":
1202
- cuda = False
1203
- else:
1204
- raise LaunchError(
1205
- f"Invalid value for --cuda: {cuda!r} is not a valid boolean."
1206
- )
1207
-
1208
1213
  args_dict = util._user_args_to_dict(args_list)
1209
1214
 
1210
1215
  if resource_args is not None:
@@ -1231,8 +1236,8 @@ def launch(
1231
1236
 
1232
1237
  try:
1233
1238
  check_logged_in(api)
1234
- except Exception as e:
1235
- print(e)
1239
+ except Exception:
1240
+ wandb.termerror(f"Error running job: {traceback.format_exc()}")
1236
1241
 
1237
1242
  run_id = config.get("run_id")
1238
1243
 
@@ -1254,38 +1259,42 @@ def launch(
1254
1259
  resource_args=resource_args,
1255
1260
  config=config,
1256
1261
  synchronous=(not run_async),
1257
- cuda=cuda,
1258
1262
  run_id=run_id,
1259
1263
  repository=repository,
1260
1264
  )
1261
1265
  except LaunchError as e:
1262
1266
  logger.error("=== %s ===", e)
1267
+ util.sentry_exc(e)
1263
1268
  sys.exit(e)
1264
1269
  except ExecutionError as e:
1265
1270
  logger.error("=== %s ===", e)
1271
+ util.sentry_exc(e)
1266
1272
  sys.exit(e)
1267
1273
  else:
1268
- _launch_add(
1269
- api,
1270
- uri,
1271
- job,
1272
- config,
1273
- project,
1274
- entity,
1275
- queue,
1276
- resource,
1277
- entry_point,
1278
- name,
1279
- git_version,
1280
- docker_image,
1281
- args_dict,
1282
- project_queue,
1283
- resource_args,
1284
- cuda=cuda,
1285
- build=build,
1286
- run_id=run_id,
1287
- repository=repository,
1288
- )
1274
+ try:
1275
+ _launch_add(
1276
+ api,
1277
+ uri,
1278
+ job,
1279
+ config,
1280
+ project,
1281
+ entity,
1282
+ queue,
1283
+ resource,
1284
+ entry_point,
1285
+ name,
1286
+ git_version,
1287
+ docker_image,
1288
+ args_dict,
1289
+ project_queue,
1290
+ resource_args,
1291
+ build=build,
1292
+ run_id=run_id,
1293
+ repository=repository,
1294
+ )
1295
+ except Exception as e:
1296
+ util.sentry_exc(e)
1297
+ raise e
1289
1298
 
1290
1299
 
1291
1300
  @cli.command(
@@ -1324,6 +1333,13 @@ def launch(
1324
1333
  @click.option(
1325
1334
  "--config", "-c", default=None, help="path to the agent config yaml to use"
1326
1335
  )
1336
+ @click.option(
1337
+ "--url",
1338
+ "-u",
1339
+ default=None,
1340
+ hidden=True,
1341
+ help="a wandb client registration URL, this is generated in the UI",
1342
+ )
1327
1343
  @display_error
1328
1344
  def launch_agent(
1329
1345
  ctx,
@@ -1332,10 +1348,16 @@ def launch_agent(
1332
1348
  queues=None,
1333
1349
  max_jobs=None,
1334
1350
  config=None,
1351
+ url=None,
1335
1352
  ):
1336
1353
  logger.info(
1337
1354
  f"=== Launch-agent called with kwargs {locals()} CLI Version: {wandb.__version__} ==="
1338
1355
  )
1356
+ util.sentry_set_scope(process_context="launch_agent")
1357
+ if url is not None:
1358
+ raise LaunchError(
1359
+ "--url is not supported in this version, upgrade with: pip install -u wandb"
1360
+ )
1339
1361
 
1340
1362
  from wandb.sdk.launch import launch as wandb_launch
1341
1363
 
@@ -1344,7 +1366,7 @@ def launch_agent(
1344
1366
  )
1345
1367
  api = _get_cling_api()
1346
1368
  agent_config, api = wandb_launch.resolve_agent_config(
1347
- api, entity, project, max_jobs, queues
1369
+ api, entity, project, max_jobs, queues, config
1348
1370
  )
1349
1371
  if agent_config.get("project") is None:
1350
1372
  raise LaunchError(
@@ -1359,7 +1381,11 @@ def launch_agent(
1359
1381
  check_logged_in(api)
1360
1382
 
1361
1383
  wandb.termlog("Starting launch agent ✨")
1362
- wandb_launch.create_and_run_agent(api, agent_config)
1384
+ try:
1385
+ wandb_launch.create_and_run_agent(api, agent_config)
1386
+ except Exception as e:
1387
+ util.sentry_exc(e)
1388
+ raise e
1363
1389
 
1364
1390
 
1365
1391
  @cli.command(context_settings=CONTEXT, help="Run the W&B agent")
@@ -1402,23 +1428,31 @@ def scheduler(
1402
1428
  ctx.invoke(login, no_offline=True)
1403
1429
  api = _get_cling_api(reset=True)
1404
1430
 
1431
+ util.sentry_set_scope(process_context="sweep_scheduler")
1405
1432
  wandb.termlog("Starting a Launch Scheduler 🚀")
1406
1433
  from wandb.sdk.launch.sweeps import load_scheduler
1407
1434
 
1435
+ # TODO(gst): remove this monstrosity
1408
1436
  # Future-proofing hack to pull any kwargs that get passed in through the CLI
1409
1437
  kwargs = {}
1410
1438
  for i, _arg in enumerate(ctx.args):
1411
1439
  if isinstance(_arg, str) and _arg.startswith("--"):
1412
1440
  # convert input kwargs from hyphens to underscores
1413
1441
  _key = _arg[2:].replace("-", "_")
1414
- kwargs[_key] = ctx.args[i + 1]
1415
-
1416
- _scheduler = load_scheduler("sweep")(
1417
- api,
1418
- sweep_id=sweep_id,
1419
- **kwargs,
1420
- )
1421
- _scheduler.start()
1442
+ _args = ctx.args[i + 1]
1443
+ if str.isdigit(_args):
1444
+ _args = int(_args)
1445
+ kwargs[_key] = _args
1446
+ try:
1447
+ _scheduler = load_scheduler("sweep")(
1448
+ api,
1449
+ sweep_id=sweep_id,
1450
+ **kwargs,
1451
+ )
1452
+ _scheduler.start()
1453
+ except Exception as e:
1454
+ util.sentry_exc(e)
1455
+ raise e
1422
1456
 
1423
1457
 
1424
1458
  @cli.command(context_settings=CONTEXT, help="Run the W&B local sweep controller")
@@ -1437,11 +1471,10 @@ def controller(verbose, sweep_id):
1437
1471
  @click.pass_context
1438
1472
  @click.argument("docker_run_args", nargs=-1)
1439
1473
  def docker_run(ctx, docker_run_args):
1440
- """Simple wrapper for `docker run` which adds WANDB_API_KEY and WANDB_DOCKER
1441
- environment variables to any docker run command.
1474
+ """Wrap `docker run` and adds WANDB_API_KEY and WANDB_DOCKER environment variables.
1442
1475
 
1443
- This will also set the runtime to nvidia if the nvidia-docker executable is present on the system
1444
- and --runtime wasn't set.
1476
+ This will also set the runtime to nvidia if the nvidia-docker executable is present
1477
+ on the system and --runtime wasn't set.
1445
1478
 
1446
1479
  See `docker run --help` for more details.
1447
1480
  """
@@ -1516,19 +1549,25 @@ def docker(
1516
1549
  cmd,
1517
1550
  no_tty,
1518
1551
  ):
1519
- """W&B docker lets you run your code in a docker image ensuring wandb is configured. It adds the WANDB_DOCKER and WANDB_API_KEY
1520
- environment variables to your container and mounts the current directory in /app by default. You can pass additional
1521
- args which will be added to `docker run` before the image name is declared, we'll choose a default image for you if
1522
- one isn't passed:
1552
+ """Run your code in a docker container.
1553
+
1554
+ W&B docker lets you run your code in a docker image ensuring wandb is configured. It
1555
+ adds the WANDB_DOCKER and WANDB_API_KEY environment variables to your container and
1556
+ mounts the current directory in /app by default. You can pass additional args which
1557
+ will be added to `docker run` before the image name is declared, we'll choose a
1558
+ default image for you if one isn't passed:
1523
1559
 
1560
+ ```sh
1524
1561
  wandb docker -v /mnt/dataset:/app/data
1525
1562
  wandb docker gcr.io/kubeflow-images-public/tensorflow-1.12.0-notebook-cpu:v0.4.0 --jupyter
1526
1563
  wandb docker wandb/deepo:keras-gpu --no-tty --cmd "python train.py --epochs=5"
1564
+ ```
1527
1565
 
1528
- By default, we override the entrypoint to check for the existence of wandb and install it if not present. If you pass the --jupyter
1529
- flag we will ensure jupyter is installed and start jupyter lab on port 8888. If we detect nvidia-docker on your system we will use
1530
- the nvidia runtime. If you just want wandb to set environment variable to an existing docker run command, see the wandb docker-run
1531
- command.
1566
+ By default, we override the entrypoint to check for the existence of wandb and
1567
+ install it if not present. If you pass the --jupyter flag we will ensure jupyter is
1568
+ installed and start jupyter lab on port 8888. If we detect nvidia-docker on your
1569
+ system we will use the nvidia runtime. If you just want wandb to set environment
1570
+ variable to an existing docker run command, see the wandb docker-run command.
1532
1571
  """
1533
1572
  api = InternalApi()
1534
1573
  if not find_executable("docker"):
@@ -2206,11 +2245,19 @@ def status(settings):
2206
2245
 
2207
2246
 
2208
2247
  @cli.command("disabled", help="Disable W&B.")
2209
- def disabled():
2248
+ @click.option(
2249
+ "--service",
2250
+ is_flag=True,
2251
+ show_default=True,
2252
+ default=True,
2253
+ help="Disable W&B service",
2254
+ )
2255
+ def disabled(service):
2210
2256
  api = InternalApi()
2211
2257
  try:
2212
2258
  api.set_setting("mode", "disabled", persist=True)
2213
2259
  click.echo("W&B disabled.")
2260
+ os.environ[wandb.env._DISABLE_SERVICE] = str(service)
2214
2261
  except configparser.Error:
2215
2262
  click.echo(
2216
2263
  "Unable to write config, copy and paste the following in your terminal to turn off W&B:\nexport WANDB_MODE=disabled"
@@ -2218,11 +2265,19 @@ def disabled():
2218
2265
 
2219
2266
 
2220
2267
  @cli.command("enabled", help="Enable W&B.")
2221
- def enabled():
2268
+ @click.option(
2269
+ "--service",
2270
+ is_flag=True,
2271
+ show_default=True,
2272
+ default=True,
2273
+ help="Enable W&B service",
2274
+ )
2275
+ def enabled(service):
2222
2276
  api = InternalApi()
2223
2277
  try:
2224
2278
  api.set_setting("mode", "online", persist=True)
2225
2279
  click.echo("W&B enabled.")
2280
+ os.environ[wandb.env._DISABLE_SERVICE] = str(not service)
2226
2281
  except configparser.Error:
2227
2282
  click.echo(
2228
2283
  "Unable to write config, copy and paste the following in your terminal to turn on W&B:\nexport WANDB_MODE=online"
@@ -2289,3 +2344,30 @@ def verify(host):
2289
2344
  and url_success
2290
2345
  ):
2291
2346
  sys.exit(1)
2347
+
2348
+
2349
+ @cli.group("import", help="Commands for importing data from other systems")
2350
+ def importer():
2351
+ pass
2352
+
2353
+
2354
+ @importer.command("mlflow", help="Import from MLFlow")
2355
+ @click.option("--mlflow-tracking-uri", help="MLFlow Tracking URI")
2356
+ @click.option(
2357
+ "--target-entity", required=True, help="Override default entity to import data into"
2358
+ )
2359
+ @click.option(
2360
+ "--target-project",
2361
+ required=True,
2362
+ help="Override default project to import data into",
2363
+ )
2364
+ def mlflow(mlflow_tracking_uri, target_entity, target_project):
2365
+ from wandb.apis.importers import MlflowImporter
2366
+
2367
+ importer = MlflowImporter(mlflow_tracking_uri=mlflow_tracking_uri)
2368
+ overrides = {
2369
+ "entity": target_entity,
2370
+ "project": target_project,
2371
+ }
2372
+
2373
+ importer.import_all_parallel(overrides=overrides)