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

try to fix imports for parsing #6256

Merged
merged 2 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pytorch_lightning/core/datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from torch.utils.data import DataLoader, Dataset

from pytorch_lightning.core.hooks import CheckpointHooks, DataHooks
from pytorch_lightning.utilities import parsing, rank_zero_only
from pytorch_lightning.utilities import rank_zero_only
from pytorch_lightning.utilities.parsing import str_to_bool, str_to_bool_or_str


class _DataModuleWrapper(type):
Expand Down Expand Up @@ -272,10 +273,10 @@ def add_argparse_args(cls, parent_parser: ArgumentParser) -> ArgumentParser:
arg_kwargs.update(nargs="?", const=True)
# if the only arg type is bool
if len(arg_types) == 1:
use_type = parsing.str_to_bool
use_type = str_to_bool
# if only two args (str, bool)
elif len(arg_types) == 2 and set(arg_types) == {str, bool}:
use_type = parsing.str_to_bool_or_str
use_type = str_to_bool_or_str
else:
# filter out the bool as we need to use more general
use_type = [at for at in arg_types if at is not bool][0]
Expand Down
6 changes: 3 additions & 3 deletions pytorch_lightning/utilities/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from contextlib import suppress
from typing import Any, Dict, List, Tuple, Union

from pytorch_lightning.utilities import parsing
from pytorch_lightning.utilities.parsing import str_to_bool, str_to_bool_or_str


def from_argparse_args(cls, args: Union[Namespace, ArgumentParser], **kwargs):
Expand Down Expand Up @@ -175,9 +175,9 @@ def add_argparse_args(cls, parent_parser: ArgumentParser) -> ArgumentParser:
arg_kwargs.update(nargs="?", const=True)
# if the only arg type is bool
if len(arg_types) == 1:
use_type = parsing.str_to_bool
use_type = str_to_bool
elif str in arg_types:
use_type = parsing.str_to_bool_or_str
use_type = str_to_bool_or_str
else:
# filter out the bool as we need to use more general
use_type = [at for at in arg_types if at is not bool][0]
Expand Down
1 change: 1 addition & 0 deletions tests/checkpointing/test_legacy_checkpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"1.1.7",
"1.1.8",
"1.2.0",
"1.2.1",
]
)
def test_resume_legacy_checkpoints(tmpdir, pl_version):
Expand Down