Skip to content

Commit

Permalink
fix(components): Remove the unused generate_default_instruction and r…
Browse files Browse the repository at this point in the history
…esolve_upload_location from function_based

PiperOrigin-RevId: 620015429
  • Loading branch information
Googler committed Apr 5, 2024
1 parent 5216a82 commit 2005b6b
Showing 1 changed file with 0 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,46 +372,6 @@ def convert_to_delimited_string(items: List[str], delimiter: str = ',') -> str:
return delimiter.join(items)


@dsl.component(base_image=_image.GCPC_IMAGE_TAG, install_kfp_package=False)
def generate_default_instruction(
task: str,
target_sequence_length: int,
instruction_override: str = '',
) -> str:
"""Generates a default instruction if no override is provided."""
if instruction_override:
return instruction_override
task = task.lower()
if task == 'summarization':
return f'Summarize in less than {target_sequence_length} words.'

elif task == 'question_answer':
return f'Answer the question in less than {target_sequence_length} words.'

else:
raise ValueError(
f'Task not recognized: {task}. Supported tasks are: "summarization",'
' "question_answer".'
)


@dsl.component(base_image=_image.GCPC_IMAGE_TAG, install_kfp_package=False)
def resolve_upload_location(upload_location: Optional[str] = None) -> str:
"""Gets the region to upload the model.
Args:
upload_location: User-specified region to upload the model to.
Returns:
Where to upload the model. If no location is specified, the model will be
uploaded to the region where the pipeline is running.
"""
# pylint: disable=g-import-not-at-top
import os
# pylint: enable=g-import-not-at-top
return upload_location or os.environ['CLOUD_ML_REGION']


@dsl.component(base_image=_image.GCPC_IMAGE_TAG, install_kfp_package=False)
def resolve_regional_endpoint(upload_location: str) -> str:
"""Gets the regional endpoint used to upload a model to the registry.
Expand Down

0 comments on commit 2005b6b

Please sign in to comment.