ImperialCollegeLondon / pyrealm

Development of the pyrealm package, providing an integrated toolbox for modelling plant productivity, growth and demography using Python.
https://pyrealm.readthedocs.io/
MIT License
19 stars 8 forks source link

Break the profiling report script up into functions #195

Closed davidorme closed 5 months ago

davidorme commented 5 months ago

Is your feature request related to a problem? Please describe.

At the moment, profiling/report.py is a long script that does lots of different things, some of which we might want to run independently and which would be clearer broken up into units.

Describe the solution you'd like

def prof_file_to_benchmark_csv(
    profile_file: Path,
    results_csv: Path,
    min_cumtime: float = 0.01,
    selector: str = "",
    append_results: bool = True,
):
    ...

def benchmark_pyrealm(results_csv: Path, max_benchmark: int = 5, fail_threshold: float = 1.05):
    ...

def profile_plot(results_csv: Path, outpath: Path):
    ...

def benchmark_plot(results_csv: Path, outpath: Path):
    ...

# And then a wrapper of the above functions to expose as a command line 
# argument via if __name__ == "__main__":

def automated_profiling():
    args = ArgumentParser()
    ...

I think it would also be good if the automated profiling workflow passed {{ github.sha }} rather than the event name through. It is probably more practical to be able to identify rows in the benchmark by their commit than by the run date and event name.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

davidorme commented 5 months ago

Closed by #188