Skip to content

Commit

Permalink
Simplify SimulationProgress() to a normal class instead of a decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
jorblancoa committed Feb 23, 2024
1 parent bd410f5 commit 0038d51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions neurodamus/core/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,15 @@ def rank0_wrapper(*args, **kw):


class SimulationProgress:
def __init__(self, f):
def __init__(self):
"""
Decorator class which will set up a timer to perioducally check the amount of time lapsed
in the simulation compared to the final tstop value. This is converted into a percentage
Class which will set up a timer to perioducally check the amount of time lapsed
in the simulation compared to the final tstop value. This is converted into a percentage
of the job complete which is then printed to the console.
"""
self.f = f
wraps(f)(self)

def __call__(self, *args, **kwargs):
# Start / update progress tracking
self.last_time_check = time.time()
self.sim_start = self.last_time_check
self.update_progress()
# Execute the decorated function
result = self.f(*args, **kwargs)
return result

@run_only_rank0
def update_progress(self):
Expand Down
2 changes: 1 addition & 1 deletion neurodamus/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,8 @@ def run_all(self):

# -
@return_neuron_timings
@SimulationProgress
def _run_neuron(self):
SimulationProgress()
self.solve()
logging.info("Simulation finished.")

Expand Down

0 comments on commit 0038d51

Please sign in to comment.