Skip to content

Commit

Permalink
gaarf-wf: workflow support different writers via 'writer' argument
Browse files Browse the repository at this point in the history
wf: `bq_writer_options` was renamed to `writer_options`
cf: Cloud Function gaarf support different writers via 'writer' QS argument ('bq' is still the default)
cf: setting `outputPath` option by default for all writers (as `gs://${projectId}/tmp`)

Change-Id: I20eae43b0ee1aeaadcee460dbb29dd6be4259b27
  • Loading branch information
evil-shrike committed Aug 12, 2024
1 parent abbea8b commit 01c4540
Show file tree
Hide file tree
Showing 27 changed files with 585 additions and 178 deletions.
8 changes: 6 additions & 2 deletions gcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions gcp/create-gaarf-wf/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gcp/create-gaarf-wf/build/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gcp/create-gaarf-wf/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gcp/create-gaarf-wf/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
5 changes: 3 additions & 2 deletions gcp/create-gaarf-wf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
};
Expand All @@ -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}")
`
);

Expand Down
14 changes: 14 additions & 0 deletions gcp/functions/build/src/gaarf-bq-view.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gcp/functions/build/src/gaarf-bq-view.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions gcp/functions/build/src/gaarf-bq.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gcp/functions/build/src/gaarf-bq.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 01c4540

Please sign in to comment.