Skip to content

Commit 23a8a27

Browse files
authored
chore: move pipeline constants to constants file (googleapis#1471)
1 parent b24b390 commit 23a8a27

File tree

2 files changed

+44
-11
lines changed

2 files changed

+44
-11
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright 2022 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
import re
19+
20+
from google.cloud.aiplatform.compat.types import (
21+
pipeline_state as gca_pipeline_state,
22+
)
23+
24+
_PIPELINE_COMPLETE_STATES = set(
25+
[
26+
gca_pipeline_state.PipelineState.PIPELINE_STATE_SUCCEEDED,
27+
gca_pipeline_state.PipelineState.PIPELINE_STATE_FAILED,
28+
gca_pipeline_state.PipelineState.PIPELINE_STATE_CANCELLED,
29+
gca_pipeline_state.PipelineState.PIPELINE_STATE_PAUSED,
30+
]
31+
)
32+
33+
_PIPELINE_ERROR_STATES = set([gca_pipeline_state.PipelineState.PIPELINE_STATE_FAILED])
34+
35+
# Pattern for valid names used as a Vertex resource name.
36+
_VALID_NAME_PATTERN = re.compile("^[a-z][-a-z0-9]{0,127}$")
37+
38+
# Pattern for an Artifact Registry URL.
39+
_VALID_AR_URL = re.compile(r"^https:\/\/([\w-]+)-kfp\.pkg\.dev\/.*")

google/cloud/aiplatform/pipeline_jobs.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from google.cloud.aiplatform import base
2626
from google.cloud.aiplatform import initializer
2727
from google.cloud.aiplatform import utils
28+
from google.cloud.aiplatform.constants import pipeline as pipeline_constants
2829
from google.cloud.aiplatform.metadata import artifact
2930
from google.cloud.aiplatform.metadata import context
3031
from google.cloud.aiplatform.metadata import execution
@@ -42,22 +43,15 @@
4243

4344
_LOGGER = base.Logger(__name__)
4445

45-
_PIPELINE_COMPLETE_STATES = set(
46-
[
47-
gca_pipeline_state.PipelineState.PIPELINE_STATE_SUCCEEDED,
48-
gca_pipeline_state.PipelineState.PIPELINE_STATE_FAILED,
49-
gca_pipeline_state.PipelineState.PIPELINE_STATE_CANCELLED,
50-
gca_pipeline_state.PipelineState.PIPELINE_STATE_PAUSED,
51-
]
52-
)
46+
_PIPELINE_COMPLETE_STATES = pipeline_constants._PIPELINE_COMPLETE_STATES
5347

54-
_PIPELINE_ERROR_STATES = set([gca_pipeline_state.PipelineState.PIPELINE_STATE_FAILED])
48+
_PIPELINE_ERROR_STATES = pipeline_constants._PIPELINE_ERROR_STATES
5549

5650
# Pattern for valid names used as a Vertex resource name.
57-
_VALID_NAME_PATTERN = re.compile("^[a-z][-a-z0-9]{0,127}$")
51+
_VALID_NAME_PATTERN = pipeline_constants._VALID_NAME_PATTERN
5852

5953
# Pattern for an Artifact Registry URL.
60-
_VALID_AR_URL = re.compile(r"^https:\/\/([\w-]+)-kfp\.pkg\.dev\/.*")
54+
_VALID_AR_URL = pipeline_constants._VALID_AR_URL
6155

6256

6357
def _get_current_time() -> datetime.datetime:

0 commit comments

Comments
 (0)