-
Notifications
You must be signed in to change notification settings - Fork 61
/
exceptions.py
1361 lines (1074 loc) 路 47.6 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# Copyright (c) 2022, Neptune Labs Sp. z o.o.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
__all__ = [
"InternalClientError",
"NeptuneException",
"NeptuneInvalidApiTokenException",
"NeptuneApiException",
"MetadataInconsistency",
"MissingFieldException",
"TypeDoesNotSupportAttributeException",
"MalformedOperation",
"FileNotFound",
"FileUploadError",
"FileSetUploadError",
"ClientHttpError",
"MetadataContainerNotFound",
"ProjectNotFound",
"RunNotFound",
"ModelNotFound",
"ModelVersionNotFound",
"ExceptionWithProjectsWorkspacesListing",
"ContainerUUIDNotFound",
"RunUUIDNotFound",
"ProjectNotFoundWithSuggestions",
"AmbiguousProjectName",
"NeptuneMissingProjectNameException",
"InactiveContainerException",
"InactiveRunException",
"InactiveModelException",
"InactiveModelVersionException",
"InactiveProjectException",
"NeptuneMissingApiTokenException",
"CannotSynchronizeOfflineRunsWithoutProject",
"NeedExistingExperimentForReadOnlyMode",
"NeedExistingRunForReadOnlyMode",
"NeedExistingModelForReadOnlyMode",
"NeedExistingModelVersionForReadOnlyMode",
"NeptuneParametersCollision",
"NeptuneWrongInitParametersException",
"NeptuneRunResumeAndCustomIdCollision",
"NeptuneClientUpgradeRequiredError",
"NeptuneMissingRequiredInitParameter",
"CannotResolveHostname",
"NeptuneSSLVerificationError",
"NeptuneConnectionLostException",
"InternalServerError",
"Unauthorized",
"Forbidden",
"NeptuneOfflineModeException",
"NeptuneOfflineModeFetchException",
"NeptuneOfflineModeChangeStageException",
"NeptuneProtectedPathException",
"NeptuneCannotChangeStageManually",
"OperationNotSupported",
"NeptuneLegacyProjectException",
"NeptuneUninitializedException",
"NeptuneIntegrationNotInstalledException",
"NeptuneLimitExceedException",
"NeptuneFieldCountLimitExceedException",
"NeptuneStorageLimitException",
"FetchAttributeNotFoundException",
"ArtifactNotFoundException",
"PlotlyIncompatibilityException",
"NeptunePossibleLegacyUsageException",
"NeptuneLegacyIncompatibilityException",
"NeptuneUnhandledArtifactSchemeException",
"NeptuneUnhandledArtifactTypeException",
"NeptuneLocalStorageAccessException",
"NeptuneRemoteStorageCredentialsException",
"NeptuneRemoteStorageAccessException",
"ArtifactUploadingError",
"NeptuneUnsupportedArtifactFunctionalityException",
"NeptuneEmptyLocationException",
"NeptuneFeatureNotAvailableException",
"NeptuneObjectCreationConflict",
"NeptuneModelKeyAlreadyExistsError",
"NeptuneSynchronizationAlreadyStoppedException",
"StreamAlreadyUsedException",
]
from typing import (
List,
Optional,
Union,
)
from urllib.parse import urlparse
from packaging.version import Version
from neptune.common.envs import API_TOKEN_ENV_NAME
# Backward compatibility import
from neptune.common.exceptions import (
STYLES,
InternalClientError,
NeptuneException,
NeptuneInvalidApiTokenException,
)
from neptune.new import envs
from neptune.new.envs import CUSTOM_RUN_ID_ENV_NAME
from neptune.new.internal.backends.api_model import (
Project,
Workspace,
)
from neptune.new.internal.container_type import ContainerType
from neptune.new.internal.id_formats import QualifiedName
from neptune.new.internal.utils import replace_patch_version
class NeptuneApiException(NeptuneException):
pass
class MetadataInconsistency(NeptuneException):
pass
class MissingFieldException(NeptuneException, AttributeError, KeyError):
"""Raised when get-like action is called on `Handler`, instead of on `Attribute`."""
def __init__(self, field_path):
message = """
{h1}
----MissingFieldException-------------------------------------------------------
{end}
The field "{field_path}" was not found.
There are two possible reasons:
- There is a typo in a path. Double-check your code for typos.
- You are fetching a field that another process created, but the local representation is not synchronized.
If you are sending metadata from multiple processes at the same time, synchronize the local representation before fetching values:
{python}run.sync(){end}
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
""" # noqa: E501
self._msg = message.format(field_path=field_path, **STYLES)
super().__init__(self._msg)
def __str__(self):
# required because of overriden `__str__` in `KeyError`
return self._msg
class TypeDoesNotSupportAttributeException(NeptuneException, AttributeError):
def __init__(self, type_, attribute):
message = """
{h1}
----TypeDoesNotSupportAttributeException----------------------------------------
{end}
{type} has no attribute {attribute}.
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
self._msg = message.format(type=type_, attribute=attribute, **STYLES)
super().__init__(self._msg)
def __str__(self):
# required because of overriden `__str__` in `KeyError`
return self._msg
class MalformedOperation(NeptuneException):
pass
class FileNotFound(NeptuneException):
def __init__(self, file: str):
super().__init__("File not found: {}".format(file))
class FileUploadError(NeptuneException):
def __init__(self, filename: str, msg: str):
super().__init__("Cannot upload file {}: {}".format(filename, msg))
class FileSetUploadError(NeptuneException):
def __init__(self, globs: List[str], msg: str):
super().__init__("Cannot upload file set {}: {}".format(globs, msg))
class ClientHttpError(NeptuneException):
def __init__(self, status, response):
self.status = status
self.response = response
message = """
{h1}
----ClientHttpError-----------------------------------------------------------------------
{end}
The Neptune server returned the status {fail}{status}{end}.
The server response was:
{fail}{response}{end}
Verify the correctness of your call or contact Neptune support.
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(status=status, response=response, **STYLES))
class MetadataContainerNotFound(NeptuneException):
container_id: str
container_type: ContainerType
def __init__(self, container_id: str, container_type: Optional[ContainerType]):
self.container_id = container_id
self.container_type = container_type
container_type_str = container_type.value.capitalize() if container_type else "object"
super().__init__("{} {} not found.".format(container_type_str, container_id))
@classmethod
def of_container_type(cls, container_type: Optional[ContainerType], container_id: str):
if container_type is None:
return MetadataContainerNotFound(container_id=container_id, container_type=None)
elif container_type == ContainerType.PROJECT:
return ProjectNotFound(project_id=container_id)
elif container_type == ContainerType.RUN:
return RunNotFound(run_id=container_id)
elif container_type == ContainerType.MODEL:
return ModelNotFound(model_id=container_id)
elif container_type == ContainerType.MODEL_VERSION:
return ModelVersionNotFound(model_version_id=container_id)
else:
raise InternalClientError(f"Unexpected ContainerType: {container_type}")
class ProjectNotFound(MetadataContainerNotFound):
def __init__(self, project_id: str):
super().__init__(container_id=project_id, container_type=ContainerType.PROJECT)
class RunNotFound(MetadataContainerNotFound):
def __init__(self, run_id: str):
super().__init__(container_id=run_id, container_type=ContainerType.RUN)
class ModelNotFound(MetadataContainerNotFound):
def __init__(self, model_id: str):
super().__init__(container_id=model_id, container_type=ContainerType.MODEL)
class ModelVersionNotFound(MetadataContainerNotFound):
def __init__(self, model_version_id: str):
super().__init__(container_id=model_version_id, container_type=ContainerType.MODEL_VERSION)
class ExceptionWithProjectsWorkspacesListing(NeptuneException):
def __init__(
self,
message: str,
available_projects: List[Project] = (),
available_workspaces: List[Workspace] = (),
**kwargs,
):
available_projects_message = """
Did you mean any of these?
{projects}
"""
available_workspaces_message = """
You can check all of your projects on the Projects page:
{workspaces_urls}
"""
projects_formated_list = "\n".join(
map(
lambda project: f" - {project.workspace}/{project.name}",
available_projects,
)
)
workspaces_formated_list = "\n".join(
map(
lambda workspace: f" - https://app.neptune.ai/{workspace.name}/-/projects",
available_workspaces,
)
)
super().__init__(
message.format(
available_projects_message=available_projects_message.format(projects=projects_formated_list)
if available_projects
else "",
available_workspaces_message=available_workspaces_message.format(
workspaces_urls=workspaces_formated_list
)
if available_workspaces
else "",
**STYLES,
**kwargs,
)
)
class ContainerUUIDNotFound(NeptuneException):
container_id: str
container_type: ContainerType
def __init__(self, container_id: str, container_type: ContainerType):
self.container_id = container_id
self.container_type = container_type
super().__init__(
"{} with ID {} not found. It may have been deleted. "
"You can use the 'neptune clear' command to delete junk objects from local storage.".format(
container_type.value.capitalize(), container_id
)
)
# for backward compatibility
RunUUIDNotFound = ContainerUUIDNotFound
class ProjectNotFoundWithSuggestions(ExceptionWithProjectsWorkspacesListing, ProjectNotFound):
def __init__(
self,
project_id: QualifiedName,
available_projects: List[Project] = (),
available_workspaces: List[Workspace] = (),
):
message = """
{h1}
----NeptuneProjectNotFoundException------------------------------------
{end}
We couldn't find project {fail}"{project}"{end}.
{available_projects_message}{available_workspaces_message}
You may want to check the following docs page:
- https://docs.neptune.ai/setup/creating_project/
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(
message=message,
available_projects=available_projects,
available_workspaces=available_workspaces,
project=project_id,
)
class AmbiguousProjectName(ExceptionWithProjectsWorkspacesListing):
def __init__(self, project_id: str, available_projects: List[Project] = ()):
message = """
{h1}
----NeptuneProjectNameCollisionException------------------------------------
{end}
Cannot resolve project {fail}"{project}"{end}. Name is ambiguous.
{available_projects_message}
You may also want to check the following docs pages:
- https://docs.neptune.ai/setup/creating_project/
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message=message, available_projects=available_projects, project=project_id)
class NeptuneMissingProjectNameException(ExceptionWithProjectsWorkspacesListing):
def __init__(
self,
available_projects: List[Project] = (),
available_workspaces: List[Workspace] = (),
):
message = """
{h1}
----NeptuneMissingProjectNameException----------------------------------------
{end}
The Neptune client couldn't find your project name.
{available_projects_message}{available_workspaces_message}
There are two options two add it:
- specify it in your code
- set an environment variable in your operating system.
{h2}CODE{end}
Pass it to the {bold}init(){end} method via the {bold}project{end} argument:
{python}neptune.init_run(project='WORKSPACE_NAME/PROJECT_NAME'){end}
{h2}ENVIRONMENT VARIABLE{end}
or export or set an environment variable depending on your operating system:
{correct}Linux/Unix{end}
In your terminal run:
{bash}export {env_project}=WORKSPACE_NAME/PROJECT_NAME{end}
{correct}Windows{end}
In your CMD run:
{bash}set {env_project}=WORKSPACE_NAME/PROJECT_NAME{end}
and skip the {bold}project{end} argument of the {bold}init(){end} method:
{python}neptune.init_run(){end}
You may also want to check the following docs pages:
- https://docs.neptune.ai/setup/creating_project/
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(
message=message,
available_projects=available_projects,
available_workspaces=available_workspaces,
env_project=envs.PROJECT_ENV_NAME,
)
class InactiveContainerException(NeptuneException):
resume_info: str
def __init__(self, container_type: ContainerType, label: str):
message = """
{h1}
----{cls}----------------------------------------
{end}
It seems you are trying to log metadata to (or fetch it from) a {container_type} that was stopped ({label}).
Here's what you can do:{resume_info}
You may also want to check the following docs pages:
- https://docs.neptune.ai/logging/to_existing_object/
- https://docs.neptune.ai/usage/querying_metadata/
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(
message.format(
cls=self.__class__.__name__,
label=label,
container_type=container_type.value,
resume_info=self.resume_info,
**STYLES,
)
)
class InactiveRunException(InactiveContainerException):
resume_info = """
- Resume the run to continue logging to it:
https://docs.neptune.ai/logging/to_existing_object/
- Don't invoke `stop()` on a run that you want to access. If you want to stop monitoring only,
you can resume a run in read-only mode:
https://docs.neptune.ai/api/connection_modes/#read-only-mode"""
def __init__(self, label: str):
super().__init__(label=label, container_type=ContainerType.RUN)
class InactiveModelException(InactiveContainerException):
resume_info = """
- Resume the model to continue logging to it:
https://docs.neptune.ai/api/neptune/#init_model
- Don't invoke `stop()` on a model that you want to access. If you want to stop monitoring only,
you can resume a model in read-only mode:
https://docs.neptune.ai/api/connection_modes/#read-only-mode"""
def __init__(self, label: str):
super().__init__(label=label, container_type=ContainerType.MODEL)
class InactiveModelVersionException(InactiveContainerException):
resume_info = """
- Resume the model version to continue logging to it:
https://docs.neptune.ai/api/neptune/#init_model_version
- Don't invoke `stop()` on a model version that you want to access. If you want to stop monitoring only,
you can resume a model version in read-only mode:
https://docs.neptune.ai/api/connection_modes/#read-only-mode"""
def __init__(self, label: str):
super().__init__(label=label, container_type=ContainerType.MODEL_VERSION)
class InactiveProjectException(InactiveContainerException):
resume_info = """
- Resume the connection to the project to continue logging to it:
https://docs.neptune.ai/api/neptune/#init_project
- Don't invoke `stop()` on a project that you want to access."""
def __init__(self, label: str):
super().__init__(label=label, container_type=ContainerType.PROJECT)
class NeptuneMissingApiTokenException(NeptuneException):
def __init__(self):
message = """
{h1}
----NeptuneMissingApiTokenException-------------------------------------------
{end}
The Neptune client couldn't find your API token.
You can get it here:
- https://app.neptune.ai/get_my_api_token
There are two options to add it:
- specify it in your code
- set an environment variable in your operating system.
{h2}CODE{end}
Pass the token to the {bold}init(){end} method via the {bold}api_token{end} argument:
{python}neptune.init_run(project='WORKSPACE_NAME/PROJECT_NAME', api_token='YOUR_API_TOKEN'){end}
{h2}ENVIRONMENT VARIABLE{end} {correct}(Recommended option){end}
or export or set an environment variable depending on your operating system:
{correct}Linux/Unix{end}
In your terminal run:
{bash}export {env_api_token}="YOUR_API_TOKEN"{end}
{correct}Windows{end}
In your CMD run:
{bash}set {env_api_token}="YOUR_API_TOKEN"{end}
and skip the {bold}api_token{end} argument of the {bold}init(){end} method:
{python}neptune.init_run(project='WORKSPACE_NAME/PROJECT_NAME'){end}
You may also want to check the following docs pages:
- https://docs.neptune.ai/setup/setting_api_token/
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(env_api_token=API_TOKEN_ENV_NAME, **STYLES))
class CannotSynchronizeOfflineRunsWithoutProject(NeptuneException):
def __init__(self):
super().__init__("Cannot synchronize offline runs without a project.")
class NeedExistingExperimentForReadOnlyMode(NeptuneException):
container_type: ContainerType
callback_name: str
def __init__(self, container_type: ContainerType, callback_name: str):
message = """
{h1}
----{class_name}-----------------------------------------
{end}
Read-only mode can be used only with an existing {container_type}.
The {python}{container_type}{end} parameter of {python}{callback_name}{end} must be provided and reference
an existing run when using {python}mode="read-only"{end}.
You may also want to check the following docs pages:
- https://docs.neptune.ai/logging/to_existing_object/
- https://docs.neptune.ai/api/connection_modes/#read-only-mode
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
self.container_type = container_type
self.callback_name = callback_name
super().__init__(
message.format(
class_name=type(self).__name__,
container_type=self.container_type.value,
callback_name=self.callback_name,
**STYLES,
)
)
class NeedExistingRunForReadOnlyMode(NeedExistingExperimentForReadOnlyMode):
def __init__(self):
super().__init__(container_type=ContainerType.RUN, callback_name="neptune.init_run")
class NeedExistingModelForReadOnlyMode(NeedExistingExperimentForReadOnlyMode):
def __init__(self):
super().__init__(container_type=ContainerType.MODEL, callback_name="neptune.init_model")
class NeedExistingModelVersionForReadOnlyMode(NeedExistingExperimentForReadOnlyMode):
def __init__(self):
super().__init__(
container_type=ContainerType.MODEL_VERSION,
callback_name="neptune.init_model_version",
)
class NeptuneParametersCollision(NeptuneException):
def __init__(self, parameter1, parameter2, method_name):
self.parameter1 = parameter1
self.parameter2 = parameter2
self.method_name = method_name
message = """
{h1}
----NeptuneParametersCollision-----------------------------------------
{end}
The {python}{parameter1}{end} and {python}{parameter2}{end} parameters of the {python}{method_name}(){end} method are mutually exclusive.
You may also want to check the following docs page:
- https://docs.neptune.ai/api/universal/#initialization-methods
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
""" # noqa: E501
super().__init__(
message.format(
parameter1=parameter1,
parameter2=parameter2,
method_name=method_name,
**STYLES,
)
)
class NeptuneWrongInitParametersException(NeptuneException):
pass
class NeptuneRunResumeAndCustomIdCollision(NeptuneWrongInitParametersException):
def __init__(self):
message = """
{h1}
----NeptuneRunResumeAndCustomIdCollision-----------------------------------------
{end}
It's not possible to use {python}custom_run_id{end} while resuming a run.
The {python}run{end} and {python}custom_run_id{end} parameters of the {python}init_run(){end} method are mutually exclusive.
Make sure you have no {bash}{custom_id_env}{end} environment variable set
and no value is explicitly passed to the `custom_run_id` argument when you are resuming a run.
You may also want to check the following docs page:
- https://docs.neptune.ai/logging/to_existing_object/
- https://docs.neptune.ai/logging/custom_run_id/
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
""" # noqa: E501
super().__init__(message.format(custom_id_env=CUSTOM_RUN_ID_ENV_NAME, **STYLES))
class NeptuneClientUpgradeRequiredError(NeptuneException):
def __init__(
self,
version: Union[Version, str],
min_version: Optional[Union[Version, str]] = None,
max_version: Optional[Union[Version, str]] = None,
):
current_version = str(version)
required_version = "==" + replace_patch_version(str(max_version)) if max_version else ">=" + str(min_version)
message = """
{h1}
----NeptuneClientUpgradeRequiredError-------------------------------------------------------------
{end}
Your version of the Neptune client library ({current_version}) is no longer supported by the Neptune
server. The minimum required version is {required_version}.
In order to update the Neptune client library, run the following command in your terminal:
{bash}pip install -U neptune-client{end}
Or if you are using Conda, run the following instead:
{bash}conda update -c conda-forge neptune-client{end}
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(
message.format(
current_version=current_version,
required_version=required_version,
**STYLES,
)
)
class NeptuneMissingRequiredInitParameter(NeptuneWrongInitParametersException):
def __init__(
self,
called_function: str,
parameter_name: str,
):
message = """
{h1}
----NeptuneMissingRequiredInitParameter---------------------------------------
{end}
{python}neptune.{called_function}(){end} invocation was missing {python}{parameter_name}{end}.
If you want to create a new object using {python}{called_function}{end}, {python}{parameter_name}{end} is required:
https://docs.neptune.ai/api/neptune#{called_function}
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(
message.format(
called_function=called_function,
parameter_name=parameter_name,
**STYLES,
)
)
class CannotResolveHostname(NeptuneException):
def __init__(self, host):
message = """
{h1}
----CannotResolveHostname-----------------------------------------------------------------------
{end}
The Neptune client library was not able to resolve hostname {underline}{host}{end}.
What should I do?
- Check if your computer is connected to the internet.
- Check if your computer is supposed to be using a proxy to access the internet.
If so, you may want to use the {python}proxies{end} parameter of the {python}init(){end} method.
See https://docs.neptune.ai/api/universal/#proxies
and https://requests.readthedocs.io/en/latest/user/advanced/#proxies
- Check the status of Neptune services: https://status.neptune.ai/
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(host=host, **STYLES))
class NeptuneSSLVerificationError(NeptuneException):
def __init__(self):
message = """
{h1}
----NeptuneSSLVerificationError-----------------------------------------------------------------------
{end}
The Neptune client was unable to verify your SSL Certificate.
{bold}What could have gone wrong?{end}
- You are behind a proxy that inspects traffic to Neptune servers.
- Contact your network administrator
- The SSL/TLS certificate of your on-premises installation is not recognized due to a custom Certificate Authority (CA).
- To check, run the following command in your terminal:
{bash}curl https://<your_domain>/api/backend/echo {end}
- Where <your_domain> is the address that you use to access Neptune app, such as abc.com
- Contact your network administrator if you get the following output:
{fail}"curl: (60) server certificate verification failed..."{end}
- Your machine software is outdated.
- Minimal OS requirements:
- Windows >= XP SP3
- macOS >= 10.12.1
- Ubuntu >= 12.04
- Debian >= 8
{bold}What can I do?{end}
You can manually configure Neptune to skip all SSL checks. To do that,
set the NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE environment variable to 'TRUE'.
{bold}Note: This might mean that your connection is less secure{end}.
Linux/Unix
In your terminal run:
{bash}export NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end}
Windows
In your terminal run:
{bash}set NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end}
Jupyter notebook
In your code cell:
{bash}%env NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE='TRUE'{end}
You may also want to check the following docs page:
- https://docs.neptune.ai/api/environment_variables/#neptune_allow_self_signed_certificate
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
""" # noqa: E501
super().__init__(message.format(**STYLES))
class NeptuneConnectionLostException(NeptuneException):
def __init__(self, cause: Exception):
self.cause = cause
message = """
{h1}
----NeptuneConnectionLostException---------------------------------------------------------
{end}
The connection to the Neptune server was lost.
If you are using the asynchronous (default) connection mode, Neptune continues to locally track your metadata and continuously tries to re-establish a connection to the Neptune servers.
If the connection is not re-established, you can upload your data later with the Neptune Command Line Interface tool:
{bash}neptune sync -p workspace_name/project_name{end}
What should I do?
- Check if your computer is connected to the internet.
- If your connection is unstable, consider working in offline mode:
{python}run = neptune.init_run(mode="offline"){end}
You can find detailed instructions on the following doc pages:
- https://docs.neptune.ai/api/connection_modes/#offline-mode
- https://docs.neptune.ai/api/neptune_sync/
You may also want to check the following docs page:
- https://docs.neptune.ai/api/connection_modes/#connectivity-issues
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
""" # noqa: E501
super().__init__(message.format(**STYLES))
class InternalServerError(NeptuneApiException):
def __init__(self, response):
message = """
{h1}
----InternalServerError-----------------------------------------------------------------------
{end}
The Neptune client library encountered an unexpected internal server error.
The server response was:
{fail}{response}{end}
Please try again later or contact Neptune support.
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(response=response, **STYLES))
class Unauthorized(NeptuneApiException):
def __init__(self):
message = """
{h1}
----Unauthorized-----------------------------------------------------------------------
{end}
You don't have permission to access the given resource.
- Verify that your API token is correct.
See: https://app.neptune.ai/get_my_api_token
- Verify that the provided project name is correct.
The correct project name should look like this: {correct}WORKSPACE_NAME/PROJECT_NAME{end}
It has two parts:
- {correct}WORKSPACE_NAME{end}: can be your username or your organization name
- {correct}PROJECT_NAME{end}: the name specified for the project
- Ask your organization administrator to grant you necessary privileges to the project.
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(**STYLES))
class Forbidden(NeptuneApiException):
def __init__(self):
message = """
{h1}
----Forbidden-----------------------------------------------------------------------
{end}
You don't have permission to access the given resource.
- Verify that your API token is correct.
See: https://app.neptune.ai/get_my_api_token
- Verify that the provided project name is correct.
The correct project name should look like this: {correct}WORKSPACE_NAME/PROJECT_NAME{end}
It has two parts:
- {correct}WORKSPACE_NAME{end}: can be your username or your organization name
- {correct}PROJECT_NAME{end}: the name specified for the project
- Ask your organization administrator to grant you necessary privileges to the project.
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(**STYLES))
class NeptuneOfflineModeException(NeptuneException):
pass
class NeptuneOfflineModeFetchException(NeptuneOfflineModeException):
def __init__(self):
message = """
{h1}
----NeptuneOfflineModeFetchException---------------------------------------------------
{end}
It seems you are trying to fetch data from the server while working in offline mode.
You need to work in a non-offline connection mode to fetch data from the server.
You can set the connection mode when creating a new run:
{python}run = neptune.init_run(mode="async"){end}
You may also want to check the following docs page:
- https://docs.neptune.ai/api/connection_modes
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(**STYLES))
class NeptuneOfflineModeChangeStageException(NeptuneOfflineModeException):
def __init__(self):
message = """
{h1}
----NeptuneOfflineModeChangeStageException---------------------------------------
{end}
You cannot change the stage of the model version while in offline mode.
"""
super().__init__(message.format(**STYLES))
class NeptuneProtectedPathException(NeptuneException):
extra_info = ""
def __init__(self, path: str):
message = """
{h1}
----NeptuneProtectedPathException----------------------------------------------
{end}
Field {path} cannot be changed directly.
{extra_info}
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
self._path = path
super().__init__(
message.format(
path=path,
extra_info=self.extra_info.format(**STYLES),
**STYLES,
)
)
class NeptuneCannotChangeStageManually(NeptuneProtectedPathException):
extra_info = """
If you want to change the stage of the model version,
use the {python}.change_stage(){end} method:
{python}model_version.change_stage("staging"){end}"""
class OperationNotSupported(NeptuneException):
def __init__(self, message: str):
super().__init__(f"Operation not supported: {message}")
class NeptuneLegacyProjectException(NeptuneException):
def __init__(self, project: QualifiedName):
message = """
{h1}
----NeptuneLegacyProjectException---------------------------------------------------------
{end}
Your project "{project}" has not been migrated to the new structure yet.
Unfortunately the neptune.new Python API is incompatible with projects using the old structure,
so please use legacy neptune Python API.
Don't worry - we are working hard on migrating all the projects and you will be able to use the neptune.new API soon.
You can find documentation for the legacy neptune Python API here:
- https://docs-legacy.neptune.ai/index.html
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(project=project, **STYLES))
class NeptuneUninitializedException(NeptuneException):
def __init__(self):
message = """
{h1}
----NeptuneUninitializedException----------------------------------------------------
{end}
You must initialize the Neptune client library before you can access `get_last_run`.
Looks like you forgot to add:
{python}neptune.init_run(project='WORKSPACE_NAME/PROJECT_NAME', api_token='YOUR_API_TOKEN'){end}
before you ran:
{python}neptune.get_last_run(){end}
You may also want to check the following docs page:
- https://docs.neptune.ai/api/neptune/#get_last_run
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(message.format(**STYLES))
class NeptuneIntegrationNotInstalledException(NeptuneException):
def __init__(self, integration_package_name, framework_name):
message = """
{h1}
----NeptuneIntegrationNotInstalledException-----------------------------------------
{end}
Looks like integration {integration_package_name} wasn't installed.
To install, run:
{bash}pip install {integration_package_name}{end}
Or:
{bash}pip install "neptune-client[{framework_name}]"{end}
You may also want to check the following docs page:
- https://docs.neptune.ai/integrations
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
"""
super().__init__(
message.format(
integration_package_name=integration_package_name,
framework_name=framework_name,
**STYLES,
)
)
class NeptuneLimitExceedException(NeptuneException):
def __init__(self, reason: str):