Neptune fix bug init run (#22836)

* [neptune] fix checkpoint bug with relative out_dir

* update imports

* reformat with black

* check neptune without imports

* fix typing-related issue

* run black on code

* use os.path.sep instead of raw \

* simplify imports and remove type annotation

* make ruff happy

* apply review suggestions

* replace run with with_id kwarg to run

* update imports to avoid deprecation warnings for the latest client

---------

Co-authored-by: kshitij12345 <kshitijkalambarkar@gmail.com>
This commit is contained in:
AleksanderWWW 2023-04-25 14:51:05 +02:00 committed by GitHub
parent d4d628462f
commit 0a570dbd2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1220,8 +1220,12 @@ class NeptuneCallback(TrainerCallback):
self._run = None
def _initialize_run(self, **additional_neptune_kwargs):
from neptune.new import init_run
from neptune.new.exceptions import NeptuneMissingApiTokenException, NeptuneMissingProjectNameException
try:
from neptune import init_run
from neptune.exceptions import NeptuneMissingApiTokenException, NeptuneMissingProjectNameException
except ImportError:
from neptune.new import init_run
from neptune.new.exceptions import NeptuneMissingApiTokenException, NeptuneMissingProjectNameException
self._stop_run_if_exists()
@ -1245,7 +1249,7 @@ class NeptuneCallback(TrainerCallback):
return
if self._run and not self._is_monitoring_run and not self._force_reset_monitoring_run:
self._initialize_run(run=self._run_id)
self._initialize_run(with_id=self._run_id)
self._is_monitoring_run = True
else:
self._initialize_run()
@ -1257,7 +1261,7 @@ class NeptuneCallback(TrainerCallback):
else:
if not self._run:
self._initialize_run(
run=self._run_id,
with_id=self._run_id,
capture_stdout=False,
capture_stderr=False,
capture_hardware_metrics=False,