gen3-dataops-toolkit 2.1.0__tar.gz → 2.1.2__tar.gz
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.
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/PKG-INFO +1 -1
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/pyproject.toml +1 -1
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/release_cmds.py +8 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/config.py +3 -1
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/resolver.py +30 -6
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/utils/athena_utils.py +19 -6
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/utils/release_writer.py +11 -2
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/README.md +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/__init__.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/__init__.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/__init__.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/dispatch.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/registry.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/resolve.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/runner.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/safety.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/config_cmds.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/delete_cmds.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/dict_cmds.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/ec2_cmds.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/indexd_cmds.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/jobs.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/k8s.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/main.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/metadata.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/pipeline_cmds.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/synth.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/indexd/__init__.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/indexd/indexd_registrar.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/ingest/ingest.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/delete/delete_all_metadata_for_project.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/delete/delete_metadata.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/delete/delete_metadata_by_guid.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/dictionary/deploy_dd.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/dictionary/pull_dict.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/dictionary/upload_dictionary.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/indexd/register_indexd.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/k8s_ops/argocd_restart_etl.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/k8s_ops/argocd_restart_ms.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/k8s_ops/argocd_restart_schema.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/k8s_ops/login_to_pod.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/k8s_ops/restart_etl_and_ms.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/synthetic_data/delete_synth_metadata_sheepdog.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/synthetic_data/full_deploy_dd_and_synth.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/synthetic_data/generate_synth_metadata.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/synthetic_data/upload_synth_metadata_sheepdog.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/upload/metadata/upload_all_studies.sh +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/upload/metadata/upload_metadata.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/upload/__init__.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/upload/metadata_deleter.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/upload/metadata_submitter.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/upload/upload_synthdata_s3.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/utils/dbt_utils.py +0 -0
- {gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/validate/validate.py +0 -0
|
@@ -55,6 +55,12 @@ def write(
|
|
|
55
55
|
f"(workgroup output {rc.athena_output_location})",
|
|
56
56
|
bold=True,
|
|
57
57
|
)
|
|
58
|
+
# The env's own silver/gold DBs (from SSM) scope the model->DB search:
|
|
59
|
+
# deterministic in shared accounts, no account-wide Glue perms needed.
|
|
60
|
+
search_databases = [
|
|
61
|
+
db for db in (rc.get("glue/db/rawSilver"), rc.get("glue/db/rawGold"))
|
|
62
|
+
if db
|
|
63
|
+
] or None
|
|
58
64
|
release_writer.run(
|
|
59
65
|
dbt_schema_path=dbt_schema_path,
|
|
60
66
|
release_db=rc.release_db,
|
|
@@ -65,6 +71,8 @@ def write(
|
|
|
65
71
|
aws_region=rc.region,
|
|
66
72
|
athena_s3_output=rc.athena_output_location,
|
|
67
73
|
aws_profile=profile,
|
|
74
|
+
workgroup=rc.athena_workgroup,
|
|
75
|
+
search_databases=search_databases,
|
|
68
76
|
dry_run=dry_run,
|
|
69
77
|
)
|
|
70
78
|
except config.ConfigError as exc:
|
|
@@ -336,7 +336,9 @@ def _studies_from_s3_cached(project: str, base_env: str, profile: Optional[str])
|
|
|
336
336
|
from g3dt import resolver
|
|
337
337
|
|
|
338
338
|
rc = resolver.resolve(project, base_env, profile=profile)
|
|
339
|
-
|
|
339
|
+
# Explicit region: botocore ignores AWS_REGION (only AWS_DEFAULT_REGION),
|
|
340
|
+
# so an ambient session on the EC2 box would have no region at all.
|
|
341
|
+
session = boto3.Session(profile_name=profile, region_name=rc.region)
|
|
340
342
|
try:
|
|
341
343
|
body = session.client("s3").get_object(
|
|
342
344
|
Bucket=rc.metadata_bucket, Key=STUDIES_S3_KEY
|
|
@@ -127,31 +127,55 @@ class ResolvedConfig:
|
|
|
127
127
|
return self.params.get(key, default)
|
|
128
128
|
|
|
129
129
|
|
|
130
|
+
def _session(profile: Optional[str], region: Optional[str]) -> boto3.Session:
|
|
131
|
+
"""A boto3 session with an EXPLICIT region.
|
|
132
|
+
|
|
133
|
+
The region always comes from the marker (file value, or its AWS_REGION
|
|
134
|
+
env-var override) rather than boto3's own chain: botocore only honours
|
|
135
|
+
AWS_DEFAULT_REGION, so on the EC2 job box — where user-data exports
|
|
136
|
+
AWS_REGION and there is no ~/.aws/config — an ambient-chain session has
|
|
137
|
+
no region at all (NoRegionError).
|
|
138
|
+
"""
|
|
139
|
+
if region is None:
|
|
140
|
+
from g3dt.config import load_marker # late import (config imports us)
|
|
141
|
+
|
|
142
|
+
region = load_marker()["region"]
|
|
143
|
+
return boto3.Session(profile_name=profile, region_name=region)
|
|
144
|
+
|
|
145
|
+
|
|
130
146
|
@functools.lru_cache(maxsize=None)
|
|
131
|
-
def resolve(
|
|
147
|
+
def resolve(
|
|
148
|
+
project: str,
|
|
149
|
+
env: str,
|
|
150
|
+
profile: Optional[str] = None,
|
|
151
|
+
region: Optional[str] = None,
|
|
152
|
+
) -> ResolvedConfig:
|
|
132
153
|
"""Resolve all deployed names for ``project``/``env`` from SSM (cached).
|
|
133
154
|
|
|
134
|
-
Cached on ``(project, env, profile)`` for the life of the process,
|
|
135
|
-
single CLI invocation makes exactly one ``get_parameters_by_path``
|
|
155
|
+
Cached on ``(project, env, profile, region)`` for the life of the process,
|
|
156
|
+
so a single CLI invocation makes exactly one ``get_parameters_by_path``
|
|
136
157
|
round-trip no matter how many commands ask for a name. Call
|
|
137
158
|
``resolve.cache_clear()`` in tests.
|
|
138
159
|
|
|
139
160
|
``profile`` is the local AWS named profile to authenticate the read (e.g.
|
|
140
161
|
``etl_test``); ``None`` uses the default credential chain — which is the
|
|
141
162
|
instance profile on the EC2 job box and the build role in CodeBuild.
|
|
163
|
+
``region`` defaults to the marker's region.
|
|
142
164
|
"""
|
|
143
|
-
session =
|
|
165
|
+
session = _session(profile, region)
|
|
144
166
|
return ResolvedConfig(
|
|
145
167
|
project=project, env=env, params=_fetch_params(project, env, session=session)
|
|
146
168
|
)
|
|
147
169
|
|
|
148
170
|
|
|
149
|
-
def list_envs(
|
|
171
|
+
def list_envs(
|
|
172
|
+
project: str, profile: Optional[str] = None, region: Optional[str] = None
|
|
173
|
+
) -> list:
|
|
150
174
|
"""Return the environment names that have an SSM tree under /{project}/.
|
|
151
175
|
|
|
152
176
|
Reads the parameter names one level down (e.g. ``/etl/test/...`` -> ``test``).
|
|
153
177
|
"""
|
|
154
|
-
session =
|
|
178
|
+
session = _session(profile, region)
|
|
155
179
|
client = session.client("ssm")
|
|
156
180
|
paginator = client.get_paginator("get_parameters_by_path")
|
|
157
181
|
envs = set()
|
|
@@ -26,10 +26,14 @@ class AthenaConfig:
|
|
|
26
26
|
aws_region (str): AWS region for Athena and S3 operations.
|
|
27
27
|
aws_profile (str): AWS profile to use for authentication.
|
|
28
28
|
athena_s3_output (str): S3 location for Athena query output.
|
|
29
|
+
workgroup (str, optional): Athena workgroup to run queries in. Roles on
|
|
30
|
+
the platform are scoped to the env's workgroup, so leaving this
|
|
31
|
+
unset (awswrangler defaults to 'primary') fails under them.
|
|
29
32
|
"""
|
|
30
33
|
aws_region: str
|
|
31
34
|
aws_profile: str
|
|
32
35
|
athena_s3_output: str
|
|
36
|
+
workgroup: Optional[str] = None
|
|
33
37
|
|
|
34
38
|
def as_dict(self) -> Dict[str, Any]:
|
|
35
39
|
return {
|
|
@@ -87,13 +91,16 @@ class AthenaQuery:
|
|
|
87
91
|
logger.info(f"Running Athena query: {sql}")
|
|
88
92
|
boto3_session = self._get_boto_session()
|
|
89
93
|
try:
|
|
90
|
-
|
|
94
|
+
kwargs = dict(
|
|
91
95
|
sql=sql,
|
|
92
96
|
boto3_session=boto3_session,
|
|
93
97
|
database=athena_database,
|
|
94
98
|
ctas_approach=ctas_approach,
|
|
95
|
-
s3_output=self.config.athena_s3_output
|
|
99
|
+
s3_output=self.config.athena_s3_output,
|
|
96
100
|
)
|
|
101
|
+
if getattr(self.config, "workgroup", None):
|
|
102
|
+
kwargs["workgroup"] = self.config.workgroup
|
|
103
|
+
df = wr.athena.read_sql_query(**kwargs)
|
|
97
104
|
logger.info(
|
|
98
105
|
f"Athena query completed successfully. Returned {len(df)} rows."
|
|
99
106
|
)
|
|
@@ -159,7 +166,7 @@ class AthenaQuery:
|
|
|
159
166
|
database=athena_database,
|
|
160
167
|
table=table_name,
|
|
161
168
|
boto3_session=boto3_session,
|
|
162
|
-
workgroup='primary',
|
|
169
|
+
workgroup=getattr(self.config, "workgroup", None) or 'primary',
|
|
163
170
|
temp_path=temp_s3_path
|
|
164
171
|
)
|
|
165
172
|
logger.info(
|
|
@@ -172,7 +179,7 @@ class AthenaQuery:
|
|
|
172
179
|
)
|
|
173
180
|
raise
|
|
174
181
|
|
|
175
|
-
def find_db_for_model(self, model_name: str) -> Optional[str]:
|
|
182
|
+
def find_db_for_model(self, model_name: str, databases: Optional[list] = None) -> Optional[str]:
|
|
176
183
|
"""
|
|
177
184
|
Search all Athena databases for a table with the given name and return the database name if found.
|
|
178
185
|
|
|
@@ -202,8 +209,14 @@ class AthenaQuery:
|
|
|
202
209
|
try:
|
|
203
210
|
# Create a session and pass it to wrangler
|
|
204
211
|
boto3_session = self._get_boto_session()
|
|
205
|
-
|
|
206
|
-
|
|
212
|
+
if databases:
|
|
213
|
+
# Scoped search (e.g. the env's own silver/gold DBs from SSM):
|
|
214
|
+
# deterministic in shared accounts and needs no account-wide
|
|
215
|
+
# Glue permissions.
|
|
216
|
+
db_list = list(databases)
|
|
217
|
+
else:
|
|
218
|
+
all_dbs = wr.catalog.databases(boto3_session=boto3_session)
|
|
219
|
+
db_list = all_dbs.get('Database', [])
|
|
207
220
|
for db in db_list:
|
|
208
221
|
try:
|
|
209
222
|
# Pass the session to other wrangler calls too
|
|
@@ -143,6 +143,10 @@ def parse_args():
|
|
|
143
143
|
help="S3 URI for Athena query results (e.g., 's3://athena-results-bucket/').")
|
|
144
144
|
parser.add_argument("--release-s3-location", type=str, required=True,
|
|
145
145
|
help="S3 location for the release table (e.g., 's3://<metadata-bucket>/').")
|
|
146
|
+
parser.add_argument("--workgroup", type=str, required=False,
|
|
147
|
+
help="Athena workgroup to run queries in (platform roles are workgroup-scoped).")
|
|
148
|
+
parser.add_argument("--search-database", action="append", default=None,
|
|
149
|
+
help="Restrict the model->database search to this DB (repeatable).")
|
|
146
150
|
parser.add_argument("--dry-run", action="store_true", default=False,
|
|
147
151
|
help="Resolve everything and log the SQL; write nothing.")
|
|
148
152
|
parser.add_argument("-v", "--verbose", action="store_true", default=False,
|
|
@@ -161,6 +165,8 @@ def run(
|
|
|
161
165
|
aws_region: str,
|
|
162
166
|
athena_s3_output: str,
|
|
163
167
|
aws_profile: Optional[str] = None,
|
|
168
|
+
workgroup: Optional[str] = None,
|
|
169
|
+
search_databases: Optional[list] = None,
|
|
164
170
|
dry_run: bool = False,
|
|
165
171
|
) -> None:
|
|
166
172
|
"""Write one release row per dbt model (idempotent; see insert_release_row).
|
|
@@ -176,7 +182,8 @@ def run(
|
|
|
176
182
|
athena_config = AthenaConfig(
|
|
177
183
|
aws_region=aws_region,
|
|
178
184
|
aws_profile=aws_profile,
|
|
179
|
-
athena_s3_output=athena_s3_output
|
|
185
|
+
athena_s3_output=athena_s3_output,
|
|
186
|
+
workgroup=workgroup,
|
|
180
187
|
)
|
|
181
188
|
|
|
182
189
|
dbt_models = get_model_names(dbt_schema_path)
|
|
@@ -197,7 +204,7 @@ def run(
|
|
|
197
204
|
|
|
198
205
|
for model_name in dbt_models:
|
|
199
206
|
logger.info(f"--- Processing model: {model_name}")
|
|
200
|
-
db_name = athena_query.find_db_for_model(model_name)
|
|
207
|
+
db_name = athena_query.find_db_for_model(model_name, databases=search_databases)
|
|
201
208
|
if not db_name:
|
|
202
209
|
logger.warning(f"Database not found for model '{model_name}'. Skipping...")
|
|
203
210
|
continue
|
|
@@ -239,6 +246,8 @@ def main():
|
|
|
239
246
|
aws_region=args.aws_region,
|
|
240
247
|
athena_s3_output=args.athena_s3_output,
|
|
241
248
|
aws_profile=args.aws_profile,
|
|
249
|
+
workgroup=args.workgroup,
|
|
250
|
+
search_databases=args.search_database,
|
|
242
251
|
dry_run=args.dry_run,
|
|
243
252
|
)
|
|
244
253
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/__init__.py
RENAMED
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/dispatch.py
RENAMED
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/cli/_internal/registry.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/indexd/indexd_registrar.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/dictionary/deploy_dd.sh
RENAMED
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/dictionary/pull_dict.sh
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/services/k8s_ops/login_to_pod.sh
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/upload/metadata_deleter.py
RENAMED
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/upload/metadata_submitter.py
RENAMED
|
File without changes
|
{gen3_dataops_toolkit-2.1.0 → gen3_dataops_toolkit-2.1.2}/src/g3dt/upload/upload_synthdata_s3.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|