Skip to content

Separate promptflow-core package #8376

Separate promptflow-core package

Separate promptflow-core package #8376

GitHub Actions / Executor Unit Test Result [](https://github.com/microsoft/promptflow/actions/workflows/promptflow-executor-unit-test.yml?query=branch:++) failed Mar 27, 2024 in 0s

5 fail, 716 pass in 3m 45s

721 tests   716 ✅  3m 45s ⏱️
  1 suites    0 💤
  1 files      5 ❌

Results for commit bb93ab6.

Annotations

Check warning on line 0 in tests.executor.unittests.contracts.test_tool.TestConnectionType

See this annotation in the file changed.

@github-actions github-actions / Executor Unit Test Result [](https://github.com/microsoft/promptflow/actions/workflows/promptflow-executor-unit-test.yml?query=branch:++)

test_is_connection_value[value1-True] (tests.executor.unittests.contracts.test_tool.TestConnectionType) failed

artifacts/Test Results (Python 3.9) (OS ubuntu-latest)/test-results.xml [took 0s]
Raw output
assert False == True
 +  where False = <function ConnectionType.is_connection_value at 0x7f24c08c0040>(<promptflow._sdk.entities._connection.AzureContentSafetyConnection object at 0x7f24bd942070>)
 +    where <function ConnectionType.is_connection_value at 0x7f24c08c0040> = ConnectionType.is_connection_value
self = <executor.unittests.contracts.test_tool.TestConnectionType object at 0x7f24bd7f7460>
value = <promptflow._sdk.entities._connection.AzureContentSafetyConnection object at 0x7f24bd942070>
expected = True

    @pytest.mark.parametrize(
        "value, expected",
        [
            (connections.get("AzureContentSafetyConnection"), True),
            (AzureContentSafetyConnection("api_key", "endpoint"), True),
            (Status, False),
            (ConnectionType.is_connection_value("non_connection_instance"), False),
        ],
    )
    def test_is_connection_value(self, value, expected):
>       assert ConnectionType.is_connection_value(value) == expected
E       assert False == True
E        +  where False = <function ConnectionType.is_connection_value at 0x7f24c08c0040>(<promptflow._sdk.entities._connection.AzureContentSafetyConnection object at 0x7f24bd942070>)
E        +    where <function ConnectionType.is_connection_value at 0x7f24c08c0040> = ConnectionType.is_connection_value

/home/runner/work/promptflow/promptflow/src/promptflow/tests/executor/unittests/contracts/test_tool.py:164: AssertionError

Check warning on line 0 in tests.executor.unittests.contracts.test_flow.TestInputAssignment

See this annotation in the file changed.

@github-actions github-actions / Executor Unit Test Result [](https://github.com/microsoft/promptflow/actions/workflows/promptflow-executor-unit-test.yml?query=branch:++)

test_serialize[value4-ABCMeta] (tests.executor.unittests.contracts.test_flow.TestInputAssignment) failed

artifacts/Test Results (Python 3.9) (OS ubuntu-latest)/test-results.xml [took 0s]
Raw output
AssertionError: assert <class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'> == 'ABCMeta'
 +  where <class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'> = <bound method InputAssignment.serialize of InputAssignment(value=<class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>, value_type=<InputValueType.LITERAL: 'Literal'>, section='section', property='property')>()
 +    where <bound method InputAssignment.serialize of InputAssignment(value=<class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>, value_type=<InputValueType.LITERAL: 'Literal'>, section='section', property='property')> = InputAssignment(value=<class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>, value_type=<InputValueType.LITERAL: 'Literal'>, section='section', property='property').serialize
self = <executor.unittests.contracts.test_flow.TestInputAssignment object at 0x7fa7649c8a60>
value = InputAssignment(value=<class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>, value_type=<InputValueType.LITERAL: 'Literal'>, section='section', property='property')
expected_value = 'ABCMeta'

    @pytest.mark.parametrize(
        "value, expected_value",
        [
            (InputAssignment("value", InputValueType.LITERAL), "value"),
            (InputAssignment("value", InputValueType.FLOW_INPUT), "${flow.value}"),
            (InputAssignment("value", InputValueType.NODE_REFERENCE, "section"), "${value.section}"),
            (
                InputAssignment("value", InputValueType.NODE_REFERENCE, "section", "property"),
                "${value.section.property}",
            ),
            (InputAssignment(AzureContentSafetyConnection, InputValueType.LITERAL, "section", "property"), "ABCMeta"),
        ],
    )
    def test_serialize(self, value, expected_value):
>       assert value.serialize() == expected_value
E       AssertionError: assert <class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'> == 'ABCMeta'
E        +  where <class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'> = <bound method InputAssignment.serialize of InputAssignment(value=<class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>, value_type=<InputValueType.LITERAL: 'Literal'>, section='section', property='property')>()
E        +    where <bound method InputAssignment.serialize of InputAssignment(value=<class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>, value_type=<InputValueType.LITERAL: 'Literal'>, section='section', property='property')> = InputAssignment(value=<class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>, value_type=<InputValueType.LITERAL: 'Literal'>, section='section', property='property').serialize

/home/runner/work/promptflow/promptflow/src/promptflow/tests/executor/unittests/contracts/test_flow.py:525: AssertionError

Check warning on line 0 in tests.executor.unittests.executor.test_tool_resolver.TestToolResolver

See this annotation in the file changed.

@github-actions github-actions / Executor Unit Test Result [](https://github.com/microsoft/promptflow/actions/workflows/promptflow-executor-unit-test.yml?query=branch:++)

test_convert_to_custom_strong_type_connection_value[conn_types1-CustomConnection] (tests.executor.unittests.executor.test_tool_resolver.TestToolResolver) failed

artifacts/Test Results (Python 3.9) (OS ubuntu-latest)/test-results.xml [took 0s]
Raw output
AssertionError: assert False
 +  where False = isinstance(<promptflow.core._connection.CustomConnection object at 0x7f8849ade280>, <class 'promptflow._sdk.entities._connection.CustomConnection'>)
self = <executor.unittests.executor.test_tool_resolver.TestToolResolver object at 0x7f8856c4f970>
conn_types = ['CustomConnection', 'MyFirstCSTConnection']
expected_type = <class 'promptflow._sdk.entities._connection.CustomConnection'>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f8849ade1f0>

    @pytest.mark.parametrize(
        "conn_types, expected_type",
        [
            (["MyFirstCSTConnection"], MyFirstCSTConnection),
            (["CustomConnection", "MyFirstCSTConnection"], CustomConnection),
            (["CustomConnection", "MyFirstCSTConnection", "MySecondCSTConnection"], CustomConnection),
            (["MyFirstCSTConnection", "MySecondCSTConnection"], MyFirstCSTConnection),
        ],
    )
    def test_convert_to_custom_strong_type_connection_value(self, conn_types: List[str], expected_type, mocker):
        connections = {"conn_name": {"type": "CustomConnection", "value": {"api_key": "mock", "api_base": "mock"}}}
        tool_resolver = ToolResolver(working_dir=None, connections=connections)
    
        node = mocker.Mock(name="node", tool=None, inputs={})
        node.type = ToolType.PYTHON
        node.source = mocker.Mock(type=ToolSourceType.Code)
        tool = Tool(name="tool", type="python", inputs={"conn": InputDefinition(type=["CustomConnection"])})
        m = sys.modules[__name__]
        v = InputAssignment(value="conn_name", value_type=InputValueType.LITERAL)
        actual = tool_resolver._convert_to_custom_strong_type_connection_value(
            "conn_name", v, node, tool, conn_types, m
        )
>       assert isinstance(actual, expected_type)
E       AssertionError: assert False
E        +  where False = isinstance(<promptflow.core._connection.CustomConnection object at 0x7f8849ade280>, <class 'promptflow._sdk.entities._connection.CustomConnection'>)

/home/runner/work/promptflow/promptflow/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py:514: AssertionError

Check warning on line 0 in tests.executor.unittests.contracts.test_tool.TestConnectionType

See this annotation in the file changed.

@github-actions github-actions / Executor Unit Test Result [](https://github.com/microsoft/promptflow/actions/workflows/promptflow-executor-unit-test.yml?query=branch:++)

test_serialize_conn (tests.executor.unittests.contracts.test_tool.TestConnectionType) failed

artifacts/Test Results (Python 3.9) (OS ubuntu-latest)/test-results.xml [took 0s]
Raw output
ValueError: Invalid connection value <class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>
self = <executor.unittests.contracts.test_tool.TestConnectionType object at 0x7f24bd80d1f0>

    def test_serialize_conn(self):
>       assert ConnectionType.serialize_conn(AzureContentSafetyConnection) == "ABCMeta"

/home/runner/work/promptflow/promptflow/src/promptflow/tests/executor/unittests/contracts/test_tool.py:201: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

connection = <class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>

    @staticmethod
    def serialize_conn(connection: Any) -> dict:
        """Serialize the given connection.
    
        :param connection: The connection to serialize
        :type connection: Any
        :return: A dictionary representation of the connection.
        :rtype: dict
        """
    
        if not ConnectionType.is_connection_value(connection):
>           raise ValueError(f"Invalid connection value {connection!r}")
E           ValueError: Invalid connection value <class 'promptflow._sdk.entities._connection.AzureContentSafetyConnection'>

/home/runner/work/promptflow/promptflow/src/promptflow/promptflow/contracts/tool.py:228: ValueError

Check warning on line 0 in tests.executor.unittests.executor.test_tool_resolver.TestToolResolver

See this annotation in the file changed.

@github-actions github-actions / Executor Unit Test Result [](https://github.com/microsoft/promptflow/actions/workflows/promptflow-executor-unit-test.yml?query=branch:++)

test_convert_to_custom_strong_type_connection_value[conn_types2-CustomConnection] (tests.executor.unittests.executor.test_tool_resolver.TestToolResolver) failed

artifacts/Test Results (Python 3.9) (OS ubuntu-latest)/test-results.xml [took 0s]
Raw output
AssertionError: assert False
 +  where False = isinstance(<promptflow.core._connection.CustomConnection object at 0x7f8849ac17f0>, <class 'promptflow._sdk.entities._connection.CustomConnection'>)
self = <executor.unittests.executor.test_tool_resolver.TestToolResolver object at 0x7f8856c4f460>
conn_types = ['CustomConnection', 'MyFirstCSTConnection', 'MySecondCSTConnection']
expected_type = <class 'promptflow._sdk.entities._connection.CustomConnection'>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f8849ac1ac0>

    @pytest.mark.parametrize(
        "conn_types, expected_type",
        [
            (["MyFirstCSTConnection"], MyFirstCSTConnection),
            (["CustomConnection", "MyFirstCSTConnection"], CustomConnection),
            (["CustomConnection", "MyFirstCSTConnection", "MySecondCSTConnection"], CustomConnection),
            (["MyFirstCSTConnection", "MySecondCSTConnection"], MyFirstCSTConnection),
        ],
    )
    def test_convert_to_custom_strong_type_connection_value(self, conn_types: List[str], expected_type, mocker):
        connections = {"conn_name": {"type": "CustomConnection", "value": {"api_key": "mock", "api_base": "mock"}}}
        tool_resolver = ToolResolver(working_dir=None, connections=connections)
    
        node = mocker.Mock(name="node", tool=None, inputs={})
        node.type = ToolType.PYTHON
        node.source = mocker.Mock(type=ToolSourceType.Code)
        tool = Tool(name="tool", type="python", inputs={"conn": InputDefinition(type=["CustomConnection"])})
        m = sys.modules[__name__]
        v = InputAssignment(value="conn_name", value_type=InputValueType.LITERAL)
        actual = tool_resolver._convert_to_custom_strong_type_connection_value(
            "conn_name", v, node, tool, conn_types, m
        )
>       assert isinstance(actual, expected_type)
E       AssertionError: assert False
E        +  where False = isinstance(<promptflow.core._connection.CustomConnection object at 0x7f8849ac17f0>, <class 'promptflow._sdk.entities._connection.CustomConnection'>)

/home/runner/work/promptflow/promptflow/src/promptflow/tests/executor/unittests/executor/test_tool_resolver.py:514: AssertionError