Skip to content

Commit 3c9bd58

Browse files
CristhianzlAlfio Gliozzoautofix-ci[bot]
authored andcommitted
feat(agentics): Refactor bundle components to agenerate/amap/areduce pattern for Langflow 1.9 (#12518)
Co-authored-by: Alfio Gliozzo <gliozzo@us.ibm.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 0ac12be commit 3c9bd58

25 files changed

Lines changed: 1512 additions & 289 deletions

src/backend/tests/unit/agentic/services/test_provider_service.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,7 @@ async def test_should_return_empty_when_no_credentials(self):
198198

199199
mock_session = MagicMock()
200200

201-
with (
202-
patch("langflow.agentic.services.provider_service.get_variable_service", return_value=mock_db_service),
203-
patch("langflow.agentic.services.provider_service.os.getenv", return_value=None),
204-
):
201+
with patch("langflow.agentic.services.provider_service.get_variable_service", return_value=mock_db_service):
205202
enabled_providers, provider_status = await get_enabled_providers_for_user("user-1", mock_session)
206203

207204
assert enabled_providers == []
@@ -228,7 +225,6 @@ async def test_should_return_enabled_providers_with_credentials(self):
228225
"langflow.agentic.services.provider_service.get_model_provider_variable_mapping",
229226
return_value={"Anthropic": "ANTHROPIC_API_KEY", "OpenAI": "OPENAI_API_KEY"},
230227
),
231-
patch("langflow.agentic.services.provider_service.os.getenv", return_value=None),
232228
):
233229
enabled, status = await get_enabled_providers_for_user("user-1", mock_session)
234230

@@ -276,10 +272,7 @@ async def test_should_return_empty_when_get_all_returns_empty(self):
276272

277273
mock_session = MagicMock()
278274

279-
with (
280-
patch("langflow.agentic.services.provider_service.get_variable_service", return_value=mock_db_service),
281-
patch("langflow.agentic.services.provider_service.os.getenv", return_value=None),
282-
):
275+
with patch("langflow.agentic.services.provider_service.get_variable_service", return_value=mock_db_service):
283276
enabled_providers, provider_status = await get_enabled_providers_for_user("user-1", mock_session)
284277

285278
assert enabled_providers == []

src/backend/tests/unit/components/bundles/agentics/test_agentics_component.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
except ImportError:
1111
pytest.skip("agentics-py and crewai not installed", allow_module_level=True)
1212

13-
from lfx.components.agentics import SemanticAggregator, SemanticMap, SyntheticDataGenerator
13+
from lfx.components.agentics import AgenerateComponent, AMapComponent, AreduceComponent
1414
from lfx.components.agentics.constants import (
1515
TRANSDUCTION_AMAP,
1616
TRANSDUCTION_AREDUCE,
@@ -20,25 +20,25 @@
2020

2121

2222
@pytest.mark.unit
23-
class TestSemanticMapComponent:
24-
"""Tests for SemanticMap (aMap) component metadata."""
23+
class TestAMapComponent:
24+
"""Tests for AMapComponent (aMap) component metadata."""
2525

2626
def test_should_have_correct_display_name(self):
2727
"""Test that component has correct display name."""
28-
assert SemanticMap.display_name == "aMap"
28+
assert AMapComponent.display_name == "aMap"
2929

3030
def test_should_have_correct_icon(self):
3131
"""Test that component has correct icon."""
32-
assert SemanticMap.icon == "Agentics"
32+
assert AMapComponent.icon == "Agentics"
3333

3434
def test_should_have_correct_description(self):
3535
"""Test that component has correct description."""
36-
assert "augment" in SemanticMap.description.lower()
37-
assert "dataframe" in SemanticMap.description.lower()
36+
assert "augment" in AMapComponent.description.lower()
37+
assert "dataframe" in AMapComponent.description.lower()
3838

3939
def test_should_have_required_inputs(self):
4040
"""Test that component has all required inputs."""
41-
input_names = {i.name for i in SemanticMap.inputs}
41+
input_names = {i.name for i in AMapComponent.inputs}
4242

4343
assert "model" in input_names
4444
assert "api_key" in input_names
@@ -48,12 +48,12 @@ def test_should_have_required_inputs(self):
4848

4949
def test_should_have_dataframe_output(self):
5050
"""Test that component has DataFrame output."""
51-
output_names = {o.name for o in SemanticMap.outputs}
51+
output_names = {o.name for o in AMapComponent.outputs}
5252
assert "states" in output_names
5353

5454
def test_should_have_provider_specific_inputs(self):
5555
"""Test that component has provider-specific inputs."""
56-
input_names = {i.name for i in SemanticMap.inputs}
56+
input_names = {i.name for i in AMapComponent.inputs}
5757

5858
assert "base_url_ibm_watsonx" in input_names
5959
assert "project_id" in input_names
@@ -67,13 +67,13 @@ def test_should_have_valid_transduction_constants(self):
6767

6868
def test_should_have_model_input_with_real_time_refresh(self):
6969
"""Test that model input has real_time_refresh enabled."""
70-
model_input = next((i for i in SemanticMap.inputs if i.name == "model"), None)
70+
model_input = next((i for i in AMapComponent.inputs if i.name == "model"), None)
7171
assert model_input is not None
7272
assert model_input.real_time_refresh is True
7373

7474
def test_should_have_schema_input_with_table_schema(self):
7575
"""Test that schema input has table_schema defined."""
76-
schema_input = next((i for i in SemanticMap.inputs if i.name == "schema"), None)
76+
schema_input = next((i for i in AMapComponent.inputs if i.name == "schema"), None)
7777
assert schema_input is not None
7878
assert schema_input.table_schema is not None
7979
assert len(schema_input.table_schema) > 0
@@ -86,20 +86,20 @@ def test_should_have_schema_input_with_table_schema(self):
8686

8787

8888
@pytest.mark.unit
89-
class TestSemanticAggregatorComponent:
90-
"""Tests for SemanticAggregator (aReduce) component metadata."""
89+
class TestAreduceComponent:
90+
"""Tests for AreduceComponent (aReduce) component metadata."""
9191

9292
def test_should_have_correct_display_name(self):
9393
"""Test that component has correct display name."""
94-
assert SemanticAggregator.display_name == "aReduce"
94+
assert AreduceComponent.display_name == "aReduce"
9595

9696
def test_should_have_correct_icon(self):
9797
"""Test that component has correct icon."""
98-
assert SemanticAggregator.icon == "Agentics"
98+
assert AreduceComponent.icon == "Agentics"
9999

100100
def test_should_have_required_inputs(self):
101101
"""Test that component has all required inputs."""
102-
input_names = {i.name for i in SemanticAggregator.inputs}
102+
input_names = {i.name for i in AreduceComponent.inputs}
103103

104104
assert "model" in input_names
105105
assert "api_key" in input_names
@@ -108,30 +108,30 @@ def test_should_have_required_inputs(self):
108108

109109
def test_should_have_states_output(self):
110110
"""Test that component has states output."""
111-
output_names = {o.name for o in SemanticAggregator.outputs}
111+
output_names = {o.name for o in AreduceComponent.outputs}
112112
assert "states" in output_names
113113

114114

115115
@pytest.mark.unit
116-
class TestSyntheticDataGeneratorComponent:
117-
"""Tests for SyntheticDataGenerator (aGenerate) component metadata."""
116+
class TestAgenerateComponent:
117+
"""Tests for AgenerateComponent (aGenerate) component metadata."""
118118

119119
def test_should_have_correct_display_name(self):
120120
"""Test that component has correct display name."""
121-
assert SyntheticDataGenerator.display_name == "aGenerate"
121+
assert AgenerateComponent.display_name == "aGenerate"
122122

123123
def test_should_have_correct_icon(self):
124124
"""Test that component has correct icon."""
125-
assert SyntheticDataGenerator.icon == "Agentics"
125+
assert AgenerateComponent.icon == "Agentics"
126126

127127
def test_should_have_batch_size_input(self):
128128
"""Test that component has batch_size input."""
129-
input_names = {i.name for i in SyntheticDataGenerator.inputs}
129+
input_names = {i.name for i in AgenerateComponent.inputs}
130130
assert "batch_size" in input_names
131131

132132
def test_should_have_states_output(self):
133133
"""Test that component has states output."""
134-
output_names = {o.name for o in SyntheticDataGenerator.outputs}
134+
output_names = {o.name for o in AgenerateComponent.outputs}
135135
assert "states" in output_names
136136

137137

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Unit tests for Agentics SemanticAggregator component."""
1+
"""Unit tests for Agentics AreduceComponent (formerly SemanticAggregator)."""
22

33
from __future__ import annotations
44

@@ -10,29 +10,29 @@
1010
except ImportError:
1111
pytest.skip("agentics-py and crewai not installed", allow_module_level=True)
1212

13-
from lfx.components.agentics.semantic_aggregator import SemanticAggregator
13+
from lfx.components.agentics.areduce_component import AreduceComponent
1414

1515

1616
@pytest.mark.unit
17-
class TestSemanticAggregatorComponent:
18-
"""Tests for SemanticAggregator component metadata."""
17+
class TestAreduceComponent:
18+
"""Tests for AreduceComponent metadata."""
1919

2020
def test_should_have_correct_display_name(self):
2121
"""Test that component has correct display name."""
22-
assert SemanticAggregator.display_name == "aReduce"
22+
assert AreduceComponent.display_name == "aReduce"
2323

2424
def test_should_have_correct_icon(self):
2525
"""Test that component has correct icon."""
26-
assert SemanticAggregator.icon == "Agentics"
26+
assert AreduceComponent.icon == "Agentics"
2727

2828
def test_should_have_correct_description(self):
2929
"""Test that component has correct description."""
30-
assert "dataframe" in SemanticAggregator.description.lower()
31-
assert "schema" in SemanticAggregator.description.lower()
30+
assert "dataframe" in AreduceComponent.description.lower()
31+
assert "schema" in AreduceComponent.description.lower()
3232

3333
def test_should_have_required_inputs(self):
3434
"""Test that component has all required inputs."""
35-
input_names = {i.name for i in SemanticAggregator.inputs}
35+
input_names = {i.name for i in AreduceComponent.inputs}
3636

3737
assert "model" in input_names
3838
assert "api_key" in input_names
@@ -42,26 +42,26 @@ def test_should_have_required_inputs(self):
4242

4343
def test_should_have_dataframe_output(self):
4444
"""Test that component has DataFrame output."""
45-
output_names = {o.name for o in SemanticAggregator.outputs}
45+
output_names = {o.name for o in AreduceComponent.outputs}
4646
assert "states" in output_names
4747

4848
def test_should_have_provider_specific_inputs(self):
4949
"""Test that component has provider-specific inputs."""
50-
input_names = {i.name for i in SemanticAggregator.inputs}
50+
input_names = {i.name for i in AreduceComponent.inputs}
5151

5252
assert "base_url_ibm_watsonx" in input_names
5353
assert "project_id" in input_names
5454
assert "ollama_base_url" in input_names
5555

5656
def test_should_have_model_input_with_real_time_refresh(self):
5757
"""Test that model input has real_time_refresh enabled."""
58-
model_input = next((i for i in SemanticAggregator.inputs if i.name == "model"), None)
58+
model_input = next((i for i in AreduceComponent.inputs if i.name == "model"), None)
5959
assert model_input is not None
6060
assert model_input.real_time_refresh is True
6161

6262
def test_should_have_schema_with_table_schema(self):
6363
"""Test that schema input has table_schema defined."""
64-
schema_input = next((i for i in SemanticAggregator.inputs if i.name == "schema"), None)
64+
schema_input = next((i for i in AreduceComponent.inputs if i.name == "schema"), None)
6565
assert schema_input is not None
6666
assert schema_input.table_schema is not None
6767
assert len(schema_input.table_schema) > 0
@@ -74,18 +74,18 @@ def test_should_have_schema_with_table_schema(self):
7474

7575
def test_should_have_api_key_as_advanced(self):
7676
"""Test that api_key input is marked as advanced."""
77-
api_key_input = next((i for i in SemanticAggregator.inputs if i.name == "api_key"), None)
77+
api_key_input = next((i for i in AreduceComponent.inputs if i.name == "api_key"), None)
7878
assert api_key_input is not None
7979
assert api_key_input.advanced is True
8080

8181
def test_should_have_source_as_required(self):
8282
"""Test that source input is marked as required."""
83-
source_input = next((i for i in SemanticAggregator.inputs if i.name == "source"), None)
83+
source_input = next((i for i in AreduceComponent.inputs if i.name == "source"), None)
8484
assert source_input is not None
8585
assert source_input.required is True
8686

8787
def test_should_have_output_with_correct_method(self):
8888
"""Test that output has correct method name."""
89-
output = next((o for o in SemanticAggregator.outputs if o.name == "states"), None)
89+
output = next((o for o in AreduceComponent.outputs if o.name == "states"), None)
9090
assert output is not None
9191
assert output.method == "aReduce"
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Unit tests for Agentics SemanticMap component."""
1+
"""Unit tests for Agentics AMapComponent (formerly SemanticMap)."""
22

33
from __future__ import annotations
44

@@ -10,24 +10,24 @@
1010
except ImportError:
1111
pytest.skip("agentics-py and crewai not installed", allow_module_level=True)
1212

13-
from lfx.components.agentics.semantic_map import SemanticMap
13+
from lfx.components.agentics.amap_component import AMapComponent
1414

1515

1616
@pytest.mark.unit
17-
class TestSemanticMapComponent:
18-
"""Tests for SemanticMap component metadata."""
17+
class TestAMapComponent:
18+
"""Tests for AMapComponent metadata."""
1919

2020
def test_should_have_correct_display_name(self):
2121
"""Test that component has correct display name."""
22-
assert SemanticMap.display_name == "aMap"
22+
assert AMapComponent.display_name == "aMap"
2323

2424
def test_should_have_correct_icon(self):
2525
"""Test that component has correct icon."""
26-
assert SemanticMap.icon == "Agentics"
26+
assert AMapComponent.icon == "Agentics"
2727

2828
def test_should_have_required_inputs(self):
2929
"""Test that component has all required inputs."""
30-
input_names = {i.name for i in SemanticMap.inputs}
30+
input_names = {i.name for i in AMapComponent.inputs}
3131

3232
assert "model" in input_names
3333
assert "api_key" in input_names
@@ -38,26 +38,26 @@ def test_should_have_required_inputs(self):
3838

3939
def test_should_have_dataframe_output(self):
4040
"""Test that component has DataFrame output."""
41-
output_names = {o.name for o in SemanticMap.outputs}
41+
output_names = {o.name for o in AMapComponent.outputs}
4242
assert "states" in output_names
4343

4444
def test_should_have_provider_specific_inputs(self):
4545
"""Test that component has provider-specific inputs."""
46-
input_names = {i.name for i in SemanticMap.inputs}
46+
input_names = {i.name for i in AMapComponent.inputs}
4747

4848
assert "base_url_ibm_watsonx" in input_names
4949
assert "project_id" in input_names
5050
assert "ollama_base_url" in input_names
5151

5252
def test_should_have_model_input_with_real_time_refresh(self):
5353
"""Test that model input has real_time_refresh enabled."""
54-
model_input = next((i for i in SemanticMap.inputs if i.name == "model"), None)
54+
model_input = next((i for i in AMapComponent.inputs if i.name == "model"), None)
5555
assert model_input is not None
5656
assert model_input.real_time_refresh is True
5757

5858
def test_should_have_schema_with_table_schema(self):
5959
"""Test that schema input has table_schema defined."""
60-
schema_input = next((i for i in SemanticMap.inputs if i.name == "schema"), None)
60+
schema_input = next((i for i in AMapComponent.inputs if i.name == "schema"), None)
6161
assert schema_input is not None
6262
assert schema_input.table_schema is not None
6363
assert len(schema_input.table_schema) > 0
@@ -70,6 +70,6 @@ def test_should_have_schema_with_table_schema(self):
7070

7171
def test_should_have_append_to_input_columns_as_boolean(self):
7272
"""Test that append_to_input_columns input is a boolean."""
73-
append_input = next((i for i in SemanticMap.inputs if i.name == "append_to_input_columns"), None)
73+
append_input = next((i for i in AMapComponent.inputs if i.name == "append_to_input_columns"), None)
7474
assert append_input is not None
7575
assert append_input.value is True

0 commit comments

Comments
 (0)