def test_fsspec_support_false(self): self.assertEqual('fr', get_config_read_mode()) with self.assertRaises(ImportError): set_config_read_mode(fsspec_enabled=True) self.assertEqual('fr', get_config_read_mode()) set_config_read_mode(fsspec_enabled=False) self.assertEqual('fr', get_config_read_mode())
from types import MethodType from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Type, Union from torch.optim import Optimizer from pytorch_lightning import Callback, LightningDataModule, LightningModule, seed_everything, Trainer from pytorch_lightning.utilities import _JSONARGPARSE_AVAILABLE, warnings from pytorch_lightning.utilities.cloud_io import get_filesystem from pytorch_lightning.utilities.exceptions import MisconfigurationException from pytorch_lightning.utilities.model_helpers import is_overridden from pytorch_lightning.utilities.types import LRSchedulerType, LRSchedulerTypeTuple if _JSONARGPARSE_AVAILABLE: from jsonargparse import ActionConfigFile, ArgumentParser, class_from_function, set_config_read_mode set_config_read_mode(fsspec_enabled=True) else: ArgumentParser = object class LightningArgumentParser(ArgumentParser): """Extension of jsonargparse's ArgumentParser for pytorch-lightning""" def __init__(self, *args: Any, parse_as_dict: bool = True, **kwargs: Any) -> None: """Initialize argument parser that supports configuration file input For full details of accepted arguments see `ArgumentParser.__init__ <https://jsonargparse.readthedocs.io/en/stable/#jsonargparse.core.ArgumentParser.__init__>`_. """
def test_url_support_true(self): self.assertEqual('fr', get_config_read_mode()) set_config_read_mode(urls_enabled=True) self.assertEqual('fur', get_config_read_mode()) set_config_read_mode(urls_enabled=False) self.assertEqual('fr', get_config_read_mode())
def test_fsspec_support_true(self): self.assertEqual('fr', get_config_read_mode()) set_config_read_mode(fsspec_enabled=True) self.assertEqual('fsr', get_config_read_mode()) set_config_read_mode(fsspec_enabled=False) self.assertEqual('fr', get_config_read_mode())
def setUpClass(cls): set_config_read_mode()