Hi everyone, I'm following along the tutorial in t...
# ask-the-community
j
Hi everyone, I'm following along the tutorial in the Getting Started section. I'm trying to run the sample example.py locally but kept running into this error. Any change someone could help me with this?
Copy code
File "/Library/Frameworks/Python.framework/Versions/3.11/bin/pyflyte", line 5, in <module>
    from flytekit.clis.sdk_in_container.pyflyte import main
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/flytekit/__init__.py", line 165, in <module>
    from flytekit.core.base_sql_task import SQLTask
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/flytekit/core/base_sql_task.py", line 4, in <module>
    from flytekit.core.base_task import PythonTask, TaskMetadata
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/flytekit/core/base_task.py", line 26, in <module>
    from flytekit.configuration import SerializationSettings
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/flytekit/configuration/__init__.py", line 473, in <module>
    @dataclass(init=True, repr=True, eq=True, frozen=True)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 1210, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'flytekit.configuration.S3Config'> for field s3 is not allowed: use default_factory
s
Hi @Jay Phan! What's the flytekit version you're using? Can you
pip show flytekit
?
j
@Samhita Alla here it is
n
python 3.11 is currently not supported (only 3.7 - 3.10). We need to (a) update our
setup.py
to reflect this (b) open up a PR to test changes necessary for 3.11 support. Last time I checked we’re blocked by some upstream dependencies. @Jay Phan would it be possible for you to use a venv with an earlier version of Python?
d
Also related: I created an issue trying to capture the need to include pre-requisites in the docs (system reqs, Python supported versions, etc) Feel free to comment
I just ran into the very same error using Python 3.10 in a venv
n
oh man, 3.10 also has dataclass issues? @Eduardo Apolinario (eapolinario)
e
interesting. @David Espejo (he/him), also on a mac, right? Can you paste the stacktrace of the error you're seeing here?
d
yep @Eduardo Apolinario (eapolinario), MacOS Ventura, M1:
Copy code
pyflyte run --remote example.py training_workflow \                   1 ✘ ╱ python 
    --hyperparameters '{"C": 0.1, "max_iter": 3000}'
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/bin/pyflyte", line 5, in <module>
    from flytekit.clis.sdk_in_container.pyflyte import main
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/flytekit/_init_.py", line 165, in <module>
    from flytekit.core.base_sql_task import SQLTask
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/flytekit/core/base_sql_task.py", line 4, in <module>
    from flytekit.core.base_task import PythonTask, TaskMetadata
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/flytekit/core/base_task.py", line 26, in <module>
    from flytekit.configuration import SerializationSettings
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/flytekit/configuration/_init_.py", line 473, in <module>
    @dataclass(init=True, repr=True, eq=True, frozen=True)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 1210, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'flytekit.configuration.S3Config'> for field s3 is not allowed: use default_factory
when I invoke
pyflyte run
using the absolute path for the 3.10 package, I get a different error:
Copy code
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/pyflyte", line 8, in <module>
    sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1651, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/click/core.py", line 1698, in resolve_command
    cmd = self.get_command(ctx, cmd_name)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flytekit/clis/sdk_in_container/run.py", line 607, in get_command
    entity = load_naive_entity(module, exe_entity, project_root)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/flytekit/clis/sdk_in_container/run.py", line 447, in load_naive_entity
    importlib.import_module(module_name)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/davidespejo/code/python/example.py", line 2, in <module>
    from sklearn.datasets import load_wine
ModuleNotFoundError: No module named 'sklearn'
Already verified that the package is installed and accesible from the venv
n
will need to install
scikit-learn
, this should be fixed by https://github.com/flyteorg/flytesnacks/pull/950
d
yep, it's already installed but the error is still the same.
Copy code
Requirement already satisfied: scikit-learn in ./lib/python3.10/site-packages (1.2.1)
n
Copy code
/Library/Frameworks/Python.framework/Versions/3.11/bin/pyflyte
hmm, doesn’t seem like this is a venv is it?
e
@David Espejo (he/him), just following up on this. Were you able to install flytekit and run the example? Notice that we don't support python 3.11, which is caught now in flytekit 1.3.2.
d
I saw a different behavior after ensuring I'm using Python 3.10 in a venv No reported errors besides a repetitive and never-ending
Waiting for thread pool to idle before forking
and the workflow execution never starts
e
very interesting. Let's get on a call next week. I want to debug this as I can't repro (also on an arm mac)
135 Views