@@ -7,24 +7,33 @@ class NeptuneLogger(BaseOutput):
77 """See: https://github.com/neptune-ai/neptune-client
88 YOUR_API_TOKEN and USERNAME/PROJECT_NAME
99 """
10- def __init__ (self , api_token : Optional [str ] = None , project_qualified_name : Optional [str ] = None , ** kwargs ):
10+
11+ def __init__ (
12+ self ,
13+ api_token : Optional [str ] = None ,
14+ project_qualified_name : Optional [str ] = None ,
15+ ** kwargs
16+ ):
1117 """Set secrets and create experiment
1218 Args:
1319 api_token: your api token, you can create NEPTUNE_API_TOKEN environment variable instead
1420 project_qualified_name: <user>/<project>, you can create NEPTUNE_PROJECT environment variable instead
1521 **kwargs: keyword args, that will be passed to create_experiment function
1622 """
1723 import neptune
24+
1825 self .neptune = neptune
19- self .neptune .init (api_token = api_token , project_qualified_name = project_qualified_name )
20- self .experiment = self .neptune .create_experiment (** kwargs )
26+ self .run = self .neptune .init_run (
27+ api_token = api_token , project = project_qualified_name , ** kwargs
28+ )
2129
2230 def close (self ):
2331 """Close connection"""
24- self .neptune .stop ()
32+ if hasattr (self , "run" ):
33+ self .run .stop ()
2534
2635 def send (self , logger : MainLogger ):
2736 """Send metrics collected in last step to neptune server"""
2837 for name , log_items in logger .log_history .items ():
2938 last_log_item = log_items [- 1 ]
30- self .neptune . send_metric ( name , x = last_log_item .step , y = last_log_item .value )
39+ self .run [ name ]. append ( value = last_log_item .value , step = last_log_item .step )
0 commit comments