|
12 | 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
15 | | -import json |
16 | | -import tempfile |
17 | | -from unittest.mock import MagicMock, Mock, patch |
| 15 | +from unittest.mock import Mock, patch |
18 | 16 |
|
19 | 17 | import neo4j |
20 | 18 | from neo4j_graphrag.embeddings import Embedder |
|
32 | 30 | from neo4j_graphrag.experimental.pipeline.config.pipeline_config import ( |
33 | 31 | AbstractPipelineConfig, |
34 | 32 | ) |
35 | | -from neo4j_graphrag.experimental.pipeline.config.runner import PipelineRunner |
36 | 33 | from neo4j_graphrag.experimental.pipeline.types import ComponentDefinition |
37 | 34 | from neo4j_graphrag.llm import LLMInterface |
38 | 35 |
|
@@ -379,69 +376,3 @@ def test_abstract_pipeline_config_resolve_component_definition_with_run_params( |
379 | 376 | assert component_definition.component == component |
380 | 377 | assert component_definition.run_params == {"param": "resolver param result"} |
381 | 378 | mock_resolve_params.assert_called_once_with({"param1": "value1"}) |
382 | | - |
383 | | - |
384 | | -@patch( |
385 | | - "neo4j_graphrag.experimental.pipeline.config.object_config.Neo4jDriverConfig.parse" |
386 | | -) |
387 | | -@patch("os.environ.get") |
388 | | -def test_simple_kg_pipeline_config_from_file( |
389 | | - mock_getenv: Mock, |
390 | | - mock_neo4j_config: Mock, |
391 | | -) -> None: |
392 | | - mock_getenv.return_value = "some_value" |
393 | | - neo4j_driver_mock = MagicMock() |
394 | | - neo4j_driver_mock.return_value.execute_query.return_value = ("5.23", None, None) |
395 | | - mock_neo4j_config.return_value.execute_query.return_value = ( |
396 | | - [{"versions": ["5.23"]}], |
397 | | - None, |
398 | | - None, |
399 | | - ) |
400 | | - json_config_dict = { |
401 | | - "version_": "1", |
402 | | - "template_": "SimpleKGPipeline", |
403 | | - "extras": { |
404 | | - "openai_api_key": {"resolver_": "ENV", "var_": "MY_ENV_VAR"}, |
405 | | - }, |
406 | | - "neo4j_config": { |
407 | | - "params_": { |
408 | | - "uri": "bolt://myhost", |
409 | | - "user": "neo4j", |
410 | | - "password": "password", |
411 | | - } |
412 | | - }, |
413 | | - "llm_config": { |
414 | | - "class_": "OpenAILLM", |
415 | | - "params_": { |
416 | | - "model_name": "gpt-4o", |
417 | | - "api_key": { |
418 | | - "resolver_": "CONFIG_KEY", |
419 | | - "key_": "extras.openai_api_key", |
420 | | - }, |
421 | | - }, |
422 | | - }, |
423 | | - "embedder_config": { |
424 | | - "class_": "OpenAIEmbeddings", |
425 | | - "params_": { |
426 | | - "api_key": { |
427 | | - "resolver_": "CONFIG_KEY", |
428 | | - "key_": "extras.openai_api_key", |
429 | | - } |
430 | | - }, |
431 | | - }, |
432 | | - } |
433 | | - json_string = json.dumps(json_config_dict) |
434 | | - with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as fp: |
435 | | - fp.write(json_string) |
436 | | - fp.close() |
437 | | - # the file is closed, but not removed |
438 | | - # open the file again by using its name |
439 | | - runner = PipelineRunner.from_config_file(fp.name) |
440 | | - config = runner.config |
441 | | - |
442 | | - assert config is not None |
443 | | - # check 'extras' have been resolved |
444 | | - assert config._global_data["extras"] == {"openai_api_key": "some_value"} |
445 | | - # check api key is propagated to the LLM |
446 | | - default_llm = config._global_data["llm_config"]["default"] |
447 | | - assert default_llm.client.api_key == "some_value" |
0 commit comments