Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/cli/requests-2.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwire authored Oct 27, 2023
2 parents 4077d23 + d03efbf commit a445bbd
Show file tree
Hide file tree
Showing 63 changed files with 5,925 additions and 2,792 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
**Make reliable data integration and data processing with Google easy for
advertisers.**

* [User Documentation](https://google.github.io/crmint)
* [Deploy Guide](https://github.com/google/crmint/wiki/Deploy-CRMint-on-Google-Cloud-Platform)
* [Contributor's Guide](https://github.com/google/crmint/wiki/Contributor's-Guide)
* [Wiki](https://github.com/google/crmint/wiki)
* [User Documentation](https://google-marketing-solutions.github.io/crmint/)
* [Deploy Guide](https://github.com/google-marketing-solutions/crmint/wiki/Deploy-CRMint-on-Google-Cloud-Platform)
* [Contributor's Guide](https://github.com/google-marketing-solutions/crmint/wiki/Contributor's-Guide)
* [Wiki](https://github.com/google-marketing-solutions/crmint/wiki)


| Status | Coverage | Description |
| :----- | :--------- | :---------- |
| [![testing-cli](https://github.com/google/crmint/actions/workflows/testing-cli.yml/badge.svg?branch=master)](https://github.com/google/crmint/actions/workflows/testing-cli.yml) | [![codecov](https://codecov.io/gh/google/crmint/branch/master/graph/badge.svg?flag=cli)](https://codecov.io/gh/google/crmint) | Testing the reliability of our deployment tool |
| [![testing-backend](https://github.com/google/crmint/actions/workflows/testing-backend.yml/badge.svg?branch=master)](https://github.com/google/crmint/actions/workflows/testing-backend.yml) | [![codecov](https://codecov.io/gh/google/crmint/branch/master/graph/badge.svg?flag=backend)](https://codecov.io/gh/google/crmint) | Testing the core of CRMint backend engine |
| [![testing-frontend](https://github.com/google/crmint/actions/workflows/testing-frontend.yml/badge.svg?branch=master)](https://github.com/google/crmint/actions/workflows/testing-frontend.yml) | - | Testing our frontend |
| [![build-images](https://github.com/google/crmint/actions/workflows/build-images.yml/badge.svg?branch=master)](https://github.com/google/crmint/actions/workflows/build-images.yml) | - | Building docker images for our services |
| [![terraform-plan](https://github.com/google/crmint/actions/workflows/terraform.yml/badge.svg?branch=master)](https://github.com/google/crmint/actions/workflows/terraform.yml) | - | Testing our Terraform plan |
| [![testing-cli](https://github.com/google-marketing-solutions/crmint/actions/workflows/testing-cli.yml/badge.svg?branch=master)](https://github.com/google-marketing-solutions/crmint/actions/workflows/testing-cli.yml) | [![codecov](https://codecov.io/gh/google/crmint/branch/master/graph/badge.svg?flag=cli)](https://codecov.io/gh/google/crmint) | Testing the reliability of our deployment tool |
| [![testing-backend](https://github.com/google-marketing-solutions/crmint/actions/workflows/testing-backend.yml/badge.svg?branch=master)](https://github.com/google-marketing-solutions/crmint/actions/workflows/testing-backend.yml) | [![codecov](https://codecov.io/gh/google/crmint/branch/master/graph/badge.svg?flag=backend)](https://codecov.io/gh/google/crmint) | Testing the core of CRMint backend engine |
| [![testing-frontend](https://github.com/google-marketing-solutions/crmint/actions/workflows/testing-frontend.yml/badge.svg?branch=master)](https://github.com/google-marketing-solutions/crmint/actions/workflows/testing-frontend.yml) | - | Testing our frontend |
| [![build-images](https://github.com/google-marketing-solutions/crmint/actions/workflows/build-images.yml/badge.svg?branch=master)](https://github.com/google-marketing-solutions/crmint/actions/workflows/build-images.yml) | - | Building docker images for our services |
| [![terraform-plan](https://github.com/google-marketing-solutions/crmint/actions/workflows/terraform.yml/badge.svg?branch=master)](https://github.com/google-marketing-solutions/crmint/actions/workflows/terraform.yml) | - | Testing our Terraform plan |

## Deploy CRMint

Expand Down
4 changes: 2 additions & 2 deletions backend/common/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, message, code):


class TooEarlyError(_Error):
"""Exception to be raised when it's too eraly to process a delayed message."""
"""Exception to be raised when it's too early to process a delayed message."""

def __init__(self, scheduled_time):
message = f'Resend message after {scheduled_time}'
Expand Down Expand Up @@ -97,7 +97,7 @@ def extract_data(request: flask.Request) -> dict[str, Any]:
try:
start_time = datetime.datetime.fromtimestamp(
int(message['attributes']['start_time']))
if datetime.datetime.utcnow() < start_time:
if datetime.datetime.utcnow() <= start_time:
raise TooEarlyError(start_time)
except KeyError as e:
raise BadRequestError() from e
Expand Down
35 changes: 1 addition & 34 deletions backend/common/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Generic utilities."""

from typing import Any, Callable, Iterable, Optional, TypeVar

T = TypeVar('T')
from typing import Any


def detect_patch_update(patch: Any, target: Any) -> bool:
Expand Down Expand Up @@ -36,34 +34,3 @@ def detect_patch_update(patch: Any, target: Any) -> bool:
return True

return False


def first(iterable: Iterable[T],
condition: Callable[[T], bool] = lambda x: True,
default: Optional[T] = None) -> T:
"""Returns the first item in the `iterable` that satisfies the `condition`.
If the condition is not given, returns the first item of
the iterable.
If the `default` argument is given and the iterable is empty,
or if it has no items matching the condition, the `default` argument
is returned if it matches the condition.
The `default` argument being None is the same as it not being given.
Raises `StopIteration` if no item satisfying the condition is found
and default is not given or doesn't satisfy the condition.
Args:
iterable: List of elements.
condition: Condition to test elements on.
default: Optional default value.
"""
try:
return next(x for x in iterable if condition(x))
except StopIteration:
if default is not None and condition(default):
return default
else:
raise
13 changes: 12 additions & 1 deletion backend/controller/cron_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Utilities to deal with cron formats.
Inspired from the pycron library, but simplified the implementation.
cron_match and all associated code inspired from the pycron library,
but simplified the implementation.
Source: https://github.com/kipe/pycron
License: MIT
"""

import datetime
import croniter


def _to_int(value) -> int:
Expand Down Expand Up @@ -68,3 +70,12 @@ def cron_match(cron: str, dt: datetime.datetime = None) -> bool:
_parse_arg(dow, 0 if weekday == 7 else weekday),
]
return all(conditions)


def cron_valid(cron: str) -> bool:
"""Returns True if cron schedule string is valid.
Args:
cron: Cron-like string (minute, hour, day of month, month, day of week).
"""
return croniter.croniter.is_valid(cron)
8 changes: 4 additions & 4 deletions backend/controller/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def load_fixtures(logger_func: Optional[Callable[[str], None]] = None) -> None:
'client_secret',
'google_ads_authentication_code',
'google_ads_refresh_token',
'developer_token',
'app_conversion_api_developer_token',
'google_ads_developer_token',
'google_ads_service_account_file',
'google_analytics_4_bigquery_dataset',
'google_analytics_4_measurement_id',
'google_analytics_4_api_secret',
]
'google_analytics_4_api_secret']

for setting in general_settings:
general_setting = models.GeneralSetting.where(name=setting).first()
if not general_setting:
Expand Down
3 changes: 2 additions & 1 deletion backend/controller/ml_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from . import bigquery
from . import compiler
from . import shared
from . import views

__all__ = ['bigquery', 'compiler', 'views']
__all__ = ['bigquery', 'compiler', 'shared', 'views']
Loading

0 comments on commit a445bbd

Please sign in to comment.