outerbounds 0.3.52rc2__py3-none-any.whl → 0.3.52rc5__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -805,22 +805,6 @@ def switch_perimeter(output="", id=None, force=False):
805
805
  "Perimeter was successfully switched!",
806
806
  )
807
807
 
808
- if "WORKSTATION_ID" not in os.environ:
809
- click.secho(
810
- "outerbounds switch-perimeter is only supported on workstations.",
811
- fg="red",
812
- err=True,
813
- )
814
- switch_perimeter_step.update(
815
- status=OuterboundsCommandStatus.FAIL,
816
- reason="outerbounds switch-perimeter is only supported on workstations.",
817
- mitigation="",
818
- )
819
- switch_perimeter_response.add_step(switch_perimeter_step)
820
- if output == "json":
821
- click.echo(json.dumps(switch_perimeter_response.as_dict(), indent=4))
822
- return
823
-
824
808
  metaflow_home_dir = path.expanduser(
825
809
  os.environ.get("METAFLOW_HOME", "~/.metaflowconfig")
826
810
  )
@@ -881,6 +865,7 @@ def switch_perimeter(output="", id=None, force=False):
881
865
  click.secho(
882
866
  "Force flag is set. Perimeter will be switched, but can have unintended consequences on other running processes.",
883
867
  fg="yellow",
868
+ err=True,
884
869
  )
885
870
 
886
871
  ob_config_dict = {"OB_CURRENT_PERIMETER": id}
@@ -889,9 +874,12 @@ def switch_perimeter(output="", id=None, force=False):
889
874
  with os.fdopen(fd, "w") as file:
890
875
  json.dump(ob_config_dict, file, indent=4)
891
876
 
892
- click.secho("Perimeter switched to {}".format(id), fg="green")
877
+ click.secho("Perimeter switched to {}".format(id), fg="green", err=True)
893
878
  except BlockingIOError:
894
879
  # This exception is raised if the file is already locked (non-blocking mode)
880
+ # Note that its the metaflow package (the extension actually) that acquires a shared read lock
881
+ # on the file whenever a process imports metaflow.
882
+ # In the future we might want to get smarter about it and show which process is holding the lock.
895
883
  click.secho(
896
884
  "Can't switch perimeter while Metaflow is in use. Please make sure there are no running python processes or notebooks using metaflow.",
897
885
  fg="red",
@@ -926,22 +914,6 @@ def show_current_perimeter(output=""):
926
914
  "Current Perimeter Fetch Successful.",
927
915
  )
928
916
 
929
- if "WORKSTATION_ID" not in os.environ:
930
- click.secho(
931
- "outerbounds switch-perimeter is only supported on workstations.",
932
- fg="red",
933
- err=True,
934
- )
935
- show_current_perimeter_step.update(
936
- status=OuterboundsCommandStatus.FAIL,
937
- reason="outerbounds show-current-perimeter is only supported on workstations.",
938
- mitigation="",
939
- )
940
- show_current_perimeter_response.add_step(show_current_perimeter_step)
941
- if output == "json":
942
- click.echo(json.dumps(show_current_perimeter_response.as_dict(), indent=4))
943
- return
944
-
945
917
  metaflow_home_dir = path.expanduser(
946
918
  os.environ.get("METAFLOW_HOME", "~/.metaflowconfig")
947
919
  )
@@ -1000,6 +972,7 @@ def show_current_perimeter(output=""):
1000
972
  click.secho(
1001
973
  "Current Perimeter: {}".format(ob_config_dict["OB_CURRENT_PERIMETER"]),
1002
974
  fg="green",
975
+ err=True,
1003
976
  )
1004
977
  show_current_perimeter_response.add_or_update_data(
1005
978
  "current_perimeter", ob_config_dict["OB_CURRENT_PERIMETER"]
@@ -1043,22 +1016,6 @@ def list_perimeters(output=""):
1043
1016
  "ListPerimeters", OuterboundsCommandStatus.OK, "Perimeter Fetch Successful."
1044
1017
  )
1045
1018
 
1046
- if "WORKSTATION_ID" not in os.environ:
1047
- click.secho(
1048
- "outerbounds list-perimeters is only supported on workstations.",
1049
- fg="red",
1050
- err=True,
1051
- )
1052
- list_perimeters_step.update(
1053
- status=OuterboundsCommandStatus.FAIL,
1054
- reason="outerbounds list-perimeters is only supported on workstations.",
1055
- mitigation="",
1056
- )
1057
- list_perimeters_response.add_step(list_perimeters_step)
1058
- if output == "json":
1059
- click.echo(json.dumps(list_perimeters_response.as_dict(), indent=4))
1060
- return
1061
-
1062
1019
  metaflow_home_dir = path.expanduser(
1063
1020
  os.environ.get("METAFLOW_HOME", "~/.metaflowconfig")
1064
1021
  )
@@ -1134,8 +1091,12 @@ def list_perimeters(output=""):
1134
1091
  ),
1135
1092
  )
1136
1093
  list_perimeters_response.add_step(list_perimeters_step)
1094
+ if output == "json":
1095
+ click.echo(json.dumps(list_perimeters_response.as_dict(), indent=4))
1137
1096
  return
1138
1097
 
1098
+ click.secho("Perimeter: {} (active)".format(active_perimeter), fg="green", err=True)
1099
+
1139
1100
  perimeter_list = []
1140
1101
  for file in os.listdir(metaflow_home_dir):
1141
1102
  if file.startswith("config_") and file.endswith(".json"):
@@ -1144,6 +1105,10 @@ def list_perimeters(output=""):
1144
1105
  {"id": perimeter_id, "active": perimeter_id == active_perimeter}
1145
1106
  )
1146
1107
 
1108
+ if perimeter_id != active_perimeter:
1109
+ click.secho("Perimeter: {}".format(perimeter_id), err=True)
1110
+
1147
1111
  list_perimeters_response.add_or_update_data("perimeters", perimeter_list)
1112
+
1148
1113
  if output == "json":
1149
1114
  click.echo(json.dumps(list_perimeters_response.as_dict(), indent=4))
@@ -196,11 +196,25 @@ def configure_cloud_workstation(config_dir=None, profile=None, binary=None, outp
196
196
  default="",
197
197
  help="The named metaflow profile in which your workstation exists",
198
198
  )
199
- def list_workstations(config_dir=None, profile=None):
199
+ @click.option(
200
+ "-o",
201
+ "--output",
202
+ default="json",
203
+ help="Show output in the specified format.",
204
+ type=click.Choice(["json"]),
205
+ )
206
+ def list_workstations(config_dir=None, profile=None, output="json"):
207
+ list_response = OuterboundsCommandResponse()
208
+ list_step = CommandStatus(
209
+ "listWorkstations",
210
+ OuterboundsCommandStatus.OK,
211
+ "Workstation list successfully fetched!",
212
+ )
213
+ list_response.add_or_update_data("workstations", [])
214
+
200
215
  try:
201
216
  if not profile:
202
217
  profile = metaflowconfig.get_metaflow_profile()
203
-
204
218
  metaflow_token = metaflowconfig.get_metaflow_token_from_config(
205
219
  config_dir, profile
206
220
  )
@@ -210,17 +224,23 @@ def list_workstations(config_dir=None, profile=None):
210
224
  workstations_response = requests.get(
211
225
  f"{api_url}/v1/workstations", headers={"x-api-key": metaflow_token}
212
226
  )
213
- try:
214
- workstations_response.raise_for_status()
215
- click.echo(json.dumps(workstations_response.json(), indent=4))
216
- except HTTPError:
217
- click.secho("Failed to generate workstation token.", fg="red")
218
- click.secho(
219
- "Error: {}".format(json.dumps(workstations_response.json(), indent=4))
220
- )
227
+ workstations_response.raise_for_status()
228
+ list_response.add_or_update_data(
229
+ "workstations", workstations_response.json()["workstations"]
230
+ )
231
+ if output == "json":
232
+ click.echo(json.dumps(list_response.as_dict(), indent=4))
221
233
  except Exception as e:
222
- click.secho("Failed to list workstations", fg="red")
223
- click.secho("Error: {}".format(str(e)), fg="red")
234
+ list_step.update(
235
+ OuterboundsCommandStatus.FAIL, "Failed to list workstations", ""
236
+ )
237
+ list_response.add_step(list_step)
238
+ if output == "json":
239
+ list_response.add_or_update_data("error", str(e))
240
+ click.echo(json.dumps(list_response.as_dict(), indent=4))
241
+ else:
242
+ click.secho("Failed to list workstations", fg="red", err=True)
243
+ click.secho("Error: {}".format(str(e)), fg="red", err=True)
224
244
 
225
245
 
226
246
  @cli.command(help="Hibernate workstation", hidden=True)
@@ -63,11 +63,11 @@ class OuterboundsCommandResponse:
63
63
  self._message = "We found one or more warnings with your installation."
64
64
 
65
65
  def as_dict(self):
66
+ self._data["steps"] = [step.as_dict() for step in self._steps]
66
67
  return {
67
68
  "status": self.status.value,
68
69
  "code": self._code,
69
70
  "message": self._message,
70
- "steps": [step.as_dict() for step in self._steps],
71
71
  "metadata": self.metadata,
72
72
  "data": self._data,
73
73
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: outerbounds
3
- Version: 0.3.52rc2
3
+ Version: 0.3.52rc5
4
4
  Summary: More Data Science, Less Administration
5
5
  License: Proprietary
6
6
  Keywords: data science,machine learning,MLOps
@@ -2,13 +2,13 @@ outerbounds/__init__.py,sha256=GPdaubvAYF8pOFWJ3b-sPMKCpyfpteWVMZWkmaYhxRw,32
2
2
  outerbounds/cli_main.py,sha256=e9UMnPysmc7gbrimq2I4KfltggyU7pw59Cn9aEguVcU,74
3
3
  outerbounds/command_groups/__init__.py,sha256=QPWtj5wDRTINDxVUL7XPqG3HoxHNvYOg08EnuSZB2Hc,21
4
4
  outerbounds/command_groups/cli.py,sha256=61VsBlPG2ykP_786eCyllqeM8DMhPAOfj2FhktrSd7k,207
5
- outerbounds/command_groups/local_setup_cli.py,sha256=mzNKshItJkIz7vmHtkX1hakfHFfT5gTI5HK3xBLFxqk,41846
6
- outerbounds/command_groups/workstations_cli.py,sha256=rV8_DlF7coEmJ84VLEtqo6-HyY3ALAyU_ig6Cy-8npk,18605
5
+ outerbounds/command_groups/local_setup_cli.py,sha256=fHZJTFJJO49X0_uhAmDwyOMtvOZVlbMxAF9iLs8euwo,40672
6
+ outerbounds/command_groups/workstations_cli.py,sha256=f3gwHMZPHzeOcGj5VfC5tZZA18JQhFzy2LRGzqAosOk,19286
7
7
  outerbounds/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  outerbounds/utils/kubeconfig.py,sha256=l1mUP1j9VIq3fsffi5bJ1Nk-hYlwd1dIqkpj7DvVS1E,7936
9
9
  outerbounds/utils/metaflowconfig.py,sha256=_Khqzu0KE6X05KkVbb39GXN6CFpG2WRr6Xs35pT2l7A,3299
10
- outerbounds/utils/schema.py,sha256=4_ONlvZGpBb51KKd-q6mNSKWI9P1huOKafrsf9kVqp8,2152
11
- outerbounds-0.3.52rc2.dist-info/METADATA,sha256=fe_E3svueXjSzXsQJaJYXYt8LDGfOP_S3cA6wTcIskI,1367
12
- outerbounds-0.3.52rc2.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
13
- outerbounds-0.3.52rc2.dist-info/entry_points.txt,sha256=7ye0281PKlvqxu15rjw60zKg2pMsXI49_A8BmGqIqBw,47
14
- outerbounds-0.3.52rc2.dist-info/RECORD,,
10
+ outerbounds/utils/schema.py,sha256=Ht_Yf5uoKO0m36WXHZLSPmWPH6EFWXfZDQsiAUquc5k,2160
11
+ outerbounds-0.3.52rc5.dist-info/METADATA,sha256=XUUknKD5TQrXjRRdnGHCiH3G07aZPWdnbeUYs1xyfOo,1367
12
+ outerbounds-0.3.52rc5.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
13
+ outerbounds-0.3.52rc5.dist-info/entry_points.txt,sha256=7ye0281PKlvqxu15rjw60zKg2pMsXI49_A8BmGqIqBw,47
14
+ outerbounds-0.3.52rc5.dist-info/RECORD,,