Skip to content

Commit

Permalink
Merge branch 'development' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanBergenov committed Feb 16, 2024
2 parents 3a19c5d + e38cdc4 commit 365b505
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

on:
push:
branches: [ master ]
branches: [ staging ]
pull_request:
branches: [ master ]

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ The GCP resources for the solutions are installed via Deployment Manager.
* Cloud Build API
* Cloud Deployment Manager V2 API
* Cloud Functions API
* Artifact Registry API
* Identity and Access Management (IAM) API
* Cloud Scheduler API (if you need to flatten intraday tables)

Expand Down
3 changes: 2 additions & 1 deletion cf/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ google-cloud-bigquery~=3.13.0
google-cloud-pubsub~=2.2.0
google-cloud-bigquery-storage~=2.10.1
pytz~=2022.7.1
db_dtypes~=1.1.1
db_dtypes~=1.1.1
flask<3.0,>=1.0
11 changes: 5 additions & 6 deletions cfintraday/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,11 @@ def manage_intraday_schedule(event, context="context"):
# Construct the request body.
cron_schedule = input_event.intraday_schedule()

MESSAGE_DATA = {"protoPayload": {
"serviceData": {"jobCompletedEvent": {"job": {"jobConfiguration": {"load": {"destinationTable": {
"datasetId": input_event.dataset
, "projectId": input_event.gcp_project
, "tableId": f"events_intraday_{input_event.table_date_shard}"
}}}}}}}}
MESSAGE_DATA = {
"protoPayload": {
"resourceName": f"projects/{input_event.gcp_project}/datasets/{input_event.dataset}/tables/events_intraday_{input_event.table_date_shard}"
}
}

topic_name = os.environ["TOPIC_NAME"]

Expand Down
9 changes: 2 additions & 7 deletions tests/test_manage_intraday_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,9 @@ def test_create_intraday_flattening_schedule_minutes(self, logcapture):
})
self.assertEqual(job_id_full_path, response_get_job.name)
self.assertEqual('*/30 * * * *', response_get_job.schedule)
# I refactored %s to be an f-string. In case with a stringified dictionary, f-strings actully became less readable and maintainable
# While using a dict with an f-string, we need to duplicate { for this to appear in the string, we also have to escape the quotes
# https://realpython.com/python-f-strings/#python-f-strings-the-pesky-details
# For now, I decided to keep both % and f-string
expected_percent_string = 'b\'{"protoPayload": {"serviceData": {"jobCompletedEvent": {"job": {"jobConfiguration": {"load": {"destinationTable": {"datasetId": "%s", "projectId": "%s", "tableId": "events_intraday_%s"}}}}}}}}\'' % (self.dataset_id, self.project_id, self.date_shard)
expected_f_string = f"b\'{{\"protoPayload\": {{\"serviceData\": {{\"jobCompletedEvent\": {{\"job\": {{\"jobConfiguration\": {{\"load\": {{\"destinationTable\": {{\"datasetId\": \"{self.dataset_id}\", \"projectId\": \"{self.project_id}\", \"tableId\": \"events_intraday_{self.date_shard}\"}}}}}}}}}}}}}}}}\'"
expected = f"b\'{{\"protoPayload\": {{\"resourceName\": \"projects/{self.project_id}/datasets/{self.dataset_id}/tables/events_intraday_{self.date_shard}\"}}}}\'"
actual = str(response_get_job.pubsub_target.data)
assert expected_percent_string == expected_f_string == actual
assert expected == actual

# check log
expected_log = ('root', 'INFO',
Expand Down

0 comments on commit 365b505

Please sign in to comment.