Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create progress bar for experiments #41

Open
BenSchZA opened this issue Sep 2, 2021 · 6 comments
Open

Create progress bar for experiments #41

BenSchZA opened this issue Sep 2, 2021 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@BenSchZA
Copy link
Collaborator

BenSchZA commented Sep 2, 2021

Introduce a progress bar for long-running experiments, across runs/subsets/timesteps (granularity to be determined, to be most efficient).

  • Not enabled by default, perhaps progress mode.
@BenSchZA BenSchZA added enhancement New feature or request good first issue Good for newcomers labels Sep 2, 2021
@BenSchZA
Copy link
Collaborator Author

BenSchZA commented Sep 2, 2021

Some code already exists for this feature, very much WIP, ping to get access to this.

@FonsSicca
Copy link

@BenSchZA hello Ben! Would like to see the progress bar feature :)

@WooSungD
Copy link

Been looking at progress and tqdm for implementing a MVP progress bar

@BenSchZA
Copy link
Collaborator Author

@WooSungD I have some code (somewhere) that I recall uses tqdm. I had some issues with multiprocessing, but it was working with single process mode. I was hoping to have multiple progress bars—maybe one for # subsets, one for # runs, and one for total timesteps across all subsets and runs (i.e. overall simulation progress). It would be a great feature to have!

@BenSchZA
Copy link
Collaborator Author

The following is pseudo-code, untested, but might give an idea of how to integrate using radCAD hooks:

class CustomTQDM(tqdm):
    """A custom class that disables deepcopy for tqdm progress bars."""
    def __deepcopy__(self, memo):
        return self

@dataclass
class Parameters:
    """
    A dataclass to store the parameters of the simulation
    """
    progress_bar: CustomTQDM = CustomTQDM(total=0)
 
 ...
 
 class CustomSimulationExecution(SimulationExecution):
    def __init_subclass__(cls) -> None:
        return super().__init_subclass__()

    def before_subset(self):
        """
        radCAD simulation hook called before each simulation parameter subset
        """
        super().before_subset()
        params: Parameters = self.context.parameters
        params.progress_bar.total = int(self.context.timesteps)

    def before_timestep(self):
        """
        radCAD simulation hook called before each simulation timestep
        """
        super().before_timestep()
        params: Parameters = self.context.parameters
        params.progress_bar.update(1)

@WooSungD
Copy link

thanks for sharing the code @BenSchZA!

as a start I think a single progress bar for overall simulation progress bar would be great :) will give this a crack once in our next model build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants