Skip to content

Commit

Permalink
chore: move pipeline constants to constants file (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
sararob authored Jul 6, 2022
1 parent b24b390 commit 23a8a27
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
39 changes: 39 additions & 0 deletions google/cloud/aiplatform/constants/pipeline.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-

# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import re

from google.cloud.aiplatform.compat.types import (
pipeline_state as gca_pipeline_state,
)

_PIPELINE_COMPLETE_STATES = set(
[
gca_pipeline_state.PipelineState.PIPELINE_STATE_SUCCEEDED,
gca_pipeline_state.PipelineState.PIPELINE_STATE_FAILED,
gca_pipeline_state.PipelineState.PIPELINE_STATE_CANCELLED,
gca_pipeline_state.PipelineState.PIPELINE_STATE_PAUSED,
]
)

_PIPELINE_ERROR_STATES = set([gca_pipeline_state.PipelineState.PIPELINE_STATE_FAILED])

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

# Pattern for an Artifact Registry URL.
_VALID_AR_URL = re.compile(r"^https:\/\/([\w-]+)-kfp\.pkg\.dev\/.*")
16 changes: 5 additions & 11 deletions google/cloud/aiplatform/pipeline_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from google.cloud.aiplatform import base
from google.cloud.aiplatform import initializer
from google.cloud.aiplatform import utils
from google.cloud.aiplatform.constants import pipeline as pipeline_constants
from google.cloud.aiplatform.metadata import artifact
from google.cloud.aiplatform.metadata import context
from google.cloud.aiplatform.metadata import execution
Expand All @@ -42,22 +43,15 @@

_LOGGER = base.Logger(__name__)

_PIPELINE_COMPLETE_STATES = set(
[
gca_pipeline_state.PipelineState.PIPELINE_STATE_SUCCEEDED,
gca_pipeline_state.PipelineState.PIPELINE_STATE_FAILED,
gca_pipeline_state.PipelineState.PIPELINE_STATE_CANCELLED,
gca_pipeline_state.PipelineState.PIPELINE_STATE_PAUSED,
]
)
_PIPELINE_COMPLETE_STATES = pipeline_constants._PIPELINE_COMPLETE_STATES

_PIPELINE_ERROR_STATES = set([gca_pipeline_state.PipelineState.PIPELINE_STATE_FAILED])
_PIPELINE_ERROR_STATES = pipeline_constants._PIPELINE_ERROR_STATES

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

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


def _get_current_time() -> datetime.datetime:
Expand Down

0 comments on commit 23a8a27

Please sign in to comment.