From 112d4f8ec04e1a99de0ef8e7b868d3915e2dda10 Mon Sep 17 00:00:00 2001 From: paulruelle Date: Mon, 23 Dec 2024 15:42:28 +0100 Subject: [PATCH] fix(LAB-3307): export LLM_STATIC --- .../adapters/kili_api_gateway/asset/operations_mixin.py | 7 ++++++- .../adapters/kili_api_gateway/label/operations_mixin.py | 7 ++++++- src/kili/llm/services/export/__init__.py | 2 +- src/kili/llm/services/export/dynamic.py | 7 ++++--- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/kili/adapters/kili_api_gateway/asset/operations_mixin.py b/src/kili/adapters/kili_api_gateway/asset/operations_mixin.py index 10ee1f828..7bc04bb0f 100644 --- a/src/kili/adapters/kili_api_gateway/asset/operations_mixin.py +++ b/src/kili/adapters/kili_api_gateway/asset/operations_mixin.py @@ -42,7 +42,12 @@ def list_assets( project_info = get_project( self.graphql_client, filters.project_id, ("inputType", "jsonInterface") ) - if project_info["inputType"] in {"VIDEO", "LLM_RLHF", "LLM_INSTR_FOLLOWING"}: + if project_info["inputType"] in { + "VIDEO", + "LLM_RLHF", + "LLM_INSTR_FOLLOWING", + "LLM_STATIC", + }: yield from self.list_assets_split(filters, fields, options, project_info) return diff --git a/src/kili/adapters/kili_api_gateway/label/operations_mixin.py b/src/kili/adapters/kili_api_gateway/label/operations_mixin.py index bcb6d68da..70b7a50d8 100644 --- a/src/kili/adapters/kili_api_gateway/label/operations_mixin.py +++ b/src/kili/adapters/kili_api_gateway/label/operations_mixin.py @@ -61,7 +61,12 @@ def list_labels( project_info = get_project( self.graphql_client, filters.project_id, ("inputType", "jsonInterface") ) - if project_info["inputType"] in {"VIDEO", "LLM_RLHF", "LLM_INSTR_FOLLOWING"}: + if project_info["inputType"] in { + "VIDEO", + "LLM_RLHF", + "LLM_INSTR_FOLLOWING", + "LLM_STATIC", + }: yield from self.list_labels_split(filters, fields, options, project_info) return diff --git a/src/kili/llm/services/export/__init__.py b/src/kili/llm/services/export/__init__.py index 3cbb00595..e9aa91c11 100644 --- a/src/kili/llm/services/export/__init__.py +++ b/src/kili/llm/services/export/__init__.py @@ -87,7 +87,7 @@ def export( # pylint: disable=too-many-arguments, too-many-locals return LLMStaticExporter(kili_api_gateway).export( cleaned_assets, project_id, project["jsonInterface"] ) - if input_type == "LLM_INSTR_FOLLOWING": + if input_type in ["LLM_STATIC", "LLM_INSTR_FOLLOWING"]: return LLMDynamicExporter(kili_api_gateway).export(cleaned_assets, project["jsonInterface"]) raise ValueError(f'Project Input type "{input_type}" cannot be used for llm exports.') diff --git a/src/kili/llm/services/export/dynamic.py b/src/kili/llm/services/export/dynamic.py index 78ece9592..849a98a24 100644 --- a/src/kili/llm/services/export/dynamic.py +++ b/src/kili/llm/services/export/dynamic.py @@ -1,4 +1,4 @@ -"""Handle LLM_INSTR_FOLLOWING project exports.""" +"""Handle LLM_INSTR_FOLLOWING & LLM_STATIC project exports.""" import logging from typing import Dict, List, Union @@ -32,7 +32,7 @@ class LLMDynamicExporter: - """Handle exports of LLM_RLHF projects.""" + """Handle exports of LLM_STATIC and LLM_INSTR_FOLLOWING projects.""" def __init__(self, kili_api_gateway: KiliAPIGateway): self.kili_api_gateway = kili_api_gateway @@ -228,7 +228,8 @@ def _format_comparison_annotation(annotation, completions, job, obfuscated_model break if model_id is None: - raise ValueError(f"Failed to found model of annotation {annotation['id']}") + # FIXME : model_id can be null on LLM_STATIC + return None iteration = 0 for _comparison_code, comparison_note in job["content"]["options"].items():