Skip to content

Commit

Permalink
Display warning when user has third-party dataclasses/typing installed
Browse files Browse the repository at this point in the history
Hopefully makes the solution to #10 more obvious.
  • Loading branch information
jasonnance committed Sep 24, 2019
1 parent 3bb9622 commit 841e01f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gobbli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import warnings

import pkg_resources

import gobbli.augment as augment
import gobbli.dataset as dataset
import gobbli.experiment as experiment
import gobbli.io as io
import gobbli.model as model
from gobbli.util import TokenizeMethod

# Warn the user of potential conflicts using the old third-party typing/dataclasses
# modules
for conflicting_pkg in ("typing", "dataclasses"):
req = pkg_resources.Requirement.parse(conflicting_pkg)
if pkg_resources.working_set.find(req) is not None:
warnings.warn(
f"You've installed a third-party module named '{conflicting_pkg}' which "
"conflicts with a standard library module of the same name. This can cause "
"errors when unpickling code, e.g. when running experiments using Ray. Consider "
f"uninstalling the module:\n\npip uninstall {conflicting_pkg}"
)

__all__ = [
# Modules
"augment",
Expand Down

0 comments on commit 841e01f

Please sign in to comment.