Hello! We regularly, and for an hour constantly, h...
# prefect-server
c
Hello! We regularly, and for an hour constantly, have the following unexpected error: (full logs in the thread)
Copy code
Unexpected error: AttributeError("partially initialized module 'prefect' has no attribute 'schedules' (most likely due to a circular import)")
during our flows executions. This seems to occur randomly between tasks executions. Is there some known issue about it? Thanks!
Here is the full stack trace:
Copy code
Unexpected error: AttributeError("partially initialized module 'prefect' has no attribute 'schedules' (most likely due to a circular import)")
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/prefect/engine/runner.py", line 48, in inner
    new_state = method(self, state, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/prefect/engine/flow_runner.py", line 643, in get_flow_run_state
    final_states = executor.wait(
  File "/usr/local/lib/python3.8/dist-packages/prefect/executors/dask.py", line 440, in wait
    return self.client.gather(futures)
  File "/usr/local/lib/python3.8/dist-packages/distributed/client.py", line 1980, in gather
    return self.sync(
  File "/usr/local/lib/python3.8/dist-packages/distributed/client.py", line 868, in sync
    return sync(
  File "/usr/local/lib/python3.8/dist-packages/distributed/utils.py", line 332, in sync
    raise exc.with_traceback(tb)
  File "/usr/local/lib/python3.8/dist-packages/distributed/utils.py", line 315, in f
    result[0] = yield future
  File "/usr/local/lib/python3.8/dist-packages/tornado/gen.py", line 762, in run
    value = future.result()
  File "/usr/local/lib/python3.8/dist-packages/distributed/client.py", line 1845, in _gather
    raise exception.with_traceback(traceback)
  File "/usr/local/lib/python3.8/dist-packages/distributed/protocol/pickle.py", line 75, in loads
    return pickle.loads(x)
  File "/usr/local/lib/python3.8/dist-packages/prefect/__init__.py", line 9, in <module>
    import prefect.triggers
  File "/usr/local/lib/python3.8/dist-packages/prefect/triggers.py", line 48, in <module>
    from prefect.engine import signals
  File "/usr/local/lib/python3.8/dist-packages/prefect/engine/__init__.py", line 7, in <module>
    from prefect.engine.flow_runner import FlowRunner
  File "/usr/local/lib/python3.8/dist-packages/prefect/engine/flow_runner.py", line 15, in <module>
    from prefect.core import Edge, Flow, Task
  File "/usr/local/lib/python3.8/dist-packages/prefect/core/__init__.py", line 4, in <module>
    from prefect.core.flow import Flow
  File "/usr/local/lib/python3.8/dist-packages/prefect/core/flow.py", line 85, in <module>
    class Flow:
  File "/usr/local/lib/python3.8/dist-packages/prefect/core/flow.py", line 159, in Flow
    schedule: prefect.schedules.Schedule = None,
AttributeError: partially initialized module 'prefect' has no attribute 'schedules' (most likely due to a circular import)
a
This can happen when you have a local file with the same name as an imported module – Python sees the local file and thinks it’s the module. Do you have by any chance prefect.py or a directory called “prefect” in your project?
c
@Anna Geller Thanks for your answer We don’t have any file or directory named
prefect.py
or
prefect
in our project though
a
Alright, in that case I will try to reproduce and open an issue. Can you share a minimal reproducible flow that leads to this error? Also, can you share the output of “prefect diagnostics”?
c
Here is the output of `prefect diagnostics`:
Copy code
{
  "config_overrides": {},
  "env_vars": [],
  "system_information": {
    "platform": "macOS-10.16-x86_64-i386-64bit",
    "prefect_backend": "cloud",
    "prefect_version": "0.15.9",
    "python_version": "3.8.5"
  }
}
I’m not sure to be able to easily provide a minimal reproductible flow to leads to this error though, is that mandatory?
a
it’s hard to reproduce the issue otherwise
as an alternative, perhaps you can zip your project and send it to me via DM?
c
@Anna Geller It seems that our runs are starting to finish successfully again, without any update on our side Are you aware of any update on your side maybe?
a
Nope, the latest commit is 4 days ago… How should we progress? Would you be willing to open a Github issue if this happens again?