Hi community, I am currently working on the unit-t...
# ask-the-community
h
Hi community, I am currently working on the unit-test for snowflake structure dataset encoder/decoder. However, I keep found this error while I tried to run my unit-test, any good suggestion? (I’ve confirmed the registration of encoder/decoder. in the init.py) Here is the error,
Copy code
wrapped = <function wf at 0x16316a670>, instance = None, args = (), kwargs = {}

    @_decorator
    def user_entry_point(wrapped, instance, args, kwargs):
        """
        See the comment for the system_entry_point above as well.

        Decorator for wrapping functions that enter into a user context.  This will help us differentiate user-created
        failures even when it is re-entrant into system code.

        Note: a user_entry_point can ONLY ever be called from within a @system_entry_point wrapped function, therefore,
        we can always ensure we will hit a system_entry_point to correctly reformat our exceptions.  Also, any exception
        we create here will only be handled within our system code so we don't need to worry about leaking weird exceptions
        to the user.
        """
        try:
            _CONTEXT_STACK.append(_USER_CONTEXT)
            if _is_base_context():
                # See comment at this location for system_entry_point
                fn_name = wrapped.__name__
                try:
                    return wrapped(*args, **kwargs)
                except FlyteScopedException as exc:
                    raise exc.type(f"Error encountered while executing '{fn_name}':\n  {exc.value}") from exc
                except Exception as exc:
>                   raise type(exc)(f"Error encountered while executing '{fn_name}':\n  {exc}") from exc
E                   TypeError: Encountered error while executing workflow '<http://test_snowflake.wf|test_snowflake.wf>':
E                     Error encountered while executing 'wf':
E                     Failed to convert outputs of task 'test_snowflake.t1' at position 0:
E                     Protocol not known: snowflake

flytekit/exceptions/scopes.py:203: TypeError
-------------------------------------------------------------------------------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------------------------------------------------------------------------------
{"asctime": "2023-08-30 18:11:48,258", "name": "flytekit", "levelname": "ERROR", "message": "Failed to convert outputs of task 'test_snowflake.t1' at position 0:\n  Protocol not known: snowflake"}
y
I might be wrong, but just wanted to share my experience. Sometimes (I don't know why at the moment), when you modify the flytekit code and try to run the unit test, the test utilizes the wrong source code. Maybe you can try force-installing the flytekit version to see if this resolves the problem. For example, in your virtual environment, try:
Copy code
pip install -U git+<https://github.com/Yicheng-Lu-llll/flytekit.git@real-time-deck-support>
h
Hi @Yicheng Lu, Thanks for the help. Can you explain a bit more here? I thought it related to some protocol is not register, which it should register (which is the code I wrote, and the part I want to test, and I
pip install -e .
to make sure we run the version) when it run the workflow.
y
Do you feel like the test is running on the original version of flytekit? I mean, sometime, the test is not running you modified code.
h
I don’t think the test is running on my modified code. since I add some logs in the base class for encoder/decoder, when it create an object of it, it suppose to print them out.
y
Then, I would suggest you try: 1. push you code to your repo 2. Run pip install -U git+https://github.com/Yicheng-Lu-llll/flytekit.git@real-time-deck-support (replace with yours) in your terminal.
To see if this solves the problem.
h
I see, thanks for the help.
still the same, looks like I miss something, here is the related PR
looks like I am unable to import the snowflake-connector lib while I am using
@mock.patch("snowflake.connector.connect")
in my unit-test function. Any good suggestion?
resolve my self [Solution] ⇒ we need the agent plugins code to import and add entry-points in setup.py to load the module