Skip to content

Commit 6497e36

Browse files
Bordapre-commit-ci[bot]carmocca
authored
bump: transmission to use neptune only, drop neptune-client (#19265)
* bump: min version `neptune>=1.0.0` * Apply suggestions from code review --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Carlos Mocholí <[email protected]>
1 parent 5998dd1 commit 6497e36

File tree

2 files changed

+17
-34
lines changed

2 files changed

+17
-34
lines changed

requirements/pytorch/loggers.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# all supported loggers. this list is here as a reference, but they are not installed in CI
22

3-
neptune
3+
neptune >=1.0.0
44
comet-ml >=3.31.0
55
mlflow >=1.0.0
66
wandb >=0.12.10

src/lightning/pytorch/loggers/neptune.py

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@
3939

4040
log = logging.getLogger(__name__)
4141

42-
# neptune is available with two names on PyPI : `neptune` and `neptune-client`
42+
# Neptune is available with two names on PyPI : `neptune` and `neptune-client`
43+
# `neptune` was introduced as a name transition of neptune-client and the long-term target is to get
44+
# rid of Neptune-client package completely someday. It was introduced as a part of breaking-changes with a release
45+
# of neptune-client==1.0. neptune-client>=1.0 is just an alias of neptune package and have some breaking-changes
46+
# in compare to neptune-client<1.0.0.
4347
_NEPTUNE_AVAILABLE = RequirementCache("neptune>=1.0")
44-
_NEPTUNE_CLIENT_AVAILABLE = RequirementCache("neptune-client")
4548
_INTEGRATION_VERSION_KEY = "source_code/integrations/pytorch-lightning"
4649

4750

@@ -224,8 +227,9 @@ def __init__(
224227
prefix: str = "training",
225228
**neptune_run_kwargs: Any,
226229
):
227-
if not _NEPTUNE_AVAILABLE and not _NEPTUNE_CLIENT_AVAILABLE:
230+
if not _NEPTUNE_AVAILABLE:
228231
raise ModuleNotFoundError(str(_NEPTUNE_AVAILABLE))
232+
229233
# verify if user passed proper init arguments
230234
self._verify_input_arguments(api_key, project, name, run, neptune_run_kwargs)
231235
super().__init__()
@@ -254,10 +258,7 @@ def __init__(
254258
root_obj[_INTEGRATION_VERSION_KEY] = pl.__version__
255259

256260
def _retrieve_run_data(self) -> None:
257-
if _NEPTUNE_AVAILABLE:
258-
from neptune.handler import Handler
259-
else:
260-
from neptune.new.handler import Handler
261+
from neptune.handler import Handler
261262

262263
assert self._run_instance is not None
263264
root_obj = self._run_instance
@@ -310,12 +311,9 @@ def _verify_input_arguments(
310311
run: Optional[Union["Run", "Handler"]],
311312
neptune_run_kwargs: dict,
312313
) -> None:
313-
if _NEPTUNE_AVAILABLE:
314-
from neptune import Run
315-
from neptune.handler import Handler
316-
else:
317-
from neptune.new import Run
318-
from neptune.new.handler import Handler
314+
from neptune import Run
315+
from neptune.handler import Handler
316+
319317
# check if user passed the client `Run`/`Handler` object
320318
if run is not None and not isinstance(run, (Run, Handler)):
321319
raise ValueError("Run parameter expected to be of type `neptune.Run`, or `neptune.handler.Handler`.")
@@ -335,10 +333,7 @@ def __getstate__(self) -> Dict[str, Any]:
335333
return state
336334

337335
def __setstate__(self, state: Dict[str, Any]) -> None:
338-
if _NEPTUNE_AVAILABLE:
339-
import neptune
340-
else:
341-
import neptune.new as neptune
336+
import neptune
342337

343338
self.__dict__ = state
344339
self._run_instance = neptune.init_run(**self._neptune_init_args)
@@ -376,10 +371,7 @@ def training_step(self, batch, batch_idx):
376371
@property
377372
@rank_zero_experiment
378373
def run(self) -> "Run":
379-
if _NEPTUNE_AVAILABLE:
380-
import neptune
381-
else:
382-
import neptune.new as neptune
374+
import neptune
383375

384376
if not self._run_instance:
385377
self._run_instance = neptune.init_run(**self._neptune_init_args)
@@ -426,10 +418,7 @@ def log_hyperparams(self, params: Union[Dict[str, Any], Namespace]) -> None:
426418
neptune_logger.log_hyperparams(PARAMS)
427419
428420
"""
429-
if _NEPTUNE_AVAILABLE:
430-
from neptune.utils import stringify_unsupported
431-
else:
432-
from neptune.new.utils import stringify_unsupported
421+
from neptune.utils import stringify_unsupported
433422

434423
params = _convert_params(params)
435424
params = _sanitize_callable_params(params)
@@ -485,10 +474,7 @@ def save_dir(self) -> Optional[str]:
485474

486475
@rank_zero_only
487476
def log_model_summary(self, model: "pl.LightningModule", max_depth: int = -1) -> None:
488-
if _NEPTUNE_AVAILABLE:
489-
from neptune.types import File
490-
else:
491-
from neptune.new.types import File
477+
from neptune.types import File
492478

493479
model_str = str(ModelSummary(model=model, max_depth=max_depth))
494480
self.run[self._construct_path_with_prefix("model/summary")] = File.from_content(
@@ -507,10 +493,7 @@ def after_save_checkpoint(self, checkpoint_callback: Checkpoint) -> None:
507493
if not self._log_model_checkpoints:
508494
return
509495

510-
if _NEPTUNE_AVAILABLE:
511-
from neptune.types import File
512-
else:
513-
from neptune.new.types import File
496+
from neptune.types import File
514497

515498
file_names = set()
516499
checkpoints_namespace = self._construct_path_with_prefix("model/checkpoints")

0 commit comments

Comments
 (0)