diff --git a/gcp/README.md b/gcp/README.md index e99390fc..95d54d68 100644 --- a/gcp/README.md +++ b/gcp/README.md @@ -134,15 +134,18 @@ Alternatively you can provide all configuration values for Ads API via environme Body: * `script` - an object with two fields `query` and `name`, where `query` contains an Ads query text (as alternative to providing it via the `script_path` query argument) and `name` is a name (normally base file name would use) used for target table with data retuned by the script * `macro` - an object with macros for ads queries +* `writer_options` - an object with additional options for a writer Query string: * `ads_config_path` - a path to Ads config, e.g. gs://bucket/path/to/google-ads.yaml, if not passed then a local file will be tried to used (should be deployed with the function) * `script_path` - a path to Ads query file, currently only GCS paths are supported, e.g. gs://bucket/path/to/file, it's mandatory if script/name were not provided via body -* `single_customer` - true/false, pass true to prevent fetching child accounts for a given customer id (`customer_id`) +* `writer` - writer to use: "bq", "json", "csv". By default - "bq" (BigQuery) * `customer_id` - customer id (CID), without '-', can be specified in google-ads.yaml as well, if so then can be omitted +* `expand_mcc` - true to expand account in `customer_id` argument. By default (if false) it also disables creating union views * `bq_project_id` - BigQuery project id for output * `bq_dataset` - BiQuery dataset id for output * `bq_dataset_location` - BigQuery dataset location +* `output_path` - output path for interim data (for BigQueryWriter) or generated data (Csv/Json writers) Returns: * A map of CID (customer account id) to row counts. @@ -165,11 +168,12 @@ Query string: * `ads_config_path` - a path to Ads config, same as for gaarf * `customer_id` - customer id (CID), without '-', can be specified in google-ads.yaml as well, if so then can be omitted * `customer_ids_query` - custom Ads query to filter customer accounts expanded from `customer_id`, same as same-name argument for gaarf cli tool. Query's first column should be a customer id (CID) +* `customer_ids_ignore` - a list of customer ids to exclude from the result * `customer_ids_batchsize` - a size of batches into which account ids list will be split. * `customer_ids_offset` - an offset in the customer ids list resulted from the seed CIDs and optional query in `customer_ids_query`, it allows to implement an external batching. * `flatten` - flatten the list of customer ids. If `customer_ids_offset` is provided then the list will be a subset of CIDs otherwise it will be the whole list of accounts, ignoring batching (regadless of the customer_ids_batchsize's value) Body: -* `customer_ids_query` - same as QueryString's argument as alternative +* `customer_ids_query` - same as QueryString's argument as an alternative Returns: if no `flatten` specifiedd then the CF returns an object: diff --git a/gcp/create-gaarf-wf/build/index.js b/gcp/create-gaarf-wf/build/index.js index b7770b39..fe99f7a3 100755 --- a/gcp/create-gaarf-wf/build/index.js +++ b/gcp/create-gaarf-wf/build/index.js @@ -825,7 +825,7 @@ cd .. // now we detect macro used in queries and ask for their values const macro_ads = await get_macro_values(path.join(cwd, path_to_ads_queries), answers, 'ads_macro'); const macro_bq = await get_macro_values(path.join(cwd, path_to_bq_queries), answers, 'bq_macro'); - const bq_writer_options = answers.bq_writer_options; + const writer_options = answers.writer_options; const bq_location = gcp_region && gcp_region.startsWith('europe') ? 'europe' : ''; const output_dataset = answers2.output_dataset; const customer_id = sanitizeCustomerId(answers2.customer_id); @@ -840,7 +840,7 @@ cd .. ads_config_path: `${gcs_base_path}/google-ads.yaml`, customer_ids_query: custom_query_gcs_path, bq_dataset_location: bq_location, - bq_writer_options: bq_writer_options, + writer_options: writer_options, ads_macro: macro_ads, bq_macro: macro_bq, }; @@ -849,6 +849,7 @@ cd .. // Create run-wf.sh deploy_shell_script('run-wf.sh', `set -e ./ads-api-fetcher/gcp/setup.sh run_wf --settings $(readlink -f "./${settings_file}") --data $(readlink -f "./${wf_data_file}") +#./ads-api-fetcher/gcp/setup.sh run_job --settings $(readlink -f "./${settings_file}") `); fs.writeFileSync(settings_file, dump_settings(settings)); // now execute some scripts diff --git a/gcp/create-gaarf-wf/build/index.js.map b/gcp/create-gaarf-wf/build/index.js.map index 74242980..f8d54548 100644 --- a/gcp/create-gaarf-wf/build/index.js.map +++ b/gcp/create-gaarf-wf/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,oCAAoC;AACpC;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAA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I,CACf,mBAAmB,CACpB,gDAAgD,CAClD,CAAC;IACF,OAAO,CAAC,GAAG,CACT,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAA0C,CAC5E,CAAC;IACF,OAAO,CAAC,GAAG,CACT,OAAO,KAAK,CAAC,IAAI,CACf,WAAW,CACZ,kDAAkD,YAAY,EAAE,CAClE,CAAC;IACF,OAAO,CAAC,GAAG,CACT,OAAO,KAAK,CAAC,IAAI,CACf,gBAAgB,CACjB,sDAAsD,YAAY,EAAE,CACtE,CAAC;IACF,OAAO,CAAC,GAAG,CACT,OAAO,KAAK,CAAC,IAAI,CACf,gBAAgB,CACjB,oEAAoE,CACtE,CAAC;IAEF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC;IAClD,IAAI,WAAW,EAAE;QACf,MAAM,WAAW,GAAG,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;QACxE,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,WAAW,EAAE,CAAC,CAAC,CAAC;KAC9D;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,oCAAoC;AACpC;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,aAA8B,MAAM,eAAe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C;IACF,OAAO,CAAC,GAAG,CACT,OAAO,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,0CAA0C,CAC5E,CAAC;IACF,OAAO,CAAC,GAAG,CACT,OAAO,KAAK,CAAC,IAAI,CACf,WAAW,CACZ,kDAAkD,YAAY,EAAE,CAClE,CAAC;IACF,OAAO,CAAC,GAAG,CACT,OAAO,KAAK,CAAC,IAAI,CACf,gBAAgB,CACjB,sDAAsD,YAAY,EAAE,CACtE,CAAC;IACF,OAAO,CAAC,GAAG,CACT,OAAO,KAAK,CAAC,IAAI,CACf,gBAAgB,CACjB,oEAAoE,CACtE,CAAC;IAEF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC;IAClD,IAAI,WAAW,EAAE;QACf,MAAM,WAAW,GAAG,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;QACxE,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAsB,WAAW,EAAE,CAAC,CAAC,CAAC;KAC9D;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/gcp/create-gaarf-wf/package-lock.json b/gcp/create-gaarf-wf/package-lock.json index a29164c3..c4f0f228 100644 --- a/gcp/create-gaarf-wf/package-lock.json +++ b/gcp/create-gaarf-wf/package-lock.json @@ -1,12 +1,12 @@ { "name": "create-gaarf-wf", - "version": "1.11.1", + "version": "1.11.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "create-gaarf-wf", - "version": "1.11.1", + "version": "1.11.2", "license": "Apache-2.0", "dependencies": { "chalk": "^5.0.1", diff --git a/gcp/create-gaarf-wf/package.json b/gcp/create-gaarf-wf/package.json index 675c27ae..9a9d5913 100644 --- a/gcp/create-gaarf-wf/package.json +++ b/gcp/create-gaarf-wf/package.json @@ -1,6 +1,6 @@ { "name": "create-gaarf-wf", - "version": "1.11.1", + "version": "1.11.2", "description": "Interactive generator for Gaarf (Google Ads API Report Fetcher) Workflow", "type": "module", "bin": { diff --git a/gcp/create-gaarf-wf/src/index.ts b/gcp/create-gaarf-wf/src/index.ts index 572bd75c..96a6d1f0 100644 --- a/gcp/create-gaarf-wf/src/index.ts +++ b/gcp/create-gaarf-wf/src/index.ts @@ -1058,7 +1058,7 @@ cd .. answers, 'bq_macro' ); - const bq_writer_options = answers.bq_writer_options; + const writer_options = answers.writer_options; const bq_location = gcp_region && gcp_region.startsWith('europe') ? 'europe' : ''; const output_dataset = answers2.output_dataset; @@ -1074,7 +1074,7 @@ cd .. ads_config_path: `${gcs_base_path}/google-ads.yaml`, customer_ids_query: custom_query_gcs_path, bq_dataset_location: bq_location, - bq_writer_options: bq_writer_options, + writer_options: writer_options, ads_macro: macro_ads, bq_macro: macro_bq, }; @@ -1086,6 +1086,7 @@ cd .. 'run-wf.sh', `set -e ./ads-api-fetcher/gcp/setup.sh run_wf --settings $(readlink -f "./${settings_file}") --data $(readlink -f "./${wf_data_file}") +#./ads-api-fetcher/gcp/setup.sh run_job --settings $(readlink -f "./${settings_file}") ` ); diff --git a/gcp/functions/build/src/gaarf-bq-view.js b/gcp/functions/build/src/gaarf-bq-view.js index d41bda8a..2d88be87 100644 --- a/gcp/functions/build/src/gaarf-bq-view.js +++ b/gcp/functions/build/src/gaarf-bq-view.js @@ -45,9 +45,16 @@ async function main_bq_view_unsafe(req, res, projectId, logger) { res.end(); } const main_bq_view = async (req, res) => { + (0, utils_1.setLogLevel)(req); + const dumpMemory = !!(req.query.dump_memory || process.env.DUMP_MEMORY); const projectId = await (0, utils_1.getProject)(); const logger = (0, logger_1.createLogger)(req, projectId, process.env.K_SERVICE || 'gaarf-bq'); await logger.info('request', { body: req.body, query: req.query }); + let dispose; + if (dumpMemory) { + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('Start')); + dispose = (0, utils_1.startPeriodicMemoryLogging)(logger, 60000); + } try { await main_bq_view_unsafe(req, res, projectId, logger); } @@ -56,6 +63,13 @@ const main_bq_view = async (req, res) => { await logger.error(e.message, { error: e }); res.status(500).send(e.message).end(); } + finally { + if (dumpMemory) { + if (dispose) + dispose(); + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('End')); + } + } }; exports.main_bq_view = main_bq_view; //# sourceMappingURL=gaarf-bq-view.js.map \ No newline at end of file diff --git a/gcp/functions/build/src/gaarf-bq-view.js.map b/gcp/functions/build/src/gaarf-bq-view.js.map index 68642230..256164b5 100644 --- a/gcp/functions/build/src/gaarf-bq-view.js.map +++ b/gcp/functions/build/src/gaarf-bq-view.js.map @@ -1 +1 @@ -{"version":3,"file":"gaarf-bq-view.js","sourceRoot":"","sources":["../../src/gaarf-bq-view.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,0DAA6B;AAC7B,iFAA+D;AAI/D,qCAA+C;AAC/C,mCAAmC;AAEnC,KAAK,UAAU,mBAAmB,CAChC,GAAoB,EACpB,GAAqB,EACrB,SAAiB,EACjB,MAAe;IAEf,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAE/B,IAAI,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,KA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C,CAAC;KACtD;IAED,IAAI;QACF,MAAM,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;KACxD;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACf,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAC;QAC1C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;KACvC;YAAS;QACR,IAAI,UAAU,EAAE;YACd,IAAI,OAAO;gBAAE,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,IAAA,8CAAc,EAAC,KAAK,CAAC,CAAC,CAAC;SACpC;KACF;AACH,CAAC,CAAC;AA/BW,QAAA,YAAY,gBA+BvB"} \ No newline at end of file diff --git a/gcp/functions/build/src/gaarf-bq.js b/gcp/functions/build/src/gaarf-bq.js index f52a93f8..8d0686a0 100644 --- a/gcp/functions/build/src/gaarf-bq.js +++ b/gcp/functions/build/src/gaarf-bq.js @@ -40,9 +40,16 @@ async function main_bq_unsafe(req, res, projectId, logger) { } } const main_bq = async (req, res) => { + (0, utils_1.setLogLevel)(req); + const dumpMemory = !!(req.query.dump_memory || process.env.DUMP_MEMORY); const projectId = await (0, utils_1.getProject)(); const logger = (0, logger_1.createLogger)(req, projectId, process.env.K_SERVICE || 'gaarf-bq'); await logger.info('request', { body: req.body, query: req.query }); + let dispose; + if (dumpMemory) { + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('Start')); + dispose = (0, utils_1.startPeriodicMemoryLogging)(logger, 60000); + } try { await main_bq_unsafe(req, res, projectId, logger); } @@ -51,6 +58,13 @@ const main_bq = async (req, res) => { await logger.error(e.message, { error: e }); res.status(500).send(e.message).end(); } + finally { + if (dumpMemory) { + if (dispose) + dispose(); + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('End')); + } + } }; exports.main_bq = main_bq; //# sourceMappingURL=gaarf-bq.js.map \ No newline at end of file diff --git a/gcp/functions/build/src/gaarf-bq.js.map b/gcp/functions/build/src/gaarf-bq.js.map index b30d3117..17b83356 100644 --- a/gcp/functions/build/src/gaarf-bq.js.map +++ b/gcp/functions/build/src/gaarf-bq.js.map @@ -1 +1 @@ -{"version":3,"file":"gaarf-bq.js","sourceRoot":"","sources":["../../src/gaarf-bq.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,iFAA+D;AAG/D,mCAA8C;AAE9C,qCAA+C;AAE/C,KAAK,UAAU,cAAc,CAC3B,GAAoB,EACpB,GAAqB,EACrB,SAAiB,EACjB,MAAe;IAEf,MAAM,OAAO,GAA4B;QACvC,eAAe,EAAU,GAAG,CAAC,KAAK,CAAC,gBAAgB;KACpD,CAAC;IACF,MAAM,EAAC,SAAS,EAAE,UAAU,EAAC,GAAG,MAAM,IAAA,iBAAS,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,IAAI,gDAAgB,CAAS,SAAS,EAAE,OAAO,CAAC,CAAC;IAElE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC;IAC3B,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC;IAE/B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,SAAS,EAAE;QAC3D,SAAS;QACT,WAAW;KACZ,CAAC,CAAC;IACH,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;QAC3B,GAAG,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAC,CAAC,CAAC;KACrC;SAAM;QACL,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC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AAC,OAAO,CAAC,CAAC,CAAC;QACrC,OAAO,GAAG,IAAA,kCAA0B,EAAC,MAAM,EAAE,KAAM,CAAC,CAAC;KACtD;IAED,IAAI;QACF,MAAM,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;KACnD;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACf,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,CAAC,CAAC;QAC1C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;KACvC;YAAS;QACR,IAAI,UAAU,EAAE;YACd,IAAI,OAAO;gBAAE,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,IAAA,8CAAc,EAAC,KAAK,CAAC,CAAC,CAAC;SACpC;KACF;AACH,CAAC,CAAC;AA/BW,QAAA,OAAO,WA+BlB"} \ No newline at end of file diff --git a/gcp/functions/build/src/gaarf-getcids.js b/gcp/functions/build/src/gaarf-getcids.js index 3f684bf1..f6126517 100644 --- a/gcp/functions/build/src/gaarf-getcids.js +++ b/gcp/functions/build/src/gaarf-getcids.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.main_getcids = void 0; /** - * Copyright 2022 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,22 @@ exports.main_getcids = void 0; * See the License for the specific language governing permissions and * limitations under the License. */ +/** + * Cloud Function 'gaarf-getids' - executes Ads query (suplied either via body or as a GCS path) and writes data to BigQuery + * arguments: +* `ads_config_path` - a path to Ads config, same as for gaarf +* `customer_id` - a seed customer id (CID), without '-'; + can be specified in google-ads.yaml as well, if so then can be omitted +* `customer_ids_query` - custom Ads query to filter customer accounts expanded from `customer_id`, + same as same-name argument for gaarf cli tool. Query's first column should be a customer id (CID). +* `customer_ids_ignore` - a list of customer ids to exclude from the result +* `customer_ids_batchsize` - a size of batches into which account ids list will be split. +* `customer_ids_offset` - an offset in the customer ids list resulted from the seed CIDs and + optional query in `customer_ids_query`, it allows to implement an external batching. +* `flatten` - flatten the list of customer ids. If `customer_ids_offset` is provided then + the list will be a subset of CIDs otherwise it will be the whole list of accounts, + ignoring batching (regadless of the customer_ids_batchsize's value). + **/ const google_ads_api_report_fetcher_1 = require("google-ads-api-report-fetcher"); const utils_1 = require("./utils"); const logger_1 = require("./logger"); @@ -36,6 +52,7 @@ async function main_getcids_unsafe(req, res, logger) { else { customerIdsIgnore = [customerIdsIgnoreQS]; } + customerIdsIgnore = customerIdsIgnore.map(v => v.trim()); } if (!customerIds || customerIds.length === 0) { throw new Error("Customer id is not specified in either 'customer_id' query argument or google-ads.yaml"); @@ -43,8 +60,15 @@ async function main_getcids_unsafe(req, res, logger) { if (!adsConfig.login_customer_id && customerIds && customerIds.length === 1) { adsConfig.login_customer_id = customerIds[0]; } - const adsClient = new google_ads_api_report_fetcher_1.GoogleAdsApiClient(adsConfig); - customerIds = await adsClient.getCustomerIds(customerIds); + let adsClient; + if (req.query.api === 'rest') { + const apiVersion = req.query.apiVersion; + adsClient = new google_ads_api_report_fetcher_1.GoogleAdsRestApiClient(adsConfig, apiVersion); + } + else { + adsClient = new google_ads_api_report_fetcher_1.GoogleAdsRpcApiClient(adsConfig); + } + customerIds = await (0, google_ads_api_report_fetcher_1.getCustomerIds)(adsClient, customerIds); let customer_ids_query = ''; if (req.body && req.body.customer_ids_query) { customer_ids_query = req.body.customer_ids_query; @@ -54,8 +78,7 @@ async function main_getcids_unsafe(req, res, logger) { } if (customer_ids_query) { await logger.info(`Fetching customer id using custom query: ${customer_ids_query}`); - const executor = new google_ads_api_report_fetcher_1.AdsQueryExecutor(adsClient); - customerIds = await executor.getCustomerIds(customerIds, customer_ids_query); + customerIds = await (0, google_ads_api_report_fetcher_1.filterCustomerIds)(adsClient, customerIds, customer_ids_query); await logger.info(`Loaded ${customerIds.length} accounts`); } customerIds = customerIds || []; @@ -98,9 +121,16 @@ async function main_getcids_unsafe(req, res, logger) { } } const main_getcids = async (req, res) => { + (0, utils_1.setLogLevel)(req); + const dumpMemory = !!(req.query.dump_memory || process.env.DUMP_MEMORY); const projectId = await (0, utils_1.getProject)(); const logger = (0, logger_1.createLogger)(req, projectId, process.env.K_SERVICE || 'gaarf-getcids'); await logger.info('request', { body: req.body, query: req.query }); + let dispose; + if (dumpMemory) { + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('Start')); + dispose = (0, utils_1.startPeriodicMemoryLogging)(logger, 60000); + } try { await main_getcids_unsafe(req, res, logger); } @@ -108,6 +138,13 @@ const main_getcids = async (req, res) => { await logger.error(e.message, { error: e }); res.status(500).send(e.message).end(); } + finally { + if (dumpMemory) { + if (dispose) + dispose(); + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('End')); + } + } }; exports.main_getcids = main_getcids; //# sourceMappingURL=gaarf-getcids.js.map \ No newline at end of file diff --git a/gcp/functions/build/src/gaarf-getcids.js.map b/gcp/functions/build/src/gaarf-getcids.js.map index 9fcb9cb7..9c7d9953 100644 --- a/gcp/functions/build/src/gaarf-getcids.js.map +++ b/gcp/functions/build/src/gaarf-getcids.js.map @@ -1 +1 @@ -{"version":3,"file":"gaarf-getcids.js","sourceRoot":"","sources":["../../src/gaarf-getcids.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,iFAMuC;AAGvC,mCAAkE;AAClE,qCAA+C;AAE/C,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,KAAK,UAAU,mBAAmB,CAChC,GAAoB,EACpB,GAAqB,EACrB,MAAe;IAEf,6BAA6B;IAC7B,MAAM,SAAS,GAAuB,MAAM,IAAA,oBAAY,EAAC,GAAG,CAAC,CAAC;IAC9D,6D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C,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;KACvC;YAAS;QACR,IAAI,UAAU,EAAE;YACd,IAAI,OAAO;gBAAE,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,IAAA,8CAAc,EAAC,KAAK,CAAC,CAAC,CAAC;SACpC;KACF;AACH,CAAC,CAAC;AA9BW,QAAA,YAAY,gBA8BvB"} \ No newline at end of file diff --git a/gcp/functions/build/src/gaarf.d.ts b/gcp/functions/build/src/gaarf.d.ts index 03803568..120703b0 100644 --- a/gcp/functions/build/src/gaarf.d.ts +++ b/gcp/functions/build/src/gaarf.d.ts @@ -1,5 +1,5 @@ /** - * Copyright 2022 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/gcp/functions/build/src/gaarf.js b/gcp/functions/build/src/gaarf.js index d85daa5b..cb61c23b 100644 --- a/gcp/functions/build/src/gaarf.js +++ b/gcp/functions/build/src/gaarf.js @@ -1,6 +1,6 @@ "use strict"; /** - * Copyright 2022 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,72 +17,103 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.main = void 0; /** - * Cloud Function 'gaarf' - executes Ads query (suplied either via body or as gcs path) and writes data to BigQuery + * Cloud Function 'gaarf' - executes Ads query (suplied either via body or as a GCS path) and writes data to BigQuery (or other writer) * arguments: - * - (required) ads config - different sources are supported, see `getAdsConfig` fucntion - * - (required) bq_dataset - (can be taken from envvar DATASET) output BQ dataset id + * - (required) ads config - different sources are supported, see `getAdsConfig` function + * - writer - writer to use: "bq", "json", "csv". By default - "bq" (BigQuery) + * - bq_dataset - (can be taken from envvar DATASET) output BQ dataset id * - bq_project_id - BigQuery project id, be default the current project is used * - customer_id - Ads customer id (a.k.a. CID), can be taken from google-ads.yaml if specified - * - single_customer - true for skipping loading of subaccount, assuming the supplied CID is a leaf one (not MCC) + * - expand_mcc - true to expand account in `customer_id` argument. By default (if fale) it also disables creating union views. * - bq_dataset_location - BigQuery dataset location ('us' or 'europe'), optional, by default 'us' is used + * - output_path - output path for interim data (for BigQueryWriter) or generated data (Csv/Json writers) */ const google_ads_api_report_fetcher_1 = require("google-ads-api-report-fetcher"); const utils_1 = require("./utils"); const logger_1 = require("./logger"); +function getQueryWriter(req, projectId) { + var _a, _b, _c, _d, _e, _f; + const body = req.body || {}; + if (!req.query.writer || req.query.writer === 'bq') { + const bqWriterOptions = { + datasetLocation: req.query.bq_dataset_location, + arrayHandling: (_a = body.writer_options) === null || _a === void 0 ? void 0 : _a.array_handling, + arraySeparator: (_b = body.writer_options) === null || _b === void 0 ? void 0 : _b.array_separator, + outputPath: req.query.output_path || `gs://${projectId}/tmp`, + noUnionView: true, + }; + if (req.query.expand_mcc) { + bqWriterOptions.noUnionView = false; + } + const dataset = req.query.bq_dataset || process.env.DATASET; + if (!dataset) + throw new Error("Dataset is not specified in either 'bq_dataset' query argument or DATASET envvar"); + const writer = new google_ads_api_report_fetcher_1.BigQueryWriter(projectId, dataset, bqWriterOptions); + return writer; + } + if (req.query.writer === 'csv') { + const options = { + quoted: (_c = body.writer_options) === null || _c === void 0 ? void 0 : _c.quoted, + arraySeparator: (_d = body.writer_options) === null || _d === void 0 ? void 0 : _d.array_separator, + outputPath: req.query.output_path || `gs://${projectId}/tmp`, + }; + return new google_ads_api_report_fetcher_1.CsvWriter(options); + } + if (req.query.writer === 'json') { + const options = { + format: (_e = body.writer_options) === null || _e === void 0 ? void 0 : _e.format, + valueFormat: (_f = body.writer_options) === null || _f === void 0 ? void 0 : _f.value_format, + outputPath: req.query.output_path || `gs://${projectId}/tmp`, + }; + return new google_ads_api_report_fetcher_1.JsonWriter(options); + } +} async function main_unsafe(req, res, projectId, logger, functionName) { - var _a, _b; // prepare Ads API parameters const adsConfig = await (0, utils_1.getAdsConfig)(req); projectId = req.query.bq_project_id || process.env.PROJECT_ID || projectId; - const dataset = req.query.bq_dataset || process.env.DATASET; - if (!dataset) - throw new Error("Dataset is not specified in either 'bq_dataset' query argument or DATASET envvar"); const customerId = req.query.customer_id || adsConfig.customer_id; if (!customerId) throw new Error("Customer id is not specified in either 'customer_id' query argument or google-ads.yaml"); if (!adsConfig.login_customer_id) { adsConfig.login_customer_id = customerId; } - const ads_client = new google_ads_api_report_fetcher_1.GoogleAdsApiClient(adsConfig); - // TODO: support CsvWriter and output path to GCS - // (csv.destination_folder=gs://bucket/path) - const singleCustomer = req.query.single_customer; - const body = req.body || {}; - const macroParams = body.macro; - const bq_writer_options = { - datasetLocation: req.query.bq_dataset_location, - arrayHandling: (_a = body.bq_writer_options) === null || _a === void 0 ? void 0 : _a.array_handling, - arraySeparator: (_b = body.bq_writer_options) === null || _b === void 0 ? void 0 : _b.array_separator, - }; + let adsClient; + if (req.query.api === 'rest') { + const apiVersion = req.query.apiVersion; + adsClient = new google_ads_api_report_fetcher_1.GoogleAdsRestApiClient(adsConfig, apiVersion); + } + else { + adsClient = new google_ads_api_report_fetcher_1.GoogleAdsRpcApiClient(adsConfig); + } const { queryText, scriptName } = await (0, utils_1.getScript)(req, logger); // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars const { refresh_token, developer_token, ...ads_config_wo_token } = (adsConfig); - ads_config_wo_token['ApiVersion'] = google_ads_api_report_fetcher_1.AdsApiVersion; - await logger.info(`Running Cloud Function ${functionName}, Ads API ${google_ads_api_report_fetcher_1.AdsApiVersion}, ${singleCustomer - ? 'without MCC expansion (CID=' + customerId + ')' - : 'with MCC expansion (MCC=' + customerId + ')'}, see Ads API config in metadata field`, { + ads_config_wo_token['ApiVersion'] = adsClient.apiVersion; + await logger.info(`Running Cloud Function ${functionName}, Ads API ${adsClient.apiType} ${adsClient.apiVersion}, ${req.query.expand_mcc + ? 'with MCC expansion (MCC=' + customerId + ')' + : 'CID=' + customerId}, see Ads API config in metadata field`, { adsConfig: ads_config_wo_token, scriptName, customerId, request: { body: req.body, query: req.query }, }); let customers; - if (singleCustomer) { - customers = [customerId]; - bq_writer_options.noUnionView = true; - } - else { - customers = await ads_client.getCustomerIds(customerId); + if (req.query.expand_mcc) { + customers = await (0, google_ads_api_report_fetcher_1.getCustomerIds)(adsClient, customerId); await logger.info(`[${scriptName}] Customers to process (${customers.length})`, { customerId, scriptName, customers, }); } - const executor = new google_ads_api_report_fetcher_1.AdsQueryExecutor(ads_client); - const writer = new google_ads_api_report_fetcher_1.BigQueryWriter(projectId, dataset, bq_writer_options); - const result = await executor.execute(scriptName, queryText, customers, macroParams, writer); + else { + customers = [customerId]; + } + const executor = new google_ads_api_report_fetcher_1.AdsQueryExecutor(adsClient); + const writer = getQueryWriter(req, projectId); + const result = await executor.execute(scriptName, queryText, customers, req.body.macro, writer); await logger.info(`Cloud Function ${functionName} compeleted`, { customerId, scriptName, @@ -93,17 +124,35 @@ async function main_unsafe(req, res, projectId, logger, functionName) { res.end(); } const main = async (req, res) => { + (0, utils_1.setLogLevel)(req); + const dumpMemory = !!(req.query.dump_memory || process.env.DUMP_MEMORY); const projectId = await (0, utils_1.getProject)(); const functionName = process.env.K_SERVICE || 'gaarf'; const logger = (0, logger_1.createLogger)(req, projectId, functionName); + let dispose; + if (dumpMemory) { + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('Start')); + dispose = (0, utils_1.startPeriodicMemoryLogging)(logger, 60000); + } try { await main_unsafe(req, res, projectId, logger, functionName); } catch (e) { console.log(e); - await logger.error(e.message, { error: e, body: req.body, query: req.query }); + await logger.error(e.message, { + error: e, + body: req.body, + query: req.query, + }); res.status(500).send(e.message).end(); } + finally { + if (dumpMemory) { + if (dispose) + dispose(); + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('End')); + } + } }; exports.main = main; //# sourceMappingURL=gaarf.js.map \ No newline at end of file diff --git a/gcp/functions/build/src/gaarf.js.map b/gcp/functions/build/src/gaarf.js.map index 29031870..ad5c7e7b 100644 --- a/gcp/functions/build/src/gaarf.js.map +++ b/gcp/functions/build/src/gaarf.js.map @@ -1 +1 @@ -{"version":3,"file":"gaarf.js","sourceRoot":"","sources":["../../src/gaarf.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;;;;;;GASG;AACH,iFAMuC;AAIvC,mCAA4D;AAC5D,qCAA+C;AAE/C,KAAK,UAAU,WAAW,CACxB,GAAoB,EACpB,GAAqB,EACrB,SAAiB,EACjB,MAAe,EACf,YAAoB;;IAEpB,6BAA6B;IAC7B,MAAM,SAAS,GAAuB,MAAM,IAAA,oBAAY,EAAC,GAAG,CAAC,CAAC;IAC9D,SAAS;QACC,GAAG,CAAC,KAAK,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,SAAS,CAAC;IAEzE,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAC5D,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,IAAI,SAAS,CAAC,WAAW,CAAC;IAClE,IAAI,CAAC,UAAU;QACb,MAAM,IAAI,KAAK,CACb,wFAAwF,CACzF,CAAC;IACJ,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE;QAChC,SAAS,CAAC,iBAAiB,GAAW,UAAU,CAAC;KAClD;IAED,MAAM,UAAU,GAAG,IAAI,kDAAkB,CAAC,SAAS,CAAC,CAAC;IACrD,iDAAiD;IACjD,4CAA4C;IAE5C,MAAM,cAAc,GAAG,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC;IACjD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,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EAAE;YAC5B,KAAK,EAAE,CAAC;YACR,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE,GAAG,CAAC,KAAK;SACjB,CAAC,CAAC;QACH,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;KACvC;YAAS;QACR,IAAI,UAAU,EAAE;YACd,IAAI,OAAO;gBAAE,OAAO,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,IAAA,8CAAc,EAAC,KAAK,CAAC,CAAC,CAAC;SACpC;KACF;AACH,CAAC,CAAC;AA/BW,QAAA,IAAI,QA+Bf"} \ No newline at end of file diff --git a/gcp/functions/build/src/utils.d.ts b/gcp/functions/build/src/utils.d.ts index afb07b4a..699a71b4 100644 --- a/gcp/functions/build/src/utils.d.ts +++ b/gcp/functions/build/src/utils.d.ts @@ -8,3 +8,11 @@ export declare function getScript(req: express.Request, logger: ILogger): Promis export declare function getAdsConfig(req: express.Request): Promise; export declare function getProject(): Promise; export declare function splitIntoChunks(array: Array, max: number): any[][]; +export declare function setLogLevel(req: express.Request): void; +/** + * Start a periodic logging of memory usage in backgroung. + * @param logger logger to write to + * @param intervalMs interval in milliseconds + * @returns a callback to call for stopping logging + */ +export declare function startPeriodicMemoryLogging(logger: ILogger, intervalMs?: number): () => void; diff --git a/gcp/functions/build/src/utils.js b/gcp/functions/build/src/utils.js index debeeb7e..65caa4c6 100644 --- a/gcp/functions/build/src/utils.js +++ b/gcp/functions/build/src/utils.js @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.splitIntoChunks = exports.getProject = exports.getAdsConfig = exports.getScript = void 0; +exports.startPeriodicMemoryLogging = exports.setLogLevel = exports.splitIntoChunks = exports.getProject = exports.getAdsConfig = exports.getScript = void 0; const google_auth_library_1 = require("google-auth-library"); const google_ads_api_report_fetcher_1 = require("google-ads-api-report-fetcher"); const node_path_1 = __importDefault(require("node:path")); @@ -89,4 +89,25 @@ function splitIntoChunks(array, max) { return result; } exports.splitIntoChunks = splitIntoChunks; +function setLogLevel(req) { + const logLevel = req.query.log_level || process.env.LOG_LEVEL; + if (logLevel) { + process.env.LOG_LEVEL = logLevel; + (0, google_ads_api_report_fetcher_1.getLogger)().level = logLevel; + } +} +exports.setLogLevel = setLogLevel; +/** + * Start a periodic logging of memory usage in backgroung. + * @param logger logger to write to + * @param intervalMs interval in milliseconds + * @returns a callback to call for stopping logging + */ +function startPeriodicMemoryLogging(logger, intervalMs = 5000) { + const intervalId = setInterval(() => { + logger.info((0, google_ads_api_report_fetcher_1.getMemoryUsage)('Periodic')); + }, intervalMs); + return () => clearInterval(intervalId); // Return function to stop logging +} +exports.startPeriodicMemoryLogging = startPeriodicMemoryLogging; //# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/gcp/functions/build/src/utils.js.map b/gcp/functions/build/src/utils.js.map index 296692b4..81ca51e7 100644 --- a/gcp/functions/build/src/utils.js.map +++ b/gcp/functions/build/src/utils.js.map @@ -1 +1 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;;;;AACA,6DAA+C;AAC/C,iFAIuC;AACvC,0DAA6B;AAC7B,sDAAyB;AAGlB,KAAK,UAAU,SAAS,CAC7B,GAAoB,EACpB,MAAe;IAEf,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC;IACzC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAC5B,IAAI,SAA6B,CAAC;IAClC,IAAI,UAA8B,CAAC;IACnC,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;QAC9B,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAC9B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MAAe,EAAE,UAAU,GAAG,IAAI;IAC3E,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,MAAM,CAAC,IAAI,CAAC,IAAA,8CAAc,EAAC,UAAU,CAAC,CAAC,CAAC;IAC1C,CAAC,EAAE,UAAU,CAAC,CAAC;IACf,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,kCAAkC;AAC5E,CAAC;AALD,gEAKC"} \ No newline at end of file diff --git a/gcp/functions/package-lock.json b/gcp/functions/package-lock.json index c2dc0513..d391e6bf 100644 --- a/gcp/functions/package-lock.json +++ b/gcp/functions/package-lock.json @@ -11,7 +11,7 @@ "@google-cloud/functions-framework": "^3.3.0", "@google-cloud/logging": "^11.0.0", "@google-cloud/logging-winston": "^6.0.0", - "google-ads-api-report-fetcher": "^2.9.0", + "google-ads-api-report-fetcher": "2.11", "google-auth-library": "^9.1.0", "js-yaml": "^4.1.0" }, @@ -1605,6 +1605,29 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/axios": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.3.tgz", + "integrity": "sha512-Ar7ND9pU99eJ9GpoGQKhKf58GpUOgnzuaB7ueNQ5BMi0p+LZ5oaEnfF999fAArcTIBwXTCHAmGcHOZJaWPq9Nw==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -3023,6 +3046,25 @@ "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" }, + "node_modules/follow-redirects": { + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -3330,9 +3372,9 @@ } }, "node_modules/google-ads-api-report-fetcher": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/google-ads-api-report-fetcher/-/google-ads-api-report-fetcher-2.9.0.tgz", - "integrity": "sha512-SFeE4rEKuIwoRP7UIJIyzm67trVSg77/cHeG4MAAcoQLB+Jm6bb69ZGXIsQSj8pTEDPFFNUNd8/41BHlnZ/mqg==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/google-ads-api-report-fetcher/-/google-ads-api-report-fetcher-2.11.0.tgz", + "integrity": "sha512-MZYYpWjyjDaNjUGqMuOMQIMQf7WFb7IzZfO8+XOWefEooRLhGalf8v5/lC87dptUNHqF72pZ0yzuWiQnFpMzVw==", "dependencies": { "@google-cloud/bigquery": "^7.3.0", "@google-cloud/logging": "^11.0.0", @@ -3344,6 +3386,7 @@ "@types/lodash": "^4.14.195", "@types/yargs": "^17.0.24", "async": "^3.2.5", + "axios": "^1.7.2", "chalk": "^4.1.2", "csv": "^6.3.5", "csv-stringify": "^6.4.4", @@ -5010,6 +5053,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/pstree.remy": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", diff --git a/gcp/functions/package.json b/gcp/functions/package.json index 6c9d5ae3..c7f889a2 100644 --- a/gcp/functions/package.json +++ b/gcp/functions/package.json @@ -23,7 +23,7 @@ "@google-cloud/functions-framework": "^3.3.0", "@google-cloud/logging": "^11.0.0", "@google-cloud/logging-winston": "^6.0.0", - "google-ads-api-report-fetcher": "^2.9.0", + "google-ads-api-report-fetcher": "2.11", "google-auth-library": "^9.1.0", "js-yaml": "^4.1.0" }, diff --git a/gcp/functions/src/gaarf-bq-view.ts b/gcp/functions/src/gaarf-bq-view.ts index 29ece391..f017942d 100644 --- a/gcp/functions/src/gaarf-bq-view.ts +++ b/gcp/functions/src/gaarf-bq-view.ts @@ -14,12 +14,12 @@ * limitations under the License. */ import path from 'node:path'; -import {BigQueryExecutor} from 'google-ads-api-report-fetcher'; +import {BigQueryExecutor, getMemoryUsage} from 'google-ads-api-report-fetcher'; import type {HttpFunction} from '@google-cloud/functions-framework/build/src/functions'; import express from 'express'; import {BigQueryExecutorOptions} from 'google-ads-api-report-fetcher/src/lib/bq-executor'; import {createLogger, ILogger} from './logger'; -import {getProject} from './utils'; +import {getProject, setLogLevel, startPeriodicMemoryLogging} from './utils'; async function main_bq_view_unsafe( req: express.Request, @@ -55,6 +55,8 @@ export const main_bq_view: HttpFunction = async ( req: express.Request, res: express.Response ) => { + setLogLevel(req); + const dumpMemory = !!(req.query.dump_memory || process.env.DUMP_MEMORY); const projectId = await getProject(); const logger = createLogger( req, @@ -62,6 +64,11 @@ export const main_bq_view: HttpFunction = async ( process.env.K_SERVICE || 'gaarf-bq' ); await logger.info('request', {body: req.body, query: req.query}); + let dispose; + if (dumpMemory) { + logger.info(getMemoryUsage('Start')); + dispose = startPeriodicMemoryLogging(logger, 60_000); + } try { await main_bq_view_unsafe(req, res, projectId, logger); @@ -69,5 +76,10 @@ export const main_bq_view: HttpFunction = async ( console.log(e); await logger.error(e.message, {error: e}); res.status(500).send(e.message).end(); + } finally { + if (dumpMemory) { + if (dispose) dispose(); + logger.info(getMemoryUsage('End')); + } } }; diff --git a/gcp/functions/src/gaarf-bq.ts b/gcp/functions/src/gaarf-bq.ts index fa6f8d50..a43c77c6 100644 --- a/gcp/functions/src/gaarf-bq.ts +++ b/gcp/functions/src/gaarf-bq.ts @@ -13,10 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {BigQueryExecutor} from 'google-ads-api-report-fetcher'; +import {BigQueryExecutor, getMemoryUsage} from 'google-ads-api-report-fetcher'; import type {HttpFunction} from '@google-cloud/functions-framework/build/src/functions'; import express from 'express'; -import {getProject, getScript} from './utils'; +import { + getProject, + getScript, + setLogLevel, + startPeriodicMemoryLogging, +} from './utils'; import {BigQueryExecutorOptions} from 'google-ads-api-report-fetcher/src/lib/bq-executor'; import {createLogger, ILogger} from './logger'; @@ -51,6 +56,8 @@ export const main_bq: HttpFunction = async ( req: express.Request, res: express.Response ) => { + setLogLevel(req); + const dumpMemory = !!(req.query.dump_memory || process.env.DUMP_MEMORY); const projectId = await getProject(); const logger = createLogger( req, @@ -58,6 +65,11 @@ export const main_bq: HttpFunction = async ( process.env.K_SERVICE || 'gaarf-bq' ); await logger.info('request', {body: req.body, query: req.query}); + let dispose; + if (dumpMemory) { + logger.info(getMemoryUsage('Start')); + dispose = startPeriodicMemoryLogging(logger, 60_000); + } try { await main_bq_unsafe(req, res, projectId, logger); @@ -65,5 +77,10 @@ export const main_bq: HttpFunction = async ( console.log(e); await logger.error(e.message, {error: e}); res.status(500).send(e.message).end(); + } finally { + if (dumpMemory) { + if (dispose) dispose(); + logger.info(getMemoryUsage('End')); + } } }; diff --git a/gcp/functions/src/gaarf-getcids.ts b/gcp/functions/src/gaarf-getcids.ts index f212ba49..346550bd 100644 --- a/gcp/functions/src/gaarf-getcids.ts +++ b/gcp/functions/src/gaarf-getcids.ts @@ -1,5 +1,5 @@ /** - * Copyright 2022 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,16 +13,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/** + * Cloud Function 'gaarf-getids' - executes Ads query (suplied either via body or as a GCS path) and writes data to BigQuery + * arguments: +* `ads_config_path` - a path to Ads config, same as for gaarf +* `customer_id` - a seed customer id (CID), without '-'; + can be specified in google-ads.yaml as well, if so then can be omitted +* `customer_ids_query` - custom Ads query to filter customer accounts expanded from `customer_id`, + same as same-name argument for gaarf cli tool. Query's first column should be a customer id (CID). +* `customer_ids_ignore` - a list of customer ids to exclude from the result +* `customer_ids_batchsize` - a size of batches into which account ids list will be split. +* `customer_ids_offset` - an offset in the customer ids list resulted from the seed CIDs and + optional query in `customer_ids_query`, it allows to implement an external batching. +* `flatten` - flatten the list of customer ids. If `customer_ids_offset` is provided then + the list will be a subset of CIDs otherwise it will be the whole list of accounts, + ignoring batching (regadless of the customer_ids_batchsize's value). + **/ import { - AdsQueryExecutor, getFileContent, - GoogleAdsApiClient, + GoogleAdsRestApiClient, GoogleAdsApiConfig, parseCustomerIds, + getMemoryUsage, + IGoogleAdsApiClient, + GoogleAdsRpcApiClient, + getCustomerIds, + filterCustomerIds, } from 'google-ads-api-report-fetcher'; import type {HttpFunction} from '@google-cloud/functions-framework/build/src/functions'; import express from 'express'; -import {getAdsConfig, getProject, splitIntoChunks} from './utils'; +import { + getAdsConfig, + getProject, + setLogLevel, + splitIntoChunks, + startPeriodicMemoryLogging, +} from './utils'; import {createLogger, ILogger} from './logger'; const DEFAULT_BATCH_SIZE = 500; @@ -47,6 +73,7 @@ async function main_getcids_unsafe( } else { customerIdsIgnore = [customerIdsIgnoreQS]; } + customerIdsIgnore = customerIdsIgnore.map(v => v.trim()); } if (!customerIds || customerIds.length === 0) { throw new Error( @@ -56,8 +83,15 @@ async function main_getcids_unsafe( if (!adsConfig.login_customer_id && customerIds && customerIds.length === 1) { adsConfig.login_customer_id = customerIds[0]; } - const adsClient = new GoogleAdsApiClient(adsConfig); - customerIds = await adsClient.getCustomerIds(customerIds); + let adsClient: IGoogleAdsApiClient; + if (req.query.api === 'rest') { + const apiVersion = req.query.apiVersion; + adsClient = new GoogleAdsRestApiClient(adsConfig, apiVersion); + } else { + adsClient = new GoogleAdsRpcApiClient(adsConfig); + } + + customerIds = await getCustomerIds(adsClient, customerIds); let customer_ids_query = ''; if (req.body && req.body.customer_ids_query) { customer_ids_query = req.body.customer_ids_query; @@ -70,8 +104,8 @@ async function main_getcids_unsafe( await logger.info( `Fetching customer id using custom query: ${customer_ids_query}` ); - const executor = new AdsQueryExecutor(adsClient); - customerIds = await executor.getCustomerIds( + customerIds = await filterCustomerIds( + adsClient, customerIds, customer_ids_query ); @@ -125,6 +159,8 @@ export const main_getcids: HttpFunction = async ( req: express.Request, res: express.Response ) => { + setLogLevel(req); + const dumpMemory = !!(req.query.dump_memory || process.env.DUMP_MEMORY); const projectId = await getProject(); const logger = createLogger( req, @@ -132,11 +168,21 @@ export const main_getcids: HttpFunction = async ( process.env.K_SERVICE || 'gaarf-getcids' ); await logger.info('request', {body: req.body, query: req.query}); + let dispose; + if (dumpMemory) { + logger.info(getMemoryUsage('Start')); + dispose = startPeriodicMemoryLogging(logger, 60_000); + } try { await main_getcids_unsafe(req, res, logger); } catch (e) { await logger.error(e.message, {error: e}); res.status(500).send(e.message).end(); + } finally { + if (dumpMemory) { + if (dispose) dispose(); + logger.info(getMemoryUsage('End')); + } } }; diff --git a/gcp/functions/src/gaarf.ts b/gcp/functions/src/gaarf.ts index f69cde9b..35331670 100644 --- a/gcp/functions/src/gaarf.ts +++ b/gcp/functions/src/gaarf.ts @@ -1,5 +1,5 @@ /** - * Copyright 2022 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,28 +15,87 @@ */ /** - * Cloud Function 'gaarf' - executes Ads query (suplied either via body or as gcs path) and writes data to BigQuery + * Cloud Function 'gaarf' - executes Ads query (suplied either via body or as a GCS path) and writes data to BigQuery (or other writer) * arguments: - * - (required) ads config - different sources are supported, see `getAdsConfig` fucntion - * - (required) bq_dataset - (can be taken from envvar DATASET) output BQ dataset id + * - (required) ads config - different sources are supported, see `getAdsConfig` function + * - writer - writer to use: "bq", "json", "csv". By default - "bq" (BigQuery) + * - bq_dataset - (can be taken from envvar DATASET) output BQ dataset id * - bq_project_id - BigQuery project id, be default the current project is used * - customer_id - Ads customer id (a.k.a. CID), can be taken from google-ads.yaml if specified - * - single_customer - true for skipping loading of subaccount, assuming the supplied CID is a leaf one (not MCC) + * - expand_mcc - true to expand account in `customer_id` argument. By default (if fale) it also disables creating union views. * - bq_dataset_location - BigQuery dataset location ('us' or 'europe'), optional, by default 'us' is used + * - output_path - output path for interim data (for BigQueryWriter) or generated data (Csv/Json writers) */ import { AdsQueryExecutor, - AdsApiVersion, BigQueryWriter, BigQueryWriterOptions, - GoogleAdsApiClient, + GoogleAdsRpcApiClient, + getMemoryUsage, + getCustomerIds, + GoogleAdsApiConfig, + GoogleAdsRestApiClient, + IGoogleAdsApiClient, + CsvWriter, + CsvWriterOptions, + JsonWriter, + JsonWriterOptions, } from 'google-ads-api-report-fetcher'; import type {HttpFunction} from '@google-cloud/functions-framework/build/src/functions'; import express from 'express'; -import {GoogleAdsApiConfig} from 'google-ads-api-report-fetcher/src/lib/ads-api-client'; -import {getAdsConfig, getProject, getScript} from './utils'; +import { + getAdsConfig, + getProject, + getScript, + setLogLevel, + startPeriodicMemoryLogging, +} from './utils'; import {ILogger, createLogger} from './logger'; +function getQueryWriter(req: express.Request, projectId: string) { + const body = req.body || {}; + + if (!req.query.writer || req.query.writer === 'bq') { + const bqWriterOptions: BigQueryWriterOptions = { + datasetLocation: req.query.bq_dataset_location, + arrayHandling: body.writer_options?.array_handling, + arraySeparator: body.writer_options?.array_separator, + outputPath: req.query.output_path || `gs://${projectId}/tmp`, + noUnionView: true, + }; + if (req.query.expand_mcc) { + bqWriterOptions.noUnionView = false; + } + const dataset = req.query.bq_dataset || process.env.DATASET; + if (!dataset) + throw new Error( + "Dataset is not specified in either 'bq_dataset' query argument or DATASET envvar" + ); + const writer = new BigQueryWriter( + projectId, + dataset, + bqWriterOptions + ); + return writer; + } + if (req.query.writer === 'csv') { + const options: CsvWriterOptions = { + quoted: body.writer_options?.quoted, + arraySeparator: body.writer_options?.array_separator, + outputPath: req.query.output_path || `gs://${projectId}/tmp`, + }; + return new CsvWriter(options); + } + if (req.query.writer === 'json') { + const options: JsonWriterOptions = { + format: body.writer_options?.format, + valueFormat: body.writer_options?.value_format, + outputPath: req.query.output_path || `gs://${projectId}/tmp`, + }; + return new JsonWriter(options); + } +} + async function main_unsafe( req: express.Request, res: express.Response, @@ -49,11 +108,6 @@ async function main_unsafe( projectId = req.query.bq_project_id || process.env.PROJECT_ID || projectId; - const dataset = req.query.bq_dataset || process.env.DATASET; - if (!dataset) - throw new Error( - "Dataset is not specified in either 'bq_dataset' query argument or DATASET envvar" - ); const customerId = req.query.customer_id || adsConfig.customer_id; if (!customerId) throw new Error( @@ -63,30 +117,27 @@ async function main_unsafe( adsConfig.login_customer_id = customerId; } - const ads_client = new GoogleAdsApiClient(adsConfig); - // TODO: support CsvWriter and output path to GCS - // (csv.destination_folder=gs://bucket/path) - - const singleCustomer = req.query.single_customer; - const body = req.body || {}; - const macroParams = body.macro; - const bq_writer_options: BigQueryWriterOptions = { - datasetLocation: req.query.bq_dataset_location, - arrayHandling: body.bq_writer_options?.array_handling, - arraySeparator: body.bq_writer_options?.array_separator, - }; + let adsClient: IGoogleAdsApiClient; + if (req.query.api === 'rest') { + const apiVersion = req.query.apiVersion; + adsClient = new GoogleAdsRestApiClient(adsConfig, apiVersion); + } else { + adsClient = new GoogleAdsRpcApiClient(adsConfig); + } const {queryText, scriptName} = await getScript(req, logger); // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars const {refresh_token, developer_token, ...ads_config_wo_token} = ( adsConfig ); - ads_config_wo_token['ApiVersion'] = AdsApiVersion; + ads_config_wo_token['ApiVersion'] = adsClient.apiVersion; await logger.info( - `Running Cloud Function ${functionName}, Ads API ${AdsApiVersion}, ${ - singleCustomer - ? 'without MCC expansion (CID=' + customerId + ')' - : 'with MCC expansion (MCC=' + customerId + ')' + `Running Cloud Function ${functionName}, Ads API ${adsClient.apiType} ${ + adsClient.apiVersion + }, ${ + req.query.expand_mcc + ? 'with MCC expansion (MCC=' + customerId + ')' + : 'CID=' + customerId }, see Ads API config in metadata field`, { adsConfig: ads_config_wo_token, @@ -97,11 +148,8 @@ async function main_unsafe( ); let customers: string[]; - if (singleCustomer) { - customers = [customerId]; - bq_writer_options.noUnionView = true; - } else { - customers = await ads_client.getCustomerIds(customerId); + if (req.query.expand_mcc) { + customers = await getCustomerIds(adsClient, customerId); await logger.info( `[${scriptName}] Customers to process (${customers.length})`, { @@ -110,20 +158,18 @@ async function main_unsafe( customers, } ); + } else { + customers = [customerId]; } - const executor = new AdsQueryExecutor(ads_client); - const writer = new BigQueryWriter( - projectId, - dataset, - bq_writer_options - ); + const executor = new AdsQueryExecutor(adsClient); + const writer = getQueryWriter(req, projectId); const result = await executor.execute( scriptName, queryText, customers, - macroParams, + req.body.macro, writer ); @@ -141,15 +187,31 @@ export const main: HttpFunction = async ( req: express.Request, res: express.Response ) => { + setLogLevel(req); + const dumpMemory = !!(req.query.dump_memory || process.env.DUMP_MEMORY); const projectId = await getProject(); const functionName = process.env.K_SERVICE || 'gaarf'; const logger = createLogger(req, projectId, functionName); + let dispose; + if (dumpMemory) { + logger.info(getMemoryUsage('Start')); + dispose = startPeriodicMemoryLogging(logger, 60_000); + } try { await main_unsafe(req, res, projectId, logger, functionName); } catch (e) { console.log(e); - await logger.error(e.message, {error: e, body: req.body, query: req.query}); + await logger.error(e.message, { + error: e, + body: req.body, + query: req.query, + }); res.status(500).send(e.message).end(); + } finally { + if (dumpMemory) { + if (dispose) dispose(); + logger.info(getMemoryUsage('End')); + } } }; diff --git a/gcp/functions/src/utils.ts b/gcp/functions/src/utils.ts index 10535615..b1b1ffaf 100644 --- a/gcp/functions/src/utils.ts +++ b/gcp/functions/src/utils.ts @@ -4,6 +4,8 @@ import { getFileContent, GoogleAdsApiConfig, loadAdsConfigYaml, + getLogger, + getMemoryUsage, } from 'google-ads-api-report-fetcher'; import path from 'node:path'; import fs from 'node:fs'; @@ -97,3 +99,24 @@ export function splitIntoChunks(array: Array, max: number) { } return result; } + +export function setLogLevel(req: express.Request) { + const logLevel = req.query.log_level || process.env.LOG_LEVEL; + if (logLevel) { + process.env.LOG_LEVEL = logLevel; + getLogger().level = logLevel; + } +} + +/** + * Start a periodic logging of memory usage in backgroung. + * @param logger logger to write to + * @param intervalMs interval in milliseconds + * @returns a callback to call for stopping logging + */ +export function startPeriodicMemoryLogging(logger: ILogger, intervalMs = 5000) { + const intervalId = setInterval(() => { + logger.info(getMemoryUsage('Periodic')); + }, intervalMs); + return () => clearInterval(intervalId); // Return function to stop logging +} diff --git a/gcp/workflow/workflow-ads.yaml b/gcp/workflow/workflow-ads.yaml index c7e93d8c..a33cfa45 100644 --- a/gcp/workflow/workflow-ads.yaml +++ b/gcp/workflow/workflow-ads.yaml @@ -4,15 +4,16 @@ main: - init: assign: - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} - - location: ${default(map.get(args, "location"), "us-central1")} - scripts: ${args.scripts} - accounts: ${args.accounts} - - cloud_function: ${default(map.get(args, "cloud_function"), "gaarf")} + - function_name: ${default(map.get(args, "function_name"), "gaarf")} + - function_location: ${default(map.get(args, "function_location"), "us-central1")} - ads_config_path: ${args.ads_config_path} - - bq_dataset: ${args.bq_dataset} - - bq_dataset_location: ${map.get(args, "bq_dataset_location")} + - writer: ${default(map.get(args, "writer"), "bq")} + - bq_dataset: ${default(map.get(args, "bq_dataset"), "")} + - bq_dataset_location: ${default(map.get(args, "bq_dataset_location"), "")} - macros: ${map.get(args, "macros")} - - writer_options: ${map.get(args, "bq_writer_options")} + - writer_options: ${map.get(args, "writer_options")} - output_path: ${default(map.get(args, "output_path"), "")} - concurrency_limit: ${default(map.get(args, "concurrency_limit"), 20)} @@ -20,14 +21,14 @@ main: - get_function: call: http.get args: - url: ${"https://cloudfunctions.googleapis.com/v2/projects/" + project + "/locations/" + location + "/functions/" + cloud_function} + url: ${"https://cloudfunctions.googleapis.com/v2/projects/" + project + "/locations/" + function_location + "/functions/" + function_name} auth: type: OAuth2 result: function # TODO: move to using CF adapter when it's ready (currently only v1 supported): #call: googleapis.cloudfunctions.v2.projects.locations.functions.get #args: - # name: ${"projects/" + project + "/locations/" + location + "/functions/" + cloud_function} + # name: ${"projects/" + project + "/locations/" + function_location + "/functions/" + function_name} #result: function - initialize_functions_uris: assign: @@ -63,6 +64,7 @@ main: account: ${accounts[0]} macros: ${macros} project: ${project} + writer: ${writer} bq_dataset: ${bq_dataset} bq_dataset_location: ${bq_dataset_location} ads_config_path: ${ads_config_path} @@ -93,6 +95,7 @@ main: account: ${account} macros: ${macros} project: ${project} + writer: ${writer} bq_dataset: ${bq_dataset} bq_dataset_location: ${bq_dataset_location} ads_config_path: ${ads_config_path} @@ -149,6 +152,7 @@ executeAdsQuery: account, macros, project, + writer, bq_dataset, bq_dataset_location, ads_config_path, @@ -170,11 +174,10 @@ executeAdsQuery: script_path: ${script_path} ads_config_path: ${ads_config_path} bq_project_id: ${project} + writer: ${writer} bq_dataset: ${bq_dataset} bq_dataset_location: ${bq_dataset_location} customer_id: ${account} - single_customer: true # it's important to prevent fetching child accounts for the supplied cid - writer: "bq" output_path: ${output_path} body: macro: ${macros} diff --git a/gcp/workflow/workflow.yaml b/gcp/workflow/workflow.yaml index cfe28a75..45eca17c 100644 --- a/gcp/workflow/workflow.yaml +++ b/gcp/workflow/workflow.yaml @@ -3,18 +3,18 @@ main: steps: - init: assign: - - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} - - location: ${default(map.get(args, "location"), "us-central1")} - - cloud_function: ${default(map.get(args, "cloud_function"), "gaarf")} - - bq_dataset_location: ${if(default(map.get(args, "bq_dataset_location"), "us") == "", "us", default(map.get(args, "bq_dataset_location"), "us"))} - - gcs_bucket: ${default(map.get(args,"gcs_bucket"), project)} - - only_run_bq: ${default(map.get(args,"only_run_bq"), false)} - - completion_topic: ${default(map.get(args, "completion_topic"), "gaarf_wf_completed")} - # 20 is the default for "Concurrent branches and iterations" - https://cloud.google.com/workflows/quotas#parallel_steps - - concurrency_limit: ${default(map.get(args, "concurrency_limit"), 20)} - - workflow_ads_id: ${default(map.get(args, "workflow_ads_id"), sys.get_env("GOOGLE_CLOUD_WORKFLOW_ID") + "-ads")} - #- recreate_dataset: ${default(map.get(args,"recreate_dataset"), false)} - - disable_strict_views: ${default(map.get(args,"disable_strict_views"), false)} + - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} + - cloud_function: ${default(map.get(args, "cloud_function"), "gaarf")} + - function_location: ${default(map.get(args, "location"), "us-central1")} + - bq_dataset_location: ${if(default(map.get(args, "bq_dataset_location"), "us") == "", "us", default(map.get(args, "bq_dataset_location"), "us"))} + - gcs_bucket: ${default(map.get(args,"gcs_bucket"), project)} + - only_run_bq: ${default(map.get(args,"only_run_bq"), false)} + - completion_topic: ${default(map.get(args, "completion_topic"), "gaarf_wf_completed")} + # 20 is the default for "Concurrent branches and iterations" - https://cloud.google.com/workflows/quotas#parallel_steps + - concurrency_limit: ${default(map.get(args, "concurrency_limit"), 20)} + - workflow_ads_id: ${default(map.get(args, "workflow_ads_id"), sys.get_env("GOOGLE_CLOUD_WORKFLOW_ID") + "-ads")} + #- recreate_dataset: ${default(map.get(args,"recreate_dataset"), false)} + - disable_strict_views: ${default(map.get(args,"disable_strict_views"), false)} - check_shortcut_arg: switch: - condition: ${only_run_bq} @@ -24,7 +24,7 @@ main: call: runAdsQueries args: project: ${project} - location: ${location} + function_location: ${function_location} function_name: ${cloud_function} gcs_bucket: ${gcs_bucket} queries_path: ${args.ads_queries_path} @@ -34,10 +34,11 @@ main: customer_ids_query: ${map.get(args, "customer_ids_query")} customer_ids_offset: ${map.get(args, "customer_ids_offset")} customer_ids_batchsize: ${map.get(args, "customer_ids_batchsize")} - bq_dataset: ${args.dataset} + writer: ${default(map.get(args, "writer"), "bq")} + bq_dataset: ${default(map.get(args,"dataset"), "")} bq_dataset_location: ${bq_dataset_location} macros: ${map.get(args, "ads_macro")} - bq_writer_options: ${map.get(args, "bq_writer_options")} + writer_options: ${default(map.get(args, "writer_options"), map.get(args, "bq_writer_options"))} output_path: ${map.get(args, "output_path")} concurrency_limit: ${concurrency_limit} workflow_ads_id: ${workflow_ads_id} @@ -47,8 +48,8 @@ main: call: runBigQueryQueries args: project: ${project} - location: ${location} function_name: ${cloud_function + "-bq"} + function_location: ${function_location} gcs_bucket: ${gcs_bucket} queries_path: ${args.bq_queries_path} dataset_location: ${bq_dataset_location} @@ -71,14 +72,36 @@ main: return: ${accounts} runAdsQueries: - params: [project, location, function_name, gcs_bucket, queries_path, ads_config_path, cid, cid_ignore, customer_ids_query, customer_ids_offset, customer_ids_batchsize, bq_dataset, bq_dataset_location, macros, bq_writer_options, output_path, concurrency_limit, workflow_ads_id, disable_strict_views] + params: + [ + project, + function_name, + function_location, + gcs_bucket, + queries_path, + ads_config_path, + cid, + cid_ignore, + customer_ids_query, + customer_ids_offset, + customer_ids_batchsize, + writer, + bq_dataset, + bq_dataset_location, + macros, + writer_options, + output_path, + concurrency_limit, + workflow_ads_id, + disable_strict_views, + ] # NOTE: currently it's assumed that CF's project is the same as project for BQ datasets steps: # get CF 'gaarf-getcids' function's URL - get_function_cids: call: http.get args: - url: ${"https://cloudfunctions.googleapis.com/v2/projects/" + project + "/locations/" + location + "/functions/" + function_name + "-getcids"} + url: ${"https://cloudfunctions.googleapis.com/v2/projects/" + project + "/locations/" + function_location + "/functions/" + function_name + "-getcids"} auth: type: OAuth2 result: function_cids @@ -86,7 +109,7 @@ runAdsQueries: - get_function_view: call: http.get args: - url: ${"https://cloudfunctions.googleapis.com/v2/projects/" + project + "/locations/" + location + "/functions/" + function_name + "-bq-view"} + url: ${"https://cloudfunctions.googleapis.com/v2/projects/" + project + "/locations/" + function_location + "/functions/" + function_name + "-bq-view"} auth: type: OAuth2 result: function_view @@ -157,36 +180,37 @@ runAdsQueries: in: ${accounts} index: index steps: - - log_cids_batch: - call: sys.log - args: - json: - text: "Executing Ads subworkflow" - index: ${index} - count: ${len(accounts_batch)} - accounts: ${accounts_batch} - severity: "INFO" - - run_ads_workflow: - call: googleapis.workflowexecutions.v1.projects.locations.workflows.executions.run - args: - workflow_id: ${workflow_ads_id} - connector_params: - timeout: 86400 # 24h=60*60*24 seconds - argument: - location: ${location} - scripts: ${scripts} - accounts: ${accounts_batch} - cloud_function: ${function_name} - ads_config_path: ${ads_config_path} - bq_dataset: ${bq_dataset} - bq_dataset_location: ${bq_dataset_location} - macros: ${macros} - bq_writer_options: ${bq_writer_options} - output_path: ${output_path} - concurrency_limit: ${concurrency_limit} - result: execution_result + - log_cids_batch: + call: sys.log + args: + json: + text: "Executing Ads subworkflow" + index: ${index} + count: ${len(accounts_batch)} + accounts: ${accounts_batch} + severity: "INFO" + - run_ads_workflow: + call: googleapis.workflowexecutions.v1.projects.locations.workflows.executions.run + args: + workflow_id: ${workflow_ads_id} + connector_params: + timeout: 86400 # 24h=60*60*24 seconds + argument: + scripts: ${scripts} + accounts: ${accounts_batch} + function_name: ${function_name} + function_location: ${function_location} + ads_config_path: ${ads_config_path} + writer: ${writer} + bq_dataset: ${bq_dataset} + bq_dataset_location: ${bq_dataset_location} + macros: ${macros} + writer_options: ${writer_options} + output_path: ${output_path} + concurrency_limit: ${concurrency_limit} + result: execution_result - # collection account ids from `accounts` where they are slit into batched into a flatten list + # collecting account ids from `accounts` where they are slit into batched into a flatten list - initialize_accounts_flatten: assign: - accounts_flatten: [] @@ -204,6 +228,12 @@ runAdsQueries: assign: - accounts_flatten: ${list.concat(accounts_flatten, account)} + - check_for_bq_writer: + switch: + - condition: ${writer == "bq" or writer == "bigquery"} + next: create_views + next: return_result + # for each script (excluding constants) create a unified view - create_views: for: @@ -234,9 +264,18 @@ runAdsQueries: - return_result: return: ${accounts} - runBigQueryQueries: - params: [project, location, function_name, gcs_bucket, queries_path, macros, sqlParams, dataset_location] + params: + [ + project, + function_location, + function_name, + gcs_bucket, + queries_path, + macros, + sqlParams, + dataset_location, + ] steps: - get_bq_scripts_from_gcs: call: googleapis.storage.v1.objects.list @@ -272,18 +311,26 @@ runBigQueryQueries: args: data: ${bq_scripts} severity: "INFO" + + # check if there are any bq scripts on GCS + - check_scripts2: + switch: + - condition: ${len(bq_scripts) > 0} + next: get_function_bq + next: end + # get clound function's uri - get_function_bq: call: http.get args: - url: ${"https://cloudfunctions.googleapis.com/v2/projects/" + project + "/locations/" + location + "/functions/" + function_name} + url: ${"https://cloudfunctions.googleapis.com/v2/projects/" + project + "/locations/" + function_location + "/functions/" + function_name} auth: type: OAuth2 result: function_bq # TODO: move to using CF adapter when it's ready (currently only v1 supported): #call: googleapis.cloudfunctions.v2.projects.locations.functions.get #args: - # name: ${"projects/" + project + "/locations/" + location + "/functions/" + function_name} + # name: ${"projects/" + project + "/locations/" + function_location + "/functions/" + function_name} #result: function_bq - runBqQueries: for: