Skip to content

Commit b465826

Browse files
author
gdgate
authored
Merge pull request #389 from jaceksan/gartner
TRIVIAL: gooddata-dbt - run dbt cloud jobs only one, not for each org Reviewed-by: Jan Kadlec https://github.com/hkad98
2 parents 210a182 + c7cd930 commit b465826

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

gooddata-dbt/gooddata_dbt/args.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ def set_gooddata_endpoint_args(parser: argparse.ArgumentParser) -> None:
3636
default=os.getenv("GOODDATA_OVERRIDE_HOST"),
3737
)
3838
# Alternative - use profile.yml file
39+
env_profiles = os.getenv("GOODDATA_PROFILES")
40+
if env_profiles:
41+
env_profiles_list = env_profiles.split(" ")
42+
else:
43+
env_profiles_list = []
3944
parser.add_argument(
4045
"-gp",
4146
"--gooddata-profiles",
4247
nargs="*",
4348
help="Profiles in profile.yml file. Overrides gooddata-host, gooddata-token and gooddata-override-host."
4449
+ "You can use multiple profiles separated by space to deliver models/analytics to multiple organizations.",
45-
default=os.getenv("GOODDATA_PROFILES", None),
50+
default=env_profiles_list,
4651
)
4752

4853

gooddata-dbt/gooddata_dbt/dbt_plugin.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,7 @@ def process_organization(
298298
gd_config: GoodDataConfig,
299299
organization: Optional[GoodDataConfigOrganization] = None,
300300
) -> None:
301-
if args.method == "dbt_cloud_run":
302-
dbt_cloud_run(args, logger, gd_config.all_model_ids)
303-
elif args.method == "dbt_cloud_stats":
304-
dbt_cloud_stats(args, logger, gd_config.all_model_ids, args.environment_id)
305-
elif args.method == "upload_notification":
301+
if args.method == "upload_notification":
306302
dbt_profiles = DbtProfiles(args)
307303
# Caches are invalidated only per data source, not per data product
308304
upload_notification(logger, sdk_wrapper.sdk, dbt_profiles.data_source_id)
@@ -343,17 +339,22 @@ def main() -> None:
343339
logger.info("Start")
344340
with open(args.gooddata_config) as fp:
345341
gd_config = GoodDataConfig.from_dict(yaml.safe_load(fp))
346-
347-
if args.gooddata_profiles:
348-
logger.info(f"Process multiple organizations profiles={args.gooddata_profiles}")
349-
for organization in gd_config.organizations:
350-
if organization.gooddata_profile in args.gooddata_profiles:
351-
sdk_wrapper = GoodDataSdkWrapper(args, logger, profile=organization.gooddata_profile)
352-
logger.info(f"Process organization profile={organization.gooddata_profile}")
353-
process_organization(args, logger, sdk_wrapper, gd_config, organization)
342+
# dbt cloud tasks must run only once, not for each organization
343+
if args.method == "dbt_cloud_run":
344+
dbt_cloud_run(args, logger, gd_config.all_model_ids)
345+
elif args.method == "dbt_cloud_stats":
346+
dbt_cloud_stats(args, logger, gd_config.all_model_ids, args.environment_id)
354347
else:
355-
sdk_wrapper = GoodDataSdkWrapper(args, logger)
356-
logger.info(f"Process single organization from env vars host={args.gooddata_host}")
357-
process_organization(args, logger, sdk_wrapper, gd_config)
348+
if args.gooddata_profiles:
349+
logger.info(f"Process multiple organizations profiles={args.gooddata_profiles}")
350+
for organization in gd_config.organizations:
351+
if organization.gooddata_profile in args.gooddata_profiles:
352+
sdk_wrapper = GoodDataSdkWrapper(args, logger, profile=organization.gooddata_profile)
353+
logger.info(f"Process organization profile={organization.gooddata_profile}")
354+
process_organization(args, logger, sdk_wrapper, gd_config, organization)
355+
else:
356+
sdk_wrapper = GoodDataSdkWrapper(args, logger)
357+
logger.info(f"Process single organization from env vars host={args.gooddata_host}")
358+
process_organization(args, logger, sdk_wrapper, gd_config)
358359

359360
logger.info("End")

0 commit comments

Comments
 (0)