GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add holiday regions for vertex forecasting (#1253) · googleapis/python-aiplatform@0036ab0

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • google/cloud/aiplatform
    • training_jobs.py
  • tests/unit/aiplatform
    • test_automl_forecasting_training_jobs.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎google/cloud/aiplatform/training_jobs.py‎

Copy file name to clipboardExpand all lines: google/cloud/aiplatform/training_jobs.py
+31-1Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4044,6 +4044,7 @@ def run(
40444044
window_column: Optional[str] = None,
40454045
window_stride_length: Optional[int] = None,
40464046
window_max_count: Optional[int] = None,
4047+
holiday_regions: Optional[List[str]] = None,
40474048
sync: bool = True,
40484049
create_request_timeout: Optional[float] = None,
40494050
) -> models.Model:
@@ -4238,10 +4239,23 @@ def run(
42384239
Optional. Number of rows that should be used to generate input
42394240
examples. If the total row count is larger than this number, the
42404241
input data will be randomly sampled to hit the count.
4242+
holiday_regions (List[str]):
4243+
Optional. The geographical regions to use when creating holiday
4244+
features. This option is only allowed when data_granularity_unit
4245+
is ``day``. Acceptable values can come from any of the following
4246+
levels:
4247+
Top level: GLOBAL
4248+
Second level: continental regions
4249+
NA: North America
4250+
JAPAC: Japan and Asia Pacific
4251+
EMEA: Europe, the Middle East and Africa
4252+
LAC: Latin America and the Caribbean
4253+
Third level: countries from ISO 3166-1 Country codes.
42414254
sync (bool):
4242-
Whether to execute this method synchronously. If False, this method
4255+
Optional. Whether to execute this method synchronously. If False, this method
42434256
will be executed in concurrent Future and any downstream object will
42444257
be immediately returned and synced when the Future has completed.
4258+
42454259
Returns:
42464260
model: The trained Vertex AI Model resource or None if training did not
42474261
produce a Vertex AI Model.
@@ -4299,6 +4313,7 @@ def run(
42994313
window_column=window_column,
43004314
window_stride_length=window_stride_length,
43014315
window_max_count=window_max_count,
4316+
holiday_regions=holiday_regions,
43024317
sync=sync,
43034318
create_request_timeout=create_request_timeout,
43044319
)
@@ -4338,6 +4353,7 @@ def _run(
43384353
window_column: Optional[str] = None,
43394354
window_stride_length: Optional[int] = None,
43404355
window_max_count: Optional[int] = None,
4356+
holiday_regions: Optional[List[str]] = None,
43414357
sync: bool = True,
43424358
create_request_timeout: Optional[float] = None,
43434359
) -> models.Model:
@@ -4536,12 +4552,25 @@ def _run(
45364552
Optional. Number of rows that should be used to generate input
45374553
examples. If the total row count is larger than this number, the
45384554
input data will be randomly sampled to hit the count.
4555+
holiday_regions (List[str]):
4556+
Optional. The geographical regions to use when creating holiday
4557+
features. This option is only allowed when data_granularity_unit
4558+
is ``day``. Acceptable values can come from any of the following
4559+
levels:
4560+
Top level: GLOBAL
4561+
Second level: continental regions
4562+
NA: North America
4563+
JAPAC: Japan and Asia Pacific
4564+
EMEA: Europe, the Middle East and Africa
4565+
LAC: Latin America and the Caribbean
4566+
Third level: countries from ISO 3166-1 Country codes.
45394567
sync (bool):
45404568
Whether to execute this method synchronously. If False, this method
45414569
will be executed in concurrent Future and any downstream object will
45424570
be immediately returned and synced when the Future has completed.
45434571
create_request_timeout (float):
45444572
Optional. The timeout for the create request in seconds.
4573+
45454574
Returns:
45464575
model: The trained Vertex AI Model resource or None if training did not
45474576
produce a Vertex AI Model.
@@ -4592,6 +4621,7 @@ def _run(
45924621
"quantiles": quantiles,
45934622
"validationOptions": validation_options,
45944623
"optimizationObjective": self._optimization_objective,
4624+
"holidayRegions": holiday_regions,
45954625
}
45964626

45974627
# TODO(TheMichaelHu): Remove the ifs once the API supports these inputs.
Collapse file

‎tests/unit/aiplatform/test_automl_forecasting_training_jobs.py‎

Copy file name to clipboardExpand all lines: tests/unit/aiplatform/test_automl_forecasting_training_jobs.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
_TEST_WINDOW_COLUMN = None
8989
_TEST_WINDOW_STRIDE_LENGTH = 1
9090
_TEST_WINDOW_MAX_COUNT = None
91+
_TEST_TRAINING_HOLIDAY_REGIONS = ["GLOBAL"]
9192
_TEST_TRAINING_TASK_INPUTS_DICT = {
9293
# required inputs
9394
"targetColumn": _TEST_TRAINING_TARGET_COLUMN,
@@ -122,6 +123,7 @@
122123
"windowConfig": {
123124
"strideLength": _TEST_WINDOW_STRIDE_LENGTH,
124125
},
126+
"holidayRegions": _TEST_TRAINING_HOLIDAY_REGIONS,
125127
}
126128

127129
_TEST_TRAINING_TASK_INPUTS_WITH_ADDITIONAL_EXPERIMENTS = json_format.ParseDict(
@@ -322,6 +324,7 @@ def test_run_call_pipeline_service_create(
322324
window_max_count=_TEST_WINDOW_MAX_COUNT,
323325
sync=sync,
324326
create_request_timeout=None,
327+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
325328
)
326329

327330
if not sync:
@@ -417,6 +420,7 @@ def test_run_call_pipeline_service_create_with_timeout(
417420
window_max_count=_TEST_WINDOW_MAX_COUNT,
418421
sync=sync,
419422
create_request_timeout=180.0,
423+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
420424
)
421425

422426
if not sync:
@@ -494,6 +498,7 @@ def test_run_call_pipeline_if_no_model_display_name_nor_model_labels(
494498
window_max_count=_TEST_WINDOW_MAX_COUNT,
495499
sync=sync,
496500
create_request_timeout=None,
501+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
497502
)
498503

499504
if not sync:
@@ -571,6 +576,7 @@ def test_run_call_pipeline_if_set_additional_experiments(
571576
window_max_count=_TEST_WINDOW_MAX_COUNT,
572577
sync=sync,
573578
create_request_timeout=None,
579+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
574580
)
575581

576582
if not sync:
@@ -644,6 +650,7 @@ def test_run_called_twice_raises(
644650
window_stride_length=_TEST_WINDOW_STRIDE_LENGTH,
645651
window_max_count=_TEST_WINDOW_MAX_COUNT,
646652
sync=sync,
653+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
647654
)
648655

649656
with pytest.raises(RuntimeError):
@@ -675,6 +682,7 @@ def test_run_called_twice_raises(
675682
window_stride_length=_TEST_WINDOW_STRIDE_LENGTH,
676683
window_max_count=_TEST_WINDOW_MAX_COUNT,
677684
sync=sync,
685+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
678686
)
679687

680688
@pytest.mark.parametrize("sync", [True, False])
@@ -722,6 +730,7 @@ def test_run_raises_if_pipeline_fails(
722730
window_stride_length=_TEST_WINDOW_STRIDE_LENGTH,
723731
window_max_count=_TEST_WINDOW_MAX_COUNT,
724732
sync=sync,
733+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
725734
)
726735

727736
if not sync:
@@ -805,6 +814,7 @@ def test_splits_fraction(
805814
window_max_count=_TEST_WINDOW_MAX_COUNT,
806815
sync=sync,
807816
create_request_timeout=None,
817+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
808818
)
809819

810820
if not sync:
@@ -900,6 +910,7 @@ def test_splits_timestamp(
900910
window_max_count=_TEST_WINDOW_MAX_COUNT,
901911
sync=sync,
902912
create_request_timeout=None,
913+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
903914
)
904915

905916
if not sync:
@@ -993,6 +1004,7 @@ def test_splits_predefined(
9931004
window_max_count=_TEST_WINDOW_MAX_COUNT,
9941005
sync=sync,
9951006
create_request_timeout=None,
1007+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
9961008
)
9971009

9981010
if not sync:
@@ -1081,6 +1093,7 @@ def test_splits_default(
10811093
window_max_count=_TEST_WINDOW_MAX_COUNT,
10821094
sync=sync,
10831095
create_request_timeout=None,
1096+
holiday_regions=_TEST_TRAINING_HOLIDAY_REGIONS,
10841097
)
10851098

10861099
if not sync:

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.