Skip to content

Commit

Permalink
custom aim callback should be minimal
Browse files Browse the repository at this point in the history
Signed-off-by: Dushyant Behl <[email protected]>
  • Loading branch information
dushyantbehl committed Mar 12, 2024
1 parent f178c21 commit 2ceb54f
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions tuning/trackers/aimstack_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ def on_train_begin(self, args, state, control, model=None, **kwargs):
# call directly to make sure hyper parameters and model info is recorded.
self.setup(args=args, state=state, model=model)

def track_metrics(self, metric, name, context):
run = self.experiment
if run is not None:
run.track(metric, name=name, context=context)


def set_params(self, params, name):
run = self.experiment
if run is not None:
[run.set((name, key), value, strict=False) for key, value in params.items()]


class AimStackTracker(Tracker):
def __init__(self, tracker_config: AimConfig):
super().__init__(name="aim", tracker_config=tracker_config)
Expand Down Expand Up @@ -79,10 +67,16 @@ def get_hf_callback(self):

def track(self, metric, name, stage="additional_metrics"):
context = {"subset": stage}
self.hf_callback.track_metrics(metric, name=name, context=context)
callback = self.hf_callback
run = callback.experiment
if run is not None:
run.track(metric, name=name, context=context)

def set_params(self, params, name="extra_params"):
try:
self.hf_callback.set_params(params, name)
except:
pass
callback = self.hf_callback
run = callback.experiment
if run is not None:
[run.set((name, key), value, strict=False) for key, value in params.items()]
except Exception as e:
raise e

0 comments on commit 2ceb54f

Please sign in to comment.