outerbounds 0.3.89__py3-none-any.whl → 0.3.90__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,12 @@
1
1
  import json
2
2
  import os
3
3
  import sys
4
+ from io import StringIO
4
5
  from os import path
5
6
  from typing import Any, Dict
6
7
  from outerbounds._vendor import click
7
8
  import requests
9
+ import configparser
8
10
 
9
11
  from ..utils import metaflowconfig
10
12
  from ..utils.utils import safe_write_to_disk
@@ -440,6 +442,9 @@ def ensure_cloud_credentials_for_shell(config_dir, profile):
440
442
  if "METAFLOW_DEFAULT_GCP_CLIENT_PROVIDER" in mf_config:
441
443
  # This is a GCP deployment.
442
444
  ensure_gcp_cloud_creds(config_dir, profile)
445
+ elif "METAFLOW_DEFAULT_AWS_CLIENT_PROVIDER" in mf_config:
446
+ # This is an AWS deployment.
447
+ ensure_aws_cloud_creds(config_dir, profile)
443
448
 
444
449
 
445
450
  def confirm_user_has_access_to_perimeter_or_fail(
@@ -473,8 +478,13 @@ def ensure_gcp_cloud_creds(config_dir, profile):
473
478
  )
474
479
  metaflow_token = metaflowconfig.get_metaflow_token_from_config(config_dir, profile)
475
480
 
476
- # GOOGLE_APPLICATION_CREDENTIALS is a well known gcloud environment variable
477
- credentials_file_loc = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
481
+ try:
482
+ # GOOGLE_APPLICATION_CREDENTIALS is a well known gcloud environment variable
483
+ credentials_file_loc = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
484
+ except KeyError:
485
+ # This is most likely an old workstation when these params weren't set. Do nothing.
486
+ # Alternatively, user might have deliberately unset it to use their own auth.
487
+ return
478
488
 
479
489
  credentials_json = {
480
490
  "type": "external_account",
@@ -492,6 +502,50 @@ def ensure_gcp_cloud_creds(config_dir, profile):
492
502
  safe_write_to_disk(credentials_file_loc, json.dumps(credentials_json))
493
503
 
494
504
 
505
+ def ensure_aws_cloud_creds(config_dir, profile):
506
+ token_info = get_aws_auth_credentials(config_dir, profile)
507
+
508
+ try:
509
+ token_file_loc = os.environ["OBP_AWS_WEB_IDENTITY_TOKEN_FILE"]
510
+
511
+ # AWS_CONFIG_FILE is a well known aws cli environment variable
512
+ config_file_loc = os.environ["AWS_CONFIG_FILE"]
513
+ except KeyError:
514
+ # This is most likely an old workstation when these params weren't set. Do nothing.
515
+ # Alternatively, user might have deliberately unset it to use their own auth.
516
+ return
517
+
518
+ aws_config = configparser.ConfigParser()
519
+ aws_config.read(config_file_loc)
520
+
521
+ profile_name = "profile outerbounds"
522
+ if profile_name not in aws_config:
523
+ aws_config[profile_name] = {}
524
+
525
+ aws_config[profile_name]["role_arn"] = token_info["role_arn"]
526
+ aws_config[profile_name]["web_identity_token_file"] = token_file_loc
527
+
528
+ aws_config_string = StringIO()
529
+ aws_config.write(aws_config_string)
530
+
531
+ safe_write_to_disk(token_file_loc, token_info["token"])
532
+ safe_write_to_disk(config_file_loc, aws_config_string.getvalue())
533
+
534
+
535
+ def get_aws_auth_credentials(config_dir, profile): # pragma: no cover
536
+ token = metaflowconfig.get_metaflow_token_from_config(config_dir, profile)
537
+ auth_server_url = metaflowconfig.get_sanitized_url_from_config(
538
+ config_dir, profile, "OBP_AUTH_SERVER"
539
+ )
540
+
541
+ response = requests.get(
542
+ "{}/generate/aws".format(auth_server_url), headers={"x-api-key": token}
543
+ )
544
+ response.raise_for_status()
545
+
546
+ return response.json()
547
+
548
+
495
549
  def get_gcp_auth_credentials(config_dir, profile):
496
550
  token = metaflowconfig.get_metaflow_token_from_config(config_dir, profile)
497
551
  auth_server_url = metaflowconfig.get_sanitized_url_from_config(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: outerbounds
3
- Version: 0.3.89
3
+ Version: 0.3.90
4
4
  Summary: More Data Science, Less Administration
5
5
  License: Proprietary
6
6
  Keywords: data science,machine learning,MLOps
@@ -43,7 +43,7 @@ outerbounds/cli_main.py,sha256=e9UMnPysmc7gbrimq2I4KfltggyU7pw59Cn9aEguVcU,74
43
43
  outerbounds/command_groups/__init__.py,sha256=QPWtj5wDRTINDxVUL7XPqG3HoxHNvYOg08EnuSZB2Hc,21
44
44
  outerbounds/command_groups/cli.py,sha256=sorDdQvmTPqIwfvgtuNLILelimXu5CknFnWQFsYFGHs,286
45
45
  outerbounds/command_groups/local_setup_cli.py,sha256=tuuqJRXQ_guEwOuQSIf9wkUU0yg8yAs31myGViAK15s,36364
46
- outerbounds/command_groups/perimeters_cli.py,sha256=IFSQC7nwnPksryv4jLMf--orkCWESxTJUx0o_wcperk,16724
46
+ outerbounds/command_groups/perimeters_cli.py,sha256=mrJfFIRYFOjuiz-9h4OKg2JT8Utmbs72z6wvPzDss3s,18685
47
47
  outerbounds/command_groups/workstations_cli.py,sha256=V5Jbj1cVb4IRllI7fOgNgL6OekRpuFDv6CEhDb4xC6w,22016
48
48
  outerbounds/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  outerbounds/utils/kubeconfig.py,sha256=yvcyRXGR4AhQuqUDqmbGxEOHw5ixMFV0AZIDg1LI_Qo,7981
@@ -51,7 +51,7 @@ outerbounds/utils/metaflowconfig.py,sha256=l2vJbgPkLISU-XPGZFaC8ZKmYFyJemlD6bwB-
51
51
  outerbounds/utils/schema.py,sha256=cNlgjmteLPbDzSEUSQDsq8txdhMGyezSmM83jU3aa0w,2329
52
52
  outerbounds/utils/utils.py,sha256=4Z8cszNob_8kDYCLNTrP-wWads_S_MdL3Uj3ju4mEsk,501
53
53
  outerbounds/vendor.py,sha256=gRLRJNXtZBeUpPEog0LOeIsl6GosaFFbCxUvR4bW6IQ,5093
54
- outerbounds-0.3.89.dist-info/entry_points.txt,sha256=7ye0281PKlvqxu15rjw60zKg2pMsXI49_A8BmGqIqBw,47
55
- outerbounds-0.3.89.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
56
- outerbounds-0.3.89.dist-info/METADATA,sha256=EbJIp_Ibm7F8sO2SfCcZOnOi61wWO2RUQnnWTwDZV38,1632
57
- outerbounds-0.3.89.dist-info/RECORD,,
54
+ outerbounds-0.3.90.dist-info/entry_points.txt,sha256=7ye0281PKlvqxu15rjw60zKg2pMsXI49_A8BmGqIqBw,47
55
+ outerbounds-0.3.90.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
56
+ outerbounds-0.3.90.dist-info/METADATA,sha256=an69uvqpICHuiBfJVZJJrZU474ehFkjnnilY1jRLYFg,1632
57
+ outerbounds-0.3.90.dist-info/RECORD,,