39
39
40
40
log = logging .getLogger (__name__ )
41
41
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.
43
47
_NEPTUNE_AVAILABLE = RequirementCache ("neptune>=1.0" )
44
- _NEPTUNE_CLIENT_AVAILABLE = RequirementCache ("neptune-client" )
45
48
_INTEGRATION_VERSION_KEY = "source_code/integrations/pytorch-lightning"
46
49
47
50
@@ -224,8 +227,9 @@ def __init__(
224
227
prefix : str = "training" ,
225
228
** neptune_run_kwargs : Any ,
226
229
):
227
- if not _NEPTUNE_AVAILABLE and not _NEPTUNE_CLIENT_AVAILABLE :
230
+ if not _NEPTUNE_AVAILABLE :
228
231
raise ModuleNotFoundError (str (_NEPTUNE_AVAILABLE ))
232
+
229
233
# verify if user passed proper init arguments
230
234
self ._verify_input_arguments (api_key , project , name , run , neptune_run_kwargs )
231
235
super ().__init__ ()
@@ -254,10 +258,7 @@ def __init__(
254
258
root_obj [_INTEGRATION_VERSION_KEY ] = pl .__version__
255
259
256
260
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
261
262
262
263
assert self ._run_instance is not None
263
264
root_obj = self ._run_instance
@@ -310,12 +311,9 @@ def _verify_input_arguments(
310
311
run : Optional [Union ["Run" , "Handler" ]],
311
312
neptune_run_kwargs : dict ,
312
313
) -> 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
+
319
317
# check if user passed the client `Run`/`Handler` object
320
318
if run is not None and not isinstance (run , (Run , Handler )):
321
319
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]:
335
333
return state
336
334
337
335
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
342
337
343
338
self .__dict__ = state
344
339
self ._run_instance = neptune .init_run (** self ._neptune_init_args )
@@ -376,10 +371,7 @@ def training_step(self, batch, batch_idx):
376
371
@property
377
372
@rank_zero_experiment
378
373
def run (self ) -> "Run" :
379
- if _NEPTUNE_AVAILABLE :
380
- import neptune
381
- else :
382
- import neptune .new as neptune
374
+ import neptune
383
375
384
376
if not self ._run_instance :
385
377
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:
426
418
neptune_logger.log_hyperparams(PARAMS)
427
419
428
420
"""
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
433
422
434
423
params = _convert_params (params )
435
424
params = _sanitize_callable_params (params )
@@ -485,10 +474,7 @@ def save_dir(self) -> Optional[str]:
485
474
486
475
@rank_zero_only
487
476
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
492
478
493
479
model_str = str (ModelSummary (model = model , max_depth = max_depth ))
494
480
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:
507
493
if not self ._log_model_checkpoints :
508
494
return
509
495
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
514
497
515
498
file_names = set ()
516
499
checkpoints_namespace = self ._construct_path_with_prefix ("model/checkpoints" )
0 commit comments