Skip to content

Commit

Permalink
Update batch score src
Browse files Browse the repository at this point in the history
  • Loading branch information
novaturient95 committed Aug 29, 2024
1 parent 32c6a3a commit 8a0780c
Show file tree
Hide file tree
Showing 66 changed files with 383 additions and 102,290 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ $schema: http://azureml/sdk-2-0/ParallelComponent.json
type: parallel

name: batch_score_llm
version: 1.1.9
version: 1.2.0
display_name: Batch Score Large Language Models
is_deterministic: False

inputs:
# Predefined arguments for parallel job:
# https://learn.microsoft.com/en-us/azure/machine-learning/reference-yaml-job-parallel?source=recommendations#predefined-arguments-for-parallel-job
# Predefined arguments for parallel job: https://learn.microsoft.com/en-us/azure/machine-learning/reference-yaml-job-parallel?source=recommendations#predefined-arguments-for-parallel-job
resume_from:
type: string
optional: True
Expand Down Expand Up @@ -57,9 +56,10 @@ task:
# Using --append_row_safe_output true
program_arguments: >-
$[[--amlbi_async_mode ${{inputs.async_mode}}]]
--amlbi_dataframe_mixed_types true
--append_row_safe_output true
--configuration_file ${{inputs.configuration_file}}
--partitioned_scoring_results ${{outputs.mini_batch_results_output_directory}}
$[[--resume_from ${{inputs.resume_from}}]]
environment: azureml://registries/azureml/environments/model-evaluation/versions/30
environment: azureml://registries/azureml/environments/model-evaluation/versions/34
append_row_to: ${{outputs.job_output_path}}
12 changes: 0 additions & 12 deletions assets/batch_score/components/driver/src/batch_score/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,3 @@
# flake8: noqa: F401

"""__init__."""

import subprocess
import sys

from .utils.local_utils import is_running_in_azureml_job

# TODO: remove this hack after dedicated environment is published.
if is_running_in_azureml_job():
subprocess.check_call([sys.executable,"-m", "pip", "install",
'PyDispatcher==2.0.7',
'StrEnum==0.4.15',
'tiktoken==0.5.2'])
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import aiohttp

from ...common.configuration.configuration import Configuration
from ...common.scoring.generic_scoring_client import (
HttpResponseHandler,
HttpScoringResponse,
Expand All @@ -27,11 +28,11 @@
class AoaiHttpResponseHandler(HttpResponseHandler):
"""Defines the AOAI HTTP response handler."""

DEFAULT_MAX_RETRIES = 3
RETRIABLE_STATUS_CODES = [408, 429]

def __init__(self, tally_handler: TallyFailedRequestHandler):
def __init__(self, tally_handler: TallyFailedRequestHandler, configuration: Configuration):
"""Initialize AoaiHttpResponseHandler."""
self._configuration = configuration
self.__tally_handler = tally_handler

def handle_response(
Expand Down Expand Up @@ -100,15 +101,15 @@ def handle_response(
def is_retriable(
self,
http_status: int,
scoring_request: ScoringRequest,
max_retries: int = DEFAULT_MAX_RETRIES
scoring_request: ScoringRequest
) -> bool:
"""Is the http status retriable."""
if (http_status in self.RETRIABLE_STATUS_CODES):
return True
elif http_status and http_status >= 500:
scoring_request.retry_count_for_limited_retries += 1
return scoring_request.retry_count_for_limited_retries < max_retries
return scoring_request.retry_count_for_limited_retries < self._configuration.server_error_retries \
and self._configuration.server_error_retries > 0
return False

def _handle_exception(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""This file contains the definition for AOAI scoring client."""

from .aoai_response_handler import AoaiHttpResponseHandler
from ...common.configuration.configuration import Configuration
from ...common.header_providers.header_provider import HeaderProvider
from ...common.scoring.generic_scoring_client import GenericScoringClient
from ...common.scoring.tally_failed_request_handler import TallyFailedRequestHandler
Expand All @@ -15,10 +16,10 @@ class AoaiScoringClient(GenericScoringClient):
def __init__(
self,
header_provider: HeaderProvider,
scoring_url: str = None,
configuration: Configuration,
tally_handler: TallyFailedRequestHandler = None):
"""Initialize AoaiScoringClient."""
super().__init__(
header_provider=header_provider,
http_response_handler=AoaiHttpResponseHandler(tally_handler),
scoring_url=scoring_url)
http_response_handler=AoaiHttpResponseHandler(tally_handler, configuration),
scoring_url=configuration.scoring_url)

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8a0780c

Please sign in to comment.