Skip to content

Commit

Permalink
chore(components): Locating bug
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 600985994
  • Loading branch information
KCFindstr authored and Google Cloud Pipeline Components maintainers committed Jan 25, 2024
1 parent b9e08de commit fcca717
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
Expand Up @@ -28,7 +28,15 @@ def _parse_args(args: List[str]):
args.append('--payload')
args.append('"{}"') # Unused but required by parser_util.
parser, _ = parser_util.parse_default_args(args)
# Parse the conditionally required arguments
# Parse the conditionally required arguments.
parser.add_argument(
'--executor_input',
dest='executor_input',
type=str,
# executor_input is only needed for components that emit output artifacts.
required=True,
default=argparse.SUPPRESS,
)
parser.add_argument(
'--display_name',
dest='display_name',
Expand Down
Expand Up @@ -25,6 +25,7 @@
from google.cloud.aiplatform import training_jobs
from google.cloud.aiplatform_v1.types import model
from google.cloud.aiplatform_v1.types import training_pipeline
from google_cloud_pipeline_components.container.v1.aiplatform import remote_runner
from google_cloud_pipeline_components.container.v1.gcp_launcher import pipeline_remote_runner
from google_cloud_pipeline_components.container.v1.gcp_launcher.utils import error_util

Expand Down Expand Up @@ -195,6 +196,7 @@ def create_pipeline(
project: str,
location: str,
gcp_resources: str,
executor_input: str,
**kwargs: Dict[str, Any],
):
"""Create and poll AutoML Vision training pipeline status till it reaches a final state.
Expand Down Expand Up @@ -222,29 +224,38 @@ def create_pipeline(
project: Project name.
location: Location to start the training job.
gcp_resources: URI for storing GCP resources.
executor_input: Executor input for output.
**kwargs: Extra args for creating the payload.
"""
remote_runner = pipeline_remote_runner.PipelineRemoteRunner(
runner = pipeline_remote_runner.PipelineRemoteRunner(
type, project, location, gcp_resources
)

try:
# Create AutoML vision training pipeline if it does not exist
pipeline_name = remote_runner.check_if_pipeline_exists()
pipeline_name = runner.check_if_pipeline_exists()
if pipeline_name is None:
payload = create_payload(project, location, **kwargs)
logging.info(
'AutoML Vision training payload formatted: %s',
payload,
)
pipeline_name = remote_runner.create_pipeline(
pipeline_name = runner.create_pipeline(
create_pipeline_with_client,
payload,
)

# Poll AutoML Vision training pipeline status until
# "PipelineState.PIPELINE_STATE_SUCCEEDED"
remote_runner.poll_pipeline(get_pipeline_with_client, pipeline_name)
pipeline = runner.poll_pipeline(get_pipeline_with_client, pipeline_name)

except (ConnectionError, RuntimeError) as err:
error_util.exit_with_internal_error(err.args[0])
return # No-op, suppressing uninitialized `pipeline` variable lint error.

# Writes artifact output on success.
if not isinstance(pipeline, training_pipeline.TrainingPipeline):
raise ValueError('Internal error: no training pipeline was created.')
remote_runner.write_to_artifact(
executor_input, remote_runner.make_output(pipeline.model_to_upload)
)
Expand Up @@ -156,7 +156,7 @@ def automl_image_training_job(
),
dsl.IfPresentPlaceholder(
input_name='test_fraction_split',
then=['--test_fraction_split', test_fraction_split],
then=['--test_fraction_split2', test_fraction_split],
),
dsl.IfPresentPlaceholder(
input_name='budget_milli_node_hours',
Expand Down

0 comments on commit fcca717

Please sign in to comment.