Skip to content

Commit 841e01f

Browse files
committed
Display warning when user has third-party dataclasses/typing installed
Hopefully makes the solution to #10 more obvious.
1 parent 3bb9622 commit 841e01f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

gobbli/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1+
import warnings
2+
3+
import pkg_resources
4+
15
import gobbli.augment as augment
26
import gobbli.dataset as dataset
37
import gobbli.experiment as experiment
48
import gobbli.io as io
59
import gobbli.model as model
610
from gobbli.util import TokenizeMethod
711

12+
# Warn the user of potential conflicts using the old third-party typing/dataclasses
13+
# modules
14+
for conflicting_pkg in ("typing", "dataclasses"):
15+
req = pkg_resources.Requirement.parse(conflicting_pkg)
16+
if pkg_resources.working_set.find(req) is not None:
17+
warnings.warn(
18+
f"You've installed a third-party module named '{conflicting_pkg}' which "
19+
"conflicts with a standard library module of the same name. This can cause "
20+
"errors when unpickling code, e.g. when running experiments using Ray. Consider "
21+
f"uninstalling the module:\n\npip uninstall {conflicting_pkg}"
22+
)
23+
824
__all__ = [
925
# Modules
1026
"augment",

0 commit comments

Comments
 (0)