Skip to content

Commit

Permalink
Update hap_local_python.py
Browse files Browse the repository at this point in the history
Signed-off-by: Aisha Mohammed Farooq Darga <aisdarg1@in.ibm.com>
  • Loading branch information
AishaDarga01 committed Nov 29, 2024
1 parent b7c3ec4 commit 8c1df6c
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions transforms/universal/hap/python/src/hap_local_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
from hap_transform_python import HAPPythonTransformConfiguration

# create parameters
input_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "../test-data/input"))
output_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "../output"))
# input_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "../test-data/input"))
# output_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "../output"))

input_folder = os.getenv('INPUT_FOLDER', os.path.abspath(os.path.join(os.path.dirname(__file__), "../test-data/input")))
output_folder = os.getenv('OUTPUT_FOLDER', os.path.abspath(os.path.join(os.path.dirname(__file__), "../output"))
)
print("PATHS: ", input_folder, output_folder)

local_conf = {
"input_folder": input_folder,
"output_folder": output_folder,
Expand All @@ -35,18 +41,18 @@


hap_params = {
"model_name_or_path": 'ibm-granite/granite-guardian-hap-38m',
"annotation_column": "hap_score",
"doc_text_column": "contents",
"inference_engine": "CPU",
"max_length": 512,
"batch_size": 128,
"model_name_or_path": os.getenv('MODEL_NAME_OR_PATH', 'ibm-granite/granite-guardian-hap-38m'),
"annotation_column": os.getenv('ANNOTATION_COLUMN', "hap_score"),
"doc_text_column": os.getenv('DOC_TEXT_COLUMN', "contents"),
"inference_engine": os.getenv('INFERENCE_ENGINE', "CPU"),
"max_length": int(os.getenv('MAX_LENGTH', 512)),
"batch_size": int(os.getenv('BATCH_SIZE', 128)),
}


if __name__ == "__main__":
# Set the simulated command line args
sys.argv = ParamsUtils.dict_to_req(d=params | hap_params)
print("PARAMs: ", hap_params)
# create launcher
launcher = PythonTransformLauncher(runtime_config=HAPPythonTransformConfiguration())
# Launch the ray actor(s) to process the input
Expand Down

0 comments on commit 8c1df6c

Please sign in to comment.