Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: cannot pickle '_thread.RLock' object #625

Closed
dingtine opened this issue Sep 29, 2021 · 5 comments
Closed

TypeError: cannot pickle '_thread.RLock' object #625

dingtine opened this issue Sep 29, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@dingtine
Copy link

[2628:MainThread](2021-09-29 10:48:13,029) ERROR - qlib.workflow - [utils.py:38] - An exception has been raised[TypeError: cannot pickle '_thread.RLock' object].
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/qrun", line 8, in
sys.exit(run())
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/workflow/cli.py", line 62, in run
fire.Fire(workflow)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/workflow/cli.py", line 56, in workflow
recorder = task_train(config.get("task"), experiment_name=experiment_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/model/trainer.py", line 101, in task_train
recorder = end_task_train(recorder, experiment_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/model/trainer.py", line 65, in end_task_train
R.save_objects(
{"params.pkl": model})
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/workflow/init.py", line 449, in save_objects
self.get_exp().get_recorder().save_objects(local_path, artifact_path, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/workflow/recorder.py", line 311, in save_objects
pickle.dump(data, f)
TypeError: cannot pickle '_thread.RLock' object

When run TFT sample model, got the above error.


**- Python version: 3.8

  • OS : MacOS
  • device: CPU**

@dingtine dingtine added the bug Something isn't working label Sep 29, 2021
@dingtine
Copy link
Author

Run the TFTmodel, but use the cpu function.
My python version is 3.8.

Can change the keras store method from pickle to the kerasModel.save()?

@you-n-g
Copy link
Collaborator

you-n-g commented Sep 29, 2021

We are fixing this bug.
You can try this temporary workaround #483

@dingtine
Copy link
Author

We are fixing this bug. You can try this temporary workaround #483

when i update code to the new branch, a new error accur.

ERROR - qlib.workflow - [utils.py:38] - An exception has been raised[TypeError: expected str, bytes or os.PathLike object, not TFTModel].
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/qrun", line 8, in
sys.exit(run())
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/workflow/cli.py", line 62, in run
fire.Fire(workflow)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fire/core.py", line 466, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/workflow/cli.py", line 56, in workflow
recorder = task_train(config.get("task"), experiment_name=experiment_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/model/trainer.py", line 101, in task_train
recorder = end_task_train(recorder, experiment_name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/model/trainer.py", line 65, in end_task_train
R.save_objects(
{"params.pkl": model})
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/workflow/init.py", line 449, in save_objects
self.get_exp().get_recorder().save_objects(local_path, artifact_path, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/workflow/recorder.py", line 312, in save_objects
Serializable.general_dump(data, path)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/utils/serial.py", line 140, in general_dump
obj.to_pickle(path)
File "/Users/tine/Downloads/qlib-fix_model_bug/examples/benchmarks/TFT/tft.py", line 315, in to_pickle
super().to_pickle(self, path / "qlib_model")
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qlib/utils/serial.py", line 87, in to_pickle
with Path(path).open("wb") as f:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/pathlib.py", line 1042, in new
self = cls._from_parts(args, init=False)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/pathlib.py", line 683, in _from_parts
drv, root, parts = self._parse_args(args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/pathlib.py", line 667, in _parse_args
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not TFTModel

@zhupr
Copy link
Collaborator

zhupr commented Sep 30, 2021

@dingtine
Line 314 of qlib/examples/benchmarks/TFT/tft.py is amended to : super(TFTModel, self).to_pickle(path / "qlib_model")

2efe95f

@you-n-g
Copy link
Collaborator

you-n-g commented Oct 9, 2021

@dingtine
You can try TFT in the main branch.
It is updated and I successfully ran TFT several days ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants