outerbounds 0.3.166__py3-none-any.whl → 0.3.168rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ from . import (
6
6
  apps_cli,
7
7
  tutorials_cli,
8
8
  fast_bakery_cli,
9
+ secrets_cli,
9
10
  )
10
11
 
11
12
 
@@ -18,6 +19,7 @@ from . import (
18
19
  apps_cli.cli,
19
20
  tutorials_cli.cli,
20
21
  fast_bakery_cli.cli,
22
+ secrets_cli.cli,
21
23
  ],
22
24
  )
23
25
  def cli(**kwargs):
@@ -0,0 +1,119 @@
1
+ import json
2
+ import os
3
+ from os import path
4
+ from typing import Any, Dict
5
+ from outerbounds._vendor import click
6
+
7
+ from ..utils.utils import safe_write_to_disk
8
+
9
+
10
+ def _get_ob_provider():
11
+ from metaflow.plugins import SECRETS_PROVIDERS
12
+
13
+ ob_provider = [i for i in SECRETS_PROVIDERS if i.TYPE == "outerbounds"][0]
14
+ return ob_provider()
15
+
16
+
17
+ class SecretOutput:
18
+ def __init__(self, type):
19
+ self.type = type
20
+ self._secrets = []
21
+
22
+ def consume(self, secret_dict):
23
+ self._secrets.append(secret_dict)
24
+
25
+ def parse(self):
26
+ if self.type == "text":
27
+ return "\n".join(
28
+ [f"{k}={v}" for secret in self._secrets for k, v in secret.items()]
29
+ )
30
+ elif self.type == "json":
31
+ secrets = {}
32
+ for secret in self._secrets:
33
+ secrets.update(secret)
34
+ return json.dumps(secrets)
35
+ elif self.type == "shell":
36
+ return "\n".join(
37
+ [
38
+ f"export {k}={v}"
39
+ for secret in self._secrets
40
+ for k, v in secret.items()
41
+ ]
42
+ )
43
+
44
+
45
+ @click.group()
46
+ def cli(**kwargs):
47
+ pass
48
+
49
+
50
+ @click.group(help="Manage secrets")
51
+ def secrets(**kwargs):
52
+ pass
53
+
54
+
55
+ FORMAT_HELP = """
56
+ Format of the output. When you specify:
57
+ - `text`: The output will be in `key=value` format. All secrets will be printed on new lines.
58
+ - `json`: The output will be in JSON format. All secrets will be combined into a single dictionary so if secrets have overlapping keys, the last one will take precedence.
59
+ - `shell`: The output will be a shell script that exports all secrets as environment variables.
60
+ """
61
+
62
+
63
+ @secrets.command(
64
+ help="Get secrets. The `secret_ids` correspond to the name of the integrations configured on the Outerbounds platform."
65
+ )
66
+ # command should be like :
67
+ # `outerbounds secrets get <secret-id-0> <secret-id-1> ... --output [text|json] --config-dir <config-dir> --profile <profile> --role <role> --output-file <output-file>`
68
+ @click.argument("secret_ids", type=str, nargs=-1)
69
+ @click.option(
70
+ "--format",
71
+ type=click.Choice(["text", "json", "shell"]),
72
+ default="text",
73
+ help=FORMAT_HELP,
74
+ )
75
+ @click.option(
76
+ "--profile",
77
+ type=str,
78
+ default=None,
79
+ help="The named metaflow profile to use.",
80
+ )
81
+ @click.option(
82
+ "--role",
83
+ type=str,
84
+ default=None,
85
+ help="Any additional IAM role required to access the secrets.",
86
+ )
87
+ @click.option(
88
+ "--file",
89
+ "-f",
90
+ "output_file",
91
+ type=str,
92
+ default=None,
93
+ help="The file to write the output to. If not specified, the output will be printed to standard out.",
94
+ )
95
+ def get(
96
+ secret_ids,
97
+ format,
98
+ profile,
99
+ role,
100
+ output_file,
101
+ ):
102
+
103
+ if profile != "" and profile is not None:
104
+ os.environ["METAFLOW_PROFILE"] = profile
105
+
106
+ provider = _get_ob_provider()
107
+ output = SecretOutput(format)
108
+ for secret_id in secret_ids:
109
+ secret = provider.get_secret_as_dict(secret_id, role=role)
110
+ output.consume(secret)
111
+ output_str = output.parse()
112
+ if output_file:
113
+ output_file = os.path.abspath(output_file)
114
+ safe_write_to_disk(output_file, output_str)
115
+ else:
116
+ print(output_str)
117
+
118
+
119
+ cli.add_command(secrets, name="secrets")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: outerbounds
3
- Version: 0.3.166
3
+ Version: 0.3.168rc0
4
4
  Summary: More Data Science, Less Administration
5
5
  License: Proprietary
6
6
  Keywords: data science,machine learning,MLOps
@@ -29,8 +29,8 @@ Requires-Dist: google-cloud-secret-manager (>=2.20.0,<3.0.0) ; extra == "gcp"
29
29
  Requires-Dist: google-cloud-storage (>=2.14.0,<3.0.0) ; extra == "gcp"
30
30
  Requires-Dist: metaflow-checkpoint (==0.2.1)
31
31
  Requires-Dist: ob-metaflow (==2.15.11.2)
32
- Requires-Dist: ob-metaflow-extensions (==1.1.153)
33
- Requires-Dist: ob-metaflow-stubs (==6.0.3.166)
32
+ Requires-Dist: ob-metaflow-extensions (==1.1.155rc0)
33
+ Requires-Dist: ob-metaflow-stubs (==6.0.3.168rc0)
34
34
  Requires-Dist: opentelemetry-distro (>=0.41b0) ; extra == "otel"
35
35
  Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.20.0) ; extra == "otel"
36
36
  Requires-Dist: opentelemetry-instrumentation-requests (>=0.41b0) ; extra == "otel"
@@ -42,10 +42,11 @@ outerbounds/_vendor/yaml/tokens.py,sha256=JBSu38wihGr4l73JwbfMA7Ks1-X84g8-NskTz7
42
42
  outerbounds/cli_main.py,sha256=e9UMnPysmc7gbrimq2I4KfltggyU7pw59Cn9aEguVcU,74
43
43
  outerbounds/command_groups/__init__.py,sha256=QPWtj5wDRTINDxVUL7XPqG3HoxHNvYOg08EnuSZB2Hc,21
44
44
  outerbounds/command_groups/apps_cli.py,sha256=v9OlQ1b4BGB-cBZiHB6W5gDocDoMmrQ7zdK11QiJ-B8,20847
45
- outerbounds/command_groups/cli.py,sha256=YsDS-AKhhwwSH65mgNsmjeg1U2bk202V5NpIYnXEdb8,440
45
+ outerbounds/command_groups/cli.py,sha256=de4_QY1UeoKX6y-IXIbmklAi6bz0DsdBSmAoCg6lq1o,482
46
46
  outerbounds/command_groups/fast_bakery_cli.py,sha256=5kja7v6C651XAY6dsP_IkBPJQgfU4hA4S9yTOiVPhW0,6213
47
47
  outerbounds/command_groups/local_setup_cli.py,sha256=tuuqJRXQ_guEwOuQSIf9wkUU0yg8yAs31myGViAK15s,36364
48
48
  outerbounds/command_groups/perimeters_cli.py,sha256=iF_Uw7ROiSctf6FgoJEy30iDBLVE1j9FKuR3shgJRmc,19050
49
+ outerbounds/command_groups/secrets_cli.py,sha256=PRV_pV1JEGkgSKQop6Qq_W4o2lcK3b7rNH2P-S8nY-8,3250
49
50
  outerbounds/command_groups/tutorials_cli.py,sha256=UInFyiMqtscHFfi8YQwiY_6Sdw9quJOtRu5OukEBccw,3522
50
51
  outerbounds/command_groups/workstations_cli.py,sha256=V5Jbj1cVb4IRllI7fOgNgL6OekRpuFDv6CEhDb4xC6w,22016
51
52
  outerbounds/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -54,7 +55,7 @@ outerbounds/utils/metaflowconfig.py,sha256=l2vJbgPkLISU-XPGZFaC8ZKmYFyJemlD6bwB-
54
55
  outerbounds/utils/schema.py,sha256=lMUr9kNgn9wy-sO_t_Tlxmbt63yLeN4b0xQXbDUDj4A,2331
55
56
  outerbounds/utils/utils.py,sha256=4Z8cszNob_8kDYCLNTrP-wWads_S_MdL3Uj3ju4mEsk,501
56
57
  outerbounds/vendor.py,sha256=gRLRJNXtZBeUpPEog0LOeIsl6GosaFFbCxUvR4bW6IQ,5093
57
- outerbounds-0.3.166.dist-info/METADATA,sha256=TZ52Cxpwyuzj6z8TWn-wJa--mYiy7tpSWX_AkOOLoXQ,1837
58
- outerbounds-0.3.166.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
59
- outerbounds-0.3.166.dist-info/entry_points.txt,sha256=7ye0281PKlvqxu15rjw60zKg2pMsXI49_A8BmGqIqBw,47
60
- outerbounds-0.3.166.dist-info/RECORD,,
58
+ outerbounds-0.3.168rc0.dist-info/METADATA,sha256=cQyn3eWluj6w2YUCcpNTWXr6vZk7DncpRZu4LM6wvAU,1846
59
+ outerbounds-0.3.168rc0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
60
+ outerbounds-0.3.168rc0.dist-info/entry_points.txt,sha256=7ye0281PKlvqxu15rjw60zKg2pMsXI49_A8BmGqIqBw,47
61
+ outerbounds-0.3.168rc0.dist-info/RECORD,,